Kevin Kronmiller (kkronmil++at++metricsys.com)
Thu, 29 Jul 1999 16:06:33 -0500
We have created our own xfont class and all works well in single process mode. When going to multiprocess mode we get the following error.
PF Fatal/Usage: loadXFont: Couldn't get 129 display lists
I found the following answer in the December 1998 archives but still have not resolved the problem.
----- snip
Make sure youallocate the base for the display lists out of shared memory as well
as the XFontStruct pointer (fontInfo?). In multi-pipe mode, we had
to allocate specific display list base's and XFontStructs for each pipe.
Snip -----
I have included a portion of the class and the instantiation of that class used in our code.
Any help is greatly appreciated.
Thanks
Kevin Kronmiller
Class instantiation :
xfont = new (pfGetSharedArena() )Xfont(getenv("RANGE_TIME_FONT"));
#ifndef __XFONT_H__
#define __XFONT_H__
#include <Performer/pr/pfObject.h>
#include <Performer/pr.h>
#include <Performer/prmath.h>
#include <Performer/pr/pfLinMath.h>
#include <ulocks.h>
#include <Performer/pr/pfState.h>
#include <errno.h>
/* This class is used to draw text to screen, the drawstring functions
must be called from within a draw callback. This draw callback can
be for a pfChannel, pfNode, etc.
To use:
// first construct an Xfont object from the shared arena
xfont = new (arena )Xfont(getenv("HAA_LBL_FONT"));
// pass this data to the callback function
.
.
.
// within the draw callback,
static void DrawFunc( pfChannel *chan, void *data ){
Xfont *xfont = (Xfont *)data;
pfVec3 color( 255.0f, 255.0f, 255.0f);
pfVec3 position( 0.0f, 0.0f, 0.0f );
xfont->drawString("text in scene", color, position );
}
*/
#define FIRSTGLYPH 32
#define LASTGLYPH 128
class Xfont : public pfObject{
private:
// int fontDLHandle;
GLuint fontDLHandle;
XFontStruct *fontInfo;
public:
Xfont(char *fontName = "-sgi-fixed-bold-r-normal--24-170-100-100-c-120-iso8859-9"){
//"-*-courier-bold-r-normal--14-*-*-*-m-90-iso8859-1"
Display *xdisplay;
// get font from X Server
xdisplay = pfGetCurWSConnection();
if (xdisplay == NULL) {
pfNotify(PFNFY_FATAL, PFNFY_USAGE, "loadXFont: couldn't get xdisplay\n");
exit(1);
}
printf("XLoadQueryFont\n");
fontInfo = XLoadQueryFont(xdisplay, fontName);
if(fontInfo == NULL){
pfNotify(PFNFY_FATAL, PFNFY_USAGE, "loadXFont: Couldn't load X font\n");
exit(1);
}
// Create GL display lists for font
pfNotify(PFNFY_NOTICE, PFNFY_PRINT, "loadXFont: making X font display "
"lists\n");
fontDLHandle = glGenLists((GLsizei) LASTGLYPH + 1);
if(fontDLHandle == 0)
{
pfNotify(PFNFY_FATAL, PFNFY_USAGE, "loadXFont: Couldn't get %d "
"display lists\n", LASTGLYPH + 1);
exit(1);
}
glXUseXFont(fontInfo->fid, FIRSTGLYPH, LASTGLYPH - FIRSTGLYPH + 1,
fontDLHandle + FIRSTGLYPH);
}
// draw text over screen like a HUD, xDim is the width of the
// window, yDim is the height of the window.
void drawString(char *s, float xDim, float yDim, pfVec3 color,
pfVec3 pos){
pfMatrix tempmat;
glDepthFunc(GL_ALWAYS); // always draw
glDepthMask(GL_FALSE);
pfPushState();
pfBasicState();
glGetFloatv(GL_PROJECTION_MATRIX, (GLfloat *)tempmat.mat);
glMatrixMode(GL_PROJECTION);
glLoadMatrixf((GLfloat *)pfIdentMat.mat);
glOrtho(0.0, xDim, 0.0, yDim, 1.0, -1.0);
glMatrixMode(GL_MODELVIEW);
pfPushMatrix();
pfLoadMatrix(pfIdentMat);
glColor3f( color[PF_X], color[PF_Y], color[PF_Z] );
glRasterPos3f(pos[PF_X], pos[PF_Y], pos[PF_Z]);
glPushAttrib(GL_LIST_BIT);
glListBase(fontDLHandle);
glCallLists(strlen(s), GL_UNSIGNED_BYTE, (GLubyte *)s);
glPopAttrib();
pfPopMatrix();
glMatrixMode(GL_PROJECTION);
glLoadMatrixf((GLfloat *)tempmat.mat);
glMatrixMode(GL_MODELVIEW);
pfPopState();
glDepthFunc(GL_LEQUAL);
glDepthMask(GL_TRUE);
}
// draw text in scene
void drawString( char *s, pfVec3 color, pfVec3 pos ){
glDepthFunc(GL_ALWAYS); // always draw
glDepthMask(GL_FALSE);
pfPushState();
pfBasicState();
glColor3f( color[PF_X], color[PF_Y], color[PF_Z] );
glRasterPos3f(pos[PF_X], pos[PF_Y], pos[PF_Z]);
glPushAttrib(GL_LIST_BIT);
glListBase(fontDLHandle);
glCallLists(strlen(s), GL_UNSIGNED_BYTE, (GLubyte *)s);
glPopAttrib();
pfPopState();
glDepthFunc(GL_LEQUAL);
glDepthMask(GL_TRUE);
}
short getWidth(void){
// return width of largest character
return ( fontInfo->max_bounds.width);
}
short getHeight(void){
// return height of largest character
return ( fontInfo->max_bounds.ascent);
}
};
#endif // !__XFONT_H__
This archive was generated by hypermail 2.0b2 on Thu Jul 29 1999 - 14:07:59 PDT