Code:
procedure TForm1.FormCreate(Sender: TObject);
begin
DC := GetDC(Handle);
if not InitOpenGL then Application.Terminate;
RC := CreateRenderingContext(DC, [opDoubleBuffered], 32, 24, 0, 0, 0, 0);
ActivateRenderingContext(DC, RC);
//load textures
LoadTexture('img\char.tga', tex, false);
Timer1.Enabled := true;
end;
procedure DrawQuad(pX, pY, pZ, pWidth, pHeight:single);
begin
glBegin(GL_QUADS);
glTexCoord2f(0,1); glVertex3f(pX, pY, -pZ);
glTexCoord2f(1,1); glVertex3f(pX+pWidth, pY, -pZ);
glTexCoord2f(1,0); glVertex3f(pX+pWidth, pY+pHeight, -pZ);
glTexCoord2f(0,0); glVertex3f(pX, pY+pHeight, -pZ);
glEnd;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
DeactivateRenderingContext;
DestroyRenderingContext(RC);
ReleaseDC(Handle, DC);
end;
procedure TForm1.Render;
begin
//clear
//glClearColor(0.6, 0.7, 1, 0);
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode (GL_PROJECTION);
glLoadIdentity();
glViewport(0, 0, ClientWidth, ClientHeight);
glOrtho(0, ClientWidth, ClientHeight, 0, -1, 1);
glDisable(GL_DEPTH_TEST);
glMatrixMode (GL_MODELVIEW);
glLoadIdentity();
glTranslatef (0, 0, 0);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
//sdfffdsgfhhf
DrawQuad(x, 0, 0, 320, 32);
SwapBuffers(DC);
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Render;
end;
Bookmarks