So in my display function I have this code
void display()
{
//Basic rendering to FBO 1
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(d*sqrt3,d*sqrt3,d*sqrt3,
0.0,0.0,0.0,
0.0,1.0,0.0);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb[0].fbobj);
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
bindCgPrograms();
glPushMatrix();
glRotatef(angle,0.0,1.0,0.0);
glRotatef(angleZ,1.0,0.0,0.0);
glFrontFace(GL_CW);
glutSolidTeapot(1.0);
glFrontFace(GL_CCW);
glPopMatrix();
unBindCgPrograms();
glDisable(GL_DEPTH_TEST);
..
which gives me my image of teapot but the glut teapot has some flaws so I wanted to read in an .obj file.
Which results in this code
// OBJ loader
struct Triangle {
int v1;
int v2;
int v3;
};
struct Vertex {
float x;
float y;
float z;
};
Vertex v[50000];
Triangle t[50000];
int vertexCount = 0;
int triangleCount = 0;
void loadOBJ(){
cout<<"Load obj file"<<endl;
char line[100];
FILE *fp = fopen("cone.obj","r");
cout<<"tree.obj open"<<endl;
if (fp != NULL)
{
while (fgets(line, 99, fp))
{
if (line[0] == 'v')
{
sscanf(line, "%*c %f %f %f", &v[vertexCount].x, &v[vertexCount].y, &v[vertexCount].z);
vertexCount++;
}
else if (line[0] == 'f')
{
sscanf(line, "%*c %d %d %d", &t[triangleCount].v1, &t[triangleCount].v2, &t[triangleCount].v3);
triangleCount++;
}
}
}else{
cout<<"file not found!"<<endl;
}
fclose(fp);
}
// end OBJ loader
and this code in the display function
void display()
{
//Basic rendering to FBO 1
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(d*sqrt3,d*sqrt3,d*sqrt3,
0.0,0.0,0.0,
0.0,1.0,0.0);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb[0].fbobj);
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
bindCgPrograms();
glPushMatrix();
glRotatef(angle,0.0,1.0,0.0);
glRotatef(angleZ,1.0,0.0,0.0);
glBegin(GL_TRIANGLES);
for (int i=0; i<triangleCount; i++)
{
glVertex3f(v[t.v1-1].x * 0.25, v[t.v1-1].y * 0.25, v[t.v1-1].z * 0.25);
glVertex3f(v[t.v2-1].x * 0.25, v[t.v2-1].y * 0.25, v[t.v2-1].z * 0.25);
glVertex3f(v[t.v3-1].x * 0.25, v[t.v3-1].y * 0.25, v[t.v3-1].z * 0.25);
}
glEnd();
glPopMatrix();
unBindCgPrograms();
glDisable(GL_DEPTH_TEST);
Now I get the object I want but it's just white whereas when I use the glutsolids my cg shaders are being used as expected and I get some nice realtime env mapping. Can anyone tell me what I'm doing wrong?