Font Bitmaps

Hello,

Can I still use the wglUseFontBitmaps in core profiles 3.x or 4.x? AFAIK this function uses display lists which are deprecated in the new core profiles. What’s the alternative?

Thanks.

Can I still use the wglUseFontBitmaps in core profiles 3.x or 4.x?

No.

AFAIK this function uses display lists which are deprecated in the new core profiles.

No, they are not deprecated. They are removed.

Deprecated means “this is available, but you shouldn’t use it in new code.” Removed means, well, “removed.” The functionality was deprecated in GL 3.0, but removed in 3.1 core and above.

Interesting to know that features already in use by essential libraries and tools to the developers are removed in hope that implementation would become easier, and have better quality drivers.

How does this decision affect driver’s quality? Are we really have less buggy drivers now, or other vendors have better support for the recent specification? No. :slight_smile:

Then instead of REMOVING features that are the heart core of the OpenGL popularity, try to IMPROVE these features so that they provide more functionality and can handle situations where they could not before.

I see now the trend is which features to remove, not how to improve and replace with better alternative. Not a single person I met using OpenGL for their own projects have not used display lists. It’s very handy tool.

I could agree on removing the glBegin/End stuff because this could be implemented on top of the core API; however, it still does not make sense how this would improve driver quality. If you offloaded the task of implementing it to applications developers because it’s easy to implement, then you should have done the job. Remember the purpose of the API is to make developers’ life easy not the API’s makers’ :slight_smile:

Could be insane but it worth to re-specify the API again beginning from after version 2.1 and have more mature decisions and less ugly new calls :wink:

Thanks.

Here’s an idea: if you don’t like the core profile, if there is some functionality you need that it doesn’t provide, use the compatibility profile. I promise you that you will not be arrested by the OpenGL police. People will not come into your place of business and accost you for it. And I assure you that the compatibility profile isn’t going away any time soon.

Interesting to know that features already in use by essential libraries and tools to the developers are removed in hope that implementation would become easier, and have better quality drivers.

It would be difficult to make an argument that wglUseFontBitmaps constitutes “essential libraries and tools.” It would also be difficult to call it a feature that is at “the heart core of the OpenGL popularity” with a straight face. Does anyone use that function for anything more than toy examples?

Also “are being removed” sounds like you believe that this is a recent event. Deprecation was announced 2 years ago, and the first spec with most of the deprecated functionality removed was 1.5 years ago. This is not something that was sprung on programmers a few months ago.

How does this decision affect driver’s quality?

Didn’t we discuss this already? NVIDIA sandbagged the ARB’s attempt to clean up the API. They were the only members of the ARB to speak out against it, and they actively encouraged people to completely ignore deprecation and removal when writing OpenGL programs. In that kind of environment, with one of the major OpenGL implementers telling people to ignore it, there was no way it was going to do anything.

Because of this, every OpenGL implementation from now until the end of time will, and must, implement the compatibility profile. Every extension specification is written against the compatibility profile. The very fact that the compatibility profile exists at all is a strike against any kind of improvement that might have been gained from removing functionality, let alone having a major IHV saying, “ignore core.”

At this point, it’d make more sense if the ARB just set all pretense aside and merged the two profiles back into one. It’s already the de-facto state of affairs; may as well make it the de-jure state too.

Remember the purpose of the API is to make developers’ life easy not the API’s makers’

Well, that’s one way to think of it. The success of Direct3D, in terms of having far fewer bugs than most OpenGL implementations, seems to disagree. D3D drivers are significantly less complex than OpenGL drivers. Microsoft implements some of D3D’s user-facing functionality, while the IHV implements a much smaller, simpler back-end. Apple does something similar with OpenGL, where they control much of the implementation and the hardware makers write drivers that implement a much simpler internal API.

Either of these are substantially less buggy than most Windows OpenGL implementations. That could be due to having more software that uses it, but you’d be hard pressed to argue that the lower implementation burden has nothing to do with it.

I prefer to think of it like this. However easy and convenient an API may be, that API is of no value if you cannot rely on it to work. Therefore, doing whatever can be done to decrease the implementer’s burden, thus allowing them to write and maintain less code, is a good thing. Even if it means a less convenient way of doing things.

Well I thought this is how CAD programs using OpenGL render text into viewports…anyway

I’ve looked at FTGL but it still uses legacy stuff…

Writing my own text renderer is not an option either. Simply, I don’t have the resources. :slight_smile:

Now OpenGL ended up as a less functional API and nothing improved on the driver end. Checkmate! :wink:

Do what I did. Take the code and port the “legacy” code into a modern form. Submit a patch if you want, if not, just keep what you wrote and use it. Only minor changes are usually necessary.

Yeah but now I have to write my own text rendering (FreeType i.e) knowing that some features are removed…

I have a working graphics layer for my project on top of Direct3D and it just works for me in terms of functionality. I will do what giants like AutoDesk did. :wink:

I wrote this for fixed function

It’s superior to font bitmaps because it’s proper anti aliased text. It is win32 only. I am sure you could easily convert it to ‘modern’ opengl. If you use it, credit would be nice :slight_smile: It’s basically a drop in replacement for the wglFontBitmap functions. You use it the same way.


#include <windows.h>
#include <gl\gl.h>
#include <stdio.h>
#include <math.h>

void remapColourRange(UCHAR *data, int numberOfItems) {

	for(int i=0; i<numberOfItems; i++) {
		data[i] = (data[i] * 255) / 64;
	}
}

void copyLine(UCHAR *in, UCHAR *out, int width) {

	for(int i=0; i<width; i++) {
		out[i] = in[i];
	}
}

void flipImage(UCHAR *data, int width, int height) {

	//===========
	UCHAR *temp;
	DWORD offset;
	DWORD offset2;
	//===========

	offset	= 0;
	offset2	= 0;
	temp	= new UCHAR[width];

	for(int i=0; i<height/2; i++) {

		offset = ((width+3) & ~3) * i;
		copyLine(data+offset,temp,width);			// copy bottom line

		offset2 = ((width+3) & ~3) * (height-i-1);
		copyLine(data+offset2,data+offset,width);	// copy top line to bottom

		copyLine(temp,data+offset2,width);			// temp line to top
	}

	delete []temp;
}

void convertLine(UCHAR *in, UCHAR *out, int width) {

	for(int i=0; i<width*4; i+=4) {
		out[i+0] = 255;
		out[i+1] = 255;
		out[i+2] = 255;
		out[i+3] = in[i/4];
	}
}

void convertToRGB(UCHAR *in, UCHAR *out, int width, int height) {

	//==========
	int offset;
	int offset2;
	//==========

	offset	= (width+3) & ~3;
	offset2	= (((width*4)+3) & ~3);
	
	for(int i=0; i<height; i++) {
		convertLine(in+(offset*i),out+(offset2*i),width);
	}
}

BOOL createFont(HDC hdc, DWORD first, DWORD count, DWORD listBase) {

	//===========================
	GLYPHMETRICS	gm;
	MAT2			mat2;
	DWORD			size;
	UCHAR			*data;
	UCHAR			*RGBData;
	//===========================

	// safety checks

	if(!count)	return FALSE;
	if(!hdc)	return FALSE;

	// initiate variables

	size	= 0;
	data	= NULL;
	RGBData = NULL;
	memset(&gm,0,sizeof(GLYPHMETRICS));

	// identity matrix 

	memset(&mat2, 0, sizeof(mat2));
	mat2.eM11.value = 1;	mat2.eM21.value = 0;
	mat2.eM12.value = 0;	mat2.eM22.value = 1;

	glPushAttrib(GL_PIXEL_MODE_BIT);
	glPixelStorei(GL_UNPACK_ALIGNMENT,4);

	for(DWORD i = 0 ; i< count; i++) {

		glNewList(listBase+i,GL_COMPILE);
		glPushAttrib(GL_ENABLE_BIT|GL_COLOR_BUFFER_BIT);

		// get size of the structure first

		size = GetGlyphOutline(hdc,first+i,GGO_GRAY8_BITMAP, &gm, 0, NULL, &mat2);
		if(size == GDI_ERROR) { glEndList(); continue; }

		if(size) {

			data = new UCHAR[size];

			GetGlyphOutline(hdc,first+i,GGO_GRAY8_BITMAP,&gm,size,data,&mat2);

			remapColourRange(data,size);
			flipImage	(data,gm.gmBlackBoxX,gm.gmBlackBoxY);

			RGBData = new UCHAR[(((gm.gmBlackBoxX*4)+3) & ~3) * gm.gmBlackBoxY ];

			convertToRGB(data,RGBData,gm.gmBlackBoxX,gm.gmBlackBoxY);
		}

		glEnable	(GL_BLEND);
		glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

		glBitmap	(0,0,0,0,(GLfloat)gm.gmptGlyphOrigin.x,(GLfloat)gm.gmptGlyphOrigin.y-(GLfloat)gm.gmBlackBoxY,NULL);	//incriment raster position
		if(size)	glDrawPixels(gm.gmBlackBoxX,gm.gmBlackBoxY, GL_RGBA, GL_UNSIGNED_BYTE, RGBData);
		glBitmap	(0,0,0,0,(GLfloat)-gm.gmptGlyphOrigin.x,-((GLfloat)gm.gmptGlyphOrigin.y-(GLfloat)gm.gmBlackBoxY),NULL);	//incriment raster position
		glBitmap	(0,0,0,0,(GLfloat)gm.gmCellIncX,(GLfloat)gm.gmCellIncY,NULL);	//incriment raster position

		glDisable	(GL_BLEND);

		glPopAttrib	();
		glEndList	();

		delete []data;
		delete []RGBData;
	}

	glPopAttrib		();

	return TRUE;
}

Thanks for your help. I will give it a go and of course give you credit :slight_smile: