Bonjour,
je voudrais comprendre le placement des glutSubWindow.
Voici les infos que j'ai :
glutCreateSubWindow
La fonction glutCreateSubWindow crée une sous-fenêtre à l'intérieur d'une fenêtre parent.
<OL>
<LI>Usage
int glutCreateSubWindow ( int win, int x, int y, int width, int height );
win,
Identificateur de la fenêtre parent.
,
----
x ,
Coordonnées en pixels de la position en x relativement à la fenêtre parent.
,
----
y,
Coordonnées en pixels de la position en y relativement à la fenêtre parent.
,
----
width,
Largeur en pixels.
,
----
height,
Hauteur en pixels.
</LI></OL>
Il est à remarquer que l'origine se trouve dans le coin supérieur gauche de la fenêtre.
Donc si je cree une sous fenetre a la position 50,50 je devrais trouver ma sous fenetre a 50 pixels du bord de ma fenetre principale non ?
Ben ca se passe pas comme prevu, le code fonctionne pourtant
C'est un melange de tuto trouvé ici (merci Keniiyk) et d'essai :
#include<gl/glut.h>
static float RX=0.0;
static float RY=0.0;
static float RZ=0.0;
int principale,deux,trois,quatre;
void Reshape(int width, int height)
{
glViewport(0,0,width,height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45,(float)width/(float)height,0.01,20);
glMatrixMode(GL_MODELVIEW);
}
void InitGL(void)
{
glEnable(GL_DEPTH_TEST);
glShadeModel(GL_SMOOTH);
}
void Draw()
{
int changer,souviens;
souviens=glutGetWindow();
if (souviens==1) {changer=2;} else {changer=1;}
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
gluLookAt(1,changer,1,0,-1,0,0,1,0);
glRotatef(RX,1.0f,0,0);
glRotatef(RY,0,1.0f,0);
glRotatef(RZ,0,0,1.0f);
glColor3f(1.0f,0,0);
glBegin(GL_QUADS);
glVertex3f(1.0f,1.0f,1.0f);
glVertex3f(1.0f,-1.0f,1.0f);
glVertex3f(-1.0f,-1.0f,1.0f);
glVertex3f(-1.0f,1.0f,1.0f);
glEnd();
glColor3f(0,1.0f,0);
glBegin(GL_QUADS);
glVertex3f(1.0f,1.0f,-1.0f);
glVertex3f(1.0f,-1.0f,-1.0f);
glVertex3f(-1.0f,-1.0f,-1.0f);
glVertex3f(-1.0f,1.0f,-1.0f);
glEnd();
glColor3f(0,0,1.0f);
glBegin(GL_QUADS);
glVertex3f(1.0f,1.0f,1.0f);
glVertex3f(1.0f,-1.0f,1.0f);
glVertex3f(1.0f,-1.0f,-1.0f);
glVertex3f(1.0f,1.0f,-1.0f);
glEnd();
glColor3f(0,1.0f,1.0f);
glBegin(GL_QUADS);
glVertex3f(-1.0f,1.0f,1.0f);
glVertex3f(-1.0f,-1.0f,1.0f);
glVertex3f(-1.0f,-1.0f,-1.0f);
glVertex3f(-1.0f,1.0f,-1.0f);
glEnd();
glColor3f(1.0f,1.0f,0);
glBegin(GL_QUADS);
glVertex3f(-1.0f,1.0f,-1.0f);
glVertex3f(-1.0f,1.0f,1.0f);
glVertex3f(1.0f,1.0f,1.0f);
glVertex3f(1.0f,1.0f,-1.0f);
glEnd();
glColor3f(1.0f,0,1.0f);
glBegin(GL_QUADS);
glVertex3f(-1.0f,-1.0f,-1.0f);
glVertex3f(-1.0f,-1.0f,1.0f);
glVertex3f(1.0f,-1.0f,1.0f);
glVertex3f(1.0f,-1.0f,-1.0f);
glEnd();
glutSwapBuffers();
glutPostRedisplay();
}
void idle()
{
RX+=1.0f;
RY+=2.0f;
RZ+=3.0f;
glutPostRedisplay();
}
int main( int argc, char *argv[ ])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowSize(800,600); //Optionnel
principale=glutCreateWindow("Ma première fenêtre OpenGL !");
glutReshapeFunc(Reshape);
glutDisplayFunc(Draw);
//glutFullScreen(); //Optionnel
deux=glutCreateSubWindow(1,100,100,100,100);
glutSetWindow(deux);
glutReshapeFunc(Reshape);
glutDisplayFunc(Draw);
trois=glutCreateSubWindow(1,300,300,100,100);
glutSetWindow(trois);
glutReshapeFunc(Reshape);
glutDisplayFunc(Draw);
quatre=glutCreateSubWindow(1,315,250,135,50);
glutSetWindow(quatre);
glutReshapeFunc(Reshape);
glutDisplayFunc(Draw);
InitGL();
glutIdleFunc(idle);
glutMainLoop();
return 0;
}
Je developpe en Dev-c++ version 4.9.9.2 sous windows XP service pack 2
Merci d'avance
Afficher la suite