Looking for simple example code triple (host C, vertex & fragment) for simple texture mapping. Here’s what I’ve tried, but it’s not making it (hope the long post is OK!):
C snippet for creating the texture:
glBindTexture(GL_TEXTURE_2D, g_textureID);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 1, 1024, 1024, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, textureBuffer);
free(TextureBuffer);
C Render code:
void render( void )
{
// Clear the screen and the depth buffer
// glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
setShaderConstants();
glBindProgramARB( GL_VERTEX_PROGRAM_ARB, g_vertexProgramID );
glBindProgramARB( GL_FRAGMENT_PROGRAM_ARB, g_fragmentProgramID );
glEnable( GL_VERTEX_PROGRAM_ARB );
glEnable( GL_FRAGMENT_PROGRAM_ARB );
glBindTexture( GL_TEXTURE_2D, g_textureID );
glInterleavedArrays( GL_C4UB_V3F, 0, g_quadVertices );
glDrawArrays( GL_QUADS, 0, 4 );
glDisable( GL_FRAGMENT_PROGRAM_ARB );
glDisable( GL_VERTEX_PROGRAM_ARB );
SwapBuffers( g_hDC );
}
Vertex program:
!!ARBvp1.0
Constant Parameters
PARAM mvp[4] = { state.matrix.mvp }; # modelview projection matrix
PARAM constColor = program.env[0]; # constant color (defined by the application)
Per-vertex inputs
ATTRIB inPosition = vertex.position;
ATTRIB inColor = vertex.color;
Per-vertex outputs
OUTPUT outPosition = result.position;
OUTPUT outColor = result.color;
MOV outPosition, vertex.position;
MOV result.texcoord, vertex.texcoord;
MOV outColor, inColor;
END
And fragment shader:
!!ARBfp1.0
MOV result.color, fragment.texcoord[0];
END
So what am I doing wrong? It renders at 900 frames per second into a 1kx1k image, but the result is blank!
A related question - what turns the asm source into machine code and who provides it? Did it come with the ATI DX 9 RC0 driver I installed?
Scott