Forgot your password?
typodupeerror
Education Programming Python Linux

Recommendations For C++/OpenGL Linux Tutorials? 117

Posted by timothy
from the no-you-guide-me dept.
QuaveringGrape writes "After a few years of Python I've recently been trying to expand my programming knowledge into the realm of compiled languages. I started with C, then switched over to C++. A friend and longtime OpenGL programmer told me about NeHe's tutorials as a good step after the command-line programs started to get old, but there's a problem: all the tutorials are very Windows-based, and I've been using Linux as my single platform for a while now. I'm looking for suggestions for tutorials that are easy to learn, without being dumbed down or geared towards non-programmers."
This discussion has been archived. No new comments can be posted.

Recommendations For C++/OpenGL Linux Tutorials?

Comments Filter:
  • NeHe's good! (Score:3, Informative)

    by Xetrov (267777) on Tuesday March 23, 2010 @08:34AM (#31581884)

    Actually at the bottom of every article are downloads for a LOT of other platforms. Read the tutorial on the web, then look at the code for your platform, should be plenty of comments.

    I learned the same way :)

    • I'll also vouch for this. Having just finished (today actually) Advanced Computer Graphics at my university (which is OpenGL and SDL on Linux), using NeHe's tutorials helped a lot. Going down at the bottom of the page you can either use GLUT or Linux versions of the source to get a very good version of what is already on the site. They even build on previous lessons.

      However I must say that the site is growing old. It references a lot of depreciated functions and, quite frankly, is not the best method to lea

    • by abdulla (523920)
      The real problem is NeHe's tutorials are painfully out of date. Modern OpenGL has deprecated or removed a lot of the functionality that is used in those tutorials, and there doesn't seem to be any update for OpenGL 3 or 4.
  • by ville (29367) on Tuesday March 23, 2010 @08:35AM (#31581888)

    C++ and OpenGL are both platform agnostic, why do you need the tutorial to be for a specific platform? Perhaps you need a tutorial on how to use your toolchain to compile C++ and OpenGL programs or linux?

    // ville

    • Re: (Score:1, Informative)

      by Anonymous Coward

      Perhaps you need to read the summary? but there's a problem: all the tutorials are very Windows-based, and I've been using Linux as my single platform for a while now.

      • Re: (Score:2, Informative)

        by mdwh2 (535323)

        Perhaps you need to read his comment, where he said "C++ and OpenGL are both platform agnostic, why do you need the tutorial to be for a specific platform?"

        With the exception of the first lesson (which I address in my comment below), can you show me how NeHe's tutorials are only usable on Windows? Or indeed, how they're specific to Windows at all?

        • Re: (Score:2, Insightful)

          by bastard01 (532616)
          How about something from the 25th lesson? http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=25 [gamedev.net] The implementation of CreateGLWindow() is very windows specific, and from what I've looked at, there doesn't seem to be a tutorial for a Linux/X11 nor a SDL specific implementation, they do have GLUT for OS X and Solaris.. However, actually creating a window and polling for key input is very platform-specific with NeHe's tutorials, which may be why the OP was asking for tutorials specific to Linux.
          • by mdwh2 (535323)

            But the Windows specific code is stuff that you've learned in lesson 1 (which as I say is the only one that's platform specific) - it's just the basic stuff to set up OpenGL with your OS. The things that you learn in that lesson aren't Windows specific - and if you're not sure how to set up OpenGL with your OS, you shouldn't be doing that lesson yet.

            The bottom of the page has links to the Linux code.

          • by mdwh2 (535323)

            ...in fact, that lesson states:

            "The CreateGLWindow() and WndProc() code hasn't changed. So I'll skip over it."

            So the implementations of those functions aren't covered for any platform, Windows included.

    • by mdwh2 (535323)

      Indeed - basically all NeHe is lacking is a Linux version of http://nehe.gamedev.net/lesson.asp?index=01 [gamedev.net] , instead of just Windows, Solaris and OS X. The rest of NeHe works fine.

      I think a bigger point to watch out for is that some of NeHe's tutorials are quite old, and not that relevant for modern rendering techniques (e.g., immediate mode, display lists).

    • I didn't know windows c++ allowed you to run
      #include

      • Re: (Score:1, Informative)

        by Anonymous Coward

        you can use < and > for smaller-then and greater-then signs in slashcode

    • by Zumbs (1241138)
      But there are a few gotchas when playing around with OpenGL in Linux (using the Redbook). As an example: Which packages do you need to install? A few years back, I tried it out, and discovered (to my great annoyance) that the nVidia drivers for my graphics cards only came with with headers for OpenGL v 1.0, even though the card supported OpenGL 2.1. The open source alternatives only supported OpenGL 1.3, but had other problems.
      • Re: (Score:3, Insightful)

        by hasdikarlsam (414514)

        That is no longer the case. However, it doesn't matter; you shouldn't be using the headers directly, you should be using GLEW.

        I'm pretty sure that was around a few years back, too.

    • Re: (Score:2, Informative)

      by SupaSaru (1773854)
      How did this get insightful? Worst comment ever. Do you think OpenGL just has magic platform agnostic Window management? Do you think OpenGL just takes over the whole PC as it's own little domain? Do you think the implementation between each OS is 100% exact? In fact, it's much closer to ignorantly assuming ^handles work "anywhere" because of C++'s "platform agnostic" title. The problem isn't in the tool chain - it's in the rather annoying process of creating rendering contexts for each individual OS
    • Perhaps you need a tutorial on how to use your toolchain to compile C++ and OpenGL programs or linux?

      It isn't that simple. Both C++ and OpenGL only cover a small segment of what is needed for 3D applications and games. There is a lot of stuff not covered by either of those that are very much platform specific (controllers, sound, networking, etc.).

      That said, NeHe's tutorials are still perfectly fine since most (if not all) of them have Linux conversions of the platform-specific stuff that you can download at the end of each tutorial.

  • Since the question is specifically on OpenGL, I'd expect the tutorials to easily be converted to any other platform.

    • by Pseudonym (62607)

      OpenGL is indeed platform independent, apart from opening a window or getting input from the user. So long as you never need to do either of those, you don't need a platform-specific tutorial.

  • LazyFoo might help (Score:5, Informative)

    by Drethon (1445051) on Tuesday March 23, 2010 @08:53AM (#31582072)
    LazyFoo's website http://www.lazyfoo.net/ [lazyfoo.net] has tutorials on SDL (a very simple 2d sprite engine).

    I don't know if he has basic tutorials but he has tutorials in Windows, Linux and other OSes too I think.
    • 2D samples are great, and I see that the last touches on OpenGL, but does anyone know a place with some more in-depth tuts for SDL+GL?

      • by Reapman (740286)

        In the last few months i've been working on reteaching myself C++, as well as using SDL and OpenGL for writing a "tactics" style game (as a way to learn this stuff). I used both code from LazyFoo and NeHe for most of what I learned, and google for everything else. It's worked fairly well, I got a nice framework for writing a GUI and already have a lot of the graphics work going for the game itself, now I'm just looking at writing my own 3d model loader for some more complex stuff.

        I honestly found the most

        • by phorm (591458)

          It definitely does sound like we're in the same ballpark. I've been working from the "red book" and built a hierarchal class system for scene->object->element->face->vertex and camera, etc. My camera pitch rotation is a bit messed when it hits 180 but otherwise it was going well until life distracted me from the hobby-coding again. I'd love to trade ideas/assistance in porting the base GL code up to something like SDL or Ogre.

          Email me ph3or7mix@ph6o8rmi1x.c3om. (Remove the numbers, it's obfuscat

  • by llvllatrix (839969) on Tuesday March 23, 2010 @08:53AM (#31582076)
    ...on how to get your rendering context setup in Linux. Here are a few:

    http://www.wxwidgets.org/docs/tutorials/opengl.htm [wxwidgets.org]
    http://projects.gnome.org/gtkglext/ [gnome.org]

    Beyond these, NeHe still applies. The exception are operating system specific APIs like playing sound, but those have nothing to do with OpenGL. After NeHe, you may want to consider using shaders, which are covered in the Orange Book:

    http://www.3dshaders.com/home/ [3dshaders.com]
    • by tepples (727027)
      After you get a rendering context set up, you still need to load textures. This may differ per operating system unless you're using OpenGL with a cross-platform library like SDL_Image or Allegro.
  • You could try getting involved with some existing game engines written for Linux/whatever else. Learn the engine basics then get into the guts of it. Check out Irrlicht Engine for one, last time I was there it seemed a friendly and helpful crowd on the forums.

  • Standard C++ books (Score:5, Informative)

    by porsche911 (64841) on Tuesday March 23, 2010 @09:07AM (#31582234)

    I would recommend the following books:
    Alexandrescu - "Modern C++ Design: Generic Programming and Design Patterns Applied"
    Meyers - "Effective C++" and "More Effective C++"
    Stroustrup "The C++ Programming Language"
    Stepanov - "Elements of Programming"
    Koenig - "Accelerated C++"
    Koenig - "Ruminations on C++" (A little out of date but still a good read)

    Good luck, C++ has evolved into a large and complex language. You may want to read Stroustrups "The Design and Evolution of C++" on the side to understand how it developed.

    -c

    • Re: (Score:3, Interesting)

      by trurl7 (663880)

      Koenig's "Ruminations" are beautiful! So glad you included it!

      Definitely second that list. I would add Alexandrescu's "C++ coding standards" (I'm an Andrei fanboy), and Sutter's "Exceptional C++: 47" and "Exceptional C++: 40 new".

      For the very beginning of C++, I like Lippman's "Essential C++", and, when you're feeling up to it, Lippman's "C++ Primer". If you want to know how C++ works under the hood, read "Inside C++ Object Model", also by Lippman (it's heavy lifting, and not needed for just using the la

      • by blue_teeth (83171)
        May I add "Thinking in C++" by Bruce Eckel? It is available for free download from Bruce Eckel's site.
    • I would recommend the following books: Alexandrescu - "Modern C++ Design: Generic Programming and Design Patterns Applied" Meyers - "Effective C++" and "More Effective C++" Stroustrup "The C++ Programming Language" Stepanov - "Elements of Programming" Koenig - "Accelerated C++" Koenig - "Ruminations on C++" (A little out of date but still a good read)

      Good luck, C++ has evolved into a large and complex language. You may want to read Stroustrups "The Design and Evolution of C++" on the side to understand how it developed.

      -c

      If you're looking for something that's mainly syntax, but with some really good examples and and practice exercises (with accurate solutions online), try C++ Primer Plus by Steve Prata. Very good book.

      http://www.pearson.ch/Informatik/SamsPublishing/1449/9780672326974/C-Primer-Plus.aspx [pearson.ch]

  • http://glew.sourceforge.net/ [sourceforge.net] GLEW also comes with the NVIDIA SDK: http://developer.nvidia.com/object/sdk_home.html [nvidia.com] NVIDIA SDK is also a good place to start with OpenGL.
  • Why not take a look at the code for an existing game engine like Quake (1/2/3) ?

    • Re: (Score:3, Insightful)

      by Savage-Rabbit (308260)

      Why not take a look at the code for an existing game engine like Quake (1/2/3) ?

      That's a bit too much for a beginner if you ask me. Better start out with some simple sprite based game to learn the basics and move on to 3D from there.

  • I'd look at:
    www.cplusplus.com
    www.thefreecountry.com
    www.cprogramming.com
    Those sites are good for beginner/intermediate programmers, to start with. (Really, it depends on whether or not you have a good foundation in C/C++, as to where you should look...)

    Good luck!

  • Dear god no! (Score:4, Informative)

    by Anonymous Coward on Tuesday March 23, 2010 @09:40AM (#31582678)

    Please don't look at the NeHE tutorials. Just buy the Red book or something and work from there.

    The NeHe stuff is terribly ancient and lots of it is amazingly out of date, and never promoted very good programming practices.

  • http://www.glprogramming.com/red/

    I don't have any of the other links I used when I was learning it, but I do have the source from the maze toy program I wrote while I was doing so.

    http://www.bravegnuworld.com/~rjune/maze.tar.bz2

    I hope it helps you.

  • Here's a tutorial to get you rolling with OpenGL in SDL under linux. Once you get rolling with that, you can proceed to the NeHe tutorials. http://cone3d.gamedev.net/cgi-bin/index.pl?page=tutorials/ogladv/tut1 [gamedev.net]
  • by jimrthy (893116) on Tuesday March 23, 2010 @10:06AM (#31583062) Homepage Journal

    I say that, because I was asking myself pretty much exactly those same questions just a few months back.

    1. You want to learn OpenGL
    2. You want to broaden your horizons to C++

    Both are good goals, but they're also two distinctly different goals.

    Pyglet is a simple python gaming library that is an excellent resource for learning OpenGL. You get all the goodness of python, yet you're using the same OpenGL calls you'd use in a "real" programming language. It probably isn't stable enough for production, but it's much faster to learn when you have the command interpreter and don't have to wait around for the compiler/linker.

    There are other OpenGL implementations for python, but I had the best luck learning by using pyglet. Probably because it's very low level and doesn't hide implementation details like, say, SDL does.

    The NeHe tutorials are good for what they are. Like other posters have mentioned, they're a little out of date, and the programming style isn't all that great. But they're good, quick examples of getting something set up and seeing results pretty much immediately. Which makes them a good place to start...as long as you remember the grain of salt.

    I definitely share your pain when it comes to setting up things like the rendering context, the camera, etc, etc, etc. There are tons of options, the man pages were not written for the beginner. Again, as has been mentioned over and over, the Red Book is probably your best bet.

    Learning C++ is (really) a different question. I can't recommend the C++ FAQ Lite highly enough. You can find their recommendations at http://www.parashift.com/c++-faq-lite/how-to-learn-cpp.html [parashift.com]

  • by Mabbo (1337229)
    ... is based on the book they (GameDev) wrote and recommend on their website, "Beginning OpenGL Game Programming, Second Edition". What a waste of my money. It doesn't teach you anything unless you already knew it. The code given on paper is in snippets, never full programs, and never fully explained. It was like they never actually had a beginner to OpenGL read the book before they published it.

    But don't worry, the full source is on the CD. Of course, it's only for visual studios, and even if you get it r

    • by kazade84 (1078337)

      I'm the author of that book.

      I'm sorry you didn't enjoy the book. The book's structure and format followed that of its predecessor (the first edition) which was written by different authors. It was not possible to put entire code listings into the text of the book due to space limitations, which is why the book came with the full source on the CD.

      That said, the initial print run of the book had a fault with the project files on the CD, they did indeed have absolute paths. I posted updated versions on the boo

  • 1) OpenGL and C++ are both multi-platform, so I don't get why you need something specifically aimed at Linux. You can't just translate Windows C++ samples?

    2) Since video games aren't CPU-bound anymore, and since Python is a *much* cleaner and easier language than C++, and since Python has OpenGL libraries available-- why?

    The only benefit you're going to get from this is the knowledge that C++ kind of sucks compared to Python. I can tell you that right now and save a lot of time.

    • by SupaSaru (1773854)
      Hi! To go with point 1 - Can you "translate Windows C++" ? If so, you have the answer to a multibillion dollar portability question and the solution as to how to get Linux significantly into mainstream games and other entertainment. Go look into how to create a window in C++. Then look into how to create a window in GTK+. Tell me how good you are at instantly converting these samples while trying to understand how OpenGL contexts and rendering works.
    • by jjohnson (62583)

      Nehe's tutorials tie the OpenGL stuff into a game application framework that's totally Windows based--win32 event handlers, windowing code, etc. After following them all through, you've got something that's basically impossible to port to Linux, and learning OpenGL this way, you need that application scaffolding to do any useful work with the library.

    • Why it's an absolutely seamless transition.
      C++ is multi-platform.

      #include "stdafx.h"
      #include "resource.h"

      #define MAX_LOADSTRING 100

      // Global Variables:
      HINSTANCE hInst; // current instance
      TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
      TCHAR szWindowClass[MAX_LOADSTRING];
  • IMHO A framework can help out a lot, especially when your just getting started. A framework can help get you up and going rather quickly without having to worry about configuring everything. I'd recommend Qt. Here are some great examples: http://doc.trolltech.com/4.6/examples-opengl.html [trolltech.com]
  • You need to figure out which version of GL you want to learn.

    The newer versions of GL completely remove immediate mode (glVertex3f() etc)...

    My memory is a bit rusty but I think GL 3.2 removed immediate mode completely. Its definitely removed from the recently announce GL 4.0.

    Its a shame because immediate mode makes learning GL all the more easier to learn.

  • Suggestions (Score:2, Informative)

    by bioglaze (767105)

    Most of the tutorials are outdated and won't work in modern OpenGL core profile. Avoid tutorials that use glBegin(), glVertex(), glLight(), gluPerspective(), glMatrixMode(), glVertexPointer(), or learn just enough from them that you can create a context and draw stuff in Linux. After that you can adapt Windows-specific tutorials's code to Linux. I liked these tutorials:
    http://sites.google.com/site/opengltutorialsbyaks/introduction-to-opengl-3-2---tutorial-01 [google.com]
    http://www.opengl.org/wiki/Tutorial:_OpenGL_3.1_Th [opengl.org]

  • I recommend you to use the SMFL library, which supports opengl and it's portable to many systems including linux, windows and osx. take a look at http://www.sfml-dev.org/ [sfml-dev.org] Good lucky!
  • C++ FAQ Lite [parashift.com]

    I used this site a bunch when I found myself doing some c++ work after almost exclusively working in java.
  • by njord (548740) on Tuesday March 23, 2010 @11:44AM (#31584532)

    I just want to point out that there are 3 different topics you're talking about there:

    1. C++
    2. OpenGL
    3. Development/building on Linux

    Indeed, there are pretty deep concepts behind each of them: C++ is related to fundamental programming concepts, object orientation, and metaprogramming, OpenGL deals with framebuffer rendering/graphics, and Linux development deals with source control, Makefiles, compilers, and configuration setups.

    These concepts are not orthogonal by any stretch of the imagination, but it might help to keep in mind that each of them can be studied without the other.

    Speaking from personal experience as a 'graphics guy', I would suggest you look further than OpenGL if you want to learn C++. OpenGL is great, don't get me wrong, but it is just an API, and a fairly limited one at that. You won't learn much C++ trying to figure out how to set up texture contexts and binding VBOs.

    I would recommend writing a raytracer or your down software-based rasterizing renderer (or both!) - you'll find youself diving right into the data structures that are important to graphics and tackling 'fundamental' problems that really test your programming abilities, versus realizing that you passed GL_LINE to glBegin() instead of GL_LINES or some stupid API issue like that.

    Later, you can work on your OpenGL skills; heck, you could even play with it in Python if you're curious. You'll find that any API is easier and more satisfying to use if you say 'How does this API address the following problem in graphics?' as opposed to browsing through the API reference and saying 'Ooh, what does this function do?'.

    As for the Linux part, my advice would be to read up on Makefiles and spend some time writing them for various projects. When you've really got a handle on them, you can move on to CMake or autotools or whatever - but jumping into those without knowing that basic mechanism does you a disservice. I'd also recommend experimenting with one of those fancy programming editor (I recommend The One With All of the Modifier Keys [gnu.org]), but there are several that are very good.

    Good luck!
    njord

  • Look for OpenGL ES 2 books and tutorials, e.g this one : http://opengles-book.com/index.html [opengles-book.com]

    OpenGL ES is OpenGL minus the totally outdated stuff you should never pay attention to (and which is sadly used in most web OpenGL tutorials, because they're all old), i.e it's a subset of OpenGL and is the right way to learn and do OpenGL programming today.

  • by BerkeleyDude (827776) on Tuesday March 23, 2010 @12:03PM (#31584808)
    Get the sources of glxgears (in mesa-utils), and look through the code. It's relatively simple, and will help you get started.

    Also, when I was looking for an OpenGL example that uses just X11, without Qt/Glut/whatever, the best one I could find was this: http://msdn.microsoft.com/en-us/library/dd318252(VS.85).aspx [microsoft.com] (Yes, the irony is overwhelming...)
  • VTK (Score:1, Interesting)

    by Anonymous Coward

    If you really be able to make complicated 3D scenes quickly I'd recommend learning VTK (Visualization ToolKit). It's what professional visualization researchers use to display data, has a bit of a learning curve but it has a ridiculous number of 3D graphics algorithms (extrusion, creating meshes from point clouds, transformations, importing data from various formats, etc. etc.)

    Also if you really want to be able to prototype ways to visualize 3D data quickly there are python bindings :)

  • Bruce Eckel "Thinking in C++" Volumes 1 and 2. You can buy the softbound books or find them online for free. I suggest you develop using an IDE in linux, instead of the CL. Two popular C++ IDEs for Linux are Eclipse and my favorite Code||Blocks, which is a good option for anyone migrating from MS Visual C++
  • I'd start by downloading the full SDK here [nokia.com].

    Then fire up Qt Creator, go to welcome screen getting started tab, and dig into the rather interesting and well-documented examples. Hint: QGraphicsView combined with OpenGL is probably the way to the future, especially if you're not interested in building traditional boring GUI applications.

    If you want a little more help getting started, google "qt tutorial" for more adding-features-step-by-step type stuff.

  • There is really nothing about the OpenGL API that is in any way object-oriented. It's not just procedural, it's procedural with global state variables. So if you want to build your 3D software in OO style, your first task is going to be making object-based wrappers around the procedural OpenGL code.

    So basically, you can forget about C++ and use C, Ruby, Java, or anything else you fancy while learning OpenGL from the tutorials you've already been pointed at. Then you can learn how to wrap procedural C in a C

  • Yes, I read the question. Scroll to the bottom of the NeHe tutorial pages and see that most of them have Linux, Linux/GLX, and/or Linux/SDL code downloads.

    Use those. The OpenGL stuff is the same as it's cross platform. The Windows-specific stuff will have been replaced with Linux-specific stuff, and after a quick glance, is explained about as well as the windows-specific stuff (which is to say, mostly glossed over, since NeHe does OpenGL tutorials, not Windows/Linux/whatever tutorials).

    If you're having p

  • I remember a couple of years ago trying to get some of those working in http://www.squidoo.com/womensera [squidoo.com]

"Life is a garment we continuously alter, but which never seems to fit." -- David McCord

Working...