Texture font not displayed properly

Started by
-1 comments, last by jskywalker 13 years, 8 months ago
Problem solved, please ignore this post.

The answer:

OpenGL functions do not work unless an OpenGL context has been created and is active within that thread.

http://www.opengl.org/wiki/Common_Mistakes


----------------------------------------------------------------------------



Help please ...............


I am working on a project using OpenGL ES C++ on windows mobile.

I borrowed GLfont library for drawing font, texture font.

Two core functions of the library:

// create texture from a file.
int create (const char *file_name);

// print text
template<class T> void print (const T *text, float scalar, float x, float y);

Here is the testing code:

--------------------------------------------------------------------

class Canvas{

Font font;

public:

Canvas(){
// initialFont();
}

void initialFont(){
if (!font.create("font3.glf"))
printf("Creating font failed ... ");
}

void drawFont(){
glColor4f(0.0F, 1.0F, 0.0F, 1.0F);
font.enableStates();
font.print("hello world with 1", 0.08F, 0.0F, 50.0F);
font.print("hello world with 1", 0.08F, 0.0F, 100.0F);
font.disableStates();
}

void paint(){
initialFont();
drawFont();
}

};
--------------------------------------------------------------------

You call paint() to draw.

The issue is :

if you initial the font in local paint() function, the font displayed properly.

if you initial the font in the Canvas() constructor, the font only displayed as a colored rectangle.

To put it simple, you place this line
--------------------
initialFont();
--------------------
into the Canvas() constructor OR paint() local function, you get different drawing result, wired.

Have spent almost 3 hours to fix it, but no luck :-(

I am sure it is an OpenGL issue, but where I did wrong?

Please help me out.







[Edited by - jskywalker on August 22, 2010 6:23:42 PM]

This topic is closed to new replies.

Advertisement