Sign in to follow this  
Tigro

OpenGL A good plan for learning OpenGL

Recommended Posts

Tigro    159

This year at my Uni, we're starting a course of OpenGL. The professor gave us full freedom as to what library we use along with it and what version of OpenGL we use for our projects but the lectures will be centered around FreeGLUT and OpenGL 2.1. Could anybody more accustomed to OpenGL suggest me whether I should stick to such couple or choose something different?

 

I have absolutely no experience with OpenGL, if that matters. Also, as for the language I don't have any specific preferences. If I were to point one or two I like the most, I'd probably say C++ and Python. Of course I tried googling it and asking around but couldn't find anything - I just heard that FreeGLUT is quite basic and there are more convenient and more rewarding library to learn like SFML, GML and SDL. Also, apparently 2.1 is quite old version of OpenGL and the newer ones - based solely on shaders or so I've heard - are the standard which should be used...

 

Being quite confused on the matter, I kindly ask for your opinions. Which version should I learn if that's my start with OpenGL? What library to go with it?

Edited by Tigro

Share this post


Link to post
Share on other sites
TheChubu    9447

The issue here is that while I could recommend you OpenGL 3+, it won't help you with the course since the API changed quite a bit from OpenGL 2 to OpenGL 3 (and above).

 

FreeGLUT isn't an engine, far from it. Its just a library to set up some things, create the window, swap buffers, I think it has some geometry utility functions too, but that's it. No "engine" there.

Share this post


Link to post
Share on other sites
Tigro    159

Sorry, of course I messed up - meant "library" where "engine" stood. Edited just now.

 

Thank you for your post. I guess I wouldn't mind the API changing since the prof clearly stated he isn't interested in the version we're using as long as it solves the problems he'll throw at us and the projects we'll make to pass the course. Having said that, do you think it'd be more rewarding to go with the newer versions?

Share this post


Link to post
Share on other sites
SeanMiddleditch    17565

Thank you for your post. I guess I wouldn't mind the API changing since the prof clearly stated he isn't interested in the version we're using as long as it solves the problems he'll throw at us and the projects we'll make to pass the course. Having said that, do you think it'd be more rewarding to go with the newer versions?


Given that newer versions more closely resemble (or are even outright compatible with) GL|ES, which is the variant of GL used predominantly in the industry, I'd say yes. Even if you are more interested in "full GL" platforms like OSX or Linux, the newer GL is more applicable to what you'll need to know in a real games job.

Share this post


Link to post
Share on other sites
TheChubu    9447

Sorry, of course I messed up - meant "library" where "engine" stood. Edited just now.

 

Thank you for your post. I guess I wouldn't mind the API changing since the prof clearly stated he isn't interested in the version we're using as long as it solves the problems he'll throw at us and the projects we'll make to pass the course. Having said that, do you think it'd be more rewarding to go with the newer versions?

Ohh, I misread, I thought it was "freedom as long as you used OGL 2.1 and FreeGLUT" :D

 

More rewarding? Well yes. 2.x is old, very old. Newer API calls are different, newer GLSL is different, etc.

 

You'll understand quite a bit more of how graphics work going the OpenGL 3+ core profile route. Drawing your first perspective projected triangle will be pretty hard, but think that drawing 500 thousand more after that first one will be much easier.

 

To be fair, your professor might teach a more modern "style" of OpenGL 2.1, with shaders and such, so the differences won't be that great, but he might teach the "fixed function pipeline", and in that case the differences will be pretty big.

 

If you want to get started, I suggest http://www.arcsynthesis.org/gltut/

 

I suggest OpenGL 3 because from what I've seen, OpenGL 4 features get more specific use case oriented, so you will hit walls for things that you might not even know how to do.

Share this post


Link to post
Share on other sites
Tigro    159

Thank you all for your replies. It seems it should be the best to start with the newer instances, then. However, could you please also tell me how do they compare to each other as long as difficulty goes? Is learning the newer versions considerably harder? Less intuitive? Is the whole shaders-only attitude (I heard that's how you code in GL 3+?) harder to grasp in the beginning?

Share this post


Link to post
Share on other sites
mhagain    13430

The shaders-only approach means that you need to write a certain amount of supporting infrastructure, and think a bit more about how you're going to structure your data and how that structure relates to your overall design, than you would with the old fixed pipeline mode.

 

With modern OpenGL you'll be thinking along the lines of:

  • What shaders you need.
  • How to load them.
  • How to set things up for uniforms and attributes.
  • How to manage uniform updates.
  • How to best structure your vertex data.
  • Dividing it up by update frequency.
  • How to keep as much data as possible static by moving calculations to the GPU.
  • How to efficiently manage dynamic buffer object updates.
  • Etc etc etc.

The reality is that this is a lot more work over and above old-school GL1.1, where you only had a single resource type (textures) to worry about.  Using immediate mode and the fixed pipeline is the equivalent of a "sugar rush" with OpenGL - you can get results fast and can become all excited, but ultimately it's bad for you and will make you feel ill.  It's still hard to argue against making a few glBegin/glVertex/glEnd calls as a fast and flexible way of getting something on the screen in a hurry and without needing to plan ahead much (or at all) though.

Share this post


Link to post
Share on other sites
aregee    1072

Thank you all for your replies. It seems it should be the best to start with the newer instances, then. However, could you please also tell me how do they compare to each other as long as difficulty goes? Is learning the newer versions considerably harder? Less intuitive? Is the whole shaders-only attitude (I heard that's how you code in GL 3+?) harder to grasp in the beginning?

 

I would say it is quite a bit harder to begin with, but once everything snaps in place, the reward is so much greater.  Working with shaders is so much more flexible, than using the fixed pipeline, and gives you a powerful tool to do offload your CPU so that most of the work can be done on the GPU.  When you understand how shaders work, you will also see the beauty of it too.

 

3TATUK2 provided lots of good links that would make things a lot easier to learn too.  Open GL Superbible is not a bad book to have either.

 

If I would give you an advice, I would follow what everybody else here is telling you, to go with Open GL Core, forward compatibility.  (On Mac, you have no other choice, if you are using any version higher than 2.1.)

Share this post


Link to post
Share on other sites
timothyjlaird    599

You said any 'version' of OpenGL...does that make OpenGL ES2 an option? If so I would recommend WebGL. Not as full featured as OpenGL but it has been a good learning tool to get me started. Easy to show off your work too since it'll run in most browsers (only exception is IE and Android browsers are hit/miss). I've been able to use Google Drive for hosting which is free (although you have to jump through a few hoops to make it work). All you need for WebGL is coding knowledge of Javascript/GLSLES/OPENGLES API calls and a bare minimum of HTML5.

 

This guy did a really good tutorial job...

http://learningwebgl.com/blog/?page_id=1217

 

Good book and some JS libraries to get you started. His library handles most of the matrix stuff for you...

https://sites.google.com/site/webglbook/

 

Good luck.

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 Zaphyk
      I am developing my engine using the OpenGL 3.3 compatibility profile. It runs as expected on my NVIDIA card and on my Intel Card however when I tried it on an AMD setup it ran 3 times worse than on the other setups. Could this be a AMD driver thing or is this probably a problem with my OGL code? Could a different code standard create such bad performance?
    • By Kjell Andersson
      I'm trying to get some legacy OpenGL code to run with a shader pipeline,
      The legacy code uses glVertexPointer(), glColorPointer(), glNormalPointer() and glTexCoordPointer() to supply the vertex information.
      I know that it should be using setVertexAttribPointer() etc to clearly define the layout but that is not an option right now since the legacy code can't be modified to that extent.
      I've got a version 330 vertex shader to somewhat work:
      #version 330 uniform mat4 osg_ModelViewProjectionMatrix; uniform mat4 osg_ModelViewMatrix; layout(location = 0) in vec4 Vertex; layout(location = 2) in vec4 Normal; // Velocity layout(location = 3) in vec3 TexCoord; // TODO: is this the right layout location? out VertexData { vec4 color; vec3 velocity; float size; } VertexOut; void main(void) { vec4 p0 = Vertex; vec4 p1 = Vertex + vec4(Normal.x, Normal.y, Normal.z, 0.0f); vec3 velocity = (osg_ModelViewProjectionMatrix * p1 - osg_ModelViewProjectionMatrix * p0).xyz; VertexOut.velocity = velocity; VertexOut.size = TexCoord.y; gl_Position = osg_ModelViewMatrix * Vertex; } What works is the Vertex and Normal information that the legacy C++ OpenGL code seem to provide in layout location 0 and 2. This is fine.
      What I'm not getting to work is the TexCoord information that is supplied by a glTexCoordPointer() call in C++.
      Question:
      What layout location is the old standard pipeline using for glTexCoordPointer()? Or is this undefined?
       
      Side note: I'm trying to get an OpenSceneGraph 3.4.0 particle system to use custom vertex, geometry and fragment shaders for rendering the particles.
    • By markshaw001
      Hi i am new to this forum  i wanted to ask for help from all of you i want to generate real time terrain using a 32 bit heightmap i am good at c++ and have started learning Opengl as i am very interested in making landscapes in opengl i have looked around the internet for help about this topic but i am not getting the hang of the concepts and what they are doing can some here suggests me some good resources for making terrain engine please for example like tutorials,books etc so that i can understand the whole concept of terrain generation.
       
    • By KarimIO
      Hey guys. I'm trying to get my application to work on my Nvidia GTX 970 desktop. It currently works on my Intel HD 3000 laptop, but on the desktop, every bind textures specifically from framebuffers, I get half a second of lag. This is done 4 times as I have three RGBA textures and one depth 32F buffer. I tried to use debugging software for the first time - RenderDoc only shows SwapBuffers() and no OGL calls, while Nvidia Nsight crashes upon execution, so neither are helpful. Without binding it runs regularly. This does not happen with non-framebuffer binds.
      GLFramebuffer::GLFramebuffer(FramebufferCreateInfo createInfo) { glGenFramebuffers(1, &fbo); glBindFramebuffer(GL_FRAMEBUFFER, fbo); textures = new GLuint[createInfo.numColorTargets]; glGenTextures(createInfo.numColorTargets, textures); GLenum *DrawBuffers = new GLenum[createInfo.numColorTargets]; for (uint32_t i = 0; i < createInfo.numColorTargets; i++) { glBindTexture(GL_TEXTURE_2D, textures[i]); GLint internalFormat; GLenum format; TranslateFormats(createInfo.colorFormats[i], format, internalFormat); // returns GL_RGBA and GL_RGBA glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, createInfo.width, createInfo.height, 0, format, GL_FLOAT, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); DrawBuffers[i] = GL_COLOR_ATTACHMENT0 + i; glBindTexture(GL_TEXTURE_2D, 0); glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, textures[i], 0); } if (createInfo.depthFormat != FORMAT_DEPTH_NONE) { GLenum depthFormat; switch (createInfo.depthFormat) { case FORMAT_DEPTH_16: depthFormat = GL_DEPTH_COMPONENT16; break; case FORMAT_DEPTH_24: depthFormat = GL_DEPTH_COMPONENT24; break; case FORMAT_DEPTH_32: depthFormat = GL_DEPTH_COMPONENT32; break; case FORMAT_DEPTH_24_STENCIL_8: depthFormat = GL_DEPTH24_STENCIL8; break; case FORMAT_DEPTH_32_STENCIL_8: depthFormat = GL_DEPTH32F_STENCIL8; break; } glGenTextures(1, &depthrenderbuffer); glBindTexture(GL_TEXTURE_2D, depthrenderbuffer); glTexImage2D(GL_TEXTURE_2D, 0, depthFormat, createInfo.width, createInfo.height, 0, GL_DEPTH_COMPONENT, GL_FLOAT, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glBindTexture(GL_TEXTURE_2D, 0); glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, depthrenderbuffer, 0); } if (createInfo.numColorTargets > 0) glDrawBuffers(createInfo.numColorTargets, DrawBuffers); else glDrawBuffer(GL_NONE); if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) std::cout << "Framebuffer Incomplete\n"; glBindFramebuffer(GL_FRAMEBUFFER, 0); width = createInfo.width; height = createInfo.height; } // ... // FBO Creation FramebufferCreateInfo gbufferCI; gbufferCI.colorFormats = gbufferCFs.data(); gbufferCI.depthFormat = FORMAT_DEPTH_32; gbufferCI.numColorTargets = gbufferCFs.size(); gbufferCI.width = engine.settings.resolutionX; gbufferCI.height = engine.settings.resolutionY; gbufferCI.renderPass = nullptr; gbuffer = graphicsWrapper->CreateFramebuffer(gbufferCI); // Bind glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo); // Draw here... // Bind to textures glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, textures[0]); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, textures[1]); glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, textures[2]); glActiveTexture(GL_TEXTURE3); glBindTexture(GL_TEXTURE_2D, depthrenderbuffer); Here is an extract of my code. I can't think of anything else to include. I've really been butting my head into a wall trying to think of a reason but I can think of none and all my research yields nothing. Thanks in advance!
    • By Adrianensis
      Hi everyone, I've shared my 2D Game Engine source code. It's the result of 4 years working on it (and I still continue improving features ) and I want to share with the community. You can see some videos on youtube and some demo gifs on my twitter account.
      This Engine has been developed as End-of-Degree Project and it is coded in Javascript, WebGL and GLSL. The engine is written from scratch.
      This is not a professional engine but it's for learning purposes, so anyone can review the code an learn basis about graphics, physics or game engine architecture. Source code on this GitHub repository.
      I'm available for a good conversation about Game Engine / Graphics Programming
  • Popular Now