PDA

View Full Version : Which OpenGL Version to use for 2d games



3Shrike3
20-03-2013, 09:44 PM
Ok, I would like to make a simple 2d game in OpenGL. I have followed a few OpenGL 2 tutorials and think I could get my head around it. Is it worth learning opengl 3 or 4 simply for a 2d game?

Carver413
20-03-2013, 11:20 PM
if your just making 2d games probable not, you should check out zengl it might save you some time

LP
21-03-2013, 01:42 AM
Ok, I would like to make a simple 2d game in OpenGL. I have followed a few OpenGL 2 tutorials and think I could get my head around it. Is it worth learning opengl 3 or 4 simply for a 2d game?

You may want OpenGL 2 for compatibility with some older hardware, but if you are going to use raw OpenGL, if you stick with OpenGL 3 (Core functionality), it will be much less confusing and you will learn modern OpenGL a lot faster. My suggestion is to learn OpenGL 3 (ignore anything that is lower than this) and stick with it. As a bonus, you will find transition into OpenGL ES (iOS, Android) easier, should you decide later to pursue it.

User137
21-03-2013, 02:56 PM
Was it that some of OpenGL 2 and earlier commands don't even work on OpenGL ES?

LP
21-03-2013, 07:50 PM
Was it that some of OpenGL 2 and earlier commands don't even work on OpenGL ES?
Yes, that's right. Fixed-function pipeline don't work in OpenGL ES 2 along with some other deprecated functionality. This is why if you stick to core OpenGL 3, you get relatively clean API, which should be mostly exchangeable with OpenGL ES 2.

OpenGL ES 1.1 still has some legacy functions, but it is a deprecated API.

3Shrike3
21-03-2013, 11:11 PM
Ok, so I've decided to learn opengl 3+. Noob question time: So I have to install dglOpenGL and what should I use for windowing if I want my game to be cross-platorm? Because glut is old I think.

Carver413
22-03-2013, 02:44 AM
http://www.spacesimulator.net/index.php?p=home
I don't think we have any multi platform solutions at this time sdl2 would be a good choice if we had working header files. I'm using xlib at the moment. there is enough here to get you started if you speak a little C++

User137
22-03-2013, 03:08 AM
I'm using Lazarus form and TLazOpenGLContext. It should be perfectly multiplatform. (That with dglOpenGL header, no glut needed for me at least.)

3Shrike3
22-03-2013, 05:04 PM
right, so I think that I will try TLazOpenGLContext. Does this sacrifice any speed though?

Carver413
22-03-2013, 06:30 PM
it would not be my first choice and I dont think it is opengl 3.0+ ready so you will have to open an extended content yourself for all supported platforms.

3Shrike3
22-03-2013, 08:20 PM
Ok, so if using a lazarus for is not a good idea, what would you suggest, as I am on a mac, so I can't do any of the win32 stuff. Also, if I were to use lazarus, how would I go about doing that?

User137
22-03-2013, 09:03 PM
it would not be my first choice and I dont think it is opengl 3.0+ ready so you will have to open an extended content yourself for all supported platforms.
It is OpenGL 3 ready. Afterall you do the library loading with dglOpenGL functions, not FPC ones.

All i can say is that the executable size may be bigger, over 1mb or something, with added possibility to use LCL components. This means you can have TPanel's and stuff on the form, and it's very useful if you plan to make editor for game that uses OpenGL.

3Shrike3
27-03-2013, 04:36 PM
How do I load the dglopengl.pas file into my game as there is no .lpk?

Carver413
27-03-2013, 04:55 PM
you can make your own .lpk and add it to the list

Sascha Willems
27-03-2013, 04:57 PM
Since it's not including any components or such there is no need for a package. Just add it to your uses clausel and put it in a directory where Lazarus can find (either where your game's sources are located or any of Lazarus' search paths).

3Shrike3
28-03-2013, 12:57 PM
sorry, me again - how do I load shaders in fpc? Because in tutorials I see shader = new Shader("shader.vert", "shader.frag");

User137
28-03-2013, 01:28 PM
If you want to study ready source code, i'm happy to show you few weeks ago rewritten shader classes from nxPascal
https://code.google.com/p/nxpascal/source/browse/trunk/src/nxGL.pas#177
TShaderSource, TShaderProgram and TGLShader are responsible of creating, loading and using the shader with OpenGL with all imaginative ways possible. Also reporting errors and compile-errors that might come up.

Usage is simple (adding error reporting there's a full demo (https://code.google.com/p/nxpascal/source/browse/trunk/demos/fpc/shader/MainUnit.pas#65)):

shader:=TGLShader.Create;
shader.AddDefault3D(true);
shader.Link;
shader.Enable;

phibermon
29-03-2013, 01:49 PM
I don't believe that TLazOpenGLContext is OpenGL 3.x+ compatible, there's special things you need to do at window + context creation time, IE in windows you need to destroy/create a new window after you've checked various capabilities to support multisampling. Also on OSX there's only two ways to get an OpenGL 3.x context, either via a full screen/'windowless' process (CGL) or via opengl 'widgets' in Cocoa. (they annoyingly provide no such functionality for Carbon) So again, you're only going to be having GL3 in a Window on OSX by using cocoa. (and even then you're going to have to deal with the highly buggy GL3.2 implementation that apple decided to grace the world with)

So yeah, don't use TLazOpenGLContext unless you mind loosing multi-sampling, not being fully cross platform for 3.x and having no fine grain control over the garunteed issues you'll have with various hardware/driver/OS combos. You'd be much better off with somthing like Zen, nxPascal, my engine (shameless plug) or anything else that does Window/Context management by itself, sets up multi-sampled windows etc

User137
29-03-2013, 03:05 PM
Well, whatever engine you use it's most likely possible to create the window yourself, as needed per special project.

And all these problems only come into question if you are dealing with Apple's products... of which i'm almost a sworn hater of. Always going their own way, not a trace of backwards compatibility with anything. Draining money from you with all imaginative ways with no shame at all. At least microsoft is doing much better job at keeping old stuff working, and more modular.

Carver413
29-03-2013, 09:51 PM
Go Linux, be free

User137
30-03-2013, 01:42 AM
Go Linux, be free
If only most games would run on linux, it would be an option ;) Last time i tried Ubuntu it had difficulties with simple matter as enabling hardware acceleration for operating system...

Cybermonkey
30-03-2013, 09:03 AM
Never had a problem with that since Ubuntu from 2005... Yesterday I installed the Steam client and I am waiting now for Half Life 2 to be ported ...

Rodrigo Robles
30-03-2013, 11:43 AM
I'm using Ubuntu only since 2006. The last versions should run fine in the majority of the hardware, but I recommend ATI or NVIDIA graphic cards.
I have no dual boot, when I really need to run some windows apps, I run it via wine. It has a good compatibility, can run apps like Delphi 7 or games from old to new.
But for a lifetime windows users, I suggest a dual boot for start and some persistence, because is hard to leave the confort and habit of years in commercial apps. The price of freedom is not so cheap, you can remember that the guys that take the red pill suffer more than the ones that take the blue pill...

Sorry by the off-topic...

Super Vegeta
30-03-2013, 02:55 PM
UbuntuWell, here's your problem. I personally prefer Fedora, but I think that Mint is the best distro when it comes to hardware support.

And, as Rodrigo said, Dual Boot all the way. You can run many programs on Wine, but quite often this brings some performance issues, so it may be necessary to boot into Winderps once in a while. Just get a FAT/NTFS partition that you can share between the OSes and voila.

Carver413
30-03-2013, 03:33 PM
I'm using Mint13 and no problems, been playing tf2 on steam, best online game ever

phibermon
30-03-2013, 05:35 PM
Stop listing Linux Distros! :) it's only about the code they include and the scripts for their installers etc it's the Linux kernel that does all the support and all that jazz. Mint has a highly customized interface/installer etc and ships ready for propitiatory drivers. That's no reason to say it's better than any other because it only takes a minute to install them. Ubuntu is lamer than OSX so stop using it, it's Linux for people that want to use Linux but don't understand Linux. Redhat is for corporate snobs and IT managers that are too scared to use Linux without a big fat support contract.

If you're using Ubuntu, switch to Debian. Ubuntu is just a re-badged Debian with additonal packages, they take the skill and hard work of people working on serious distro, stick a bunch of idiot friendly wizards over the top then install their own pig-awful desktop. (Android anybody?) Even better switch to Arch, compile *everything* fully optimized for your hardware without using slower, generic kernel/binaries etc or use 'Scientifc Linux' and pretend you work at Cern! or you can use SuSE which is Redhat for Germans that wink at each other in chat rooms and throw veiled insults at non-germans that dare try and interact with them on a technical level.

Anyway, we all know that Slackware is the best.