]> git.saurik.com Git - wxWidgets.git/blob - wxPython/contrib/glcanvas/msw/myglcanvas.cpp
fixed broken TeX markup which resulted in broken links
[wxWidgets.git] / wxPython / contrib / glcanvas / msw / myglcanvas.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: glcanvas.cpp
3 // Purpose: wxGLCanvas, for using OpenGL with wxWindows under MS Windows
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 04/01/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "glcanvas.h"
14 #endif
15
16 #include "wx/wxprec.h"
17
18 #if defined(__BORLANDC__)
19 #pragma hdrstop
20 #endif
21
22 #include <wx/setup.h>
23
24
25 #undef wxUSE_GLCANVAS
26 #define wxUSE_GLCANVAS 1
27 #if wxUSE_GLCANVAS
28
29 #ifndef WX_PRECOMP
30 #include "wx/frame.h"
31 #include "wx/settings.h"
32 #include "wx/intl.h"
33 #include "wx/log.h"
34 #endif
35
36 #include "wx/msw/private.h"
37
38 #include "myglcanvas.h"
39
40 const wxChar* wxGLCanvasName = wxT("GLcanvas");
41 static const wxChar *wxGLCanvasClassName = wxT("wxGLCanvasClass");
42 static const wxChar *wxGLCanvasClassNameNoRedraw = wxT("wxGLCanvasClassNR");
43
44 LRESULT WXDLLEXPORT APIENTRY _EXPORT wxWndProc(HWND hWnd, UINT message,
45 WPARAM wParam, LPARAM lParam);
46
47 /*
48 * GLContext implementation
49 */
50
51 wxGLContext::wxGLContext(bool isRGB, wxGLCanvas *win, const wxPalette& palette)
52 {
53 m_window = win;
54
55 m_hDC = win->GetHDC();
56
57 m_glContext = wglCreateContext((HDC) m_hDC);
58 wxCHECK_RET( m_glContext, wxT("Couldn't create OpenGl context") );
59
60 wglMakeCurrent((HDC) m_hDC, m_glContext);
61 }
62
63 wxGLContext::wxGLContext(
64 bool isRGB, wxGLCanvas *win,
65 const wxPalette& palette,
66 const wxGLContext *other /* for sharing display lists */
67 )
68 {
69 m_window = win;
70
71 m_hDC = win->GetHDC();
72
73 m_glContext = wglCreateContext((HDC) m_hDC);
74 wxCHECK_RET( m_glContext, wxT("Couldn't create OpenGl context") );
75
76 if( other != 0 )
77 wglShareLists( other->m_glContext, m_glContext );
78
79 wglMakeCurrent((HDC) m_hDC, m_glContext);
80 }
81
82 wxGLContext::~wxGLContext()
83 {
84 if (m_glContext)
85 {
86 wglMakeCurrent(NULL, NULL);
87 wglDeleteContext(m_glContext);
88 }
89 }
90
91 void wxGLContext::SwapBuffers()
92 {
93 if (m_glContext)
94 {
95 wglMakeCurrent((HDC) m_hDC, m_glContext);
96 ::SwapBuffers((HDC) m_hDC); //blits the backbuffer into DC
97 }
98 }
99
100 void wxGLContext::SetCurrent()
101 {
102 if (m_glContext)
103 {
104 wglMakeCurrent((HDC) m_hDC, m_glContext);
105 }
106
107 /*
108 setupPixelFormat(hDC);
109 setupPalette(hDC);
110 */
111 }
112
113 void wxGLContext::SetColour(const wxChar *colour)
114 {
115 float r = 0.0;
116 float g = 0.0;
117 float b = 0.0;
118 wxColour *col = wxTheColourDatabase->FindColour(colour);
119 if (col)
120 {
121 r = (float)(col->Red()/256.0);
122 g = (float)(col->Green()/256.0);
123 b = (float)(col->Blue()/256.0);
124 glColor3f( r, g, b);
125 }
126 }
127
128
129 /*
130 * wxGLCanvas implementation
131 */
132
133 IMPLEMENT_CLASS(wxGLCanvas, wxWindow)
134
135 BEGIN_EVENT_TABLE(wxGLCanvas, wxWindow)
136 EVT_SIZE(wxGLCanvas::OnSize)
137 EVT_PALETTE_CHANGED(wxGLCanvas::OnPaletteChanged)
138 EVT_QUERY_NEW_PALETTE(wxGLCanvas::OnQueryNewPalette)
139 END_EVENT_TABLE()
140
141 wxGLCanvas::wxGLCanvas(wxWindow *parent, wxWindowID id,
142 const wxPoint& pos, const wxSize& size, long style, const wxString& name,
143 int *attribList, const wxPalette& palette) : wxWindow()
144 {
145 m_glContext = (wxGLContext*) NULL;
146
147 bool ret = Create(parent, id, pos, size, style, name);
148
149 if ( ret )
150 {
151 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
152 SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
153 }
154
155 m_hDC = (WXHDC) ::GetDC((HWND) GetHWND());
156
157 SetupPixelFormat(attribList);
158 SetupPalette(palette);
159
160 m_glContext = new wxGLContext(TRUE, this, palette);
161 }
162
163 wxGLCanvas::wxGLCanvas( wxWindow *parent,
164 const wxGLContext *shared, wxWindowID id,
165 const wxPoint& pos, const wxSize& size, long style, const wxString& name,
166 int *attribList, const wxPalette& palette )
167 : wxWindow()
168 {
169 m_glContext = (wxGLContext*) NULL;
170
171 bool ret = Create(parent, id, pos, size, style, name);
172
173 if ( ret )
174 {
175 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
176 SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
177 }
178
179 m_hDC = (WXHDC) ::GetDC((HWND) GetHWND());
180
181 SetupPixelFormat(attribList);
182 SetupPalette(palette);
183
184 m_glContext = new wxGLContext(TRUE, this, palette, shared );
185 }
186
187 // Not very useful for wxMSW, but this is to be wxGTK compliant
188
189 wxGLCanvas::wxGLCanvas( wxWindow *parent, const wxGLCanvas *shared, wxWindowID id,
190 const wxPoint& pos, const wxSize& size, long style, const wxString& name,
191 int *attribList, const wxPalette& palette ):
192 wxWindow()
193 {
194 m_glContext = (wxGLContext*) NULL;
195
196 bool ret = Create(parent, id, pos, size, style, name);
197
198 if ( ret )
199 {
200 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
201 SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
202 }
203
204 m_hDC = (WXHDC) ::GetDC((HWND) GetHWND());
205
206 SetupPixelFormat(attribList);
207 SetupPalette(palette);
208
209 wxGLContext *sharedContext=0;
210 if (shared) sharedContext=shared->GetContext();
211 m_glContext = new wxGLContext(TRUE, this, palette, sharedContext );
212 }
213
214 wxGLCanvas::~wxGLCanvas()
215 {
216 if (m_glContext)
217 delete m_glContext;
218
219 ::ReleaseDC((HWND) GetHWND(), (HDC) m_hDC);
220 }
221
222 // Replaces wxWindow::Create functionality, since we need to use a different
223 // window class
224 bool wxGLCanvas::Create(wxWindow *parent,
225 wxWindowID id,
226 const wxPoint& pos,
227 const wxSize& size,
228 long style,
229 const wxString& name)
230 {
231 static bool s_registeredGLCanvasClass = FALSE;
232
233 // We have to register a special window class because we need
234 // the CS_OWNDC style for GLCanvas.
235
236 /*
237 From Angel Popov <jumpo@bitex.com>
238
239 Here are two snips from a dicussion in the OpenGL Gamedev list that explains
240 how this problem can be fixed:
241
242 "There are 5 common DCs available in Win95. These are aquired when you call
243 GetDC or GetDCEx from a window that does _not_ have the OWNDC flag.
244 OWNDC flagged windows do not get their DC from the common DC pool, the issue
245 is they require 800 bytes each from the limited 64Kb local heap for GDI."
246
247 "The deal is, if you hold onto one of the 5 shared DC's too long (as GL apps
248 do), Win95 will actually "steal" it from you. MakeCurrent fails,
249 apparently, because Windows re-assigns the HDC to a different window. The
250 only way to prevent this, the only reliable means, is to set CS_OWNDC."
251 */
252
253 if (!s_registeredGLCanvasClass)
254 {
255 WNDCLASS wndclass;
256
257 // the fields which are common to all classes
258 wndclass.lpfnWndProc = (WNDPROC)wxWndProc;
259 wndclass.cbClsExtra = 0;
260 wndclass.cbWndExtra = sizeof( DWORD ); // VZ: what is this DWORD used for?
261 wndclass.hInstance = wxhInstance;
262 wndclass.hIcon = (HICON) NULL;
263 wndclass.hCursor = ::LoadCursor((HINSTANCE)NULL, IDC_ARROW);
264 wndclass.lpszMenuName = NULL;
265
266 // Register the GLCanvas class name
267 wndclass.hbrBackground = (HBRUSH)NULL;
268 wndclass.lpszClassName = wxGLCanvasClassName;
269 wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS | CS_OWNDC;
270
271 if ( !::RegisterClass(&wndclass) )
272 {
273 wxLogLastError(wxT("RegisterClass(wxGLCanvasClass)"));
274 return FALSE;
275 }
276
277 // Register the GLCanvas class name for windows which don't do full repaint
278 // on resize
279 wndclass.lpszClassName = wxGLCanvasClassNameNoRedraw;
280 wndclass.style &= ~(CS_HREDRAW | CS_VREDRAW);
281
282 if ( !::RegisterClass(&wndclass) )
283 {
284 wxLogLastError(wxT("RegisterClass(wxGLCanvasClassNameNoRedraw)"));
285
286 ::UnregisterClass(wxGLCanvasClassName, wxhInstance);
287
288 return FALSE;
289 }
290
291 s_registeredGLCanvasClass = TRUE;
292 }
293
294 wxCHECK_MSG( parent, FALSE, wxT("can't create wxWindow without parent") );
295
296 if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) )
297 return FALSE;
298
299 parent->AddChild(this);
300
301 DWORD msflags = 0;
302 if ( style & wxBORDER )
303 msflags |= WS_BORDER;
304 if ( style & wxTHICK_FRAME )
305 msflags |= WS_THICKFRAME;
306
307 /*
308 A general rule with OpenGL and Win32 is that any window that will have a
309 HGLRC built for it must have two flags: WS_CLIPCHILDREN & WS_CLIPSIBLINGS.
310 You can find references about this within the knowledge base and most OpenGL
311 books that contain the wgl function descriptions.
312 */
313
314 msflags |= WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
315
316 bool want3D;
317 WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D);
318
319 // Even with extended styles, need to combine with WS_BORDER
320 // for them to look right.
321 if ( want3D || (m_windowStyle & wxSIMPLE_BORDER) || (m_windowStyle & wxRAISED_BORDER ) ||
322 (m_windowStyle & wxSUNKEN_BORDER) || (m_windowStyle & wxDOUBLE_BORDER))
323 {
324 msflags |= WS_BORDER;
325 }
326
327 return MSWCreate(wxGLCanvasClassName, NULL, pos, size, msflags, exStyle);
328 }
329
330 static void AdjustPFDForAttributes(PIXELFORMATDESCRIPTOR& pfd, int *attribList)
331 {
332 if (attribList) {
333 pfd.dwFlags &= ~PFD_DOUBLEBUFFER;
334 pfd.iPixelType = PFD_TYPE_COLORINDEX;
335 pfd.cColorBits = 0;
336 int arg=0;
337
338 while( (attribList[arg]!=0) )
339 {
340 switch( attribList[arg++] )
341 {
342 case WX_GL_RGBA:
343 pfd.iPixelType = PFD_TYPE_RGBA;
344 break;
345 case WX_GL_BUFFER_SIZE:
346 pfd.cColorBits = attribList[arg++];
347 break;
348 case WX_GL_LEVEL:
349 // this member looks like it may be obsolete
350 if (attribList[arg] > 0) {
351 pfd.iLayerType = (BYTE)PFD_OVERLAY_PLANE;
352 } else if (attribList[arg] < 0) {
353 pfd.iLayerType = (BYTE)PFD_UNDERLAY_PLANE;
354 } else {
355 pfd.iLayerType = (BYTE)PFD_MAIN_PLANE;
356 }
357 arg++;
358 break;
359 case WX_GL_DOUBLEBUFFER:
360 pfd.dwFlags |= PFD_DOUBLEBUFFER;
361 break;
362 case WX_GL_STEREO:
363 pfd.dwFlags |= PFD_STEREO;
364 break;
365 case WX_GL_AUX_BUFFERS:
366 pfd.cAuxBuffers = attribList[arg++];
367 break;
368 case WX_GL_MIN_RED:
369 pfd.cColorBits += (pfd.cRedBits = attribList[arg++]);
370 break;
371 case WX_GL_MIN_GREEN:
372 pfd.cColorBits += (pfd.cGreenBits = attribList[arg++]);
373 break;
374 case WX_GL_MIN_BLUE:
375 pfd.cColorBits += (pfd.cBlueBits = attribList[arg++]);
376 break;
377 case WX_GL_MIN_ALPHA:
378 // doesn't count in cColorBits
379 pfd.cAlphaBits = attribList[arg++];
380 break;
381 case WX_GL_DEPTH_SIZE:
382 pfd.cDepthBits = attribList[arg++];
383 break;
384 case WX_GL_STENCIL_SIZE:
385 pfd.cStencilBits = attribList[arg++];
386 break;
387 case WX_GL_MIN_ACCUM_RED:
388 pfd.cAccumBits += (pfd.cAccumRedBits = attribList[arg++]);
389 break;
390 case WX_GL_MIN_ACCUM_GREEN:
391 pfd.cAccumBits += (pfd.cAccumGreenBits = attribList[arg++]);
392 break;
393 case WX_GL_MIN_ACCUM_BLUE:
394 pfd.cAccumBits += (pfd.cAccumBlueBits = attribList[arg++]);
395 break;
396 case WX_GL_MIN_ACCUM_ALPHA:
397 pfd.cAccumBits += (pfd.cAccumAlphaBits = attribList[arg++]);
398 break;
399 default:
400 break;
401 }
402 }
403 }
404 }
405
406 void wxGLCanvas::SetupPixelFormat(int *attribList) // (HDC hDC)
407 {
408 PIXELFORMATDESCRIPTOR pfd = {
409 sizeof(PIXELFORMATDESCRIPTOR), /* size */
410 1, /* version */
411 PFD_SUPPORT_OPENGL |
412 PFD_DRAW_TO_WINDOW |
413 PFD_DOUBLEBUFFER, /* support double-buffering */
414 PFD_TYPE_RGBA, /* color type */
415 16, /* prefered color depth */
416 0, 0, 0, 0, 0, 0, /* color bits (ignored) */
417 0, /* no alpha buffer */
418 0, /* alpha bits (ignored) */
419 0, /* no accumulation buffer */
420 0, 0, 0, 0, /* accum bits (ignored) */
421 16, /* depth buffer */
422 0, /* no stencil buffer */
423 0, /* no auxiliary buffers */
424 PFD_MAIN_PLANE, /* main layer */
425 0, /* reserved */
426 0, 0, 0, /* no layer, visible, damage masks */
427 };
428
429 AdjustPFDForAttributes(pfd, attribList);
430
431 int pixelFormat = ChoosePixelFormat((HDC) m_hDC, &pfd);
432 if (pixelFormat == 0) {
433 wxLogLastError(_T("ChoosePixelFormat"));
434 }
435 else {
436 if ( !::SetPixelFormat((HDC) m_hDC, pixelFormat, &pfd) ) {
437 wxLogLastError(_T("SetPixelFormat"));
438 }
439 }
440 }
441
442 void wxGLCanvas::SetupPalette(const wxPalette& palette)
443 {
444 int pixelFormat = GetPixelFormat((HDC) m_hDC);
445 PIXELFORMATDESCRIPTOR pfd;
446
447 DescribePixelFormat((HDC) m_hDC, pixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
448
449 if (pfd.dwFlags & PFD_NEED_PALETTE)
450 {
451 }
452 else
453 {
454 return;
455 }
456
457 m_palette = palette;
458
459 if ( !m_palette.Ok() )
460 {
461 m_palette = CreateDefaultPalette();
462 }
463
464 if (m_palette.Ok())
465 {
466 SelectPalette((HDC) m_hDC, (HPALETTE) m_palette.GetHPALETTE(), FALSE);
467 RealizePalette((HDC) m_hDC);
468 }
469 }
470
471 wxPalette wxGLCanvas::CreateDefaultPalette()
472 {
473 PIXELFORMATDESCRIPTOR pfd;
474 int paletteSize;
475 int pixelFormat = GetPixelFormat((HDC) m_hDC);
476
477 DescribePixelFormat((HDC) m_hDC, pixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
478
479 paletteSize = 1 << pfd.cColorBits;
480
481 LOGPALETTE* pPal =
482 (LOGPALETTE*) malloc(sizeof(LOGPALETTE) + paletteSize * sizeof(PALETTEENTRY));
483 pPal->palVersion = 0x300;
484 pPal->palNumEntries = paletteSize;
485
486 /* build a simple RGB color palette */
487 {
488 int redMask = (1 << pfd.cRedBits) - 1;
489 int greenMask = (1 << pfd.cGreenBits) - 1;
490 int blueMask = (1 << pfd.cBlueBits) - 1;
491 int i;
492
493 for (i=0; i<paletteSize; ++i) {
494 pPal->palPalEntry[i].peRed =
495 (((i >> pfd.cRedShift) & redMask) * 255) / redMask;
496 pPal->palPalEntry[i].peGreen =
497 (((i >> pfd.cGreenShift) & greenMask) * 255) / greenMask;
498 pPal->palPalEntry[i].peBlue =
499 (((i >> pfd.cBlueShift) & blueMask) * 255) / blueMask;
500 pPal->palPalEntry[i].peFlags = 0;
501 }
502 }
503
504 HPALETTE hPalette = CreatePalette(pPal);
505 free(pPal);
506
507 wxPalette palette;
508 palette.SetHPALETTE((WXHPALETTE) hPalette);
509
510 return palette;
511 }
512
513 void wxGLCanvas::SwapBuffers()
514 {
515 if (m_glContext)
516 m_glContext->SwapBuffers();
517 }
518
519 void wxGLCanvas::OnSize(wxSizeEvent& event)
520 {
521 }
522
523 void wxGLCanvas::SetCurrent()
524 {
525 if (m_glContext)
526 {
527 m_glContext->SetCurrent();
528 }
529 }
530
531 void wxGLCanvas::SetColour(const wxChar *colour)
532 {
533 if (m_glContext)
534 m_glContext->SetColour(colour);
535 }
536
537 // TODO: Have to have this called by parent frame (?)
538 // So we need wxFrame to call OnQueryNewPalette for all children...
539 void wxGLCanvas::OnQueryNewPalette(wxQueryNewPaletteEvent& event)
540 {
541 /* realize palette if this is the current window */
542 if ( GetPalette()->Ok() ) {
543 ::UnrealizeObject((HPALETTE) GetPalette()->GetHPALETTE());
544 ::SelectPalette((HDC) GetHDC(), (HPALETTE) GetPalette()->GetHPALETTE(), FALSE);
545 ::RealizePalette((HDC) GetHDC());
546 Refresh();
547 event.SetPaletteRealized(TRUE);
548 }
549 else
550 event.SetPaletteRealized(FALSE);
551 }
552
553 // I think this doesn't have to be propagated to child windows.
554 void wxGLCanvas::OnPaletteChanged(wxPaletteChangedEvent& event)
555 {
556 /* realize palette if this is *not* the current window */
557 if ( GetPalette() &&
558 GetPalette()->Ok() && (this != event.GetChangedWindow()) )
559 {
560 ::UnrealizeObject((HPALETTE) GetPalette()->GetHPALETTE());
561 ::SelectPalette((HDC) GetHDC(), (HPALETTE) GetPalette()->GetHPALETTE(), FALSE);
562 ::RealizePalette((HDC) GetHDC());
563 Refresh();
564 }
565 }
566
567 /* Give extensions proper function names. */
568
569 /* EXT_vertex_array */
570 void glArrayElementEXT(GLint i)
571 {
572 }
573
574 void glColorPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer)
575 {
576 }
577
578 void glDrawArraysEXT(GLenum mode, GLint first, GLsizei count)
579 {
580 #ifdef GL_EXT_vertex_array
581 static PFNGLDRAWARRAYSEXTPROC proc = 0;
582
583 if ( !proc )
584 {
585 proc = (PFNGLDRAWARRAYSEXTPROC) wglGetProcAddress("glDrawArraysEXT");
586 }
587
588 if ( proc )
589 (* proc) (mode, first, count);
590 #endif
591 }
592
593 void glEdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean *pointer)
594 {
595 }
596
597 void glGetPointervEXT(GLenum pname, GLvoid* *params)
598 {
599 }
600
601 void glIndexPointerEXT(GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer)
602 {
603 }
604
605 void glNormalPointerEXT(GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer)
606 {
607 #ifdef GL_EXT_vertex_array
608 static PFNGLNORMALPOINTEREXTPROC proc = 0;
609
610 if ( !proc )
611 {
612 proc = (PFNGLNORMALPOINTEREXTPROC) wglGetProcAddress("glNormalPointerEXT");
613 }
614
615 if ( proc )
616 (* proc) (type, stride, count, pointer);
617 #endif
618 }
619
620 void glTexCoordPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer)
621 {
622 }
623
624 void glVertexPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer)
625 {
626 #ifdef GL_EXT_vertex_array
627 static PFNGLVERTEXPOINTEREXTPROC proc = 0;
628
629 if ( !proc )
630 {
631 proc = (PFNGLVERTEXPOINTEREXTPROC) wglGetProcAddress("glVertexPointerEXT");
632 }
633 if ( proc )
634 (* proc) (size, type, stride, count, pointer);
635 #endif
636 }
637
638 /* EXT_color_subtable */
639 void glColorSubtableEXT(GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *table)
640 {
641 }
642
643 /* EXT_color_table */
644 void glColorTableEXT(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table)
645 {
646 }
647
648 void glCopyColorTableEXT(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width)
649 {
650 }
651
652 void glGetColorTableEXT(GLenum target, GLenum format, GLenum type, GLvoid *table)
653 {
654 }
655
656 void glGetColorTableParamaterfvEXT(GLenum target, GLenum pname, GLfloat *params)
657 {
658 }
659
660 void glGetColorTavleParameterivEXT(GLenum target, GLenum pname, GLint *params)
661 {
662 }
663
664 /* SGI_compiled_vertex_array */
665 void glLockArraysSGI(GLint first, GLsizei count)
666 {
667 }
668
669 void glUnlockArraysSGI()
670 {
671 }
672
673
674 /* SGI_cull_vertex */
675 void glCullParameterdvSGI(GLenum pname, GLdouble* params)
676 {
677 }
678
679 void glCullParameterfvSGI(GLenum pname, GLfloat* params)
680 {
681 }
682
683 /* SGI_index_func */
684 void glIndexFuncSGI(GLenum func, GLclampf ref)
685 {
686 }
687
688 /* SGI_index_material */
689 void glIndexMaterialSGI(GLenum face, GLenum mode)
690 {
691 }
692
693 /* WIN_swap_hint */
694 void glAddSwapHintRectWin(GLint x, GLint y, GLsizei width, GLsizei height)
695 {
696 }
697
698
699 //---------------------------------------------------------------------------
700 // wxGLApp
701 //---------------------------------------------------------------------------
702
703 IMPLEMENT_CLASS(wxGLApp, wxApp)
704
705 bool wxGLApp::InitGLVisual(int *attribList)
706 {
707 int pixelFormat;
708 PIXELFORMATDESCRIPTOR pfd = {
709 sizeof(PIXELFORMATDESCRIPTOR), /* size */
710 1, /* version */
711 PFD_SUPPORT_OPENGL |
712 PFD_DRAW_TO_WINDOW |
713 PFD_DOUBLEBUFFER, /* support double-buffering */
714 PFD_TYPE_RGBA, /* color type */
715 16, /* prefered color depth */
716 0, 0, 0, 0, 0, 0, /* color bits (ignored) */
717 0, /* no alpha buffer */
718 0, /* alpha bits (ignored) */
719 0, /* no accumulation buffer */
720 0, 0, 0, 0, /* accum bits (ignored) */
721 16, /* depth buffer */
722 0, /* no stencil buffer */
723 0, /* no auxiliary buffers */
724 PFD_MAIN_PLANE, /* main layer */
725 0, /* reserved */
726 0, 0, 0, /* no layer, visible, damage masks */
727 };
728
729 AdjustPFDForAttributes(pfd, attribList);
730
731 // use DC for whole (root) screen, since no windows have yet been created
732 pixelFormat = ChoosePixelFormat(ScreenHDC(), &pfd);
733
734 if (pixelFormat == 0) {
735 wxLogError(_("Failed to initialize OpenGL"));
736 return FALSE;
737 }
738
739 return TRUE;
740 }
741
742 wxGLApp::~wxGLApp()
743 {
744 }
745
746 #endif
747 // wxUSE_GLCANVAS