Hi All,
I setup a very small test program, with a spinning cube...
but it is absolutely not textured as expected...
Please have a quick look,
I should miss something...
thanks again...
Loic,
----------------------------------
class FROG_MainWindow : public Fl_Gl_Window {
void draw();
int handle(int);
double rotation;
unsigned int TexID;
public:
FROG_MainWindow(int x,int y,int w,int h,const char *l=0) :
Fl_Gl_Window(x,y,w,h,l) {
//Texture Generation
glGenTextures(1, &TexID);
glBindTexture(GL_TEXTURE_2D, TexID);
unsigned char Pic[100*100*3];
for(unsigned int x=0;x<100;x++){
for(unsigned int y=0;y<100;y++){
Pic[(x*100+y)*3+0] = (x/50)%2;
Pic[(x*100+y)*3+1] = (x/50)%2;
Pic[(x*100+y)*3+2] = (x/50)%2;
}
}
glTexImage2D(GL_TEXTURE_2D, 0, 3, 100, 100, 0, GL_RGB, GL_UNSIGNED_BYTE,
Pic);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
}
};
void FROG_MainWindow::draw(){
glEnable(GL_TEXTURE_2D);
glShadeModel(GL_SMOOTH);
glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glClearColor (1,1,1,0);
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glViewport (0, 0, FROG_MainWindow::w(), FROG_MainWindow::h());
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0, FROG_MainWindow::w(), 0, FROG_MainWindow::h(), -200.0f,
200.0f);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glTranslatef(FROG_MainWindow::w()/2,FROG_MainWindow::h()/2,0);
glRotatef(rotation,0.5,0.2,1);
glScalef(100,100,100);
rotation += 1.5f;
glBindTexture(GL_TEXTURE_2D, TexID);
glBegin(GL_QUADS);
// Front Face
glColor3f(1.0,0,0);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f);
// Bottom Left Of The Texture and Quad
glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f);
// Bottom Right Of The Texture and Quad
glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f);
// Top Right Of The Texture and Quad
glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f);
// Top Left Of The Texture and Quad
// Back Face
glColor3f(0.0,1,1);
glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
// Bottom Right Of The Texture and Quad
glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f);
// Top Right Of The Texture and Quad
glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f);
// Top Left Of The Texture and Quad
glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f);
// Bottom Left Of The Texture and Quad
// Top Face
glColor3f(0,1,0);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f);
// Top Left Of The Texture and Quad
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, 1.0f, 1.0f);
// Bottom Left Of The Texture and Quad
glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, 1.0f, 1.0f);
// Bottom Right Of The Texture and Quad
glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f);
// Top Right Of The Texture and Quad
// Bottom Face
glColor3f(1,0,1);
glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
// Top Right Of The Texture and Quad
glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, -1.0f);
// Top Left Of The Texture and Quad
glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f);
// Bottom Left Of The Texture and Quad
glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f);
// Bottom Right Of The Texture and Quad
// Right face
glColor3f(0,0,1);
glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f);
// Bottom Right Of The Texture and Quad
glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f);
// Top Right Of The Texture and Quad
glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f);
// Top Left Of The Texture and Quad
glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f);
// Bottom Left Of The Texture and Quad
// Left Face
glColor3f(1,1,0);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
// Bottom Left Of The Texture and Quad
glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f);
// Bottom Right Of The Texture and Quad
glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f);
// Top Right Of The Texture and Quad
glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f);
// Top Left Of The Texture and Quad
glEnd();
}
int FROG_MainWindow::handle(int e) {
switch (e) {
case FL_ENTER: cursor(FL_CURSOR_CROSS); break;
case FL_LEAVE: cursor(FL_CURSOR_DEFAULT); break;
}
return Fl_Gl_Window::handle(e);
}
int main (int argc, char *argv[])
{
FROG_MainWindow* frog_window = new
FROG_MainWindow(10,10,WINDOW_WIDTH-20,WINDOW_HEIGHT-20, "FROG Displayer");
frog_window->end();
frog_window->resizable(frog_window);
frog_window->show();
while(1){
Fl::wait(); // waits until something happens
frog_window->redraw();
}
}
_______________________________________________
fltk-opengl mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-opengl