Jump to content
  • Advertisement
Sign in to follow this  

OpenGL OpenGL for 2D

This topic is 2099 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been learning modern OpenGL for a dew days now and while I can see why it would be used instead of wrappers like SDL2 to render 2D, however are there any precautions to take with the API?


Stuff like, if I don't specify a projection matrix, will that be all? Is using an orthographic view preferred even if I'm only rendering 2D geometry?




Thanks in advance.

Share this post

Link to post
Share on other sites

it's up to you

there aren't that many matrix representations to choose from.

regular ortho from (-x to x, -y to y)

NDC (which means you don't need to specify projection) and goes from (-1 to 1, -1 to 1)

pixel-based ortho (0 to x, 0 to y) where Y goes downwards positively

and various modes of perspective with varying FOV, typically used with 3D, because it looks 3D :)


what you use it entirely up to you, but it's common to use orthographic projections with 2D

keep in mind you still have a Z axis, just there's no way for you or the player to perceive it, unless you use math-magic


SDL is just easier overall. It provides you with all the multimedia aspects you need, including window, input, sound and other things.

If you use OpenGL barebones, you will need to implement many concepts on your own, such as sprites

You'll also need to provide music & sound (typically as streams & samples)

this is nothing too complicated with todays libraries, and if you already have a good grasp of whatever language you are using, you will be ok

your challenges lie in learning OpenGL (which is inadequately documented, and I know OpenGL well), and implementing concepts for your game


If you are using glm:: you already have much of the barebones OpenGL bits covered. Create orthographic projection with whatever coordinate system you desire

The easiest version probably being mapping pixels 1:1

Implement sprites, create a train (sprites following sprites), and have it follow a path

if you can do that, you can create a game no probs :)


Ask if anything

Share this post

Link to post
Share on other sites

I see.


I've been reading arcsynthesis book, so far in ligtining and I have yet to get to textures, But with what limited knowledge I have, I've already manage to make a simple pong, However I did not specify any matrices. I simply hardcoded the vertices and rendered them. I didn't even used orthographic projection.


And you are right, Its simpler to use a wrapper lib, I'm doing this to learn OpenGL.


By the way im guessing that since openGL works with its state, rendering with both SDL and OpenGL will cause problems?

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!