在决定尝试在现代OpenGL中编程之后,我已经留下了固定功能管道,我不完全确定获得与之前相同的功能.
我正在尝试使用像素完美尺寸来纹理地图四边形,匹配纹理大小.例如,128x128纹理映射到四倍128x128的大小.
这是我的顶点着色器.
#version 110
uniform float xpos;
uniform float ypos;
uniform float tw; // texture width in pixels
uniform float th; // texture height in pixels
attribute vec4 position;
varying vec2 texcoord;
void main()
{
mat4 projectionMatrix = mat4( 2.0/600.0, 0.0, 0.0, -1.0,
0.0, 2.0/800.0, 0.0, -1.0,
0.0, 0.0, -1.0, 0.0,
0.0, 0.0, 0.0, 1.0);
gl_Position = position * projectionMatrix;
texcoord = (gl_Position.xy);
}
这是我的片段着色器:
#version 110
uniform float fade_factor;
uniform sampler2D textures[1];
varying vec2 texcoord;
void main()
{ …Run Code Online (Sandbox Code Playgroud)