tomwalters@397: // Copyright 2006, Willem van Engen tomwalters@397: // tomwalters@397: // AIM-C: A C++ implementation of the Auditory Image Model tomwalters@397: // http://www.acousticscale.org/AIMC tomwalters@397: // tomwalters@397: // Licensed under the Apache License, Version 2.0 (the "License"); tomwalters@397: // you may not use this file except in compliance with the License. tomwalters@397: // You may obtain a copy of the License at tomwalters@397: // tomwalters@397: // http://www.apache.org/licenses/LICENSE-2.0 tomwalters@397: // tomwalters@397: // Unless required by applicable law or agreed to in writing, software tomwalters@397: // distributed under the License is distributed on an "AS IS" BASIS, tomwalters@397: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. tomwalters@397: // See the License for the specific language governing permissions and tomwalters@397: // limitations under the License. tomwalters@397: tomwalters@397: /*! tomwalters@397: * \file tomwalters@397: * \brief Output device for output to a wxWidgets OpenGL canvas tomwalters@397: * tomwalters@397: * \author Willem van Engen tomwalters@397: * \date created 2006/09/21 tomwalters@397: * \version \$Id: $ tomwalters@397: */ tomwalters@397: tomwalters@397: #include "Support/Common.h" tomwalters@397: tomwalters@397: /*! \class GraphicsOutputDevicewxGLCanvas tomwalters@397: * tomwalters@397: * Graphics output takes a large part of the application's performance at the tomwalters@397: * moment when it is inline with the Process() loop. Much is gained by tomwalters@397: * putting it in a separate thread, which can be done using ShotTargetThreaded. tomwalters@397: * tomwalters@397: * OpenGL-related documents: tomwalters@397: * - http://www.opengl.org/ tomwalters@397: * - http://www.sgi.com/products/software/opengl/ tomwalters@397: * - http://developer.apple.com/graphicsimaging/opengl/ tomwalters@397: * - http://developer.nvidia.com/page/documentation.html tomwalters@397: * - Vertex arrays tomwalters@397: * - http://www.opengl.org/registry/specs/EXT/vertex_array.txt tomwalters@397: * - http://www.awprofessional.com/articles/article.asp?p=461848&seqNum=2&rl=1 tomwalters@397: * - http://jdobry.webpark.cz/opengl/opengl_maximum_performance.html tomwalters@397: * - Fonts and OpenGL tomwalters@397: * - http://gltt.sourceforge.net/ tomwalters@397: */ tomwalters@397: tomwalters@397: // And finally our own tomwalters@397: #include "Support/util.h" tomwalters@397: #include "Output/GraphicsOutputDevice.h" tomwalters@397: #include "Output/GraphicsOutputDevicewxGLCanvas.h" tomwalters@397: tomwalters@397: BEGIN_EVENT_TABLE(GraphicsOutputDevicewxGLCanvas, wxGLCanvas) tomwalters@397: EVT_SIZE(GraphicsOutputDevicewxGLCanvas::OnSize) tomwalters@397: EVT_PAINT(GraphicsOutputDevicewxGLCanvas::OnPaint) tomwalters@397: EVT_ERASE_BACKGROUND(GraphicsOutputDevicewxGLCanvas::OnEraseBackground) tomwalters@397: END_EVENT_TABLE() tomwalters@397: tomwalters@397: // wxGLCanvas attributes tomwalters@397: int GraphicsOutputDevicewxGLCanvas::GLAttrlist[] = { tomwalters@397: WX_GL_RGBA, 1, tomwalters@397: WX_GL_DOUBLEBUFFER, 1, tomwalters@397: WX_GL_MIN_RED, 5, tomwalters@397: WX_GL_MIN_GREEN, 5, tomwalters@397: WX_GL_MIN_BLUE, 5, tomwalters@397: WX_GL_MIN_ALPHA, 3, tomwalters@397: WX_GL_DEPTH_SIZE, 16, tomwalters@397: 0 tomwalters@397: }; tomwalters@397: tomwalters@397: // OpenGL get procaddress function pointer, differs across platforms tomwalters@397: typedef void (*(*glGetProcAddressPtr_t)(const char*))(); tomwalters@397: tomwalters@397: GraphicsOutputDevicewxGLCanvas::GraphicsOutputDevicewxGLCanvas(Parameters *pParam, tomwalters@398: wxWindow *parent, tomwalters@397: wxWindowID id, tomwalters@397: const wxPoint& pos, tomwalters@397: const wxSize& size, tomwalters@397: long style, tomwalters@397: const wxString& name) tomwalters@398: : wxGLCanvas(parent, (wxGLCanvas*) NULL, id, pos, size, tomwalters@397: style|wxFULL_REPAINT_ON_RESIZE, name, GLAttrlist), tomwalters@398: GraphicsOutputDevice(pParam) { tomwalters@398: m_init = false; tomwalters@398: m_gllist = 0; tomwalters@398: m_pWorkerContext = NULL; tomwalters@398: m_bAntialiasing = true; tomwalters@398: m_pFont = NULL; tomwalters@398: m_sFontFile = NULL; tomwalters@398: m_iFontsize = -1; tomwalters@397: #if !defined(_MACOSX) tomwalters@398: s_bWorkerNeedsInit = false; tomwalters@397: #endif tomwalters@397: tomwalters@397: #ifdef WITH_GL_VERTEX_ARRAYS tomwalters@398: m_iVertexType = 0xffff; // no gBegin() has happened yet tomwalters@398: m_bStaticColor = false; tomwalters@398: m_pVertices = NULL; tomwalters@398: m_iVerticesMax = 0; tomwalters@398: // Enable vertex arrays if possible tomwalters@397: #ifdef _MACOSX tomwalters@398: m_glLockArraysEXT = ::glLockArraysEXT; tomwalters@398: m_glUnlockArraysEXT = ::glUnlockArraysEXT; tomwalters@398: m_bVertexArrayLock = true; tomwalters@397: #else tomwalters@398: m_bVertexArrayLock = false; tomwalters@398: // OpenGL command needed to fetch entry point, do it in InitGL() tomwalters@397: #endif /* _MACOSX */ tomwalters@397: #endif /* WITH_GL_VERTEX_ARRAYS */ tomwalters@397: } tomwalters@397: tomwalters@397: GraphicsOutputDevicewxGLCanvas::~GraphicsOutputDevicewxGLCanvas() { tomwalters@398: // Cleanup OpenGL display list tomwalters@398: if (m_init) { tomwalters@398: glDeleteLists(m_gllist, 1); tomwalters@398: } tomwalters@398: DELETE_IF_NONNULL(m_pWorkerContext); tomwalters@398: DELETE_IF_NONNULL(m_pFont); tomwalters@397: #ifdef WITH_GL_VERTEX_ARRAYS tomwalters@398: DELETE_ARRAY_IF_NONNULL(m_pVertices); tomwalters@397: #endif tomwalters@397: } tomwalters@397: tomwalters@397: void GraphicsOutputDevicewxGLCanvas::Start() { tomwalters@398: // This seems to be needed to prevent a crash on windows, but why???? tomwalters@398: SetCurrent(); tomwalters@398: return GraphicsOutputDevice::Start(); tomwalters@397: } tomwalters@397: tomwalters@397: bool GraphicsOutputDevicewxGLCanvas::Initialize(unsigned int iVerticesMax) { tomwalters@398: AIM_ASSERT(m_pParam); tomwalters@398: // Give a chance to update anti-aliasing settings tomwalters@398: if (m_bAntialiasing != m_pParam->GetBool("output.antialias")) { tomwalters@398: m_bAntialiasing = m_pParam->GetBool("output.antialias"); tomwalters@398: if (SetCurrent()) { tomwalters@398: InitGL(); tomwalters@397: #if !defined(_MACOSX) tomwalters@398: { tomwalters@398: wxMutexLocker lock(s_mutexOpenGL); tomwalters@398: s_bWorkerNeedsInit = true; tomwalters@398: } tomwalters@397: #endif tomwalters@398: } tomwalters@398: } tomwalters@397: tomwalters@397: #ifdef WITH_GL_VERTEX_ARRAYS tomwalters@398: // Re-allocate vertices tomwalters@398: if (iVerticesMax > m_iVerticesMax) { tomwalters@398: DELETE_IF_NONNULL(m_pVertices); tomwalters@398: m_iVerticesMax = iVerticesMax; tomwalters@398: // If color is static, we need not store the color tomwalters@398: if (m_bStaticColor) tomwalters@398: m_pVertices = new GLfloat[(iVerticesMax+1)*3]; tomwalters@398: else tomwalters@398: m_pVertices = new GLfloat[(iVerticesMax+1)*6]; tomwalters@398: } tomwalters@397: #endif tomwalters@397: tomwalters@397: // Change font if requested tomwalters@398: const char *sFontFile = m_pParam->GetString("output.gl.fontfile"); tomwalters@398: unsigned int iFontsize = m_pParam->GetUInt("output.fontsize"); tomwalters@398: if (!m_sFontFile tomwalters@397: || !strcmp(m_sFontFile,sFontFile)==0 tomwalters@397: || m_iFontsize!=(int)iFontsize) { tomwalters@398: wxMutexLocker lock(s_mutexOpenGL); tomwalters@398: DELETE_IF_NONNULL(m_pFont); tomwalters@398: wxString sWorkingFontFilename = wxString::FromAscii(sFontFile); tomwalters@398: if (!wxFileExists(sWorkingFontFilename)) { tomwalters@398: sWorkingFontFilename = wxString::FromAscii(aimDataDir()); tomwalters@398: sWorkingFontFilename += _T("/"); tomwalters@398: sWorkingFontFilename += wxString::FromAscii(sFontFile); tomwalters@398: } tomwalters@398: //if (!wxFileExists(sWorkingFontFilename)) tomwalters@398: //sWorkingFontFilename.replace("Font:").append(sFontFile); tomwalters@398: m_pFont = static_cast(new FTGLBitmapFont(sWorkingFontFilename.fn_str())); tomwalters@398: if (!m_pFont || m_pFont->Error()) { tomwalters@398: aimERROR(_T("Couldn't load font '%s'"), sFontFile); tomwalters@398: DELETE_IF_NONNULL(m_pFont); tomwalters@398: } else { tomwalters@398: // Display lists don't mix with our own usage :( tomwalters@398: // May not be needed for a Bitmap font tomwalters@398: //m_pFont->UseDisplayList(false); tomwalters@398: if ( !m_pFont->FaceSize(iFontsize) ) { tomwalters@398: AIM_ERROR(_T("Couldn't select font size %u on font '%s'"), iFontsize, sFontFile); tomwalters@398: DELETE_IF_NONNULL(m_pFont); tomwalters@398: } tomwalters@398: } tomwalters@398: m_sFontFile = sFontFile; tomwalters@398: m_iFontsize = iFontsize; tomwalters@398: } tomwalters@398: return true; tomwalters@397: } tomwalters@397: bool GraphicsOutputDevicewxGLCanvas::Initialize() { tomwalters@398: return Initialize(0); tomwalters@397: } tomwalters@397: tomwalters@397: void GraphicsOutputDevicewxGLCanvas::Render() { tomwalters@398: wxPaintDC dc(this); tomwalters@398: // We want to initialize first from main thread. tomwalters@398: if (!m_init) { tomwalters@398: if (!SetCurrent()) return; tomwalters@398: InitGL(); tomwalters@398: } tomwalters@398: // Render saved list only if not animating (redrawn anyway in that case) tomwalters@398: if (!m_bRunning) { tomwalters@398: if (!SetCurrent()) { tomwalters@397: return; tomwalters@397: } tomwalters@398: glClear(GL_COLOR_BUFFER_BIT/*|GL_DEPTH_BUFFER_BIT*/); tomwalters@398: glCallList(m_gllist); tomwalters@398: SwapBuffers(); tomwalters@398: } tomwalters@397: } tomwalters@397: tomwalters@397: void GraphicsOutputDevicewxGLCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { tomwalters@397: Render(); tomwalters@397: } tomwalters@397: tomwalters@397: void GraphicsOutputDevicewxGLCanvas::OnSize(wxSizeEvent& event) { tomwalters@397: // this is also necessary to update the context on some platforms tomwalters@397: wxGLCanvas::OnSize(event); tomwalters@397: tomwalters@397: // set GL viewport tomwalters@398: // (not called by wxGLCanvas::OnSize on all platforms...) tomwalters@397: if (SetCurrent()) { tomwalters@398: DoResize(); tomwalters@398: // It is only sensible to update the other thread when it's running tomwalters@398: // Don't acquire the mutex when s_bWorkerNeedsInit already to avoid deadlock tomwalters@398: if (/*m_bRunning &&*/ !s_bWorkerNeedsInit) { tomwalters@398: wxMutexLocker lock(s_mutexOpenGL); tomwalters@398: s_bWorkerNeedsInit = true; tomwalters@398: } tomwalters@398: } tomwalters@397: } tomwalters@397: tomwalters@397: void GraphicsOutputDevicewxGLCanvas::OnEraseBackground(wxEraseEvent& WXUNUSED(event)) { tomwalters@397: } tomwalters@397: tomwalters@397: bool GraphicsOutputDevicewxGLCanvas::SetCurrent() { tomwalters@397: bool bRet=true; tomwalters@397: tomwalters@397: #ifndef __WXMOTIF__ tomwalters@398: bRet = (GetContext()!=NULL); tomwalters@398: if (bRet) tomwalters@397: #endif tomwalters@398: { tomwalters@398: wxGLCanvas::SetCurrent(); tomwalters@398: } tomwalters@398: return bRet; tomwalters@397: } tomwalters@397: tomwalters@397: void GraphicsOutputDevicewxGLCanvas::DoResize() { tomwalters@397: int w, h; tomwalters@398: GetClientSize(&w, &h); tomwalters@398: glViewport(0, 0, (GLint)w, (GLint)h); tomwalters@397: } tomwalters@397: tomwalters@397: void GraphicsOutputDevicewxGLCanvas::InitGL() { tomwalters@397: /* No SetCurrent() here, because this can be called from different GL contexts. tomwalters@398: * Convenient for multi-threaded operation. */ tomwalters@397: //aimERROR(_T("InitGL Called")); tomwalters@397: #if defined(WITH_GL_VERTEX_ARRAYS) && !defined(_MACOSX) tomwalters@398: if (!m_init) { tomwalters@398: /* This needs to be done here, because OpenGL commands may need SetCurrent() tomwalters@398: * and an already shown window. */ tomwalters@398: char *extensions = (char *)glGetString(GL_EXTENSIONS); tomwalters@398: if (!extensions) { tomwalters@398: AIM_INFO(_T("Could not query OpenGL extensions, vertex arrays disabled")); tomwalters@398: } else if (strstr(extensions, "GL_EXT_compiled_vertex_array")) { tomwalters@398: m_glLockArraysEXT = (LOCAL_PFNGLLOCKARRAYSEXTPROC)GL_GET_PROC_ADDRESS("glLockArraysEXT"); tomwalters@398: m_glUnlockArraysEXT = (LOCAL_PFNGLUNLOCKARRAYSEXTPROC)GL_GET_PROC_ADDRESS("glUnlockArraysEXT"); tomwalters@411: if (!m_glLockArraysEXT || !m_glUnlockArraysEXT) tomwalters@398: AIM_ERROR(_T("OpenGL error on GL_EXT_compiled_vertex_array")); tomwalters@398: else tomwalters@398: m_bVertexArrayLock = true; tomwalters@398: } tomwalters@398: } tomwalters@397: #endif tomwalters@398: DoResize(); tomwalters@398: glClearColor(0, 0, 0, 1); tomwalters@398: glMatrixMode( GL_PROJECTION ); tomwalters@398: glLoadIdentity( ); tomwalters@397: tomwalters@398: glEnable(GL_VERTEX_ARRAY); tomwalters@397: tomwalters@398: // Window limits in OpenGL co-ordiantes tomwalters@398: //! \todo Make this configurable, or change and document fixed values tomwalters@398: glOrtho(0.0, 1.0, 0.0, 1.0, 0.0, 1.0); tomwalters@398: glTranslatef(0.0, 0.0, 0.0); tomwalters@397: tomwalters@398: if (m_bAntialiasing) { tomwalters@398: glEnable(GL_LINE_SMOOTH); tomwalters@398: glEnable(GL_BLEND); tomwalters@398: glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); tomwalters@398: //glBlendFunc(GL_ONE, GL_ONE); tomwalters@398: glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE); tomwalters@398: } else { tomwalters@398: glDisable(GL_LINE_SMOOTH); tomwalters@398: glDisable(GL_BLEND); tomwalters@398: } tomwalters@398: glLineWidth(1.0); tomwalters@397: tomwalters@398: // Get a free display list only the first time tomwalters@398: if (!m_init) { tomwalters@397: #if !defined(_MACOSX) tomwalters@398: // Windows and Linux need a separate worker context tomwalters@398: aimASSERT(wxIsMainThread()); tomwalters@397: #if wxCHECK_VERSION(2,8,0) tomwalters@398: m_pWorkerContext = new wxGLContext(this, m_glContext); tomwalters@397: #else tomwalters@398: m_pWorkerContext = new wxGLContext(true, tomwalters@397: this, tomwalters@397: wxNullPalette, tomwalters@397: m_glContext); tomwalters@397: #endif tomwalters@398: aimASSERT(m_pWorkerContext); tomwalters@398: s_bWorkerNeedsInit = true; tomwalters@397: #endif tomwalters@398: m_gllist = glGenLists(1); tomwalters@398: aimASSERT(m_gllist); tomwalters@398: // Empty window at start tomwalters@398: glNewList(m_gllist, GL_COMPILE_AND_EXECUTE); tomwalters@398: glEndList(); tomwalters@398: m_init = true; tomwalters@398: } tomwalters@397: } tomwalters@397: tomwalters@397: // Call before any other render* functions tomwalters@397: void GraphicsOutputDevicewxGLCanvas::gGrab() { tomwalters@398: AimwxGuiLocker __lock__; tomwalters@397: #if !defined(_MACOSX) tomwalters@398: // Detect if we're the main thread or not. tomwalters@398: if (!wxIsMainThread()) { tomwalters@398: // We're called by a worker thread, make sure there's a right context tomwalters@398: AIM_ASSERT(m_pWorkerContext); tomwalters@397: #if wxCHECK_VERSION(2,8,0) tomwalters@398: m_pWorkerContext->SetCurrent(*this); tomwalters@397: #else tomwalters@398: m_pWorkerContext->SetCurrent(); tomwalters@397: #endif tomwalters@398: // Update OpenGL settings if needed tomwalters@398: wxMutexLocker lock(s_mutexOpenGL); tomwalters@398: if (s_bWorkerNeedsInit) { tomwalters@398: InitGL(); tomwalters@398: s_bWorkerNeedsInit = false; tomwalters@398: } tomwalters@398: } else tomwalters@397: #endif tomwalters@398: { tomwalters@398: // Either called by main thread, or we need no special worker glContext tomwalters@398: if (!SetCurrent()) { tomwalters@398: return; tomwalters@398: } tomwalters@398: // Init OpenGL once, but after SetCurrent tomwalters@398: if (!m_init) { tomwalters@398: InitGL(); tomwalters@398: } tomwalters@398: } tomwalters@398: glClear(GL_COLOR_BUFFER_BIT); tomwalters@397: tomwalters@398: // Start and store in a display list for redrawing tomwalters@398: glNewList(m_gllist, GL_COMPILE); tomwalters@397: } tomwalters@397: tomwalters@397: void GraphicsOutputDevicewxGLCanvas::gBeginLineStrip() { tomwalters@397: #ifdef WITH_GL_VERTEX_ARRAYS tomwalters@398: aimASSERT(m_iVertexType == 0xffff); // Previous gBegin*() must be gEnd()ed tomwalters@398: // New lines vertex array tomwalters@398: m_iVertexCount = 0; tomwalters@398: m_iVertexType = GL_LINE_STRIP; tomwalters@397: #else tomwalters@398: AimwxGuiLocker __lock__; tomwalters@398: glBegin(GL_LINE_STRIP); tomwalters@397: #endif tomwalters@397: } tomwalters@397: tomwalters@397: void GraphicsOutputDevicewxGLCanvas::gBeginQuadStrip() { tomwalters@397: #ifdef WITH_GL_VERTEX_ARRAYS tomwalters@398: aimASSERT(m_iVertexType == 0xffff); // Previous gBegin*() must be gEnd()ed tomwalters@398: // New quads vertex array tomwalters@398: m_iVertexCount = 0; tomwalters@398: m_iVertexType = GL_QUAD_STRIP; tomwalters@397: #else tomwalters@398: AimwxGuiLocker __lock__; tomwalters@398: glBegin(GL_QUAD_STRIP); tomwalters@397: #endif tomwalters@397: } tomwalters@397: tomwalters@397: void GraphicsOutputDevicewxGLCanvas::gVertex3f(float x, float y, float z) { tomwalters@397: #ifdef WITH_GL_VERTEX_ARRAYS tomwalters@398: aimASSERT(m_iVertexType != 0xffff); // Must be inside gBegin*() tomwalters@398: if (m_iVertexCount>=m_iVerticesMax) { tomwalters@398: static bool errShown=false; tomwalters@398: if (!errShown) { tomwalters@398: aimERROR(_T("Error: max vertex count reached: %d"), m_iVertexCount); tomwalters@398: errShown=true; tomwalters@398: } tomwalters@398: return; tomwalters@398: } tomwalters@398: if (m_bStaticColor) { tomwalters@398: m_pVertices[m_iVertexCount*3+0] = x; tomwalters@398: m_pVertices[m_iVertexCount*3+1] = y; tomwalters@398: m_pVertices[m_iVertexCount*3+2] = z; tomwalters@398: } else { tomwalters@398: m_pVertices[m_iVertexCount*6+0] = m_fCurColorR; tomwalters@398: m_pVertices[m_iVertexCount*6+1] = m_fCurColorG; tomwalters@398: m_pVertices[m_iVertexCount*6+2] = m_fCurColorB; tomwalters@398: m_pVertices[m_iVertexCount*6+3] = x; tomwalters@398: m_pVertices[m_iVertexCount*6+4] = y; tomwalters@398: m_pVertices[m_iVertexCount*6+5] = z; tomwalters@398: } tomwalters@398: m_iVertexCount++; tomwalters@397: #else tomwalters@398: AimwxGuiLocker __lock__; tomwalters@398: glVertex3f(x,y,z); tomwalters@397: #endif tomwalters@397: } tomwalters@397: tomwalters@397: void GraphicsOutputDevicewxGLCanvas::gColor3f(float r, float g, float b) { tomwalters@397: #ifdef WITH_GL_VERTEX_ARRAYS tomwalters@398: if (m_iVertexType==0xffff || m_bStaticColor) { tomwalters@398: // If not inside vertex array run, use the ordinary command tomwalters@398: glColor3f(r, g, b); tomwalters@398: } tomwalters@398: if (!m_bStaticColor) { tomwalters@398: // Set current color for vertex array usage tomwalters@398: m_fCurColorR = r; tomwalters@398: m_fCurColorG = g; tomwalters@398: m_fCurColorB = b; tomwalters@398: } tomwalters@397: #else tomwalters@398: AimwxGuiLocker __lock__; tomwalters@397: glColor3f(r, g, b); tomwalters@397: #endif tomwalters@397: } tomwalters@397: tomwalters@397: void GraphicsOutputDevicewxGLCanvas::gEnd() { tomwalters@397: #ifdef WITH_GL_VERTEX_ARRAYS tomwalters@398: aimASSERT(m_iVertexType != 0xffff); // Must be inside gBegin*() tomwalters@398: AimwxGuiLocker __lock__; tomwalters@397: tomwalters@398: // Draw the vertex array tomwalters@398: glEnableClientState(GL_VERTEX_ARRAY); tomwalters@397: tomwalters@398: // Draw vertices tomwalters@398: if (m_bStaticColor) tomwalters@398: glVertexPointer(3, GL_FLOAT, 0, m_pVertices); tomwalters@398: else tomwalters@398: glInterleavedArrays(GL_C3F_V3F, 0, m_pVertices); tomwalters@398: if (m_bVertexArrayLock) m_glLockArraysEXT(0, m_iVertexCount); tomwalters@398: glDrawArrays(m_iVertexType, 0, m_iVertexCount); tomwalters@398: if (m_bVertexArrayLock) m_glUnlockArraysEXT(); tomwalters@397: tomwalters@398: glDisableClientState(GL_VERTEX_ARRAY); tomwalters@397: tomwalters@398: // Remember we're outside a gBegin()..gEnd() loop tomwalters@398: m_iVertexType = 0xffff; tomwalters@397: #else tomwalters@398: AimwxGuiLocker __lock__; tomwalters@398: glEnd(); tomwalters@397: #endif tomwalters@397: } tomwalters@397: tomwalters@397: void GraphicsOutputDevicewxGLCanvas::gText3f(float x, tomwalters@397: float y, tomwalters@397: float z, tomwalters@397: const char *sStr, tomwalters@397: bool bRotated) { tomwalters@397: #ifdef WITH_GL_VERTEX_ARRAYS tomwalters@398: aimASSERT(m_iVertexType == 0xffff); // Must be outside gBegin*() tomwalters@397: #endif tomwalters@397: tomwalters@398: if (!m_pFont) tomwalters@398: return; tomwalters@397: tomwalters@398: //! \todo make rotation work tomwalters@398: if (bRotated) tomwalters@398: return; tomwalters@397: tomwalters@398: { tomwalters@398: AimwxGuiLocker __lock__; tomwalters@398: /* tomwalters@398: if (bRotated) { tomwalters@398: glPushMatrix(); tomwalters@398: glTranslatef(x,y,z); tomwalters@398: glRotatef(90.0f, 0, 0, 1.0f); tomwalters@398: glRasterPos3f(0,0,0); tomwalters@398: m_pFont->Render(sStr); tomwalters@398: glPopMatrix(); tomwalters@398: } else { tomwalters@398: */ tomwalters@398: glRasterPos3f(x, y, z); tomwalters@398: m_pFont->Render(sStr); tomwalters@398: } tomwalters@397: } tomwalters@397: tomwalters@397: void GraphicsOutputDevicewxGLCanvas::gRelease() { tomwalters@397: #ifdef WITH_GL_VERTEX_ARRAYS tomwalters@398: aimASSERT(m_iVertexType == 0xffff); // Must be gEnd()ed tomwalters@397: #endif tomwalters@398: AimwxGuiLocker __lock__; tomwalters@398: glEndList(); tomwalters@398: glCallList(m_gllist); tomwalters@398: //glFlush(); tomwalters@398: SwapBuffers(); // Doesn't matter in what context tomwalters@397: }