Sorry for the plea for help, but I am frustrated.
I don't know why, but I've never seemed to be able to get texturing to work in OpenGL. I would really appreciate a minimal example, so long as it only uses /gl.h /glu.h and standard C++ libraries. Any other insight would be appreciated.
Sorry for simply asking for you to write up a whole program for me, but I could really use it, since EVERY internet example I have seen uses glut. I can't compile it for some reason, and it is very annoying.
Thanks.
You NEED some library or interface to create an OpenGL context (and a window to display it).
GLUT is outdated, but still popular; good options nowadays are GLFW or SDL. I recommend GLFW.
(BTW, why did you even need to compile GLUT? Doesn't it have precompiled binaries for Windows?)
Or you can use system-specific functionality; in your case - WinAPI. However, this is a very tedious process; much unlike the portable solutions which create a window in just one or two lines of code and provide easy input handling.
Once you get your GL window up and running, you can learn texturing (or anything else) from any tutorial. The OpenGL calls will be the same, it doesn't matter how the window was created.
Here's a good tutorial:
http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=06
This code does not use glut.
You need a window manager to create a window, for which you are going to create a context, where you can render your image. You can not do that using standard c++.
It is not clear for which OS you are targeting, but there are cross-platform frameworks, like GLUT, SDL, etc. You can also do it using xlib, if you are on linux.
Related
One thing I keep seeing a lot is people using an openGL context with SDL, what's the reason for this?
It's not very intuitive to understand, if I use an openGL context my application will still be multiplatform? Will it run on iOS and Windows with the same code?
I'm following an OpenGL tutorial that uses a certain input/window handler (i.e. GLUT, GLFW), but I cannot, due to platform issues, use that handler. Can I use the exact code from the tutorial despite my using a different input handler? Does the OpenGL code have to be modified to work with a different handler?
It will work.
OpenGL is completely agnostic of input. It is a graphics library, and as such, cares only about graphics. Everything else, including input, audio, and all else, is completely and utterly irrelevant.
The only difference for you is that toolkits like GLUT, GLFW, SFML, and others do the setup of an OpenGL context for you.
If you want to use another toolkit, that's fine, and it will probably also set up your context for you. You can also use OpenGL directly, in which case, you will need to create the context yourself, which will require calling into the WGL (Windows), AGL (Mac), GLX (X-Windows on *nix), or EGL (everything else) APIs.
I've recently started learning OpenGL (> 3.3) & I've noticed a lot of examples & tutorials use both freeglut & glew, but don't really explain the difference at all. The best description I've found, after googling & reading ad nauseum, has been this OpenGL Related toolkits and APIs but found it lacking. I've even read the tag info on SO.
As someone really new to OpenGL I'm still trying to get a grasp of the different concepts. I've gotten to the stage of creating a basic program that uses glew, create context (on windows, VS2010), & draw really basic shapes, all without the need for explicitly including freeglut. So I don't understand why I would need it.
So my question then is, what's the difference between:
-freeglut
-glew
-(& glfw)
What can one do that the other can't?
The OpenGL Extension Wrangler (GLEW) is used to access the modern OpenGL API functions(version 3.2 up to latest version).If we use an ancient version of OpenGL then we can access the OpenGL functions simply including as #include <GL/gl.h>.But in modern OpenGL, the API functions are determined at run time, not compile time. GLEW will handle the run time loading of the OpenGL API.About GLEW see here
GLFW or freeglut will allow us to create a window, and receive mouse and keyboard input in a cross-platform way. OpenGL does not handle window creation or input, so we have to use these library for handling window, keyboard, mouse, joysticks, input and other purpose.
GLFW and freeglut are alternative for us according to our need we can choose any one but GLEW is different from them which is used for run time loading of the OpenGL API.
I'm using both of them for some work at my university.
GLEW is a "cross-platform open-source C/C++ extension loading library" (from its website), while freeglut is a window manager that replaces the default OpenGL Utility Toolkit (GLUT) library.
So, as you see, both different have different purposes. The point of using freeglut is that it's still maintained, while the default GLUT isn't, so if you want bug fixes and new features you should use it :)
I'm working with OpenGL using Win32 API. Therefore I'm using wgl (Wiggle). Everything is fine. Except if I want to use some shapes from the FREEGLUT library. For example, the teapot. I was looking at the source code of freeglut, and it seems that when I issue a
glutSolidTeaPot(1.0); ,it exists the program because of the macro: FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidSphere" ); which calls fgerror, which has an exit(1).
Therefore, the symptom that I'm getting is obvious. When I ran the OPENGL program without any GLUT commands (like the teapot) it works great. If I use the teapot, it exits.
It is clear to me, that I'm missing initialization. The question is if I can initialize (and how) glut to be used for the shapes in my wgl context ... If this is not possible, I guess I could create the shapes myself. It is just faster to use those if possible.
All the examples that I have found so far point in how to initialize glut when you are working with glut only.
I'm using Windows 7 64, Visual Studio 2012, NVIDIA 330m , FreeGlut
FreeGLUT is not intended to be used in part. It is a system for creating and managing an OpenGL rendering context. It has utilities functions, but it's primary purpose is to create and manage a window. So if you're not using FreeGLUT to create and manage OpenGL, you don't get to use it for other things too.
While It seems that combining GLUT and WGL (Wiggle) is not possible (and rightly so), I have look at the code and it seems that this could be change to make it work. Of course, why make it work? Because of the additional utilties that GLUT (FreeGlut) has... like creating a sphere...
A better approach is to create a modern library to do all of this... Of course, you have some of the geometry libraries outthere, but I haven't check them.
I'm talking something more like the AUX library, but up to date.
Glut seems rather old, and SDL also as if it's not the youngest anymore - what is being used as (cross-platform) window manager for OpenGL nowadays?
Cross platform UI toolkit
1. wxwidgets
2. fltk
3. qt
4. glut(freeglut)
5. sdl
I have used glui. Sucks real bad(in terms of performance). There huge difference in performance penalty just by including glui(without actually using it) in your apps.
To be honest, i prefer platform specific UI toolkit. Faster. Reliable.
Depends on how you want to use it. Don't think there is a clear winner.
I like to use Qt because I'm familiar with it so it feels easy to me, and because I use it for other UI elements in my mostly windowed openGL apps.
Haven't tried it myself, yet, but want to in my next project. It seems to be very popular.
SFML . It`s the "successor" to SDL written in C++
I am using freeglut, but it is just a bit improved glut.
You can also use QT
I think GLFW is the best choice for small to medium applications/games. This type of libraries should be easy,small and fast with no extra services such as image helper functions and so on. GLFW is going to remove all helper functions to focus on the main goal.
QT is the best for graphics applications but not for games or small applications.