Starting with OpenGL

Started by AzureusNation, July 20, 2015, 15:15:11

Previous topic - Next topic

AzureusNation

Hi Guys,

I have recently just gotten in to wanting to write a game in 2D. I though this would be the best library to use for the graphical features.

I have experience in loops and guis but where do I start with OpenGL and rendering?

Any help will be greatly appreciated.

Cornix

I assume that you are not a very experienced programmer (> 3 years). If I am correct I would recommend NOT to use LWJGL.
This is a very low level API. It is hard to understand and hard to use. If you still have problems with simpler concepts you will certainly not be able to work well with OpenGL right now.

Instead, try a simpler, higher level, library like libGDX. libGDX uses LWJGL internally (for desktop applications) but does all of the heavy work for you.

xsupermetroidx

LWJGL does not have any "graphical features." It provides you with access to the OpenGL API which is nothing more than the raw commands that you can send to your graphics card. Based on your current level of programming experience, it will take you months to get a simple shape to show up on the screen. I second AzureusNation's suggestion to use LibGDX.

AzureusNation

Right so ive been doing some research on the matter of libgdx, but I don't like the way that it does things and I would like to create my own engine.

So I've looked in to the pros and cons of using opengl 2- and opengl 3+, baring n mind that this is only a 2d game what would you guys suggest, learning the modern shaders route or using legacy opengl?

Cornix

For 2D it doesnt actually matter. Todays hardware is so fast that, on my (old and rather weak) machine I can still render 3.000.000 2D quads with the legacy API at 60 FPS.
If you have an actually powerful machine you could probably do ten times more. Its more then you will ever need.

However, the legacy API is indeed really outdated but its an easier way to start. You shouldnt stick to it though. Try to understand how the fixed function pipeline works by messing around with the legacy API. When you understand that go to VBO's and basic vertex + fragment shaders and then you can work your way up to versions 3 and 4 if you want to do 3D stuff.

xsupermetroidx

That is horrible advice. It does matter for 2D and the legacy API is horribly slow and dated. There is no reason to even begin to learn legacy OpenGL (unless you are a computer graphics historian perhaps), as anything you do learn will simply impede you from understanding the modern/correct way of doing things. It's not an easier way to get started, it's simply a dead-end path.

In any case, why do you hate the way LibGDX does stuff, and why do you want to create your own engine? What specifically do you think you can accomplish with your own engine that you can't do with LibGDX? How much time and energy are you planning to put into this project?

Cornix

I disagree.
The legacy API is much easier to get going. You can say whatever you want, but when people have to spend the first 5 hours just to get a simple triangle to show up they will lose their motivation roughly 2 hours in.

With the legacy API you get some VISIBLE results within a few minutes. You get the Eureka!-effect of having something accomplished.
Then you can learn why the legacy API is bad and how it was superseded. In my opinion this is a much better route then to force yourself through the new API straight away. But perhaps its personal preference.

xsupermetroidx

Anyone who is worried about losing interest 2 to 5 hours in should not begin a process of engine development that will take hundreds or thousands of hours. If he makes any actual progress toward a working game engine he will regret every moment he wasted learning the legacy API which could have been spent learning how to do things the proper way. If he wouldn't even make it to the point where something is displayed on the screen with the modern API, he should be using LibGDX.

Cornix

Humans are not machines. Humans need to be kept motivated if you want them to get something done. Yes, in the end they will have to do the same work, but it feels a lot easier if you dont have to churn through it in bulk.

AzureusNation

Thank you Cornix for the reply. I will take up your suggestion of the legacy api and if the game then needs for some reason to be updated then it can be done.

Quads and textures here I come :D

Cornix

I would definitely not recommend staying with the legacy API. But you can have a look at it just to get started.
You should try to move your code from the legacy API to VBO's and then eventually to VAO's if you need higher versions of OpenGL.
But you should definitely go to VBO's at least.

PRDibble

I'm in a similar situation, I am an experienced coder in a few languages (though mostly really, really old languages), but have been out of touch and want to start bringing some of my graphical knowledge up to date by creating a 2D-based game. OpenGL is a hill I've intended to climb for a while, but I kept making excuses to use Swing.

Like you, I'm looking at a 2D set-up, I've gone through the Immediate Mode stuff, which isn't too bad, and am just starting on the VBO tutorials. Not sure if I'll pull it out further than that though, to be honest the Graphics are more a means to an end, the purpose of my using OpenGL is (a) gaining familiarity and (b) freeing up CPU as much as possible, but I'd agree that either way it's best to avoid staying with deprecated stuff like Immediate Mode.

For now, I find this forum contains a vast amount of information that helps me, though I suspect I'll have more specific questions as things progress. If they are silly, or obvious questions, I apologize in advance :)

Anyway, good luck with what you're doing :)

BrickFarmer

I still like 'legacy' Immediate Mode OpenGL, far easier to understand when just starting out with OpenGL.  With modern OpenGL, you are already having to learn two languages, and deal with version complexity.  As for proper and correct, I agree that getting quick results is more important, and NeHe tutorials were great in that sense.  From a rotating triangle to doom style scene in hardly any code :)  and anyway I guess we are all learning Vulkan soon!

For someone just starting out with wanting to write a 2D game, then I would suggest something like cocos2d  http://cocos2d.org/

Oculus Rift CV1, MBP 2016 - 2.9 i7 - Radeon Pro 460  OSX 10.12.4,  Win7 - i5 4670K - GTX1070.
Oculus Rift VR Experiments: https://github.com/WhiteHexagon

PRDibble

The thing is, as I read through these tutorials, as someone just starting out in OGL, I'm beginning to agree the best idea possibly is the upgrade route, at least the first few times, it'll allow me to get something that works first, the act of conversion will probably link the concepts together better in my mind than just reading them, and if I'm converting something that already works, it might well make it easier to find what I've inevitably broken in the process.