Jump to content

  • Log In with Google      Sign In   
  • Create Account


mattdesl

Member Since 30 Jul 2012
Offline Last Active Jan 31 2014 01:53 PM

#5015500 Porting to OpenGL

Posted by mattdesl on 29 December 2012 - 12:54 PM

As OpenGL version a suggest 3.3+ because almoste all modern graphic card support it and is very similar to OpenGL 4.0.
As GUI library you can use the Qt library.
As math library you can use Eigen (very fast with extensive use of Expression Template and SIMD istruction (SSE, AVX, Neon)).
But you have to learn very well GLSL language. OpenGL is a C API and is not easy to write OOP code. Take a look to (http://oglplus.org/)

 

GL 3.0+ is still not very widely supported. If you are targeting a casual market, you may want to stick with 2.0 as your target. In this thread it was listed that as few as 51% of Minecraft users supports GL 3.0+. It really comes down to what you need; GL 2 is a fine target for most purposes and can be used in almost the same way as the 3+ programmable pipeline (shaders, custom built-ins, etc). Many drivers will support geometry shaders, FBOs, float textures, etc. through extensions. For example, 93% of drivers support FBO EXT, and it's pretty much a staple in any driver in the last several years. 

 

GL 2.0 and GLSL < 150 is also more compatible with OpenGL ES, so it will prepare you for iOS/Android/WebGL graphics programming.




#5015498 Most efficient way to batch drawings

Posted by mattdesl on 29 December 2012 - 12:49 PM

A VBO should be performant enough for the vast majority of cases. If you need better performance you can pass points and expand them to triangles in a geometry shader.

 

Read up here on some techniques for VBO optimization with sprite batching:

http://www.java-gaming.org/topics/opengl-lightning-fast-managed-vbo-mapping/28209/view.html

 

Since ultimately the performance may vary depending on the driver, the absolute "fastest" solution is to use whatever works best for the driver. For example, in the intro cutscene of your game you might benchmark a few different rendering techniques, and pick whichever runs the fastest.




#5013575 OpenGL ES 2.0 on Android: how to render 500 cubes effectively

Posted by mattdesl on 22 December 2012 - 11:05 PM

Doing the the matrix calculations in software shouldn't be too bad. But if you are CPU limited (maybe the case on Android) then here is an alternative that does the matrix calculation on the GPU:

 

Pass a vec4 Rotation (rotX, rotY, rotZ, angle) to your vertex shader. Then calculate the rotation matrix in your shader:

 

mat4 transform = mat4(1.0); //identity
 
... make rotation matrix from axis and angle ...
 
gl_Position = projection * view * transform * a_position;

 

Theoretically you could put the Position and Normal attributes into a separate static VBO since they are unchanged (and update the view matrix instead). If you fill all your instance data in one go, you could end up with a single draw call per frame.




#5013550 Default color attribute

Posted by mattdesl on 22 December 2012 - 08:09 PM

If you are using version 330 you should be doing some things a bit differently in GLSL:

 

- Use "in" and "out" instead of "varying" and "attribute"

- Use layout(location=X) to specify the index to bind the attribute to

- Use a custom output instead of gl_FragColor

 

Also just so you know, GL 3.0+ is still not very widely supported. If you are targeting a casual market, you may want to stick with 2.0 as your target. In one thread it was listed that as few as 51% of Minecraft users supports GL 3.0+. It really comes down to what you need; GL 2 is a fine target for most purposes and can be used in almost the same way as the 3+ programmable pipeline. Many drivers will support geometry shaders, FBOs, float textures, etc. through extensions.




PARTNERS