Sign in to follow this  
TTT_Dutch

OpenGL How did you learn modern OpenGL?

Recommended Posts

TTT_Dutch    240
Ok well I want to hear you story of how you learned modern OpenGL if you learned it at all. Go ahead and post your story! I am excited to get reading!

Share this post


Link to post
Share on other sites
karwosts    840
Just started out the same way as everyone else with my first glBegin triangle, then picked up VBOs for speed, and shaders cause they sounded fun and cool. Really not much more to it than that.

Looking at the big picture the API is not really a big deal. Whether you're using ancient immediate mode opengl, modern DirectX/OpenGL with buffers and shaders, or something else, the underlying graphics theory is all the same. Once you understand the theory behind things, then the API is just a tool for you to use.

"Modern OpenGL" is just shader syntax and API calls, its the theory that's most important to understand.

Share this post


Link to post
Share on other sites
Yours3!f    1532
well, in the beginning of this year I decided to port my "engine" to OGL 3.3 and it didn't go without problems. One thing I really disliked is you can't specify (in SDL 1.2) that you only want to get the OGL 3.3 profile, and because of this I had to use GLEW, and I have to check whether the function I'm using is proper core profile or deprecated. For this I use the official OGL 4.1 reference pages. However now that I have a solid set of functions for rendering I think I can start to use the modern features of OGL 3.3, the new functions, shader stuff etc. Because between 3.3 and 4.1 there is no such huge difference as between 2.1 and 3.3 (you can't use: immediate mode, matrix functions, GLU etc) I think moving to 4.1 will be seamless. I'm really looking forward to using tessellation and compute shaders for advanced effects.

Share this post


Link to post
Share on other sites
V-man    813
[quote name='Yours3!f' timestamp='1305641802' post='4811937']
well, in the beginning of this year I decided to port my "engine" to OGL 3.3 and it didn't go without problems. One thing I really disliked is you can't specify (in SDL 1.2) that you only want to get the OGL 3.3 profile, and because of this I had to use GLEW, and I have to check whether the function I'm using is proper core profile or deprecated. For this I use the official OGL 4.1 reference pages. However now that I have a solid set of functions for rendering I think I can start to use the modern features of OGL 3.3, the new functions, shader stuff etc. Because between 3.3 and 4.1 there is no such huge difference as between 2.1 and 3.3 (you can't use: immediate mode, matrix functions, GLU etc) I think moving to 4.1 will be seamless. I'm really looking forward to using tessellation and compute shaders for advanced effects.
[/quote]

Ya, SDL sucks. Try freeGLUT, although freeGLUT documentation sucks.

Share this post


Link to post
Share on other sites
TTT_Dutch    240
[quote name='karwosts' timestamp='1305610497' post='4811790']
Just started out the same way as everyone else with my first glBegin triangle, then picked up VBOs for speed, and shaders cause they sounded fun and cool. Really not much more to it than that.

Looking at the big picture the API is not really a big deal. Whether you're using ancient immediate mode opengl, modern DirectX/OpenGL with buffers and shaders, or something else, the underlying graphics theory is all the same. Once you understand the theory behind things, then the API is just a tool for you to use.

"Modern OpenGL" is just shader syntax and API calls, its the theory that's most important to understand.
[/quote]

What do you think the best resource for learning the theory is? Preferably not a book on theory as those can be very wordy and time consuming.

Share this post


Link to post
Share on other sites
TTT_Dutch    240
[quote name='Yours3!f' timestamp='1305641802' post='4811937']
well, in the beginning of this year I decided to port my "engine" to OGL 3.3 and it didn't go without problems. One thing I really disliked is you can't specify (in SDL 1.2) that you only want to get the OGL 3.3 profile, and because of this I had to use GLEW, and I have to check whether the function I'm using is proper core profile or deprecated. For this I use the official OGL 4.1 reference pages. However now that I have a solid set of functions for rendering I think I can start to use the modern features of OGL 3.3, the new functions, shader stuff etc. Because between 3.3 and 4.1 there is no such huge difference as between 2.1 and 3.3 (you can't use: immediate mode, matrix functions, GLU etc) I think moving to 4.1 will be seamless. I'm really looking forward to using tessellation and compute shaders for advanced effects.
[/quote]

Well what I am wondering is, how do you move your objects around the scene? This is where I am currently stuck. I would like to use shaders for this but I do not know how. I have seen stuff where they call a "uniform" float in a shader then send the data in the c++ program to it. But I tried that and could compile my shader.

Share this post


Link to post
Share on other sites
jeroenb    282
I use both immediate and VBO's in my 2D engine. The immediate mode I still use for rendering my user interface. It's easier to render rectangles, etc.. I do have plans to port them to VBO's in order to also be able to try out DirectX, but never came to it yet. The VBO's (or VB array's for those ancient systems) together with shaders I use for rendering the tiles and objects.

Transforming directly the OpenGL matrices in order to move the objects is one way, but you can also move objects using the shaders using the uniform data variables of shaders. You then only have to tranform the matrix in the shader. I found [url="http://www.lighthouse3d.com/tutorials/glsl-tutorial/uniform-variables/"]Lighthouse - uniform variables[/url] a good read about them.

Share this post


Link to post
Share on other sites
Yours3!f    1532
[quote]
Well what I am wondering is, how do you move your objects around the scene? This is where I am currently stuck. I would like to use shaders for this but I do not know how. I have seen stuff where they call a "uniform" float in a shader then send the data in the c++ program to it. But I tried that and could compile my shader.
[/quote]

I have made a maths library called libmymath you can find it at libmymath.sf.net, I use it for handling maths (moving around stuff). To add you can find examples besides the libmymath packages.
You can also use GLM, or CML, or other maths library.

Well, the basic idea is to rotate, translate, scale your objects (scene) on the CPU side (with a maths library) and upload the computed matrices to your vertex shader and use it as a uniform.
In immediate mode you'd use glRotate glTranslate glScale etc.
You can find examples in the above mentioned libmymath library.

Share this post


Link to post
Share on other sites
Yours3!f    1532
[quote name='jeroenb' timestamp='1305698281' post='4812269']
but you can also move objects using the shaders using the uniform data variables of shaders. You then only have to tranform the matrix in the shader.
[/quote]

it is NOT a good idea, because moving stuff around in the vertex shader would be a per-vertex operation, resulting in poor vertex processing performance.
see this post:
[url="http://www.gamedev.net/topic/602251-glsl-passing-mat4x4-as-light-position/"]http://www.gamedev.n...light-position/[/url]

Share this post


Link to post
Share on other sites
TTT_Dutch    240
[quote name='Yours3!f' timestamp='1305745679' post='4812680']
[quote name='jeroenb' timestamp='1305698281' post='4812269']
but you can also move objects using the shaders using the uniform data variables of shaders. You then only have to tranform the matrix in the shader.
[/quote]

it is NOT a good idea, because moving stuff around in the vertex shader would be a per-vertex operation, resulting in poor vertex processing performance.
see this post:
[url="http://www.gamedev.net/topic/602251-glsl-passing-mat4x4-as-light-position/"]http://www.gamedev.n...light-position/[/url]
[/quote]

Well what I mean is, I am not going to put all the math into the shader, I will just pass in variables that will adjust it. I have seen something where they calculate an x and y offset then send them both as a vec2 to a shader then the shader just adds them to the vertex vec4.

Share this post


Link to post
Share on other sites
jeroenb    282
[quote name='Yours3!f' timestamp='1305745679' post='4812680']
[quote name='jeroenb' timestamp='1305698281' post='4812269']
but you can also move objects using the shaders using the uniform data variables of shaders. You then only have to tranform the matrix in the shader.
[/quote]

it is NOT a good idea, because moving stuff around in the vertex shader would be a per-vertex operation, resulting in poor vertex processing performance.
see this post:
[url="http://www.gamedev.net/topic/602251-glsl-passing-mat4x4-as-light-position/"]http://www.gamedev.n...light-position/[/url]
[/quote]

In that post he mentions not to do per vertex operations on the CPU, but leave it to the GPU (thus in a shader). I haven't tried, but I do not think that there will be much performance loss when you transform a vertex by adding a pre-computed offset (e.g. by a physics engine) to it in the shader instead of setting the transform using (in OpenGL) glTransform.

Share this post


Link to post
Share on other sites
TTT_Dutch    240
[quote name='jeroenb' timestamp='1305789425' post='4812904']
[quote name='Yours3!f' timestamp='1305745679' post='4812680']
[quote name='jeroenb' timestamp='1305698281' post='4812269']
but you can also move objects using the shaders using the uniform data variables of shaders. You then only have to tranform the matrix in the shader.
[/quote]

it is NOT a good idea, because moving stuff around in the vertex shader would be a per-vertex operation, resulting in poor vertex processing performance.
see this post:
[url="http://www.gamedev.net/topic/602251-glsl-passing-mat4x4-as-light-position/"]http://www.gamedev.n...light-position/[/url]
[/quote]

In that post he mentions not to do per vertex operations on the CPU, but leave it to the GPU (thus in a shader). I haven't tried, but I do not think that there will be much performance loss when you transform a vertex by adding a pre-computed offset (e.g. by a physics engine) to it in the shader instead of setting the transform using (in OpenGL) glTransform.
[/quote]


Well now I just heard about matrices and multiplying them to the verts. It would kinda be like legacy GL but with your own matrices.

Share this post


Link to post
Share on other sites
Yours3!f    1532
[quote]
In that post he mentions not to do per vertex operations on the CPU, but leave it to the GPU (thus in a shader). I haven't tried, but I do not think that there will be much performance loss when you transform a vertex by adding a pre-computed offset (e.g. by a physics engine) to it in the shader instead of setting the transform using (in OpenGL) glTransform.
[/quote]

well, I only meant that it you think in massive scale (like a million polys) then it will probably be bad to do everything per-vertex.

Share this post


Link to post
Share on other sites
Yours3!f    1532
[quote]
Well now I just heard about matrices and multiplying them to the verts. It would kinda be like legacy GL but with your own matrices.
[/quote]

maths libraries are like legacy GL, but they're (supposed to be) faster than the GL functions.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Similar Content

    • By cebugdev
      hi all,

      i am trying to build an OpenGL 2D GUI system, (yeah yeah, i know i should not be re inventing the wheel, but this is for educational and some other purpose only),
      i have built GUI system before using 2D systems such as that of HTML/JS canvas, but in 2D system, i can directly match a mouse coordinates to the actual graphic coordinates with additional computation for screen size/ratio/scale ofcourse.
      now i want to port it to OpenGL, i know that to render a 2D object in OpenGL we specify coordiantes in Clip space or use the orthographic projection, now heres what i need help about.
      1. what is the right way of rendering the GUI? is it thru drawing in clip space or switching to ortho projection?
      2. from screen coordinates (top left is 0,0 nd bottom right is width height), how can i map the mouse coordinates to OpenGL 2D so that mouse events such as button click works? In consideration ofcourse to the current screen/size dimension.
      3. when let say if the screen size/dimension is different, how to handle this? in my previous javascript 2D engine using canvas, i just have my working coordinates and then just perform the bitblk or copying my working canvas to screen canvas and scale the mouse coordinates from there, in OpenGL how to work on a multiple screen sizes (more like an OpenGL ES question).
      lastly, if you guys know any books, resources, links or tutorials that handle or discuss this, i found one with marekknows opengl game engine website but its not free,
      Just let me know. Did not have any luck finding resource in google for writing our own OpenGL GUI framework.
      IF there are no any available online, just let me know, what things do i need to look into for OpenGL and i will study them one by one to make it work.
      thank you, and looking forward to positive replies.
    • By fllwr0491
      I have a few beginner questions about tesselation that I really have no clue.
      The opengl wiki doesn't seem to talk anything about the details.
       
      What is the relationship between TCS layout out and TES layout in?
      How does the tesselator know how control points are organized?
          e.g. If TES input requests triangles, but TCS can output N vertices.
             What happens in this case?
      In this article,
      http://www.informit.com/articles/article.aspx?p=2120983
      the isoline example TCS out=4, but TES in=isoline.
      And gl_TessCoord is only a single one.
      So which ones are the control points?
      How are tesselator building primitives?
    • By Orella
      I've been developing a 2D Engine using SFML + ImGui.
      Here you can see an image
      The editor is rendered using ImGui and the scene window is a sf::RenderTexture where I draw the GameObjects and then is converted to ImGui::Image to render it in the editor.
      Now I need to create a 3D Engine during this year in my Bachelor Degree but using SDL2 + ImGui and I want to recreate what I did with the 2D Engine. 
      I've managed to render the editor like I did in the 2D Engine using this example that comes with ImGui. 
      3D Editor preview
      But I don't know how to create an equivalent of sf::RenderTexture in SDL2, so I can draw the 3D scene there and convert it to ImGui::Image to show it in the editor.
      If you can provide code will be better. And if you want me to provide any specific code tell me.
      Thanks!
    • By Picpenguin
      Hi
      I'm new to learning OpenGL and still learning C. I'm using SDL2, glew, OpenGL 3.3, linmath and stb_image.
      I started following through learnopengl.com and got through it until I had to load models. The problem is, it uses Assimp for loading models. Assimp is C++ and uses things I don't want in my program (boost for example) and C support doesn't seem that good.
      Things like glVertexAttribPointer and shaders are still confusing to me, but I have to start somewhere right?
      I can't seem to find any good loading/rendering tutorials or source code that is simple to use and easy to understand.
      I have tried this for over a week by myself, searching for solutions but so far no luck. With tinyobjloader-c and project that uses it, FantasyGolfSimulator, I was able to actually load the model with plain color (always the same color no matter what I do) on screen and move it around, but cannot figure out how to use textures or use its multiple textures with it.
      I don't ask much: I just want to load models with textures in them, maybe have lights affect them (directional spotlight etc). Also, some models have multiple parts and multiple textures in them, how can I handle those?
      Are there solutions anywhere?
      Thank you for your time. Sorry if this is a bit confusing, English isn't my native language
    • By dpadam450
      FINALLY, upgrading my engine to openGL 4. I was having some trouble so I started with a stripped down application and was wondering if VAO's are required, because I have a sample working, but if I remove the VAO then it doesn't seem to like drawing my triangle.
  • Popular Now