lonewolff
|
|
Posted on: September 29, 2014, 09:57:53 pm |
|
|
"Guest"
|
Hi Guys, OpenGL remains a mystery to me. Information seems to be sparse for good places to begin. The things that confuse that crap out of me - There is no SDK - how the hell do you use it then
- The SDK's out there seem to be wrappers - SDL, GLUT, etc.. So, where do you start? What is the best place to start?
- Cross platformness - what version of OpenGL do you use for this?
Like I said, complete noob when it comes to OpenGL. Where the hell do you start?
|
|
|
Logged
|
|
|
|
TheExDeus
|
|
Reply #1 Posted on: September 30, 2014, 04:59:00 am |
|
|
Joined: Apr 2008
Posts: 1860
|
There is no SDK - how the hell do you use it then SDK comes with Mingw and Windows itself. To have real access to functions you need to use a library like Glew (there are other alternatives too). The SDK's out there seem to be wrappers - SDL, GLUT, etc.. So, where do you start? What is the best place to start? You take one of those wrappers and code. There are many tutorials on the internet, but they are often out of date, as versions below <GL3 were very different from newer ones (ENIGMA supports both). You can looking for some up to date tutorials here: http://www.lighthouse3d.com/ as well as youtube videos: https://www.youtube.com/watch?v=6-9XFm7XAT8#t=2591 https://www.youtube.com/watch?v=IXxc9yNBpuo. There are lot of youtube videos about opengl. Cross platformness - what version of OpenGL do you use for this? Windows, Linux and OSX run everything from GL1 to GL4. If you want embedded devices (phones - IOS, Android or ARM PC's like Raspberry Pi) you need to use OpenGLES (ES - Embedded Systems). GLES2 is about the same as GL3.3, so they are quite compatible with one another and it should be easy to convert. If you code in GL4, then it's totally 100% compatible with the newest GLES version. Where the hell do you start? I started with ENIGMA.
|
|
« Last Edit: September 30, 2014, 05:10:18 am by TheExDeus »
|
Logged
|
|
|
|
Rusky
|
|
Reply #2 Posted on: September 30, 2014, 11:42:59 am |
|
|
Joined: Feb 2008
Posts: 954
|
To add to that, the reason for the wrappers is that every platform has a different way to get an OpenGL context and to actually put things on the screen- Windows uses wgl and Win32 functions, Linux uses glX and X11 functions, etc. GLFW is probably the lightest wrapper there is- it lets you just create a window without dealing with platform-specific APIs. Probably a good place to start if you just want to #include a few headers, make a window, and start making GL calls. You'll also need GLEW whichever window/context library you use, to load GL extensions (which is a euphemism for "almost all the modern API"). But it's pretty simple too- just #include a header and call a function to initialize everything. A couple of other good tutorials: http://www.opengl-tutorial.org/ https://open.gl/
|
|
|
Logged
|
|
|
|
|
Goombert
|
|
Reply #4 Posted on: September 30, 2014, 02:46:56 pm |
|
|
Location: Cappuccino, CA Joined: Jan 2013
Posts: 2993
|
Yes if you want to just start making some small OpenGL applications I suggest you download Code::Blocks which will come with MinGW and isn't very large and you can build some nice little OpenGL apps. However if you want something a little cleaner, Qt Creator has a very nice interface for building OpenGL applications that may be a little easier to learn, and they also include examples. http://programanddesign.com/cpp/qt-opengl-code-example/Also, as an alternative to Ogre3D, which is a huge bitch to compile, I would like to suggest Irrlicht which is extremely light weight and can do quite a bit including Geomipmapped terrain and stuff as well as make 2D games, has a GUI framework and everything and makes use of different drivers for Direct3D9/10/11 and OpenGL1/2/3/4 I honestly can't suggest anything else for a budding game developer wanting to use C++ Irrlicht also likes to play nice with GNU Make. http://irrlicht.sourceforge.net/
|
|
« Last Edit: September 30, 2014, 02:48:53 pm by Robert B Colton »
|
Logged
|
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.
|
|
|
lonewolff
|
|
Reply #5 Posted on: September 30, 2014, 05:03:24 pm |
|
|
"Guest"
|
Thanks for the replies, guys! Awesome stuff. Rob - Funnily enough, I am quite familiar with Ogre3D (and it's compilation problems - lots of them). I actually wrote and Ogre 3D extension for GameMaker (unreleased) - LOL. Some of the screenies in my other thread were using that very extension (Like this). So, there is no real 'consistent' OpenGL API as such then? Is it pretty much a case of pick an API like Ogre, SDL, etc and learn their wrapper functions? Fine by me if that is the case. If that does happen to be the case then I allready know OpenGL - LOL.
|
|
|
Logged
|
|
|
|
|
|
|
Goombert
|
|
Reply #9 Posted on: October 01, 2014, 03:19:50 am |
|
|
Location: Cappuccino, CA Joined: Jan 2013
Posts: 2993
|
Yes Harri is right, and further anybody that can initialize Direct3D on a Win32 window could and should be able to easily write an OpenGL application without difficulty.
|
|
|
Logged
|
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.
|
|
|
lonewolff
|
|
Reply #10 Posted on: October 01, 2014, 03:33:50 am |
|
|
"Guest"
|
The API is the Khronos Group's published spec. There are thousands of built-in functions, which are then used to do what you want. As Rusky said, you only need special functions for context creation and some other few things. Like in fixed function pipeline you have this:
glBegin(gl_triangleList); glVertex(10,10); glVertex(50,10); glVertex(10,50); glEnd(); This will draw a triangle. Those functions are defined by OpenGL spec, and implement in all OS's. You don't need Ogre or SDL anything else to use them. ENIGMA for example doesn't use any of the wrappers. We code OpenGL from ground up and only use GLEW for extensions.
Thanks guys! And geez, that code snippet looks simple as anything. Is it really that easy to render a triangle in OpenGL? If so, where has OpenGL been all my life?
|
|
|
Logged
|
|
|
|
TheExDeus
|
|
Reply #11 Posted on: October 01, 2014, 04:28:09 am |
|
|
Joined: Apr 2008
Posts: 1860
|
That code is what is called "Immediate mode". It's <GL3 and is now deprecated. Considered slow and ugly. But it's simple. Newer GL (like our GL3.3 implementation in ENIGMA) uses Vertex Buffer Object's (VBO) and Vertex Array Objects (VAO), which makes the whole thing a lot more complicated and you need a lot more code to actually draw something. The triangle example would be something like this:
float triangle[] = {10.,10., 50.,10., 10.,50.}; GLuint VBO, VAO; glGenBuffers( 1, &VBO); glGenVertexArrays(1, &VAO);
//Bind the VBO and transfer our triangle data from RAM to VRAM glBindBuffer( GL_ARRAY_BUFFER, VBO); glBufferData( GL_ARRAY_BUFFER, sizeof(triangle), triangle, GL_STATIC_DRAW);
//This is just required so the video card knows how to interpret the data glBindVertexArray(VAO); glEnableVertexAttribArray(shader_att_vertex); glVertexAttribPointer(shader_att_vertex, 2, GL_FLOAT, GL_FALSE, 2, 0);
//Actually draw the triangle glDrawElements(GL_TRIANGLES, 6, GL_FLOAT, 0);
//Cleanup glBindBuffer( GL_ARRAY_BUFFER, 0); glBindVertexArray(0); glDeleteBuffers(1, &VBO); glDeleteVertexArrays(1, &VAO);
This is all required to draw a single triangle in GL3.3 Core Context. Additionally you have to write a pixel and vertex shader (to draw a simple triangle, they would be about 5 lines each) and add additional code to use it (like I didn't write where shader_att_vertex is from). So the newer one is a lot more complicated and usually harder to learn, but it's a lot faster. Especially if written correctly. And it allows a lot more possibilities.
|
|
« Last Edit: October 01, 2014, 04:29:51 am by TheExDeus »
|
Logged
|
|
|
|
Goombert
|
|
Reply #12 Posted on: October 01, 2014, 04:31:46 am |
|
|
Location: Cappuccino, CA Joined: Jan 2013
Posts: 2993
|
Actually Harri, I don't think you have to use VBO's. I would like you to find out, since you have the means of doing so I don't actually know how you find out which functions are which core, if vertex arrays like we use in GL1 for models can be used in newer GL cores. Do you know if they can or not? I think they can because they can also interface with vertex attribute arrays and shaders. They are immensely easier to use than VBO's. Edit: From what I gather vertex array's are usable in GLES. https://www.khronos.org/registry/gles/extensions/OES/OES_vertex_array_object.txt
|
|
|
Logged
|
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.
|
|
|
|
TheExDeus
|
|
Reply #14 Posted on: October 01, 2014, 05:57:16 am |
|
|
Joined: Apr 2008
Posts: 1860
|
Actually Harri, I don't think you have to use VBO's. I would like you to find out, since you have the means of doing so I don't actually know how you find out which functions are which core, if vertex arrays like we use in GL1 for models can be used in newer GL cores. Do you know if they can or not? I think they can because they can also interface with vertex attribute arrays and shaders. They are immensely easier to use than VBO's. They are not available in GL3. Only VBO's are supported. There is no glEnableClientState or glVertexPointer functions in GL3.3. There are several ways to see what is deprecated and what isn't. One is during runtime by setting the core context. It's done in my GL3.3Fix branch, where it actually trows an error if something deprecated is called. Second way is to search for the function in the docs, both official https://www.opengl.org/sdk/docs/man3/ or this http://docs.gl/gl3/glEnableClientState . The second site is awesome because you can choose the version of GL in the left panel, and then see what functions are unavailable (grayed out). Edit: From what I gather vertex array's are usable in GLES. https://www.khronos.org/registry/gles/extensions/OES/OES_vertex_array_object.txt Vertex array objects (VAO) is not the same as a vertex array (GL_VERTEX_ARRAY). VAO don't hold vertex data, it holds the description about that data. It's actually required in GL3.3 Core. That is why it didn't render anything previously on my GL3.3 branch, because we didn't create a VAO for the mesh.
|
|
« Last Edit: October 01, 2014, 06:04:08 am by TheExDeus »
|
Logged
|
|
|
|
|