Update of /cvsroot/pythianproject/PythianProject/Source/GameEngine
In directory slayer.i.sourceforge.net:/tmp/cvs-serv15733/Source/GameEngine
Modified Files:
GrEngState.pas
Log Message:
added transparent picture demo -mike
Index: GrEngState.pas
===================================================================
RCS file: /cvsroot/pythianproject/PythianProject/Source/GameEngine/GrEngState.pas,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** GrEngState.pas 2000/10/18 20:53:18 1.10
--- GrEngState.pas 2000/10/19 19:45:20 1.11
***************
*** 35,39 ****
uses
! glfd, OpenGL, SysUtils, Windows;
{ TGraphicsEngine }
--- 35,39 ----
uses
! glfd, OpenGL, SysUtils, Windows, Points;
{ TGraphicsEngine }
***************
*** 46,49 ****
--- 46,50 ----
function TGraphicsEngine.Initialize: Boolean;
+ const whiteByte: TByteColor = (255,255,255,255);
begin
Result := inherited Initialize;
***************
*** 72,78 ****
FTestTex := TTexture.Create;
FTestTex.Initialize;
! FTestTex.UseAlpha := false;
FTestTex.LoadFromFile(DataPath+'images\logo1.bmp');
if FTestTex.Image = nil then TraceString('Logo failed to init!');
end;
end;
--- 73,84 ----
FTestTex := TTexture.Create;
FTestTex.Initialize;
! FTestTex.UseAlpha := true;
! FTestTex.AlphaColor := whiteByte;
FTestTex.LoadFromFile(DataPath+'images\logo1.bmp');
if FTestTex.Image = nil then TraceString('Logo failed to init!');
+
+ // text antialiasing
+ glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
end;
end;
***************
*** 109,118 ****
// hmm, we seem to need to do vertices in an anti-clockwise direction
! glPushMatrix;
glTranslatef(Window.Width-270,30,0);
! glEnable(GL_TEXTURE_2D);
FTestTex.Draw; // bind texture
glMatrixMode(GL_TEXTURE);
! glPushMatrix;
glScalef(1/256,1/256,1);
--- 115,124 ----
// hmm, we seem to need to do vertices in an anti-clockwise direction
! glPushMatrix; // push logo matrix
glTranslatef(Window.Width-270,30,0);
! glEnable(GL_TEXTURE_2D); // reenable textures for this part
FTestTex.Draw; // bind texture
glMatrixMode(GL_TEXTURE);
! glPushMatrix; // push tex matrix
glScalef(1/256,1/256,1);
***************
*** 134,154 ****
glVertex2f(0,64);
glEnd;
- glPopMatrix; // pop tex matrix
- glMatrixMode(GL_MODELVIEW);
- glPopMatrix; // pop logo matrix
- glDisable(GL_TEXTURE_2D);
! { glBegin(GL_QUADS);
! glNormal3f(0,0,1);
! glColor4f(1.0,0.0,0.0,0.5);
! glVertex2f(100,100);
! glColor4f(0.0,1.0,0.0,0.5);
! glVertex2f(-100,-100);
! glColor4f(0.0,0.0,1.0,0.5);
! glVertex2f(10,-100);
! glColor4f(1.0,1.0,1.0,0.5);
! glVertex2f(-10,10);
! glEnd; }
// need this: scale it - otherwise text will be 1x1 pixels!
glScalef(10, 10, 1);
--- 140,185 ----
glVertex2f(0,64);
glEnd;
! // IMPORTANT NOTE: it appears to be important which order matrices
! // are pushed and popped. You can't :
! //
! // push texture ; push modelview
! // pop texture ; pop modelview
! //
! // as you might think, instead you must do this:
! //
! // push texture; push modelview
! // pop modelview; pop texture
! //
! // in effect - last on, first off
!
! glMatrixMode(GL_TEXTURE); glPopMatrix;
! glMatrixMode(GL_MODELVIEW); glPopMatrix; // pop logo matrix
!
! // now for non-rectangular images - ie basic transparency
! glPushMatrix; // push circle matrix
! glTranslatef(10,FWindow.Height-60,0); // move to bottom left
! glMatrixMode(GL_TEXTURE);
! glPushMatrix; // push tex matrix
! glScalef(1/256,1/256,1);
!
+ // hmm, for some reason the x axis on the texture matrix
+ // seems to be inverted. must investigate when i have time
+ // (which is probably sometime after never)
+ glBegin(GL_QUADS);
+ glTexCoord2f(256,64); glVertex2f(0,0);
+ glTexCoord2f(256,114); glVertex2f(0,50);
+ glTexCoord2f(206,114); glVertex2f(50,50);
+ glTexCoord2f(206,64); glVertex2f(50,0);
+ glEnd;
+
+ glMatrixMode(GL_TEXTURE); glPopMatrix; // pop texture matrix
+ glMatrixMode(GL_MODELVIEW); glPopMatrix; // pop circle matrix
+
+
+ glDisable(GL_TEXTURE_2D); // disable texturing again for text
+
+ // now for the text
// need this: scale it - otherwise text will be 1x1 pixels!
glScalef(10, 10, 1);
***************
*** 162,169 ****
--- 193,204 ----
glScalef(1, -1, 1);
+ glEnable(GL_POLYGON_SMOOTH);
+
glPushMatrix;
// finally draw the text
glfDrawSolidString(Format('FPS: %f',[FFPS]));
glPopMatrix;
+
+ glDisable(GL_POLYGON_SMOOTH);
glScalef(1, -1, 1);
|