Jump to content
  • Advertisement
Sign in to follow this  
????????? ????????

OpenGL Graphics Engine (C++)

This topic is 935 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

Hi.

 

I want to develop some sort of simple 2D graphics engine for my android game (using OpenGL ES 2.0, because I really want to learn about shaders). So I've managed how to process OS events, and how to draw a triangle. But where do I go next? Is there some articles or book that could guide me through? I can't say that I have absolutly no idea about what to do, but there is so much new stuff and I'm afraid to get lost in it.

 

I've searched some by myself, but there so much articles that leading to 3D graphics, which is not what I want, and there is even more about it written by Java (I'm looking for C++). I mean, I know, that all the difference between them is model-view matrix, which says, is perspective needed or not. But then there is quite a lot talking about how to render a cone, a cube or whatever 3D thingy. And then how to put the light and many more unnessesary information (for my needs, of course).

 

I want to learn about how to make sprites, how to texture them, optimize, etcetera.

 

In because of that I decided to ask you, guys: where can I find some guides for novice graphic programmer about how to build my own graphics engine?

Edited by Fennec

Share this post


Link to post
Share on other sites
Advertisement

for 2d drawing, theres one thing you need to know:

 

lets say you define your sprite (let it be a quad, made of 4 vertices tri fan) in coordinates that are the % of the screen coord

 

 

so scrW / 2, scrH / 2 is the center on the screen (let z be always 0)

 

now depending on thatyou write es 2.o vp shader like that

 

 

 

attribute vec3 Vpos;
attribute vec2 Vtexcoord;
varying vec2 vert;


void main()
{
vert = Vtexcoord;
gl_Position = vec4(Vpos.xy*2.0-1.0, 0.0, 1.0); //2.0-1.0 it converts screen coords to shader coord, (from -1 to 1)
}

 

uniform sampler2D sprite_tex;
varying vec2 vert;


void main()
{
gl_FragColor = texture2D( sprite_tex, vert );
}
 

 

 
 
 
this sample shader is responsible for drawing a textured sprite 
Edited by WiredCat

Share this post


Link to post
Share on other sites

I suggest to view AndEngine source code on github.

You can viewany other 2D engine.

 

Render is very simple

It's usually list of objects. The object contains some data:

1) Z level index

2) object position x,y

3) size coefficient ( initially you can ignore it)

4) array of vertex

5) array of textures

6) shader index.

7) draw method in class. 

 

camera is installed in Ortho.

 

Just try to write own arcanoid game.

I'm learning when writing something real. But before read 3-5 tutorials, because you need to know how start. 

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!