Ho scritto il seguente codice nel file main.cpp:
codice:
#include "glutil.h"
#import "banana.h"
OpenGL *opengl;
bool init()
{
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
glColor3f(0.0f, 0.0f, 0.0f);
return true;
}
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glVertexPointer(3, GL_FLOAT, 0, bananaVerts);
glNormalPointer(GL_FLOAT, 0, bananaNormals);
glTexCoordPointer(2, GL_FLOAT, 0, bananaTexCoords);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glDrawArrays(GL_TRIANGLES, 0, bananaNumVerts);
glFlush();
}
void resize(int w, int h)
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glViewport(0, 0, w, h);
glOrtho(-1.0f, 1.0f, -1.0f, 1.0f, -1.0f, 20.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void idle()
{
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
opengl = OpenGL::create();
opengl->setInitFunc(init);
opengl->setDisplayFunc(display);
opengl->setIdleFunc(idle);
opengl->setResizeFunc(resize);
if (!opengl->initGL("03 - OpenGL Window", 500, 500, false, 32))
return 1;
opengl->runMessageLoop();
return 0;
}
Nessun errore di compilazione, la finestra si apre ma non viene disegnato nulla, nel file banana.h ci sono tutti gli array richiamati nella funzione display.
Cosa può essere?
Grazie