PDA

View Full Version : Text is rendered as a block of color?



Mars_999
05-08-2010, 10:59 AM
Hello, I have a Radeon 3200 (780G chipset in a netbook) the drivers aren't the latest as I can't find anyway to update them to 10.4. I have a Radeon 5870 and the text renders with no problems. The 3200 will render each char as a block of color and no text...

This is not my code, the lib is "oglconsole"



void OGLCONSOLE_Render(OGLCONSOLE_Console console)
{
/* Don't render hidden console */
if (C->visibility == 0) return;

glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadMatrixd(C->pMatrix);

glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadMatrixd(C->mvMatrix);

glPushAttrib(GL_ALL_ATTRIB_BITS);

/* glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);*/

/* TODO: This SHOULD become an option at some point because the
* infrastructure for "real" consoles in the game (like you could walk up to
* a computer terminal and manipulate a console on a computer using
* oglconsole) already exists; you'd want depth testing in that case */
glDisable(GL_DEPTH_TEST);

/* Render hiding / showing console in a special manner. Zero means hidden. 1
* means visible. All other values are traveling toward zero or one. TODO:
* Make this time dependent */
if (C->visibility != 1)
{
double d; /* bra size */
int v = C->visibility;

/* Count down in both directions */
if (v < 0)
{
v ^= -1;
C->visibility++;
}
else
{
v = SLIDE_STEPS - v;
C->visibility--;
}

d = 0.04 * v;
glTranslated(0, 1-d, 0);
}

/* First we draw our console's background TODO: Add something fancy? */
glDisable(GL_TEXTURE_2D);
glEnable(GL_BLEND);

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ONE_MINUS_SRC_COLOR);
glColor4d(.1,0,0, 0.5);

glBegin(GL_QUADS);
glVertex3d(0,0,0);
glVertex3d(1,0,0);
glVertex3d(1,1,0);
glVertex3d(0,1,0);
glEnd();

// Change blend mode for drawing text
glBlendFunc(GL_ONE, GL_ONE);

/* Select the console font */
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, OGLCONSOLE_glFontHandle);

/* Recolor text */
glColor3d(0,1,0);

/* Render console contents */
glBegin(GL_QUADS);
{
/* Graphical line, and line in lines[] */
int gLine, tLine = C->lineScrollIndex;

/* Iterate through each line being displayed */
for (gLine = 0; gLine < C->textHeight; gLine++)
{
/* Draw this line of text adjusting for user scrolling up/down */
OGLCONSOLE_DrawString(C->lines + (tLine * C->textWidth),
0,
(C->textHeight - gLine) * C->characterHeight,
C->characterWidth,
C->characterHeight,
0);

/* Grab next line of text using wheel-queue wrapping */
if (++tLine >= C->maxLines) tLine = 0;
}

/* Here we draw the current commandline, it will either be a line from
* the command history or the line being edited atm */
if (C->historyScrollIndex >= 0)
{
glColor3d(1,0,0);
OGLCONSOLE_DrawString(
C->history[C->historyScrollIndex],
0, 0,
C->characterWidth,
C->characterHeight,
0);
}
else
{
/* Draw input line cyan */
glColor3d(0,1,1);
OGLCONSOLE_DrawString(C->inputLine,
0, 0,
C->characterWidth,
C->characterHeight,
0);

/* Draw cursor beige */
glColor3d(1,1,.5);
OGLCONSOLE_DrawCharacter('_'-' ',
C->inputCursorPos * C->characterWidth, 0,
C->characterWidth,
C->characterHeight,
0);
}
}
glEnd();

/* Relinquish our rendering settings */
glMatrixMode(GL_PROJECTION);
glPopMatrix();

glMatrixMode(GL_MODELVIEW);
glPopMatrix();

glPopAttrib();
}


Thanks

Mars_999
05-08-2010, 11:31 AM
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); solves the problem?

I was using glGenerateMipmap() and that should work as glGenerateMipmap() works on my other textures with in the game...

Have no clue what the problem would be....