Hi all,
I am trying to get pixel shaders working, but am stuck…
I have a cg pixel program
#pragma bind v2f.TexCoord0 = TEX0
#pragma bind main.TexMap = texunit 0
struct v2f_simple : vertex2fragment
{
float4 TexCoord0;
};
fragout main(v2f_simple IN,
uniform sampler2D TexMap)
{
fragout OUT;
float4 texcolor = tex2D(TexMap);
OUT.col = float4(1.0,0.0,0.0,1.0);//texcolor;
// OUT.col = texcolor;
return OUT;
}
and I use the cg compiler to compile it to
dx8ps
then read in the output of the compiler and
do this
char *pscode = readFfromfile(“test.pp”);
UINT idx = glGenLists(1);
glNewList(idx,GL_COMPILE);
nvparse(prog);
glEndList();
for (const char** errors= (const char **) nvparse_get_errors(); *errors; errors++)
printf("NVPARSE ERRORS %s
",*errors);
I get no parse errors - so then I render my stuff doing this…
glDepthFunc(GL_LEQUAL);
glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glCallList(idx);
glEnable(GL_TEXTURE_SHADER_NV);
glEnable(GL_REGISTER_COMBINERS_NV);
glEnable(GL_BLEND);
glBlendFunc(GL_ONE,GL_ZERO);
mesh_st* m = getMyMeshObj();
//Get the texture ID
UINT tid = m->shdr.diff_tex;
glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,tid);
glEnableClientState(GL_VERTEX_ARRAY);
glClientActiveTextureARB(GL_TEXTURE0_ARB);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, sizeof(vertex_st), &(m->vlist[0].uv[0]));
glVertexPointer(3, GL_FLOAT, sizeof(vertex_st),&(m->vlist[0].position[0]));
glDrawElements(GL_TRIANGLES, 3*m->numFaces, GL_UNSIGNED_INT, m->flist);
glDisable(GL_REGISTER_COMBINERS_NV);
glDisable(GL_TEXTURE_SHADER_NV);
And Low and behold, it doesn’t work
If I comment out enabling texture shaders
and reg combiners, it draws the mesh
with the current enabled texture as you would assume.
But with the code as above it doesn’t render anything.
I’m guessing I am missing something that I need to initialize. Any help would be appreciated.
Thanks,
-Joe