From: Michael H. <mh...@us...> - 2000-10-18 20:53:20
|
Update of /cvsroot/pythianproject/PythianProject/Source/GameEngine In directory slayer.i.sourceforge.net:/tmp/cvs-serv27384/GameEngine Modified Files: GameGrEngState.pas GrEngState.pas Log Message: texture demo in graphics engine -mike Index: GameGrEngState.pas =================================================================== RCS file: /cvsroot/pythianproject/PythianProject/Source/GameEngine/GameGrEngState.pas,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** GameGrEngState.pas 2000/10/17 06:03:12 1.11 --- GameGrEngState.pas 2000/10/18 20:53:18 1.12 *************** *** 91,94 **** --- 91,95 ---- glEnable(GL_CULL_FACE); // enable face culling (no back faces) glEnable(GL_TEXTURE_2D); + glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); // enable alpha blending teSetWedgie(2.0); *************** *** 147,151 **** teStopTesselationMap;} ! teFinishFrame; inherited; --- 148,152 ---- teStopTesselationMap;} ! teFinishFrame; inherited; Index: GrEngState.pas =================================================================== RCS file: /cvsroot/pythianproject/PythianProject/Source/GameEngine/GrEngState.pas,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** GrEngState.pas 2000/10/17 18:23:07 1.9 --- GrEngState.pas 2000/10/18 20:53:18 1.10 *************** *** 3,7 **** interface ! uses BaseObjects, Cameras, MovingObjects, Objects, OpenGLWin, States, Textures; type --- 3,7 ---- interface ! uses BaseObjects, Cameras, MovingObjects, Objects, OpenGLWin, States, Textures, Trace; type *************** *** 14,17 **** --- 14,19 ---- FtxtFont :integer; + FTestTex :TTexture; + procedure SetWindow(const Value: TOpenGLWindow); procedure SetBitDepth(const Value: TBitDepth); *************** *** 39,42 **** --- 41,45 ---- procedure TGraphicsEngine.Finalize; begin + FTestTex.Free; inherited; end; *************** *** 61,67 **** --- 64,78 ---- glfEnable(GLF_CONTOURING);} + // add some console text (not used at this time) glfConsoleClear; glfPrintString('Test Line 1'); glfPrintString('Test Line 2'); + + // init the test texture + 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; *************** *** 71,77 **** // Disable texturing so we can see our colours glDisable(GL_TEXTURE_2D); ! glColor3f(1, 1, 1); ! // glClear(GL_DEPTH_BUFFER_BIT); // don't know why we need this, but we do // well, turns out we don't :) // heh. okay :) must just be me --- 82,92 ---- // Disable texturing so we can see our colours glDisable(GL_TEXTURE_2D); ! // turn on alpha blending for this text ! glEnable(GL_BLEND); ! glEnable(GL_ALPHA_TEST); ! glColor4f(1, 1, 1, 0.4); ! ! //glClear(GL_DEPTH_BUFFER_BIT); // don't know why we need this, but we do // well, turns out we don't :) // heh. okay :) must just be me *************** *** 85,98 **** glLoadIdentity; // change co-ordinate system to 1:1 pixel mapping glScalef(2.0 / Window.Width, -2.0 / Window.Height, 1.0); glTranslatef(-(Window.Width / 2), -(Window.Height / 2), 0); // need this: scale it - otherwise text will be 1x1 pixels! glScalef(10, 10, 1); // offset it from the top by Y/2 text rows to make it look nicer ! glTranslatef(0, 2, 0); ! // need this: flip matrix because GLF is expecting OpenGL default // co-ordinates and we have changed them. Otherwise text will be --- 100,160 ---- glLoadIdentity; + // change co-ordinate system to 1:1 pixel mapping glScalef(2.0 / Window.Width, -2.0 / Window.Height, 1.0); glTranslatef(-(Window.Width / 2), -(Window.Height / 2), 0); + // draw shapes. for some reason we need to do this BEFORE text + // why? beats me :( + + // 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); + + glColor4f(1.0,1.0,1.0,0.8); + + glBegin(GL_QUADS); + glNormal3f(0,0,1); + // glColor4f(1.0,0.0,0.0,0.5); + glTexCoord2f(0,64); + glVertex2f(256,64); + // glColor4f(0.0,1.0,0.0,0.5); + glTexCoord2f(0,0); + glVertex2f(256,0); + // glColor4f(0.0,0.0,1.0,0.5); + glTexCoord2f(256,0); + glVertex2f(0,0); + // glColor4f(1.0,1.0,1.0,0.5); + glTexCoord2f(256,64); + 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); // offset it from the top by Y/2 text rows to make it look nicer ! glTranslatef(0, 2, -1); ! // need this: flip matrix because GLF is expecting OpenGL default // co-ordinates and we have changed them. Otherwise text will be *************** *** 100,109 **** --- 162,178 ---- glScalef(1, -1, 1); + glPushMatrix; // finally draw the text glfDrawSolidString(Format('FPS: %f',[FFPS])); + glPopMatrix; + + glScalef(1, -1, 1); // and restore to default glMatrixMode(GL_PROJECTION); glPopMatrix; + + glDisable(GL_BLEND); + glDisable(GL_ALPHA_TEST); // restore the colour to white because this affects everything else in the |