Bonjour,

J'ai une fenetre wxWidgets qui me permet d'afficher de l'openGl et elle fonctionne bien. Mais quand je veux passer du mode fullScreen à une fenetre normal : ça ne fonctionne pas sur Windows (et sur Linux, ça fonctionne) !

Voici mon code main.cpp :
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
#include "main.h"
 
IMPLEMENT_APP(Ini);
bool Ini::OnInit(void)
{
	(new myFrameMain())->Show(true);
	return true;
}
 
myFrameMain::myFrameMain() : wxFrame(NULL, -1, "Test", wxPoint(-1, -1), wxSize(800,600), wxDEFAULT_FRAME_STYLE)
{
	int attribsList[] = {WX_GL_RGBA, WX_GL_MIN_RED, 1, WX_GL_MIN_GREEN, 1, WX_GL_MIN_BLUE, 1, WX_GL_MIN_ALPHA, 1, WX_GL_STENCIL_SIZE, 1, WX_GL_DEPTH_SIZE, 1, WX_GL_DOUBLEBUFFER, 0};
	glCanvas = new myGLCanvas(this, attribsList);
	wxBoxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
	sizer->Add(glCanvas, 1, wxALL|wxEXPAND, 0);
	SetSizer(sizer);
}
 
myGLCanvas::myGLCanvas(myFrameMain *parent, int *attribsList) : wxGLCanvas(parent, -1, attribsList, wxPoint(0,0))
{
	fullScreen=true;
	this->parent = parent;
	glContext = new wxGLContext(this);
 
	parent->ShowFullScreen(fullScreen);
}
 
void myGLCanvas::onIdle(wxIdleEvent &event)
{
	SetCurrent(*glContext);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
	SwapBuffers();
	event.RequestMore();
}
 
void myGLCanvas::onKeyDown(wxKeyEvent &event)
{
	if(event.GetKeyCode() == WXK_F1)
	{
		fullScreen=!fullScreen;
		parent->ShowFullScreen(fullScreen);
	}
}
 
BEGIN_EVENT_TABLE(myGLCanvas, wxGLCanvas)
	EVT_IDLE(myGLCanvas::onIdle)
	EVT_KEY_DOWN(myGLCanvas::onKeyDown)
END_EVENT_TABLE()
main.h
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
#include <wx/wx.h>
#include <wx/glcanvas.h>
 
struct Ini : public wxApp
{
	virtual bool OnInit();
};
 
class myGLCanvas;
class myFrameMain : public wxFrame
{
	public:
		myFrameMain(void);
 
	private:
		myGLCanvas *glCanvas;
};
 
class myGLCanvas : public wxGLCanvas
{
	public:
		myGLCanvas(myFrameMain *, int *);
 
	protected:
		DECLARE_EVENT_TABLE()
 
	private:
		bool fullScreen;
		myFrameMain *parent;
		wxGLContext *glContext;
		void onIdle(wxIdleEvent &);
		void onKeyDown(wxKeyEvent &);
};
NB : Si je met la variable fullScreen à "false" pour commencer, le programme fonctionne parfaitement !