PDA

View Full Version : Need some advice for OpenGL



Cybermonkey
17-08-2012, 02:57 PM
Hi, I recently thought about doing a 2D game engine in OpenGL. Now, before I even started, I ran into some problems. Since I am very limited in my C/C++ knowledge I searched for other languages which utilizes OpenGL and had a closer look at the article here: http://games.freebasic.net/BASICGaming/Issue3/LachieLesson2/GL2D/gL2D_tut_1.html
(http://games.freebasic.net/BASICGaming/Issue3/LachieLesson2/GL2D/gL2D_tut_1.html)
Now I learned that almost all of that stuff is now deprecated (All the math stuff (glPushMatrix, glTranslate, glRotate ...) and all immediate rendering (glBegin, glVertex) etc. Now here's my question: is there a tutorial (best for Object Pascal) for building an OpenGL 2D engine which does not use deprecated stuff?
My second problem is what library I'll use for windowing, input etc.? Should I use SDL, so I can reuse some stuff of my SDL based engine, (Free)Glut, or something totally different? (Yes, I got that OpenGL superbible in an older (used) issue, but as said it's C/C++ and mainly about 3D programming).

Maybe a tutorial articles series here on PGD would be helpful. Something like that SDL tutorial (Artillery Game) by Jason but ported to OpenGL ...;)

LP
17-08-2012, 03:19 PM
Now here's my question: is there a tutorial (best for Object Pascal) for building an OpenGL 2D engine which does not use deprecated stuff?
Yes. Clicky. (http://duriansoftware.com/joe/An-intro-to-modern-OpenGL.-Table-of-Contents.html) ;)

Ñuño Martínez
17-08-2012, 03:43 PM
Actually, using OpenGL to draw 2D is exactly the same than doing 3D stuff but using only two axis (you know, use glVertex2f instead of glVertex3f). To make things easer you should use orthographic projection instead (glOrtho instead fo glFrustum).


Now I learned that almost all of that stuff is now deprecated (All the math stuff (glPushMatrix, glTranslate, glRotate ...) and all immediate rendering (glBegin, glVertex) etc. (...) Is it? :o Did I miss something?

Recently I recycled myself about OpenGL for my 2nd PGD Challenge entry and I didn't find nothing about obsolescence...

Cybermonkey
17-08-2012, 03:58 PM
Yes. Clicky. (http://duriansoftware.com/joe/An-intro-to-modern-OpenGL.-Table-of-Contents.html) ;)
Okay, I will have a look into that. Is there a GLEW.pas available??

FelipeFS
17-08-2012, 06:53 PM
I heard that a lot of functions will be deprecated in OpenGL 4.x, BUT most of the hardware still do not support OpenGL 4.

I recommend you to use FreeGLUT, it will give you a good cross-platform support. I'm using it on my game engine.

LP
17-08-2012, 07:25 PM
If you want to learn OpenGL well, I would recommend staying away from GLUT, SDL and other rudimentary helper libraries - you will have to write few lines of code extra, but you will know exactly what you are doing and will learn more. Besides, there is deprecated functionality too, for example gluBuild2DMipmaps, which you should replace in favor of glGenerateMipmap.



Is it? :o Did I miss something?

Recently I recycled myself about OpenGL for my 2nd PGD Challenge entry and I didn't find nothing about obsolescence...

Check this thread #1 (http://www.pascalgamedevelopment.com/showthread.php?13441-FBOs-and-OpenGL-Extensions) and this thread #2 (http://www.pascalgamedevelopment.com/showthread.php?13446-Weird-glGetError-1286), where it was discussed recently. Direct link (http://www.opengl.org/wiki/History_of_OpenGL#Deprecation_Model) to brief deprecated list.

code_glitch
18-08-2012, 01:10 PM
What platform? If your going to do as LifePower says your going to need to either talk to X or WINAPI for window handling (no idea what mac uses) and it can be quite specific... For my OpenGL - X11 code I used this page: http://content.gpwiki.org/index.php/OpenGL:Tutorials:Setting_up_OpenGL_on_X11 and friends-of-fpc have a good tutorial on writing for WINAPI if I recall. The gpwiki link will need some understanding of C/C++ but is actually really good for cerating a context, and once you have that done its all standard opengl.

Good luck :)

Cybermonkey
18-08-2012, 01:43 PM
Oh, best for all platforms: Linux, Windows, MacOS X.

code_glitch
18-08-2012, 08:49 PM
In that case youd either have to use glut or sdl for easy window handling. However if the objective is pure opengl from the ground up you'll unfortunately have to write code for each of those platforms. Good luck - some of the code you have to interface with can be a little archaic at times....

WILL
18-08-2012, 08:59 PM
If those are your main or only platforms then SDL is probably your easiest and friendliest solution. I'm not partial to GLUT myself and it doesn't do everything that SDL is going to do for you. (controller/gamepad input, audio/music mixer, some texture loading routines)

Once you have a decent SDL base to work with the rest can be all OpenGL for your graphics. The NeHe tutorials can help you get started, but I'm not sure if they cover using SDL with OpenGL. SDL is in fact designed to use OpenGL instead for graphics, that's why they bundle it together.

code_glitch
18-08-2012, 09:21 PM
The friends of fpc site has a section on starting out with the opengl/sdl combo if I recall :)

WILL
18-08-2012, 10:39 PM
Also, since we've gone through several years and different approaches to OpenGL over those years, take care to notice the date of that information. There may be more accurate or up to date literature about OpenGL for Free Pascal, Delphi or other tools. If you want the latest and greatest OpenGL stuff though, I'd recommend following Sascha Willems who run his own blog and the DelphiGL.com community for German Pascal game developers.

Cybermonkey
20-08-2012, 12:53 PM
Okay, thanks guys. A lot of things to pay attention to ...

User137
20-08-2012, 01:01 PM
I have always wondered why they made it German programming community. Don't they think there *might* be some pascal game developers outside their country? ???

SilverWarior
20-08-2012, 05:52 PM
I have always wondered why they made it German programming community. Don't they think there *might* be some pascal game developers outside their country? ???

Why this is not my intention but my reply might insult some pepole. I do apologize in advance.
One of the reasons why they make it German programing community is that Germans are a proud nation which thinks that if pepole would like to learn somethink from them they should first learn to speak German. The verry same thinking is present in American and other English speaking nations.
Another reason is the fact that back in the days both TurboPascal and Delphi were extremly popular in Germany. And since Germany is quite large country they had no need to atract pascal developers from around the world since they already had quite large comunity populated mostly by Germans.

phibermon
20-08-2012, 07:57 PM
I did write a nice reply regarding written language use in the world but it got lost.

So I'll recap :

English language skills vary greatly across Germany.

Google translate is useless when dealing with programmers terminology (it translates very poorly or rather, computer terms can be cumbersome in many languages)

Worlds 3 most common spoken languages (native speakers) : Mandarin, Spanish, English

Worlds 3 most common spoken languages (multi-lingual speakers) : Spanish, English, Mandarin

Pascal keywords are in English.

We should all probably learn Spanish.

Cybermonkey
20-08-2012, 08:13 PM
Yes, but German is the most spoken language (native speakers) in the European Union. But maybe we should learn Mandarin; it's the future. ::) Anyway, I think that's rather off-topic, isn't it?

LP
20-08-2012, 08:27 PM
Well, it's so happens that OpenGL headers are hosted by German community. They are similar communities in Spanish (http://www.clubdelphi.com/foros/index.php), Russian (http://forum.mirgames.ru/), and I'm sure there are many more in other languages, each hosting their own unique content.