tags:

views:

2520

answers:

7

Hi, every introduction and sample that I can find seems to use GLUT or some other framework to "initialize" OpenGL. Is there a way of initializing OpenGL with just what is available in GL and GLU? If not, then what is GLUT doing that is not possible without it?

+3  A: 

What you're doing is initializing a window with an OpenGL context. This requires some calls to the operating system. It is not possible to initialize OpenGL with just gl.h and glu.h. GLUT (or SDL, SMFL, etc) does that work for you in a nice platform independent way. You can do the initialization with native calls as well.

luke
A: 

You could grab the GLUT source code and see the init code for whatever platform you are concerned with.

Jim Buck
A: 

Hi TholePin!

Here's a basic and good introduction to how you initialize OpenGL (assuming windows) without using GLUT:

Init OpenGL without GLUT

As luke said, if you dont want to use GLUT, you need specific information about the operating system you are developing on. Using GLUT will make your code easier to port.

Cheers //Magnus

Magnus Skog
A: 

GL is an API, and GLU is an utility library on top of GL. It's completely operating system independent.

OpenGL initialization and extension fetching are platform dependent operations. Therefore you can do about nothing with OpenGL alone.

GLUT is fast insufficient and terribly poor library, and about only it does is that it initializes the opengl context and provides some primitive mouse/keyboard input modules to get you ongoing.

Win32 provides tools to initialize opengl context as well. For linux you could check out GLX. Also, if you want a system independent way of doing it, then you could check out SDL. For different programming languages there may be utilities that provide you a platform independent desktop API.

Cheery
+5  A: 

As luke noted, the code to create and bind the context is specific to each windowing platform.

Here are some functions to get you started in terms of initializing OpenGL on specific platforms:

Windows (a tutorial is here)

  • wglCreateContext(hDC)

Mac OS X -- OS X has essentially three options: Carbon, Cocoa, and the underlying Core Graphics Layer

Linux

  • glx: glXCreateContext
fixermark
Thanks, these are helpful. Now I realize that my problem is specific to the Windows side of the code rather than just OpenGL (i.e. trying to get OpenGL to work on top of - or along side? - GDI+).
You don't subclass NSOpenGLView, you subclass NSView and use NSOpenGLContext and NSPixelFormat for more flexibility (and you only use an NSOpenGLView for very simple things).
Mk12
Also, note that Carbon is pretty much a dead end (no 64 bit support), and CGL can't create a window, so for OS X use NSGL for Cocoa windows, menus etc. and CGL for fullscreen applications.
Mk12
A: 

I'm not interested in displaying images with OpenGL. Just rendering to frame/(color) buffers, and then copying those buffers to the client.

Can I avoid the GLX layer, and learn some OpenGL calls, enough to set up some buffers I can render to, with no display?

Mr.What
A: 

Here's mine!!

bobobobo