X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/53fcd32e576b8662c0d044d2e0e65eb15df88022..fd0fca1a25931e51d7e56695875fba5030bf3e07:/src/msw/glcanvas.cpp diff --git a/src/msw/glcanvas.cpp b/src/msw/glcanvas.cpp index 65a39574a5..a463d64c6d 100644 --- a/src/msw/glcanvas.cpp +++ b/src/msw/glcanvas.cpp @@ -9,10 +9,6 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) -#pragma implementation "glcanvas.h" -#endif - #include "wx/wxprec.h" #if defined(__BORLANDC__) @@ -39,6 +35,12 @@ WX_CHECK_BUILD_OPTIONS("wxGL") #include "wx/glcanvas.h" +#if GL_EXT_vertex_array + #define WXUNUSED_WITHOUT_GL_EXT_vertex_array(name) name +#else + #define WXUNUSED_WITHOUT_GL_EXT_vertex_array(name) WXUNUSED(name) +#endif + /* The following two compiler directives are specific to the Microsoft Visual C++ family of compilers @@ -237,11 +239,6 @@ void wxGLContext::SetCurrent() { wglMakeCurrent((HDC) m_hDC, m_glContext); } - - /* - setupPixelFormat(hDC); - setupPalette(hDC); - */ } void wxGLContext::SetColour(const wxChar *colour) @@ -401,7 +398,7 @@ static void AdjustPFDForAttributes(PIXELFORMATDESCRIPTOR& pfd, int *attribList) pfd.iPixelType = PFD_TYPE_RGBA; break; case WX_GL_BUFFER_SIZE: - pfd.cColorBits = attribList[arg++]; + pfd.cColorBits = (BYTE)attribList[arg++]; break; case WX_GL_LEVEL: // this member looks like it may be obsolete @@ -421,38 +418,38 @@ static void AdjustPFDForAttributes(PIXELFORMATDESCRIPTOR& pfd, int *attribList) pfd.dwFlags |= PFD_STEREO; break; case WX_GL_AUX_BUFFERS: - pfd.cAuxBuffers = attribList[arg++]; + pfd.cAuxBuffers = (BYTE)attribList[arg++]; break; case WX_GL_MIN_RED: - pfd.cColorBits += (pfd.cRedBits = attribList[arg++]); + pfd.cColorBits = (BYTE)(pfd.cColorBits + (pfd.cRedBits = (BYTE)attribList[arg++])); break; case WX_GL_MIN_GREEN: - pfd.cColorBits += (pfd.cGreenBits = attribList[arg++]); + pfd.cColorBits = (BYTE)(pfd.cColorBits + (pfd.cGreenBits = (BYTE)attribList[arg++])); break; case WX_GL_MIN_BLUE: - pfd.cColorBits += (pfd.cBlueBits = attribList[arg++]); + pfd.cColorBits = (BYTE)(pfd.cColorBits + (pfd.cBlueBits = (BYTE)attribList[arg++])); break; case WX_GL_MIN_ALPHA: // doesn't count in cColorBits - pfd.cAlphaBits = attribList[arg++]; + pfd.cAlphaBits = (BYTE)attribList[arg++]; break; case WX_GL_DEPTH_SIZE: - pfd.cDepthBits = attribList[arg++]; + pfd.cDepthBits = (BYTE)attribList[arg++]; break; case WX_GL_STENCIL_SIZE: - pfd.cStencilBits = attribList[arg++]; + pfd.cStencilBits = (BYTE)attribList[arg++]; break; case WX_GL_MIN_ACCUM_RED: - pfd.cAccumBits += (pfd.cAccumRedBits = attribList[arg++]); + pfd.cAccumBits = (BYTE)(pfd.cAccumBits + (pfd.cAccumRedBits = (BYTE)attribList[arg++])); break; case WX_GL_MIN_ACCUM_GREEN: - pfd.cAccumBits += (pfd.cAccumGreenBits = attribList[arg++]); + pfd.cAccumBits = (BYTE)(pfd.cAccumBits + (pfd.cAccumGreenBits = (BYTE)attribList[arg++])); break; case WX_GL_MIN_ACCUM_BLUE: - pfd.cAccumBits += (pfd.cAccumBlueBits = attribList[arg++]); + pfd.cAccumBits = (BYTE)(pfd.cAccumBits + (pfd.cAccumBlueBits = (BYTE)attribList[arg++])); break; case WX_GL_MIN_ACCUM_ALPHA: - pfd.cAccumBits += (pfd.cAccumAlphaBits = attribList[arg++]); + pfd.cAccumBits = (BYTE)(pfd.cAccumBits + (pfd.cAccumAlphaBits = (BYTE)attribList[arg++])); break; default: break; @@ -470,7 +467,7 @@ void wxGLCanvas::SetupPixelFormat(int *attribList) // (HDC hDC) PFD_DRAW_TO_WINDOW | PFD_DOUBLEBUFFER, /* support double-buffering */ PFD_TYPE_RGBA, /* color type */ - 16, /* prefered color depth */ + 16, /* preferred color depth */ 0, 0, 0, 0, 0, 0, /* color bits (ignored) */ 0, /* no alpha buffer */ 0, /* alpha bits (ignored) */ @@ -539,7 +536,7 @@ wxPalette wxGLCanvas::CreateDefaultPalette() LOGPALETTE* pPal = (LOGPALETTE*) malloc(sizeof(LOGPALETTE) + paletteSize * sizeof(PALETTEENTRY)); pPal->palVersion = 0x300; - pPal->palNumEntries = paletteSize; + pPal->palNumEntries = (WORD)paletteSize; /* build a simple RGB color palette */ { @@ -550,11 +547,11 @@ wxPalette wxGLCanvas::CreateDefaultPalette() for (i=0; ipalPalEntry[i].peRed = - (((i >> pfd.cRedShift) & redMask) * 255) / redMask; + (BYTE)((((i >> pfd.cRedShift) & redMask) * 255) / redMask); pPal->palPalEntry[i].peGreen = - (((i >> pfd.cGreenShift) & greenMask) * 255) / greenMask; + (BYTE)((((i >> pfd.cGreenShift) & greenMask) * 255) / greenMask); pPal->palPalEntry[i].peBlue = - (((i >> pfd.cBlueShift) & blueMask) * 255) / blueMask; + (BYTE)((((i >> pfd.cBlueShift) & blueMask) * 255) / blueMask); pPal->palPalEntry[i].peFlags = 0; } } @@ -580,6 +577,12 @@ void wxGLCanvas::OnSize(wxSizeEvent& WXUNUSED(event)) void wxGLCanvas::SetCurrent() { + // although on MSW it works even if the window is still hidden, it doesn't + // under wxGTK and documentation mentions that SetCurrent() can only be + // called for a shown window, so check it + wxASSERT_MSG( GetParent()->IsShown(), + _T("can't make hidden GL canvas current") ); + if (m_glContext) { m_glContext->SetCurrent(); @@ -633,7 +636,9 @@ void glColorPointerEXT(GLint WXUNUSED(size), GLenum WXUNUSED(type), GLsizei WXUN { } -void glDrawArraysEXT(GLenum mode, GLint first, GLsizei count) +void glDrawArraysEXT(GLenum WXUNUSED_WITHOUT_GL_EXT_vertex_array(mode), + GLint WXUNUSED_WITHOUT_GL_EXT_vertex_array(first), + GLsizei WXUNUSED_WITHOUT_GL_EXT_vertex_array(count)) { #ifdef GL_EXT_vertex_array static PFNGLDRAWARRAYSEXTPROC proc = 0; @@ -660,7 +665,10 @@ void glIndexPointerEXT(GLenum WXUNUSED(type), GLsizei WXUNUSED(stride), GLsizei { } -void glNormalPointerEXT(GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer) +void glNormalPointerEXT(GLenum WXUNUSED_WITHOUT_GL_EXT_vertex_array(type), + GLsizei WXUNUSED_WITHOUT_GL_EXT_vertex_array(stride), + GLsizei WXUNUSED_WITHOUT_GL_EXT_vertex_array(count), + const GLvoid *WXUNUSED_WITHOUT_GL_EXT_vertex_array(pointer)) { #ifdef GL_EXT_vertex_array static PFNGLNORMALPOINTEREXTPROC proc = 0; @@ -679,7 +687,11 @@ void glTexCoordPointerEXT(GLint WXUNUSED(size), GLenum WXUNUSED(type), GLsizei W { } -void glVertexPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer) +void glVertexPointerEXT(GLint WXUNUSED_WITHOUT_GL_EXT_vertex_array(size), + GLenum WXUNUSED_WITHOUT_GL_EXT_vertex_array(type), + GLsizei WXUNUSED_WITHOUT_GL_EXT_vertex_array(stride), + GLsizei WXUNUSED_WITHOUT_GL_EXT_vertex_array(count), + const GLvoid *WXUNUSED_WITHOUT_GL_EXT_vertex_array(pointer)) { #ifdef GL_EXT_vertex_array static PFNGLVERTEXPOINTEREXTPROC proc = 0; @@ -770,7 +782,7 @@ bool wxGLApp::InitGLVisual(int *attribList) PFD_DRAW_TO_WINDOW | PFD_DOUBLEBUFFER, /* support double-buffering */ PFD_TYPE_RGBA, /* color type */ - 16, /* prefered color depth */ + 16, /* preferred color depth */ 0, 0, 0, 0, 0, 0, /* color bits (ignored) */ 0, /* no alpha buffer */ 0, /* alpha bits (ignored) */