• Advertisement
Sign in to follow this  

OpenGL Starting with OpenGL

This topic is 4609 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello everyone, I'm fairly new to using OpenGL (and game development in general, actually), and I have a few questios. I know this post would be better off in the Beginners forum, but I feel that more experienced people will be able to answer fastrer :D Anyway, here's my questions list: 1) In the OpenGL forum FAQ, there are links given to the BlueBook, and the RedBook. The BlueBook link doesn't work anymore, and the RedBook links to a manual for version 1.0 ...so, does anyone know where I could find updated versions of these two books? 2) I'm actually trying to develop a game with graphics close to commercial quality, so...I think i should use something past OpenGL 1.1 (I'm developing on a Windows XP). What would be a good manual (besides the one provided in the "Game Programming: Tricks of teh Trade" book)? 3) Are there any benefits in developing OpenGL games on a non-Windows platform? Like, getting the latest libraries or something? 4) Does anyone have a sample code to get me started with using OpenGL? (Yeah, I know there's NeHe's tutorials, but I think they're a bit outdated....but then again, I'm fairly new to this, so I just might be talking out of my ass here) Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by celestis_genesis
Hello everyone,

I'm fairly new to using OpenGL (and game development in general, actually), and I have a few questios. I know this post would be better off in the Beginners forum, but I feel that more experienced people will be able to answer fastrer :D

Posting questions in the wrong forum for your own convenience will make people ignore and/or flame you. Fair warning. I won't move your post this time, since a couple of these questions aren't quite "For Beginners"-level.
Quote:

1) In the OpenGL forum FAQ, there are links given to the BlueBook, and the RedBook. The BlueBook link doesn't work anymore, and the RedBook links to a manual for version 1.0 ...so, does anyone know where I could find updated versions of these two books?

They are, as their names imply, books. Try your local Barnes & Noble.
Quote:

2) I'm actually trying to develop a game with graphics close to commercial quality, so...I think i should use something past OpenGL 1.1 (I'm developing on a Windows XP). What would be a good manual (besides the one provided in the "Game Programming: Tricks of teh Trade" book)?

You should try clicking that "Books" link up at the top of the page.
Quote:

3) Are there any benefits in developing OpenGL games on a non-Windows platform? Like, getting the latest libraries or something?

Not particularly. Some graphics card manufacturers, such as SGI, release extensions that are not in the main core, but since they aren't widely available on consumer machines, they aren't particularly useful.
Quote:

4) Does anyone have a sample code to get me started with using OpenGL? (Yeah, I know there's NeHe's tutorials, but I think they're a bit outdated....but then again, I'm fairly new to this, so I just might be talking out of my ass here)

You're talking out of your ass. OpenGL is a much more stable API than Direct3D; the tutorials most likely will not be outdated.

Share this post


Link to post
Share on other sites
1) I haven't updated my bookmarks too recently, but both the Blue and Red books are in the 4th edition for OpenGL version 1.4, in case you didn't already know. A google search usually comes up with a few free online copies.

2) I'm not current on OpenGL books. I've been doing a lot more DirectX lately myself. I do know that Tricks of the trade is pretty good. Maybe someone else can recommend some other material for reference.

3) Haven't done much cross-platform programming, and I'm not sure I understand the question. Sorry.

4) Actually, NeHe would still be a great way to start, and even if you get through it quickly it's a good way to refine the basics. No matter how outdated a spinning triangle seems compared to the latest graphics engines, you always have to start with a blank window.

Good luck. I wish I could give you more information.

Share this post


Link to post
Share on other sites
Quote:
Original post by celestis_genesis
Hello everyone,


Hi.

Quote:

1) In the OpenGL forum FAQ, there are links given to the BlueBook, and the RedBook. The BlueBook link doesn't work anymore, and the RedBook links to a manual for version 1.0 ...so, does anyone know where I could find updated versions of these two books?


A google query would have solved this. Here are some links that I found:
http://www.opengl.org/documentation/blue_book_1.0/
http://www.amazon.com/exec/obidos/tg/detail/-/0201657651/ref=pd_sxp_f/103-0550504-2139847?v=glance&s=books

I don't own the blue book, so I can't comment on it. However, the red book is a very good resource if you're using OpenGL.
There is yet another book, The OpenGL Shading Language. It is a very thorough reference for glsl. I would not recommend this book until you are very familiar with OpenGL.

Quote:

2) I'm actually trying to develop a game with graphics close to commercial quality, so...I think i should use something past OpenGL 1.1 (I'm developing on a Windows XP). What would be a good manual (besides the one provided in the "Game Programming: Tricks of teh Trade" book)?


The quality of the graphics do not essentially depend on which version of OpenGL you are using. In my opinion, it's got more to do with the quality of the game content.
Newer versions of OpenGL allow for a lot of functionality which can prove useful. You can still access this functionality through OpenGL extensions.

Quote:

3) Are there any benefits in developing OpenGL games on a non-Windows platform? Like, getting the latest libraries or something?


Not quite. You would probably have to access new functionality through extensions anyway.

Quote:

4) Does anyone have a sample code to get me started with using OpenGL? (Yeah, I know there's NeHe's tutorials, but I think they're a bit outdated....but then again, I'm fairly new to this, so I just might be talking out of my ass here)


I learned OpenGL from NeHe. It is a very good resource for beginning OpenGL.
Also, I recommend the OpenGL Programming Guide ("the red book").

Share this post


Link to post
Share on other sites
Quote:
I'm fairly new to using OpenGL (and game development in general, actually


Quote:
I'm actually trying to develop a game with graphics close to commercial quality, so...


ERROR
ERROR

Share this post


Link to post
Share on other sites
Your post sound like you want to start programming OpenGL without even learning the basics, just go with the advanced stuff.
That definitelly won't happen :-) A lot of people think they want to skip the basic stuff and just work on a commercial game product (including me when I was learning OpenGL :-). But take my suggestion and start with the basics at NeHe.
The tutorials are NOT outdated, as said earlier, OpenGL is a stable API. Furthermore, you won't have anything other than OpenGL 1.1 on a normal Windows PC - even with Windows XP. It's the Gfx Drivers, that add several extensions to the standard 1.1 API but read more about this on NeHe ;-) But keep in mind, that OpenGL is all based on extensions, while DirectX usually is available in a whole new release as soon as important features are added to new Hardware.

Starting with OpenGL is a good choice, though. I find the OpenGL API being more straight forward than Direct3D, though, when you're familiar with OpenGL it's not so hard anymore, to switch to Direct3D and vice versa, though the other way round might be more difficult for a beginner...

As said earlier in this thread, the reference books are available in newer versions. You might want to buy them and hold a "real copy" in your hands or just download them over the net. They are free and available from various sources: Use google on this!

So now: Go to NeHe's page and start off, putting your idea into code ;-)

Hope this helps...
ZMaster

EDIT: Sorry forgot... Here's something to read for you:
Ultimate Gameprogramming
Gametutorials

Share this post


Link to post
Share on other sites
NeHe definatly. Just start on the easy tutorials and work upwards. Some good sites are also:

Game Tutorials
(Unfortunatly it was a lot better when the tuts were free)

Ultimate Game Programming

EDIT: Make sure you are up to scratch with C++, otherwise you will be in a whole new world of s**t.

Quote:
Original post by ZMaster

EDIT: Sorry forgot... Here's something to read for you:
Ultimate Gameprogramming
Gametutorials


Bumgrapes.

Share this post


Link to post
Share on other sites
hey i got some tutorials for people new w/opengl. click on my sig. :)

Share this post


Link to post
Share on other sites
How about starting OpenGL 1.5 + GLSL on Linux and Windows? I'm especially interested in Linux.

Where can I find OGL headers and OGL precompiled libraries, samples, tutorials, etc. Also I have ATI card.


Share this post


Link to post
Share on other sites
Quote:
Original post by NamelessTwo
I'm especially interested in Linux.

Where can I find OGL headers and OGL precompiled libraries, samples, tutorials, etc. Also I have ATI card.


It would depend on your distribution. Usually the OpenGL and GLU headers are installed in /usr/include/GL. If you're running X, then it's likely that they're installed. In Debian, for instance, the headers are included in the xlibmesa-gl-dev and xlibmesa-glu-dev packages.
Otherwise, the ATI drivers should install the necessary libraries and headers.

Share this post


Link to post
Share on other sites
Quote:
Original post by James Trotter
It would depend on your distribution. Usually the OpenGL and GLU headers are installed in /usr/include/GL. If you're running X, then it's likely that they're installed. In Debian, for instance, the headers are included in the xlibmesa-gl-dev and xlibmesa-glu-dev packages.
Otherwise, the ATI drivers should install the necessary libraries and headers.


About the header files: I don't think they are part of the driver. As with windows, the drivers only overwrite your gl libraries. This can be especially annoying on linux distributions which come with bad headers (such as my old Red Hat 7.2 distribution). You can solve that by overwriting the gl headers with the MESA headers, or by using GLEW. I would recommend GLEW, as it is a perfect tool for creating platform-independant OpenGL programs (especially if you use the latest extensions).

Tom

Share this post


Link to post
Share on other sites
As far as I know, GLEW doesn't actually let you write platform-independent OpenGL programs in itself. It allows for cross-platform means of using OpenGL extensions. You might have meant GLFW, which is a framework for writing cross-platform OpenGL applications. (However, if you're new to OpenGL I'd recommend you use GLUT instead. This is what they use for the code examples in the red book.)

Share this post


Link to post
Share on other sites
Quote:
Original post by James Trotter
As far as I know, GLEW doesn't actually let you write platform-independent OpenGL programs in itself. It allows for cross-platform means of using OpenGL extensions. You might have meant GLFW, which is a framework for writing cross-platform OpenGL applications. (However, if you're new to OpenGL I'd recommend you use GLUT instead. This is what they use for the code examples in the red book.)


That is correct. My wording was rather ackward. What I meant to say, was that it allows platform independant access to the GL library and extensions. Of course, for os-dependant things like creating windows, you could use glut.

Tom

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by James Trotter
Quote:
Original post by NamelessTwo
I'm especially interested in Linux.

Where can I find OGL headers and OGL precompiled libraries, samples, tutorials, etc. Also I have ATI card.


It would depend on your distribution. Usually the OpenGL and GLU headers are installed in /usr/include/GL. If you're running X, then it's likely that they're installed. In Debian, for instance, the headers are included in the xlibmesa-gl-dev and xlibmesa-glu-dev packages.
Otherwise, the ATI drivers should install the necessary libraries and headers.


I use Ubuntu and it comes with Mesa 5 which does not support OGL 1.5 but I intend to compile Mesa 6. Is it possible to install Mesa locally just for the program I develop or I have to replace the original Mesa? I want to do this so that the end user does not need to update his Mesa.

What is GLEW? Does it replace gl.h and glu.h and the appropriate libraries?

Where can I find OpenGL 1.5 headers for Windows?

Share this post


Link to post
Share on other sites
Quote:
Original post by James Trotter
As far as I know, GLEW doesn't actually let you write platform-independent OpenGL programs in itself. It allows for cross-platform means of using OpenGL extensions. You might have meant GLFW, which is a framework for writing cross-platform OpenGL applications. (However, if you're new to OpenGL I'd recommend you use GLUT instead. This is what they use for the code examples in the red book.)


For better crossplatform compatability I'll use SDL - OpenGL, SDL, GLSL and standard C++ libraries only.

I have lots of books and tutorials about OpenGL but none explain how to use the latest versions and GLSL on ATI hardware. That's why I'm asking here.

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
I use Ubuntu and it comes with Mesa 5 which does not support OGL 1.5 but I intend to compile Mesa 6. Is it possible to install Mesa locally just for the program I develop or I have to replace the original Mesa? I want to do this so that the end user does not need to update his Mesa.


I use Ubuntu too. [smile]
If the mesa library uses shared linking, then it has to be available on the system running your programs. If it is statically linked, however, then all the symbols should be included in the executable you compile on your system.

Quote:

What is GLEW? Does it replace gl.h and glu.h and the appropriate libraries?


Not exactly. It does not replace gl.h and glu.h, but it does provide definitions and entry points for functions defined in the OpenGL specification not otherwise available. In other words, it allows you to use OpenGL 2.0. But, of course, only if your graphics card supports the necessary extensions.

Quote:

Where can I find OpenGL 1.5 headers for Windows?


GLEW is cross-platform, and works just as well in Windows as in Linux. (I've tried them both myself!)

Quote:
Original post by NamelessTwo
For better crossplatform compatability I'll use SDL - OpenGL, SDL, GLSL and standard C++ libraries only.


SDL also allows you to create cross-platform OpenGL applications. Though, personally I prefer GLFW or glut. SDL is really more than just a windowing framework, and provides alot of unnecessary functionality for my needs. Although it certainly is cool that it provides you with functionality for audio, CD-rom, timers, threads, and probably more.

Quote:

I have lots of books and tutorials about OpenGL but none explain how to use the latest versions and GLSL on ATI hardware. That's why I'm asking here.


I'm pretty sure you need to access glsl functionality through extensions, (ARB_shading_language_100, ARB_shader_objects).
That at least goes for OpenGL's interface to glsl programs. You can write glsl code independently, as it's a language of its own.

[Edited by - James Trotter on July 6, 2005 2:01:22 PM]

Share this post


Link to post
Share on other sites
Thank you for your extensive reply!

Quote:

Not exactly. It does not replace gl.h and glu.h, but it does provide definitions and entry points for functions defined in the OpenGL specification not otherwise available. In other words, it allows you to use OpenGL 2.0. But, of course, only if your graphics card supports the necessary extensions.


So I've found this tutorial:
http://www.lighthouse3d.com/opengl/glsl/index.php?ogloverview
It describes how to setup OpenGL with GLEW and glut.

I think that current ATI drivers support OpenGL 1.5 only. Probably both on Windows and Linux.
Would I be able to use OpenGL 1.5 functionality with GLEW? I've also checked GLEE but I don't see the difference.

In case I have OpenGL 2.0 compatible driver and MESA 5.0 (which supports only... I don't know what version but it isn't greater than 1.4 for sure), could I use OpenGL 2.0 functionality with GLEW?

Are there any other GLEW tutorials for beginners?

Quote:

Quote:

I have lots of books and tutorials about OpenGL but none explain how to use the latest versions and GLSL on ATI hardware. That's why I'm asking here.


I'm pretty sure you need to access glsl functionality through extensions, (ARB_shading_language_100, ARB_shader_objects).
That at least goes for OpenGL's interface to glsl programs. You can write glsl code independently, as it's a language of its own.



Yes that is true.

Share this post


Link to post
Share on other sites
Quote:
Original post by NamelessTwo
Thank you for your extensive reply!

I think that current ATI drivers support OpenGL 1.5 only. Probably both on Windows and Linux.
Would I be able to use OpenGL 1.5 functionality with GLEW? I've also checked GLEE but I don't see the difference.


I have never used GLEE, so I'm not certain. Though, I do think it generates definitions and entry points for OpenGL extensions automatically from the their specifications, like GLEW does. Someone here should be able to verify/correct this.

Quote:

In case I have OpenGL 2.0 compatible driver and MESA 5.0 (which supports only... I don't know what version but it isn't greater than 1.4 for sure), could I use OpenGL 2.0 functionality with GLEW?


I hope you realize that mesa does not benefit from hardware acceleration. If your drivers support it you should be able to use OpenGL 2.0 functionality. To check this, do something like:


if (GLEW_VERSION_2_0) {
// Use OpenGL 2.0 code...
} else if (GLEW_ARB_shading_language_100) {
// We can't use OpenGL 2.0, so use the ARB_shading_language_100 extension instead...
}


Quote:

Are there any other GLEW tutorials for beginners?


GLEW is extremely simple to use. All you should need to know is explained under GLEW basic usage.

Share this post


Link to post
Share on other sites
Quote:

I hope you realize that mesa does not benefit from hardware acceleration. If your drivers support it you should be able to use OpenGL 2.0 functionality. To check this, do something like:


I mean the OpenGL headers in Ubuntu are those from the MESA library.

Quote:


GLEW is extremely simple to use. All you should need to know is explained under GLEW basic usage.


Sometimes I'm blind and stupid. I've been reading this page and I haven't seen this link! Horrible!

Thank you you've helped me a lot. I'm going to try it soon. I'll do a little bit more research & reading before I start. I think you've cleared alot of things for me.

Share this post


Link to post
Share on other sites
Quote:
Original post by NamelessTwo
Quote:

I hope you realize that mesa does not benefit from hardware acceleration. If your drivers support it you should be able to use OpenGL 2.0 functionality. To check this, do something like:


I mean the OpenGL headers in Ubuntu are those from the MESA library.



Ah, yes. I'm sorry, I misunderstood. You can actually use GLEW to access the functionality of OpenGL 2.0 (or any other version for that matter), regardless of the OpenGL headers installed on the system. I'm pretty certain that when you include glew.h. it takes care of defining all the things which are usually in gl.h. You don't actually include gl.h at all.

Quote:

Thank you you've helped me a lot. I'm going to try it soon. I'll do a little bit more research & reading before I start. I think you've cleared alot of things for me.


I'm glad I could help. [smile]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
  • Advertisement
  • Popular Tags

  • Advertisement
  • Popular Now

  • Similar Content

    • By LifeArtist
      Good Evening,
      I want to make a 2D game which involves displaying some debug information. Especially for collision, enemy sights and so on ...
      First of I was thinking about all those shapes which I need will need for debugging purposes: circles, rectangles, lines, polygons.
      I am really stucked right now because of the fundamental question:
      Where do I store my vertices positions for each line (object)? Currently I am not using a model matrix because I am using orthographic projection and set the final position within the VBO. That means that if I add a new line I would have to expand the "points" array and re-upload (recall glBufferData) it every time. The other method would be to use a model matrix and a fixed vbo for a line but it would be also messy to exactly create a line from (0,0) to (100,20) calculating the rotation and scale to make it fit.
      If I proceed with option 1 "updating the array each frame" I was thinking of having 4 draw calls every frame for the lines vao, polygons vao and so on. 
      In addition to that I am planning to use some sort of ECS based architecture. So the other question would be:
      Should I treat those debug objects as entities/components?
      For me it would make sense to treat them as entities but that's creates a new issue with the previous array approach because it would have for example a transform and render component. A special render component for debug objects (no texture etc) ... For me the transform component is also just a matrix but how would I then define a line?
      Treating them as components would'nt be a good idea in my eyes because then I would always need an entity. Well entity is just an id !? So maybe its a component?
      Regards,
      LifeArtist
    • By QQemka
      Hello. I am coding a small thingy in my spare time. All i want to achieve is to load a heightmap (as the lowest possible walking terrain), some static meshes (elements of the environment) and a dynamic character (meaning i can move, collide with heightmap/static meshes and hold a varying item in a hand ). Got a bunch of questions, or rather problems i can't find solution to myself. Nearly all are deal with graphics/gpu, not the coding part. My c++ is on high enough level.
      Let's go:
      Heightmap - i obviously want it to be textured, size is hardcoded to 256x256 squares. I can't have one huge texture stretched over entire terrain cause every pixel would be enormous. Thats why i decided to use 2 specified textures. First will be a tileset consisting of 16 square tiles (u v range from 0 to 0.25 for first tile and so on) and second a 256x256 buffer with 0-15 value representing index of the tile from tileset for every heigtmap square. Problem is, how do i blend the edges nicely and make some computationally cheap changes so its not obvious there are only 16 tiles? Is it possible to generate such terrain with some existing program?
      Collisions - i want to use bounding sphere and aabb. But should i store them for a model or entity instance? Meaning i have 20 same trees spawned using the same tree model, but every entity got its own transformation (position, scale etc). Storing collision component per instance grats faster access + is precalculated and transformed (takes additional memory, but who cares?), so i stick with this, right? What should i do if object is dynamically rotated? The aabb is no longer aligned and calculating per vertex min/max everytime object rotates/scales is pretty expensive, right?
      Drawing aabb - problem similar to above (storing aabb data per instance or model). This time in my opinion per model is enough since every instance also does not have own vertex buffer but uses the shared one (so 20 trees share reference to one tree model). So rendering aabb is about taking the model's aabb, transforming with instance matrix and voila. What about aabb vertex buffer (this is more of a cosmetic question, just curious, bumped onto it in time of writing this). Is it better to make it as 8 points and index buffer (12 lines), or only 2 vertices with min/max x/y/z and having the shaders dynamically generate 6 other vertices and draw the box? Or maybe there should be just ONE 1x1x1 cube box template moved/scaled per entity?
      What if one model got a diffuse texture and a normal map, and other has only diffuse? Should i pass some bool flag to shader with that info, or just assume that my game supports only diffuse maps without fancy stuff?
      There were several more but i forgot/solved them at time of writing
      Thanks in advance
    • By RenanRR
      Hi All,
      I'm reading the tutorials from learnOpengl site (nice site) and I'm having a question on the camera (https://learnopengl.com/Getting-started/Camera).
      I always saw the camera being manipulated with the lookat, but in tutorial I saw the camera being changed through the MVP arrays, which do not seem to be camera, but rather the scene that changes:
      Vertex Shader:
      #version 330 core layout (location = 0) in vec3 aPos; layout (location = 1) in vec2 aTexCoord; out vec2 TexCoord; uniform mat4 model; uniform mat4 view; uniform mat4 projection; void main() { gl_Position = projection * view * model * vec4(aPos, 1.0f); TexCoord = vec2(aTexCoord.x, aTexCoord.y); } then, the matrix manipulated:
      ..... glm::mat4 projection = glm::perspective(glm::radians(fov), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f); ourShader.setMat4("projection", projection); .... glm::mat4 view = glm::lookAt(cameraPos, cameraPos + cameraFront, cameraUp); ourShader.setMat4("view", view); .... model = glm::rotate(model, glm::radians(angle), glm::vec3(1.0f, 0.3f, 0.5f)); ourShader.setMat4("model", model);  
      So, some doubts:
      - Why use it like that?
      - Is it okay to manipulate the camera that way?
      -in this way, are not the vertex's positions that changes instead of the camera?
      - I need to pass MVP to all shaders of object in my scenes ?
       
      What it seems, is that the camera stands still and the scenery that changes...
      it's right?
       
       
      Thank you
       
    • By dpadam450
      Sampling a floating point texture where the alpha channel holds 4-bytes of packed data into the float. I don't know how to cast the raw memory to treat it as an integer so I can perform bit-shifting operations.

      int rgbValue = int(textureSample.w);//4 bytes of data packed as color
      // algorithm might not be correct and endianness might need switching.
      vec3 extractedData = vec3(  rgbValue & 0xFF000000,  (rgbValue << 8) & 0xFF000000, (rgbValue << 16) & 0xFF000000);
      extractedData /= 255.0f;
    • By Devashish Khandelwal
      While writing a simple renderer using OpenGL, I faced an issue with the glGetUniformLocation function. For some reason, the location is coming to be -1.
      Anyone has any idea .. what should I do?
  • Advertisement