Jump to content
  • Advertisement
Sign in to follow this  
jskywalker

OpenGL Texture font not displayed properly

This topic is 3032 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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]

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!