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