And, in the end, I've just found out what I was doing wrong
So this code works
Code:
glClearColor(0,0,0,1.0);
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
glViewport(0,0,fRenderWidth,fRenderHeight);
glLoadIdentity;
gluOrtho2D(0,fRenderWidth,fRenderHeight,0);
glEnable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBindTexture(GL_TEXTURE_2D,fCharacterSets[0].texture);
for y:=0 to 15 do //5 do
begin
ty:=y*24;
for x:=0 to 15 do //5 do
begin
tx:=x*24;
idx:=x+(Y*16);
glDisable(GL_BLEND);
glBegin(GL_QUADS);
glColor4f(fGLPaletteColors[0][idx,0],fGLPaletteColors[0][idx,1],fGLPaletteColors[0][idx,2],1.0);
glVertex2i(tx,ty);
glVertex2i(tx+16,ty);
glVertex2i(tx+16,ty+16);
glVertex2i(tx,ty+16);
glEnd;
// Render the font
glColor4f(fGLPaletteColors[0][255-idx,0],fGLPaletteColors[0][255-idx,1],fGLPaletteColors[0][255-idx,2],1.0);
glEnable(GL_BLEND);
glBegin(GL_QUADS);
glTexCoord2f(x*ONE_16TH,y*ONE_16TH);
glVertex2i(tx,ty);
glTexCoord2f(x*ONE_16TH+ONE_16TH,y*ONE_16TH);
glVertex2i(tx+16,ty);
glTexCoord2f(x*ONE_16TH+ONE_16TH,y*ONE_16TH+ONE_16TH);
glVertex2i(tx+16,ty+16);
glTexCoord2f(x*ONE_16TH,y*ONE_16TH+ONE_16TH);
glVertex2i(tx,ty+16);
glEnd;
end;
end;
And this is the output....
CorrectResults.PNG
So what I was doing wrong, was binding the palette texture to the vertices of the background colour. Instead, this code simply uses glColor4f to set the colour, then creates a quad, specifies the points for the background. Turns on blending, changes the colour and creates a quad, specifying texture coordinates corresponding to the required character.
Interestingly though, I had a problem that was really odd involving the second column (from the left) and the bottom row, being darker. No matter what I tried I couldn't stop this and it was like this was something to do with one of the textures. Originally I was loading my textures and setting these:-
Code:
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
With those commented out, that problem went away.
And that, as they say is that... now I can crack on and write some bad code to get something working.
Bookmarks