IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

OpenGL Discussion :

Bug avec un multi-fenetrage


Sujet :

OpenGL

  1. #1
    Membre régulier
    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    101
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Septembre 2004
    Messages : 101
    Points : 75
    Points
    75
    Par défaut Bug avec un multi-fenetrage
    bonjours,
    j'essaie de faire un editeur pour mon jeu en utilisant 4 vues a la fois(comme les logiciels 3dsmax,...)

    je utilise l'api win32 mais j'ai un gros bug :


    voici mon code d'affichage :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    int DrawGLScene(GLvoid)									// Here's Where We Do All The Drawing
    {
    glClear(GL_COLOR_BUFFER_BIT);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    gluLookAt(5,5,5,0,0,0,0,1,0);
    glColor3d(1,0,0);
    glBegin(GL_QUADS);
     
    glVertex3i(1,1,1);
    glVertex3i(1,-1,1);
    glVertex3i(-1,-1,1);
    glVertex3i(-1,1,1);
    	//1 face
     
    glVertex3i(1,1,-1);
    glVertex3i(1,-1,-1);
    glVertex3i(-1,-1,-1);
    glVertex3i(-1,1,-1);
    	//2 faces
     
    glVertex3i(1,1,1);
    glVertex3i(1,-1,1);
    glVertex3i(1,-1,-1);
    glVertex3i(1,1,-1);
    	//3 faces
     
    glVertex3i(-1,1,1);
    glVertex3i(-1,-1,1);
    glVertex3i(-1,-1,-1);
    glVertex3i(-1,1,-1);
    	//4 faces
     
    glVertex3i(-1,1,-1);
    glVertex3i(-1,1,1);
    glVertex3i(1,1,1);
    glVertex3i(1,1,-1);
    	//5 faces
     
    glVertex3i(-1,-1,-1);
    glVertex3i(-1,-1,1);
    glVertex3i(1,-1,1);
    glVertex3i(1,-1,-1);
    	//6 faces
    glEnd(); 	
     
       SwapBuffers(hDC[0]);
       SwapBuffers(hDC[1]);
       SwapBuffers(hDC[2]);
       SwapBuffers(hDC[3]);
    	return TRUE;
    }
    et mon code de creation de fenetres :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    BOOL CreateGLWindow(HWND hwnd,char* title,int x, int y, int width, int height, int bits, bool fullscreenflag,WNDPROC proc)
    {
    	GLuint		PixelFormat;			// Holds The Results After Searching For A Match
    	WNDCLASS	wc;						// Windows Class Structure
    	DWORD		dwExStyle;				// Window Extended Style
    	DWORD		dwStyle;				// Window Style
    	RECT		WindowRect;				// Grabs Rectangle Upper Left / Lower Right Values
    	WindowRect.left=(long)x;			// Set Left Value To 0
    	WindowRect.right=(long)width;		// Set Right Value To Requested Width
    	WindowRect.top=(long)y;				// Set Top Value To 0
    	WindowRect.bottom=(long)height;		// Set Bottom Value To Requested Height
     
    	fullscreen=fullscreenflag;			// Set The Global Fullscreen Flag
     
    	hInstance2			= GetModuleHandle(NULL);				// Grab An Instance For Our Window
     
     
     
     
    		dwExStyle= WS_EX_CLIENTEDGE;			// Window Extended Style
    		dwStyle=WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | ES_NUMBER | ES_LEFT;							// Windows Style
     
    	//AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, dwExStyle);		// Adjust Window To True Requested Size
     
    	// Create The Window
    	if (!(hWnd[num_child]=CreateWindowEx(	dwExStyle,							// Extended Style For The Window
    								"OpenGL",							// Class Name
    								title,								// Window Title
    								dwStyle,					// Required Window Style
    								WindowRect.left, WindowRect.top,								// Window Position
    								WindowRect.right,	// Calculate Window Width
    								WindowRect.bottom,	// Calculate Window Height
    								hwnd,								// No Parent Window
    								NULL,								// No Menu
    								hInstance2,							// Instance
    								NULL)))								// Dont Pass Anything To WM_CREATE
    	{
    		KillGLWindow(num_child-1);								// Reset The Display
    		MessageBox(NULL,"Window Creation Error.","ERROR",MB_OK|MB_ICONEXCLAMATION);
    		return FALSE;								// Return FALSE
    	}
     
    	static	PIXELFORMATDESCRIPTOR pfd=				// pfd Tells Windows How We Want Things To Be
    	{
    		sizeof(PIXELFORMATDESCRIPTOR),				// Size Of This Pixel Format Descriptor
    		1,											// Version Number
    		PFD_DRAW_TO_WINDOW |						// Format Must Support Window
    		PFD_SUPPORT_OPENGL |						// Format Must Support OpenGL
    		PFD_DOUBLEBUFFER,							// Must Support Double Buffering
    		PFD_TYPE_RGBA,								// Request An RGBA Format
    		16,										// Select Our Color Depth
    		0, 0, 0, 0, 0, 0,							// Color Bits Ignored
    		0,											// No Alpha Buffer
    		0,											// Shift Bit Ignored
    		0,											// No Accumulation Buffer
    		0, 0, 0, 0,									// Accumulation Bits Ignored
    		32,											// 32Bit Z-Buffer (Depth Buffer)  
    		0,											// No Stencil Buffer
    		0,											// No Auxiliary Buffer
    		0,								// Main Drawing Layer
    		0,											// Reserved
    		0, 0, 0										// Layer Masks Ignored
    	};
     
    	if (!(hDC[num_child]=GetDC(hWnd[num_child])))							// Did We Get A Device Context?
    	{
    		KillGLWindow(num_child-1);								// Reset The Display
    		MessageBox(NULL,"Can't Create A GL Device Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
    		return FALSE;								// Return FALSE
    	}
     
    	if (!(PixelFormat=ChoosePixelFormat(hDC[num_child],&pfd)))	// Did Windows Find A Matching Pixel Format?
    	{
    		KillGLWindow(num_child-1);								// Reset The Display
    		MessageBox(NULL,"Can't Find A Suitable PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION);
    		return FALSE;								// Return FALSE
    	}
     
    	if(!SetPixelFormat(hDC[num_child],PixelFormat,&pfd))		// Are We Able To Set The Pixel Format?
    	{
    		KillGLWindow(num_child-1);								// Reset The Display
    		MessageBox(NULL,"Can't Set The PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION);
    		return FALSE;								// Return FALSE
    	}
     
    	if (!(hRC[num_child]=wglCreateContext(hDC[num_child])))				// Are We Able To Get A Rendering Context?
    	{
    		KillGLWindow(num_child-1);								// Reset The Display
    		MessageBox(NULL,"Can't Create A GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
    		return FALSE;								// Return FALSE
    	}
     
    	if(!wglMakeCurrent(hDC[num_child],hRC[num_child]))					// Try To Activate The Rendering Context
    	{
    		KillGLWindow(num_child-1);								// Reset The Display
    		MessageBox(NULL,"Can't Activate The GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
    		return FALSE;								// Return FALSE
    	}
     
    	ShowWindow(hWnd[num_child],SW_SHOW);						// Show The Window
    	SetForegroundWindow(hWnd[num_child]);						// Slightly Higher Priority
    	SetFocus(hWnd[num_child]);									// Sets Keyboard Focus To The Window
    	ReSizeGLScene(width, height);					// Set Up Our Perspective GL Screen
     
        num_child++;
    	return TRUE;
    }
    et je cree mes 4 sous fenetres comme ceci :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    WNDCLASS wc;
                 wc.style			= 0;	// Redraw On Size, And Own DC For Window.
    	         wc.lpfnWndProc		= (WNDPROC)WndProc2;					// WndProc Handles Messages
    	         wc.cbClsExtra		= 0;									// No Extra Window Data
    	         wc.cbWndExtra		= 0;									// No Extra Window Data
    	         wc.hInstance		= NULL;							// Set The Instance
    	         wc.hIcon			= LoadIcon(NULL, IDI_WINLOGO);			// Load The Default Icon
    	         wc.hCursor			= LoadCursor(NULL, IDC_ARROW);			// Load The Arrow Pointer
    	         wc.hbrBackground	= NULL;									// No Background Required For GL
    	         wc.lpszMenuName		= NULL;								// We Don't Want A Menu
    	         wc.lpszClassName	= "openGL";								// Set The Class Name
     
    	         if (!RegisterClass(&wc))									// Attempt To Register The Window Class
    	         {
    		        MessageBox(NULL,"Failed To Register The Window Class.","ERROR",MB_OK|MB_ICONEXCLAMATION);
    	         	return FALSE;											// Return FALSE
                 }
                 CreateGLWindow(hwnd,"face",0,0,320, 215,16, 0,(WNDPROC) WndProc2);
                 CreateGLWindow(hwnd,"dessus",320,0,320, 215,16, 0,(WNDPROC) WndProc2);
                 CreateGLWindow(hwnd,"cote",0,215,320, 215,16, 0,(WNDPROC) WndProc2);
                 CreateGLWindow(hwnd,"vue 3D",320,215,320, 215,16, 0,(WNDPROC) WndProc2);
     
    InitGL();
    avez vous une idee sur ce qui cause ce bug?

    delfare

  2. #2
    Membre émérite
    Avatar de Ti-R
    Homme Profil pro
    Ingénieur R&D
    Inscrit en
    Avril 2003
    Messages
    1 683
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Ingénieur R&D
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2003
    Messages : 1 683
    Points : 2 568
    Points
    2 568
    Par défaut
    Problème de « context » OpenGL non ?

    Essaye de créer un « context » OpenGL pour chaque fenêtre.
    Partage la liste entre eux.

    Tiens j'ai trouvé un lien en cherchant la commande wglShareList que tu dois utiliser, avec des personnes ayant le même problème que toi.

    http://www.gamedev.net/community/for...topic_id=36751

    Sinon je ne vois pas....

  3. #3
    Membre averti
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    349
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : Suisse

    Informations forums :
    Inscription : Novembre 2005
    Messages : 349
    Points : 379
    Points
    379
    Par défaut
    Ce que je vais dire n'a rien à voir avec ton problème, mais si tu veux faire un simple éditeur avec 4 parties graphiques de taille fixe, il serait plus facile et plus rapide(niveau performances) de faire une seule fenêtre et de la partager en utilisant 4 viewport différents.

  4. #4
    Membre régulier
    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    101
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Septembre 2004
    Messages : 101
    Points : 75
    Points
    75
    Par défaut
    cheps : je croix que je vais faire comme ca.

    au depars, je pensait que ce serait plus simple avec 4 fenetres differentes(y a les callback de souris séparés, une vraie séparation visible entre les fenetres,...) mais ca a l'air de bugger pas mal donc je vais passer aux viewport

  5. #5
    Rédacteur
    Avatar de bafman
    Profil pro
    Développeur informatique
    Inscrit en
    Novembre 2003
    Messages
    2 574
    Détails du profil
    Informations personnelles :
    Âge : 40
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Industrie

    Informations forums :
    Inscription : Novembre 2003
    Messages : 2 574
    Points : 5 323
    Points
    5 323
    Par défaut
    oui oui, un seul context de rendu et plusieurs viewport c'est la solution à adopter, car sinon, tu va tomber sur des porblemes de partages de ressources (listes, textures et autres)
    * Il est infiniment plus simple de faire rapidement un code qui marche que de faire un code rapide qui marche
    * pour faciliter les recherches, n'oubliez pas de voter pour les réponses pertinentes
    Mes articles

Discussions similaires

  1. Bug avec le test de profondeur
    Par Tellmarch dans le forum OpenGL
    Réponses: 1
    Dernier message: 17/10/2004, 00h59
  2. Bug avec requete
    Par arsgunner dans le forum ASP
    Réponses: 8
    Dernier message: 14/06/2004, 16h25
  3. [C#] Bug (?) avec la propriété TransparencyKey de la Form
    Par FrigoAcide dans le forum Windows Forms
    Réponses: 5
    Dernier message: 21/05/2004, 14h14
  4. [CR9] Bug avec les champs à valeur vide ?
    Par Djob dans le forum SAP Crystal Reports
    Réponses: 3
    Dernier message: 15/07/2003, 21h21

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo