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