Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 27 Apr 2007
Offline Last Active Oct 03 2011 01:35 PM

Topics I've Started

Lesson 17 2D Texture Font with white background.

27 September 2011 - 10:45 AM

Hi all

I am sure this is silly question but I couldn't find why it's not working.

I am using lesson 17 with 2007 C++ Builder and it's working, but if I just change font color to black.

glColor3f(0.0f,0.0f,0.0f);						// Set color to black

i don't see the font it changes color to white. So my question is why this is happening and how can I overcome this issue.

Any comment would be appreciated.

Thanks in advance.

Bitmap Fonts performance issue.

31 August 2011 - 11:51 AM

Hi everyone

I simplified my project in order to work on the performance and I found out that Bitmap Font is responsible for some of the performance issues.
So what I have is a standard cube and some text (you can check the image below to see what i mean).
Attached File  pav2dgl_snapshot.jpeg   71.57KB   72 downloads
When I render just cube everything responds fast (meaning translation and rotation of the cube), but once I add text it slows down depending from amount of text on screen (meaning if i have one or two its ok, but 15 or above performance drops a lot).

Here is the code from my project which is responsible for the text.

void GLFont::BuildBitmapFont(HDC &hdc)
	baseBitmap = glGenLists(96);	// Storage for 96 characters
	fontSize = -MulDiv(fontSize, GetDeviceCaps(hdc, LOGPIXELSY), 72);
	fontBitmap = CreateFont(   		-fontSize,        		// Height of font
						0,        			// Width of font
						0,        			// Angle of escapement
						0,        			// Orientation angle
						FW_NORMAL,        		// Font weight
						FALSE,  			// Italic
						FALSE,        			// Underline
						FALSE,        			// Strikeout
						ANSI_CHARSET,   		// Character set identifier
						OUT_TT_PRECIS,        		// Output precision
						CLIP_DEFAULT_PRECIS,    	// Clipping precision
						ANTIALIASED_QUALITY,        	// Output quality
						FF_DONTCARE|DEFAULT_PITCH,      // Family and pitch
						"Courier New");			// Font name

	oldfontBitmap = (HFONT)SelectObject(hdc, fontBitmap);   	// Selects the font we want
	wglUseFontBitmaps(hdc, 32, 96, baseBitmap);   		// Builds 96 characters starting at character 32
	SelectObject(hdc, oldfontBitmap);			// Selects the font we want
	DeleteObject(fontBitmap);				// Delete the font

void GLFont::glBitmapPrint(const char *fmt, int i, double size, double _x, double _y, double _z)
    float		length=0;			// Used To Find The Length Of The Text
	float 		heigth=0;			//Use To Find Heigth of the Text

	glColor3f(0.0f, 0.0f, 0.0f); // set Color 2 white
	char text[256];	                                        // Holds our string
	va_list ap;	        	                        // Pointer to list of arguments
		if (fmt == NULL)		                        // If there's no text
		return;			                        // Do nothing

	glRasterPos3d(_x, _y, _z);
	va_start(ap, fmt);		                        // Parses the string for variables
	vsprintf(text, fmt, ap);	                        // And converts symbols to actual numbers
	va_end(ap);			                        // Results are stored in text

	glPushAttrib(GL_LIST_BIT);	                        // Pushes the display list bits
	for (unsigned int loop=0;loop<(strlen(text));loop++)			// Loop To Find Text Length
		length+=gmfBitmap[text[loop]].gmfCellIncX;				// Increase Length By Each Characters Width

	if (size < 0.1)
		glTranslatef(-size/2,-0.01, 0.0);				// Center Our Text On The Screen
		glTranslatef(-length/20,-0.03, 0.0);				// Center Our Text On The Screen
	glPushAttrib(GL_LIST_BIT);						// Pushes The Display List Bits
	glListBase(baseBitmap - 32);		                        // Sets the base character to 32
	glScalef(size, size, 0.0);
	glCallLists(strlen(text), GL_UNSIGNED_BYTE, text);	// Draws the display list text

So my question: Are theare any better way to render text on the scene without sacrificing performance? Or I am doing something wrong which causes performance drop?

Any comment would be appreciated.
Thanks in advance.

glVertexPointer with vector

31 July 2011 - 06:20 PM

Hi everyone,

I was wondering if there is a good way to use

void glVertexPointer(
  GLint size,
  GLenum type,
  GLsizei stride,
  const GLvoid *pointer

vector<SomeClassName *> Nodes;
since its more convenient, and easy to store information in the vector.
Any help would be appreciated.

How to run executable from server

04 April 2011 - 02:57 PM

Hi all
I am developing Pre/Post processor for the Finite Element Method code, using C++ Builder 2007 and OpenGL on Windows OS.

I would like to ask if there is anyway to call FEM code which is located on the remote server/pc. Server is accessible trough web protocols.

So what I would like to accomplish, is to provide shell software to the users that they can run on they computer for Pre/Post processing if they want to run the analysis they had to submit it to the server. Ideally trough the same shell software, which will handle that.

Right now I am calling FEM code which is on the same machine using CreateProcess(..) it generates output files which I load into the shell program to show results.

If anyone can point me to the right direction i would be highly grateful. If you need any additional information please feel free to ask.

Eliminating the need to install application

31 March 2011 - 01:11 PM

Hi all,

I am relatively new in this forum, so accept my apology if I posted this question in the wrong thread.

I am Graduate student and I am developing Pre/Post processor for the Finite Element Method code, using C++ Builder 2007 and OpenGL.

I wanted to ask if anyone knows or can redirect me to the open source or free software which will hep to eliminate the need to install my software applications before running them. I already spend two days searching the web without any luck.

Something like this but without huge price tag.

Any advice would be appreciated.

Thanks in advance.