]> git.saurik.com Git - wxWidgets.git/blame - wxPython/contrib/glcanvas/msw/myglcanvas.cpp
compilation fix
[wxWidgets.git] / wxPython / contrib / glcanvas / msw / myglcanvas.cpp
CommitLineData
19cf4f80
RD
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
0122b7e3 9// Licence: wxWindows licence
19cf4f80
RD
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
8a721b35 25#undef wxUSE_GLCANVAS
19cf4f80
RD
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
0122b7e3
RD
39static const wxChar *wxGLCanvasClassName = wxT("wxGLCanvasClass");
40static const wxChar *wxGLCanvasClassNameNoRedraw = wxT("wxGLCanvasClassNR");
19cf4f80
RD
41
42LRESULT WXDLLEXPORT APIENTRY _EXPORT wxWndProc(HWND hWnd, UINT message,
43 WPARAM wParam, LPARAM lParam);
44
45/*
46 * GLContext implementation
47 */
48
49wxGLContext::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
61wxGLContext::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
80wxGLContext::~wxGLContext()
81{
82 if (m_glContext)
83 {
84 wglMakeCurrent(NULL, NULL);
85 wglDeleteContext(m_glContext);
86 }
87}
88
89void 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
98void 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
111void 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
ab11ebfa 131IMPLEMENT_CLASS(wxGLCanvas, wxWindow)
19cf4f80 132
ab11ebfa 133BEGIN_EVENT_TABLE(wxGLCanvas, wxWindow)
19cf4f80
RD
134 EVT_SIZE(wxGLCanvas::OnSize)
135 EVT_PALETTE_CHANGED(wxGLCanvas::OnPaletteChanged)
136 EVT_QUERY_NEW_PALETTE(wxGLCanvas::OnQueryNewPalette)
137END_EVENT_TABLE()
138
139wxGLCanvas::wxGLCanvas(wxWindow *parent, wxWindowID id,
140 const wxPoint& pos, const wxSize& size, long style, const wxString& name,
ab11ebfa 141 int *attribList, const wxPalette& palette) : wxWindow()
19cf4f80
RD
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
161wxGLCanvas::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 )
ab11ebfa 165 : wxWindow()
19cf4f80
RD
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
187wxGLCanvas::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 ):
ab11ebfa 190 wxWindow()
19cf4f80
RD
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
212wxGLCanvas::~wxGLCanvas()
213{
214 if (m_glContext)
215 delete m_glContext;
216
217 ::ReleaseDC((HWND) GetHWND(), (HDC) m_hDC);
218}
219
0122b7e3
RD
220// Replaces wxWindow::Create functionality, since we need to use a different
221// window class
222bool wxGLCanvas::Create(wxWindow *parent,
223 wxWindowID id,
224 const wxPoint& pos,
225 const wxSize& size,
226 long style,
227 const wxString& name)
19cf4f80 228{
0122b7e3 229 static bool s_registeredGLCanvasClass = FALSE;
19cf4f80
RD
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
0122b7e3 251 if (!s_registeredGLCanvasClass)
19cf4f80
RD
252 {
253 WNDCLASS wndclass;
254
19cf4f80
RD
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;
0122b7e3 267 wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS | CS_OWNDC;
19cf4f80 268
0122b7e3 269 if ( !::RegisterClass(&wndclass) )
19cf4f80
RD
270 {
271 wxLogLastError(wxT("RegisterClass(wxGLCanvasClass)"));
272 return FALSE;
273 }
274
0122b7e3
RD
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;
19cf4f80
RD
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
0122b7e3 312 msflags |= WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
19cf4f80
RD
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
0122b7e3 333 return MSWCreate(wxGLCanvasClassName, NULL, pos, size, msflags, exStyle);
19cf4f80
RD
334}
335
0122b7e3 336static void AdjustPFDForAttributes(PIXELFORMATDESCRIPTOR& pfd, int *attribList)
19cf4f80 337{
19cf4f80
RD
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 }
0122b7e3
RD
410}
411
412void 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
19cf4f80
RD
438 pixelFormat = ChoosePixelFormat((HDC) m_hDC, &pfd);
439 if (pixelFormat == 0) {
0122b7e3 440 wxLogWarning(_("ChoosePixelFormat failed."));
19cf4f80 441 }
0122b7e3
RD
442 else {
443 if (SetPixelFormat((HDC) m_hDC, pixelFormat, &pfd) != TRUE) {
444 wxLogWarning(_("SetPixelFormat failed."));
445 }
19cf4f80
RD
446 }
447}
448
449void 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 {
0122b7e3 461 return;
19cf4f80
RD
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
478wxPalette 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 {
0122b7e3
RD
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 }
19cf4f80
RD
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
520void wxGLCanvas::SwapBuffers()
521{
522 if (m_glContext)
523 m_glContext->SwapBuffers();
524}
525
526void wxGLCanvas::OnSize(wxSizeEvent& event)
527{
19cf4f80
RD
528}
529
530void wxGLCanvas::SetCurrent()
531{
532 if (m_glContext)
533 {
534 m_glContext->SetCurrent();
535 }
536}
537
538void wxGLCanvas::SetColour(const char *colour)
539{
540 if (m_glContext)
541 m_glContext->SetColour(colour);
542}
543
544// TODO: Have to have this called by parent frame (?)
545// So we need wxFrame to call OnQueryNewPalette for all children...
546void wxGLCanvas::OnQueryNewPalette(wxQueryNewPaletteEvent& event)
547{
548 /* realize palette if this is the current window */
549 if ( GetPalette()->Ok() ) {
550 ::UnrealizeObject((HPALETTE) GetPalette()->GetHPALETTE());
551 ::SelectPalette((HDC) GetHDC(), (HPALETTE) GetPalette()->GetHPALETTE(), FALSE);
552 ::RealizePalette((HDC) GetHDC());
553 Refresh();
554 event.SetPaletteRealized(TRUE);
555 }
556 else
557 event.SetPaletteRealized(FALSE);
558}
559
560// I think this doesn't have to be propagated to child windows.
561void wxGLCanvas::OnPaletteChanged(wxPaletteChangedEvent& event)
562{
563 /* realize palette if this is *not* the current window */
564 if ( GetPalette() &&
565 GetPalette()->Ok() && (this != event.GetChangedWindow()) )
566 {
567 ::UnrealizeObject((HPALETTE) GetPalette()->GetHPALETTE());
568 ::SelectPalette((HDC) GetHDC(), (HPALETTE) GetPalette()->GetHPALETTE(), FALSE);
569 ::RealizePalette((HDC) GetHDC());
570 Refresh();
571 }
572}
573
574/* Give extensions proper function names. */
575
576/* EXT_vertex_array */
577void glArrayElementEXT(GLint i)
578{
579}
580
581void glColorPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer)
582{
583}
584
585void glDrawArraysEXT(GLenum mode, GLint first, GLsizei count)
586{
587#ifdef GL_EXT_vertex_array
588 static PFNGLDRAWARRAYSEXTPROC proc = 0;
589
590 if ( !proc )
591 {
592 proc = (PFNGLDRAWARRAYSEXTPROC) wglGetProcAddress("glDrawArraysEXT");
593 }
594
595 if ( proc )
596 (* proc) (mode, first, count);
597#endif
598}
599
600void glEdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean *pointer)
601{
602}
603
604void glGetPointervEXT(GLenum pname, GLvoid* *params)
605{
606}
607
608void glIndexPointerEXT(GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer)
609{
610}
611
612void glNormalPointerEXT(GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer)
613{
614#ifdef GL_EXT_vertex_array
615 static PFNGLNORMALPOINTEREXTPROC proc = 0;
616
617 if ( !proc )
618 {
619 proc = (PFNGLNORMALPOINTEREXTPROC) wglGetProcAddress("glNormalPointerEXT");
620 }
621
622 if ( proc )
623 (* proc) (type, stride, count, pointer);
624#endif
625}
626
627void glTexCoordPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer)
628{
629}
630
631void glVertexPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer)
632{
633#ifdef GL_EXT_vertex_array
634 static PFNGLVERTEXPOINTEREXTPROC proc = 0;
635
636 if ( !proc )
637 {
638 proc = (PFNGLVERTEXPOINTEREXTPROC) wglGetProcAddress("glVertexPointerEXT");
639 }
640 if ( proc )
641 (* proc) (size, type, stride, count, pointer);
642#endif
643}
644
645/* EXT_color_subtable */
646void glColorSubtableEXT(GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *table)
647{
648}
649
650/* EXT_color_table */
651void glColorTableEXT(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table)
652{
653}
654
655void glCopyColorTableEXT(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width)
656{
657}
658
659void glGetColorTableEXT(GLenum target, GLenum format, GLenum type, GLvoid *table)
660{
661}
662
663void glGetColorTableParamaterfvEXT(GLenum target, GLenum pname, GLfloat *params)
664{
665}
666
667void glGetColorTavleParameterivEXT(GLenum target, GLenum pname, GLint *params)
668{
669}
670
671/* SGI_compiled_vertex_array */
672void glLockArraysSGI(GLint first, GLsizei count)
673{
674}
675
676void glUnlockArraysSGI()
677{
678}
679
680
681/* SGI_cull_vertex */
682void glCullParameterdvSGI(GLenum pname, GLdouble* params)
683{
684}
685
686void glCullParameterfvSGI(GLenum pname, GLfloat* params)
687{
688}
689
690/* SGI_index_func */
691void glIndexFuncSGI(GLenum func, GLclampf ref)
692{
693}
694
695/* SGI_index_material */
696void glIndexMaterialSGI(GLenum face, GLenum mode)
697{
698}
699
700/* WIN_swap_hint */
701void glAddSwapHintRectWin(GLint x, GLint y, GLsizei width, GLsizei height)
702{
703}
704
0122b7e3
RD
705
706//---------------------------------------------------------------------------
707// wxGLApp
708//---------------------------------------------------------------------------
709
710IMPLEMENT_CLASS(wxGLApp, wxApp)
711
712bool wxGLApp::InitGLVisual(int *attribList)
713{
714 int pixelFormat;
715 PIXELFORMATDESCRIPTOR pfd = {
716 sizeof(PIXELFORMATDESCRIPTOR), /* size */
717 1, /* version */
718 PFD_SUPPORT_OPENGL |
719 PFD_DRAW_TO_WINDOW |
720 PFD_DOUBLEBUFFER, /* support double-buffering */
721 PFD_TYPE_RGBA, /* color type */
722 16, /* prefered color depth */
723 0, 0, 0, 0, 0, 0, /* color bits (ignored) */
724 0, /* no alpha buffer */
725 0, /* alpha bits (ignored) */
726 0, /* no accumulation buffer */
727 0, 0, 0, 0, /* accum bits (ignored) */
728 16, /* depth buffer */
729 0, /* no stencil buffer */
730 0, /* no auxiliary buffers */
731 PFD_MAIN_PLANE, /* main layer */
732 0, /* reserved */
733 0, 0, 0, /* no layer, visible, damage masks */
734 };
735
736 AdjustPFDForAttributes(pfd, attribList);
737
738 // use DC for whole (root) screen, since no windows have yet been created
739 pixelFormat = ChoosePixelFormat((HDC) ::GetDC(NULL), &pfd);
740
741 if (pixelFormat == 0) {
742 wxLogError(_("Failed to initialize OpenGL"));
743 return FALSE;
744 }
745
746 return TRUE;
747}
748
749wxGLApp::~wxGLApp()
750{
751}
752
19cf4f80
RD
753#endif
754 // wxUSE_GLCANVAS