Jump to content

  • Log In with Google      Sign In   
  • Create Account


OpenGL for 2D


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Alex720   Members   -  Reputation: 105

Like
0Likes
Like

Posted 17 January 2014 - 02:31 AM

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.



Sponsor:

#2 Kaptein   Prime Members   -  Reputation: 1946

Like
1Likes
Like

Posted 17 January 2014 - 03:30 AM

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



#3 Alex720   Members   -  Reputation: 105

Like
0Likes
Like

Posted 17 January 2014 - 12:25 PM

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?






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS