Les
Srinivaz111 wrote:
> Hello all,
> I am developing one FireFox plugin for Windows which creates one
> wxWidgets window with GL enabled(wxGLCanvas). I am drawing some 3d
> objects(using OpenGL functions) and some text on this window. The problem is
> that the text disappears sporadically. I mean when any message box or dialog
> box is opened and closed, the text goes. And again any message box is opened
> and closed the text appears.
> I do not know why this is happening. The OnPaint of the window consists
> of the following code.
>
wxPaintDC dc(this);
SetCurrent();
// Init OpenGL once, but after SetCurrent
if (!m_init)
{
InitGL();
m_init = true;
}
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-0.5f, 0.5f, -0.5f, 0.5f, 1.0f, 3.0f);
glMatrixMode(GL_MODELVIEW);
// clear color and depth buffers
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
if( m_gllist == 0 )
{
m_gllist = glGenLists( 1 );
glNewList( m_gllist, GL_COMPILE_AND_EXECUTE );
// draw six faces of a cube
glBegin(GL_QUADS);
glNormal3f( 0.0f, 0.0f, 1.0f);
glVertex3f( 0.5f, 0.5f, 0.5f); glVertex3f(-0.5f, 0.5f, 0.5f);
glVertex3f(-0.5f,-0.5f, 0.5f); glVertex3f( 0.5f,-0.5f, 0.5f);
glNormal3f( 0.0f, 0.0f,-1.0f);
glVertex3f(-0.5f,-0.5f,-0.5f); glVertex3f(-0.5f, 0.5f,-0.5f);
glVertex3f( 0.5f, 0.5f,-0.5f); glVertex3f( 0.5f,-0.5f,-0.5f);
glNormal3f( 0.0f, 1.0f, 0.0f);
glVertex3f( 0.5f, 0.5f, 0.5f); glVertex3f( 0.5f, 0.5f,-0.5f);
glVertex3f(-0.5f, 0.5f,-0.5f); glVertex3f(-0.5f, 0.5f, 0.5f);
glNormal3f( 0.0f,-1.0f, 0.0f);
glVertex3f(-0.5f,-0.5f,-0.5f); glVertex3f( 0.5f,-0.5f,-0.5f );
glVertex3f( 0.5f,-0.5f, 0.5f); glVertex3f(-0.5f,-0.5f, 0.5f );
glNormal3f( 1.0f, 0.0f, 0.0f);
glVertex3f( 0.5f, 0.5f, 0.5f); glVertex3f( 0.5f,-0.5f, 0.5f );
glVertex3f( 0.5f,-0.5f,-0.5f); glVertex3f( 0.5f, 0.5f,-0.5f);
glNormal3f(-1.0f, 0.0f, 0.0f);
glVertex3f(-0.5f,-0.5f,-0.5f); glVertex3f(-0.5f ,-0.5f , 0.5f);
glVertex3f(-0.5f, 0.5f, 0.5f); glVertex3f(-0.5f, 0.5f ,-0.5f);
glEnd();
glEndList();
}
else
{
glCallList(m_gllist);
}
glFlush();
SwapBuffers();
int width, height;
GetClientSize(&width, &height);
dc.SetTextForeground( wxColour(255,255,0,128) );
wxCoord CharHeight = dc.GetCharHeight();
for (int i = 0; i < m_Index; i++)
{
dc.DrawText(m_strDisplayStrings[i].c_str(), 0, CharHeight*i);
}
dc.DrawText("Applet3", width/2-20, height/2);
I will be grateful to you if you tell me why the text is going on and off.
Thanks,
Srinu
--
View this message in context: http://www.nabble.com/wxWidgets-and-OpenGL-tp22473806p22473806.html
Sent from the wxWidgets - Users mailing list archive at Nabble.com.
Thanks,
Srinu
> _______________________________________________
> wx-users mailing list
> wx-u...@lists.wxwidgets.org
> http://lists.wxwidgets.org/mailman/listinfo/wx-users
>
>
--
View this message in context: http://www.nabble.com/wxWidgets-and-OpenGL-tp22473806p22475393.html
good luck
Srinivaz111 a écrit :
In addition to what Leslie suggested, you may check out the font-related tutorials at NeHe:
http://nehe.gamedev.net/lesson.asp?index=03
http://nehe.gamedev.net/lesson.asp?index=04
http://nehe.gamedev.net/lesson.asp?index=09
Also see http://www.opengl.org/resources/faq/technical/ (FAQ 17).
Best,
Carsten
--
Carsten Fuchs Software
Multi-Player, Multi-Platform, Real-Time 3D Graphics
http://www.Ca3D-Engine.de
Hello Srinu,
Srinivaz111 wrote:
> Hi Les,
> Thanks for the reply. I tried GLUT and found that GLUT has a stand alone
> Message Loop. I mean I found that it can`t be used in other application. Is
> there any way to use GLUT without using glutCreateWindow, glutMainLoop,
> etc...? I understood that it requires a window(Created by glutCreateWindow)
> where it draws. But what my question is can I draw in my window which is
> already created using GLUT?
Use this to initialise GLUT (only do this once):
int argc = 1;
char* argv[1] = { wxString(wxApp::argv[0]).char_str() };
glutInit(&argc, argv);
After that, you can call the GLUT functions just like OpenGL functions
(e.g. glutSolidTeapot, glutWireTeapot, etc.). You don't need to use use
glutCreateWindow, glutMainLoop, etc. for window management because
wxWidgets already handles that.
Regards,
Jonathan
Les
I use OGLFT [1] for rendering text in OpenGL. It is easy to use,
renders nicely, and is fast. It is worth looking into.
Chris.
Thanks,
Srinu
> _______________________________________________
> wx-users mailing list
> wx-u...@lists.wxwidgets.org
> http://lists.wxwidgets.org/mailman/listinfo/wx-users
>
>
--
View this message in context: http://www.nabble.com/wxWidgets-and-OpenGL-tp22473806p22478526.html
Hello Srinu,
Srinivaz111 wrote:
> Hi Jonathan,
> Thanks for your reply. I tried whatever you said. But without setting any
> window where the glut draws the text? I created one wxWidget window. I want
> to set this window to glut. Can you please tell me how to do that and help
> me in drawing text to wxWidgets window using OpenGL?
You don't need to set the window where GLUT draws the text, GLUT calls
OpenGL and will use whatever OpenGL rendering context is currently set.
In your code you called SetCurrent() which will set the proper OpenGL
rendering context.
Instead of drawing using the dc after SwapBuffers, do something like
this before glFlush:
wxString text = wxT("Hello");
const char *c = text.ToAscii();
glRasterPos3f(0.0f, 0.0f, 0.0f);
for (; c; ++c) {
glutBitmapCharacter(GLUT_BITMAP_8_BY_13, *s);
}
Regards,
Jonathan
> Instead of drawing using the dc after SwapBuffers, do something like
> this before glFlush:
> wxString text = wxT("Hello");
> const char *c = text.ToAscii();
> glRasterPos3f(0.0f, 0.0f, 0.0f);
> for (; c; ++c) {
> glutBitmapCharacter(GLUT_BITMAP_8_BY_13, *s);
> }
Sorry typo.
Fixed:
wxString text = wxT("Hello");
glRasterPos3f(0.0f, 0.0f, 0.0f);
for (const char *c = text.ToAscii(); *c; ++c) {
glutBitmapCharacter(GLUT_BITMAP_8_BY_13, *c);
}
Regards,
Jonathan
Thanks,
Srinu
--
View this message in context: http://www.nabble.com/wxWidgets-and-OpenGL-tp22473806p22495542.html