Refator
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
#version 450 core
|
||||
out vec4 FragColor;
|
||||
in vec2 TexCoord;
|
||||
|
||||
uniform sampler2D ourTexture;
|
||||
|
||||
void main() {
|
||||
FragColor = texture(ourTexture, TexCoord);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#version 450 core
|
||||
|
||||
layout (location = 0) in vec2 aPos;
|
||||
layout (location = 1) in vec2 aTexCoord;
|
||||
|
||||
out vec2 TexCoord;
|
||||
|
||||
uniform vec2 u_position; //Position in scrren coordinates (pixel)
|
||||
uniform vec2 u_size; //size in pixels (width, height)
|
||||
uniform vec2 u_resolution; //window resolution
|
||||
|
||||
void main(){
|
||||
//Covert from screen coordinated to normalized device corrdinates
|
||||
|
||||
//Screen coordinates: origin at top-left , y down
|
||||
|
||||
vec2 screen_pos = aPos * u_size + u_position;
|
||||
|
||||
vec2 ndc;
|
||||
ndc.x = (screen_pos.x / u_resolution.x) * 2.0 - 1.0;
|
||||
ndc.y = 1.0 - (screen_pos.y / u_resolution.x) * 2.0;
|
||||
|
||||
gl_Position = vec4(ndc, 0.0, 1.0);
|
||||
TexCoord = aTexCoord;
|
||||
}
|
||||
Reference in New Issue
Block a user