If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
-
waterj
- Earned a small fee

- Posts: 21
- Joined: Mon Nov 07, 2005 8:39 am
Post
by waterj » Sun Jan 08, 2006 9:08 am
I added some codes in wx sample "opegl/penguis". I just want to show a little bitmap in the left top corner of GLCanvs, but it didn't work. Is it possible to make opengl work with common gdi?
Code: Select all
void TestGLCanvas::OnPaint( wxPaintEvent& WXUNUSED(event) )
{
// must always be here
wxPaintDC dc(this);
#ifndef __WXMOTIF__
if (!GetContext()) return;
#endif
SetCurrent();
// Initialize OpenGL
if (!m_gldata.initialized)
{
InitGL();
ResetProjectionMode();
m_gldata.initialized = true;
}
// Clear
glClearColor( 0.3f, 0.4f, 0.6f, 1.0f );
glClear( GL_DEPTH_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
// Swap
wxBitmap img;
img.LoadFile("c:/hr2000/bmp/22.bmp", wxBITMAP_TYPE_BMP);
dc.BeginDrawing();
dc.DrawBitmap(img, 0, 0);
dc.EndDrawing();
// Transformations
glLoadIdentity();
glTranslatef( 0.0f, 0.0f, -20.0f );
GLfloat m[4][4];
build_rotmatrix( m, m_gldata.quat );
glMultMatrixf( &m[0][0] );
m_renderer.Render();
// Flush
glFlush();
// Swap
SwapBuffers();
}
[/code]
-
upCASE
- Site Admin

- Posts: 3176
- Joined: Mon Aug 30, 2004 6:55 am
- Location: Germany, Cologne
Post
by upCASE » Mon Jan 09, 2006 7:38 am
Just a quick thought: Does it work when displaying the bitmap after SwapBuffers()?
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4
"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda
-
waterj
- Earned a small fee

- Posts: 21
- Joined: Mon Nov 07, 2005 8:39 am
Post
by waterj » Mon Jan 09, 2006 11:15 am
upCASE wrote:Just a quick thought: Does it work when displaying the bitmap after SwapBuffers()?
Yes, bitmap showed after SwapBuffers. But my old MFC program are mixed OpenGL with GDI, so bitmap displaying might happen before SwapBuffers. I added a PFD_SUPPORT_GDI flag to wxGLCanvas and made wxMSW version work. But I don't know what to do with wxGTK.
-
waterj
- Earned a small fee

- Posts: 21
- Joined: Mon Nov 07, 2005 8:39 am
Post
by waterj » Thu Jan 12, 2006 8:10 am
??