Sign in to follow this  
jbizzler

OpenGL OpenGL, Versions, and the Fixed-Function Pipeline

Recommended Posts

I'm just starting to look into the world of OpenGL. A couple of things confuse me. 1. How does the versioning work. It's not like with Direct3D where I download an SDK version. Right now, I'm just using the libraries in the Windows SDK. I know my graphics card supports OpenGL 2.0, but how do I tap into its features and such. Is it just a series of specifications, or do I need a new SDK? 2. I know the Direct3D world is getting rid of the fixed-function pipeline. Is the OpenGL community doing the same? I've noticed in all the tutorials I find, there's the PIXELFORMATDESCRIPTOR, with what looks like a lot of fixed-function settings. Is there a clean way to work around this, or should I just forget all those values? Is there any reason I should use it, and if I shouldn't, what are my guidelines for not doing so. 3. I've noticed the WGL stuff only works in WindowProc. Why is this? Is there a workaround? What if I set up an HDC and HGLRC, make them current, but never use them because my app also supports Direct3D. Would this hurt anything? Thanks for reading my post. I hope you can answer my questions.

Share this post


Link to post
Share on other sites
Quote:
Original post by jbizzler
I'm just starting to look into the world of OpenGL. A couple of things confuse me.

1. How does the versioning work. It's not like with Direct3D where I download an SDK version. Right now, I'm just using the libraries in the Windows SDK. I know my graphics card supports OpenGL 2.0, but how do I tap into its features and such. Is it just a series of specifications, or do I need a new SDK?

2. I know the Direct3D world is getting rid of the fixed-function pipeline. Is the OpenGL community doing the same? I've noticed in all the tutorials I find, there's the PIXELFORMATDESCRIPTOR, with what looks like a lot of fixed-function settings. Is there a clean way to work around this, or should I just forget all those values? Is there any reason I should use it, and if I shouldn't, what are my guidelines for not doing so.

3. I've noticed the WGL stuff only works in WindowProc. Why is this? Is there a workaround? What if I set up an HDC and HGLRC, make them current, but never use them because my app also supports Direct3D. Would this hurt anything?

Thanks for reading my post. I hope you can answer my questions.


1) You can just use extensions.

2) AFAIK OpenGL:ES 2.0 doesn't support the old fixed function pipeline.

Share this post


Link to post
Share on other sites
A little more info on point #2:

Both OpenGL|ES and "Desktop" OpenGL are moving away from the fixed-function pipeline. There are future plans to provide a "lean and mean" version of OpenGL which will basically mirror the hardware implimentation of 3D hardware, with the old fixed-function model moving into an optional software layer. Other examples of things that are to be moved include Quad and Polygon primitives, for instance.


Basically, OpenGL is moving to resemble modern hardware more closely; this is what comprises the "Lean and Mean" version. Legacy features and interfaces will become optional and be implimented in software, such as drivers, which may or may not make use of the programmable pipeline (quads/n-sided primitives could be triangulated using a shader program for instance, but its not required).


Khronos.org is the new home of OpenGL, read the last issue of their Pipeline newsletter for more information.

Share this post


Link to post
Share on other sites
Quote:
Original post by jbizzler
2. I know the Direct3D world is getting rid of the fixed-function pipeline. Is the OpenGL community doing the same? I've noticed in all the tutorials I find, there's the PIXELFORMATDESCRIPTOR, with what looks like a lot of fixed-function settings. Is there a clean way to work around this, or should I just forget all those values? Is there any reason I should use it, and if I shouldn't, what are my guidelines for not doing so.

As people above said, OpenGL is moving away from the fixed function pipeline. However, PIXELFORMATDESCRIPTOR has nothing to do with OpenGL, nor with the fixed function pipeline. It's simply a Win32 structure used to define the pixel format of a rendering window.

Quote:
Original post by jbizzler
3. I've noticed the WGL stuff only works in WindowProc. Why is this?

It isn't. WGL functions work fine outside of a WinProc.

Quote:
Original post by jbizzler
What if I set up an HDC and HGLRC, make them current, but never use them because my app also supports Direct3D. Would this hurt anything?

That would be very bad. Either use OGL, or use D3D. Do not partially initialize one, and then continue with the other. This will seriously mess things up. OGL and D3D are mutually exclusive within the same application. They cannot be used simultaneously.

Share this post


Link to post
Share on other sites
1.) BAD NEWS: Unfortunately, because of the old "spec only" mentality, the current way versioning works in the API is based on the platform's implementation. For Windows, Microsoft has kept it lagging behind at OGL v1.2 for ages. And the only way to access functions of newer versions is through a slightly messy process of identifying whether the extension is supported or not by searching through a large string of available extensions on your platform. Then, manually loading all the functions associated with it via the clunky "wglGetProcAddress()". Before doing that, you'd also have to have downloaded the "glext.h" header file from opengl.org and included it in your project.

GOOD NEWS: The GLEW and GLEE libraries make this pitifully easy to work around. GLEE just loads every available extension, while GLEW lets you pick and choose the extensions you want, and/or the version of OGL you want via macros. Fortunately, the newer, more involved mentality of OpenGL promises to make the process less troublesome in future versions.

2.) The new "lean and mean" version of OGL, code-named Longs Peak, will be removing all the fixed-function capabilities and layering them on top of the core functionality.

As a clarification, the PIXELFORMATDESCRIPTOR, and the wgl* functions are part of how you configure Windows to receive and display drawing commands from OGL. It's somewhat akin to setting up the caps in D3D. Similarly, you're also setting up HDC (device context) and HGLRC (rendering context), which may look a little different, but is the same idea.

For a better idea of all this, check out NeHe's tutorials @ http://nehe.gamedev.net/ .

Share this post


Link to post
Share on other sites
I didn't know OpenGL was so active. These soon-to-be updates sound very exciting. How will they end up on my system, though? Will my graphics card just have a driver update, and I access it through extensions, or will they release their own SDK outside of the Windows SDK?

wglMakeCurrent fails if I do it anywhere outside of WindowProc's WM_CREATE. I don't know why.

If I start programming now, how different will any OpenGL future updates be? I want the cleanest, forward-looking implementation possible. Docs on OpenGL from 2000 don't look much different than they do now.

Okay, so PIXELFORMATDESCRIPTOR is a Windows thing? How does all its info affect OpenGL though? I haven't looked too deep, but why does it have stuff for depth and stencil buffers? Shoudl I just set these to zero and control them myself like I would with Direct3D 10, or do they have to match?

The extension/specs idealogy is going to take some getting used to. I just feel like when I'm reading a tutorial, like I don't know if it's the most modern, politically correct way of doing things.

Share this post


Link to post
Share on other sites
Right now, all updates are in driver revisions. The way forward for the new version is currently unclear, however the hope is that Khronos will release a lib/header set for people to link to for each platform; updates and hardware functionality will come in drivers still; the lib is likely to be a stub which just lets you talk to the hardware.

The new version (Longs Peak or LP) is going to be VERY different from the OpenGL people are used to; gone (or "emulated") are all the 'nice' functions such as glVertex, instead everything is buffers of data; however this is a Good Thing(tm) as it represents how the hardware works better which means better speed [smile]

Share this post


Link to post
Share on other sites
Some info on using GL 2.0 here, how to use it, etc.
http://www.opengl.org/wiki/index.php/Main_Page

Share this post


Link to post
Share on other sites
Okay, so I'm not the only one hoping for a header/static library package. I'd feel much cleaner that way.

Thanks everyone. I feel I have a better understandig of the world now.

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  

  • Forum Statistics

    • Total Topics
      627743
    • Total Posts
      2978894
  • Similar Content

    • By DelicateTreeFrog
      Hello! As an exercise for delving into modern OpenGL, I'm creating a simple .obj renderer. I want to support things like varying degrees of specularity, geometry opacity, things like that, on a per-material basis. Different materials can also have different textures. Basic .obj necessities. I've done this in old school OpenGL, but modern OpenGL has its own thing going on, and I'd like to conform as closely to the standards as possible so as to keep the program running correctly, and I'm hoping to avoid picking up bad habits this early on.
      Reading around on the OpenGL Wiki, one tip in particular really stands out to me on this page:
      For something like a renderer for .obj files, this sort of thing seems almost ideal, but according to the wiki, it's a bad idea. Interesting to note!
      So, here's what the plan is so far as far as loading goes:
      Set up a type for materials so that materials can be created and destroyed. They will contain things like diffuse color, diffuse texture, geometry opacity, and so on, for each material in the .mtl file. Since .obj files are conveniently split up by material, I can load different groups of vertices/normals/UVs and triangles into different blocks of data for different models. When it comes to the rendering, I get a bit lost. I can either:
      Between drawing triangle groups, call glUseProgram to use a different shader for that particular geometry (so a unique shader just for the material that is shared by this triangle group). or
      Between drawing triangle groups, call glUniform a few times to adjust different parameters within the "master shader", such as specularity, diffuse color, and geometry opacity. In both cases, I still have to call glBindTexture between drawing triangle groups in order to bind the diffuse texture used by the material, so there doesn't seem to be a way around having the CPU do *something* during the rendering process instead of letting the GPU do everything all at once.
      The second option here seems less cluttered, however. There are less shaders to keep up with while one "master shader" handles it all. I don't have to duplicate any code or compile multiple shaders. Arguably, I could always have the shader program for each material be embedded in the material itself, and be auto-generated upon loading the material from the .mtl file. But this still leads to constantly calling glUseProgram, much more than is probably necessary in order to properly render the .obj. There seem to be a number of differing opinions on if it's okay to use hundreds of shaders or if it's best to just use tens of shaders.
      So, ultimately, what is the "right" way to do this? Does using a "master shader" (or a few variants of one) bog down the system compared to using hundreds of shader programs each dedicated to their own corresponding materials? Keeping in mind that the "master shaders" would have to track these additional uniforms and potentially have numerous branches of ifs, it may be possible that the ifs will lead to additional and unnecessary processing. But would that more expensive than constantly calling glUseProgram to switch shaders, or storing the shaders to begin with?
      With all these angles to consider, it's difficult to come to a conclusion. Both possible methods work, and both seem rather convenient for their own reasons, but which is the most performant? Please help this beginner/dummy understand. Thank you!
    • By JJCDeveloper
      I want to make professional java 3d game with server program and database,packet handling for multiplayer and client-server communicating,maps rendering,models,and stuffs Which aspect of java can I learn and where can I learn java Lwjgl OpenGL rendering Like minecraft and world of tanks
    • By AyeRonTarpas
      A friend of mine and I are making a 2D game engine as a learning experience and to hopefully build upon the experience in the long run.

      -What I'm using:
          C++;. Since im learning this language while in college and its one of the popular language to make games with why not.     Visual Studios; Im using a windows so yea.     SDL or GLFW; was thinking about SDL since i do some research on it where it is catching my interest but i hear SDL is a huge package compared to GLFW, so i may do GLFW to start with as learning since i may get overwhelmed with SDL.  
      -Questions
      Knowing what we want in the engine what should our main focus be in terms of learning. File managements, with headers, functions ect. How can i properly manage files with out confusing myself and my friend when sharing code. Alternative to Visual studios: My friend has a mac and cant properly use Vis studios, is there another alternative to it?  
    • By ferreiradaselva
      Both functions are available since 3.0, and I'm currently using `glMapBuffer()`, which works fine.
      But, I was wondering if anyone has experienced advantage in using `glMapBufferRange()`, which allows to specify the range of the mapped buffer. Could this be only a safety measure or does it improve performance?
      Note: I'm not asking about glBufferSubData()/glBufferData. Those two are irrelevant in this case.
    • By xhcao
      Before using void glBindImageTexture(    GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format), does need to make sure that texture is completeness. 
  • Popular Now