PDA

View Full Version : Minimal OGL Framework



Luuk van Venrooij
13-01-2010, 10:02 AM
Hi All,

I couldn`t get my old ogl template to compile anymore with delphi 2009 do to some xml libs I used. Also it had gotten pretty cluttered over the years so I decided to write a new minimal template. It has:

- OGL 3.2 backwards competible (when supported)render window with input
- FPS camera
- Rendering of text
- Loading of textures

Source is only 20 kb in size:) Source like always is LGPL.

http://www.genesisdevice.net/downloads/framework.zip

Grz

Luuk

Brainer
13-01-2010, 02:06 PM
Let me make it clear - is this template OpenGL 3.x compatible?

chronozphere
13-01-2010, 05:32 PM
Cool... thanks for this one. :)

XProger
15-01-2010, 07:39 PM
Most minimal ;)

program min_ogl;

uses
Windows, OpenGL;

var
pfd : TPixelFormatDescriptor;
DC : HDC;
begin
// Creating window
DC := GetDC(CreateWindowEx(0, 'EDIT', nil, WS_POPUP or WS_VISIBLE, 0, 0, 640, 480, 0, 0, 0, nil));
ShowCursor(False); // hide cursor
// OpenGL initialization
pfd.dwFlags := PFD_DRAW_TO_WINDOW or PFD_SUPPORT_OPENGL or PFD_DOUBLEBUFFER;
SetPixelFormat(DC, ChoosePixelFormat(DC, @pfd), @pfd);
wglMakeCurrent(DC, wglCreateContext(DC));
// Main Loop
while GetAsyncKeyState(27) = 0 do
begin
glBegin(GL_QUADS);
glColor3f(1, 0, 0); glVertex2f(-0.4, -0.4);
glColor3f(0, 1, 0); glVertex2f( 0.4, -0.4);
glColor3f(0, 0, 1); glVertex2f( 0.4, 0.4);
glColor3f(1, 0, 1); glVertex2f(-0.4, 0.4);
glEnd;
SwapBuffers(DC);
end;
end.

Brainer
15-01-2010, 07:45 PM
XProger, AFAIK it's not OpenGL 3.x compatible. ;)

chronozphere
15-01-2010, 07:47 PM
Indeed. I believe glVertex is deprecated.

But it is a nice piece of code. Shows how easy it is to setup OGL. ;D