Sign in to follow this  
MrJoshL

OpenGL What OpenGL Implementation Do Real Games Use?

Recommended Posts

MrJoshL    810

Since there are many official (and unofficial) desktop OpenGL implementations, which do actual 3D games use? GLUT? FreeGLUT? Mesa3D?

 

Which performs the best?

Share this post


Link to post
Share on other sites
Brother Bob    10344

Neither GLUT nor FreeGLUT are OpenGL implementations. They are windowing layers for OpenGL. Mesa3D is a software implementation that provides limited possibilities for hardware acceleration.

 

If you're on Windows, there's pretty much only one sensible option; you use the default implementation that the operating system provides. The benefit with using that implementation is that each hardware manufacturer provides their own hardware driver for it. Just link the standard opengl32.lib that ships with your compiler to use it.

Share this post


Link to post
Share on other sites
kop0113    2453
Mesa3D is the primary implementation of OpenGL on UNIX and supports several hardware graphics adapters (More than the default implementation in Windows infact).

But, yes it can also be compiled to be software only. Edited by Karsten_

Share this post


Link to post
Share on other sites
L. Spiro    25621
Define what an “actual” 3D game is?
Low-level indie games could use anything.  Many people use wrappers such as SDL or SMFL, but this is mainly just for helping them through the learning process or to get quick but not-so-serious results.
 
Medium-level indie games get closer to the direct API of choice, but it is not consistent enough to say what they “commonly” use, and at this point the target platform becomes much more of a decision-maker.  Of course the mobile industry is booming so it is worth mentioning that for mobile platforms they will all be using raw OpenGL ES 2.0.
But at this level those who are developing for Windows start to lean more towards DirectX and start to grow their own cross-platform engine (assuming you are not interesting in those who are using Unity 3D, Unreal Engine, etc., since you seem to want to get hands-on with your work).
At this level it is not always feasible in terms of skill or finances to make a DirectX port of an existing OpenGL engine, but even those who stick to OpenGL start to tend more towards raw OpenGL (no wrappers, just raw OpenGL).
 
At the AAA end of the scale things become more consistent but there is still no single answer.
By this point OpenGL is rarely used at all except for OpenGL ES 2.0 for mobiles.  Consoles and hand-helds (such as Nintendo 3DS) often provide an OpenGL (or OpenGL ES 2.0) layer but developers avoid this for performance reasons—it is always faster to use the native API.
That carries over to PC, in which the native API is DirectX.  As a result, most “actual” games (you didn’t define it so I can only assume what you meant) for the desktop market use DirectX when possible and OpenGL when no other options are available, and they strictly use raw OpenGL.
Generally the big game developers prefer to avoid OpenGL altogether if possible because it is like developing for Android—there are too many inconsistent implementations across vendors and the drivers are usually shoddy.  What works on one machine is guaranteed not to work on some other machine out there.
Another reason is that with the expectations on today’s graphics, they will require OpenGL 4.3, which requires users of Windows to upgrade manually if they have not already on Windows.
 
Valve is trying to put an end to this situation, and we may well start to see much better drivers (which means performance) and more consistent results in the future.
 
 
OpenGL is worth learning for 2 reasons:
  • There may be a surge in OpenGL games if Valve is successful in its Linux pursuit.
  • The mobile industry is booming and is a great place to start making your own indie games.
But if we assume that by “actual” you meant “AAA”, while there are always exceptions, the main answer is that they are using DirectX 11 first, then DirectX 9, then raw OpenGL if targeting Linux or Macintosh.  Generally speaking.
 
And which implementation?  I think you meant to answer which version.  You don’t get to pick your implementation—that is up to the vendors to implement.
The version you want is up to you.  Lower versions work across more machines, but your graphics will be pretty poor.  If you want compute shaders you will need core version 4.3 or GL_ARB_compute_shader extension.  If you use extensions, prepare for headaches as you implement all the fall-backs for unsupported features.  One more reason why the big guys stay away from OpenGL when possible.
 
 
L. Spiro Edited by L. Spiro

Share this post


Link to post
Share on other sites
TheChubu    9447

As far as I know it is like this:

 

In *nix world you get: Mesa (up to 3.1 spec), proprietary GPU driver's implementation (up to 4.3 for nVidia, 4.2 for AMD) and OSS driver's implementation (i have no idea, enough to play Quake3 based games).

In Windows you get: Microsoft implementation (1.1 spec) and GPU driver's implementation (up to 4.3 for nVidia, 4.2 for AMD).

In OSX you get: Apple's implementation (up to 3.2 for everyone).

 

EDIT: Corrected Mesa's and Apple's spec implementations.

Edited by TheChubu

Share this post


Link to post
Share on other sites
Matias Goldberg    9576

Just to clarify to MrJoshL, we don't really "choose" what implementation to use (unless we want to force software rendering and we explicitly do so)

 

If we want hardware acceleration (aka get access to GPU), we'll just load the OpenGL implementation that is installed in the system (for NVIDIA cards, it's NVIDIA's, for ATI cards, it's ATI's). Since they're implementations, they implement everything they're supposed to, otherwise we would get a crash or a "cannot load routine from library" error and exit.

 

In Windows, the OGL system is called OpenGL "ICD" (Installable Client Driver). When the driver (ati, nvidia, intel, sis, s3, powervr, 3dfx, etc) didn't provide an OpenGL implementation, the application will be routed to a software implementation developed by Microsoft which is very outdated (supports 1.1 spec) so if you're using something higher, your application it will just fail to load (it's as if DirectX wouldn't be installed for Direct3D games)

When the driver did provide the implementation, the ICD will route to the driver's DLL.

 

In Linux, something very similar happens. Most distros ship the Mesa software implementation (which is usually very up to date), and if you install proprietary drivers, the installation messes with distro's folders & symbolic links to use the driver's OGL implementation instead of Mesa's.

Every now and then the installer (either driver's or distro's package manager) may mess the installation and try to mix Mesa dlls with driver's and X11 will crash when launching a GL application (been there....... multiple times). The situation has improved a lot though, in the last couple of years.

 

In Mac, I have no idea how it works, but afaik Apple controls the implementation being shipped.

 

 

You can of course ship your game with Mesa DLLs (since it's the only implementation I'm aware of that could be licensed for that) and always use Mesa's implementation, but almost nobody would like to do that.

 

GLUT & FreeGLUT are layers that simplify the creation of a GL context, and may deal with all this trouble (i.e. not having the right ICD installed, not having required GL version, loading extensions, etc) because this is all messing with DLL & function loading that has nothing to do with rendering triangles to the screen.

Edit: We just want to load the installed implementation and start rendering with hardware acceleration.

Edited by Matias Goldberg

Share this post


Link to post
Share on other sites
mhagain    13430

For the OPs benefit - GLUT, GLFW, etc are nothing more than helper libraries.  Their job is to deal with the painful (and non-cross-platform) task of creating a window, initializing a GL context, getting function pointers, etc.  This next bit is important.  Aside from that, they really have nothing much to do with GL itself; they just wrap the native API calls that would otherwise be used to get things up and running.

 

One major reason why they exist is for e.g. tutorials, sample code, and the like.  The native API code to do all this stuff can be huge, and when you're making a tutorial you really don't want the tutorial-specific code to be swamped by all of this extra stuff.  You want to focus on the lines of code that are relevant to the tutorial.

 

They can also serve another purpose in terms of providing a (at least) reasonably cross-platform way of getting a GL context up.  Some even provide other services (input, sound, etc) which may range in implementation from simplistic to comprehensive, but for the purposes of OpenGL itself, once that context is up, they step back and everything is just native GL code from there.

 

If you want to see how a real-life commercial game handles window and GL context creation, you could do a lot worse than look at the source code for one.

Share this post


Link to post
Share on other sites
TheChubu    9447

In Mac, I have no idea how it works, but afaik Apple controls the implementation being shipped.

I've read Apple provides some lower level API that driver developers code for. So Apple gets a hold of everything down to which gl calls can be made and then gives control to the driver implementation. That's all I know though...

Share this post


Link to post
Share on other sites
MrJoshL    810

Define what an “actual” 3D game is?

Sorry for being ambiguous, but what I meant by an "actual" OpenGL graphics application is something that utilizes the 3D capabilities of OpenGL, and isn't just drawing quads to the screen.

 

So if I had a list of all the things I need, and only the things I need, would this be correct:

1. opengl32.lib OR opengl32.a

2. gl.h

3. glew

4. glext

5. glu

6. wglext

Share this post


Link to post
Share on other sites
Brother Bob    10344
edit: I misread one of your points which made my response quite strange and incorrect. I'm rewriting it from the beginning in case someone read my old one.

Point 1 and 2 are necessary and are shipped with your compiler, or at least installed if you install any OpenGL distribution. Point 3 and 4 are necessary, and point 5 is useless, if you intend to go with the modern approach of OpenGL. Point 6 is necessary for the same reason, and not needed if you're not going with the modern approach, but it's for Windows only. You may need glxext to access the GLX extensions for other platfoms as well. Edited by Brother Bob

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