Hi all,
I’m having some problems getting textures to display when using the cg vp40 profile. I’ve managed to simplify the problem down to a simple testcase. Everything works perfectly when using arbvp1 – a black checkered texture appears over a blue triangle. Under vp40 all I get is a blue triangle. I’m running this on an intel OSX machine with a 6600GT.
If anyone can point me in a direction on where to look that would be appreciated! Thanks in advance.
The shader:
struct input
{
float4 position : POSITION;
float4 color : COLOR0;
float2 tex : TEXCOORD0;
};
struct fragment
{
float4 HPos : POSITION;
float4 Col0 : COLOR0;
float2 tex : TEXCOORD0;
};
fragment main(input IN, uniform float4x4 ModelViewProj)
{
fragment OUT;
OUT.HPos = mul(ModelViewProj, IN.position);
OUT.Col0 = float4(0,0,1,1);
OUT.tex = IN.tex;
return OUT;
}
Texture creation:
glGenTextures(1, &textureID);
glBindTexture(GL_TEXTURE_2D, textureID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 4, 4, 0, GL_RGB, GL_FLOAT, texture);
Display routine:
glClear(GL_COLOR_BUFFER_BIT);
glEnable(GL_TEXTURE_2D);
cgGLSetStateMatrixParameter(cgGetNamedParameter(vertexProgram, "ModelViewProj"),
CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY);
glBindTexture(GL_TEXTURE_2D, textureID);
glBegin(GL_TRIANGLES);
glTexCoord2f( -1.0f, -1.0f );
glVertex2f(-0.8, 0.8);
glTexCoord2f( -1.0f, 1.0f );
glVertex2f( 0.8, 0.8);
glTexCoord2f( 1.0f, 1.0f );
glVertex2f( 0.0,-0.8);
glEnd();
glutSwapBuffers();