Using the mouse scrollwheel in GLUT

Freeglut’s glutMouseWheelFunc callback is version dependant and not reliable in X. Use standard mouse function and test for buttons 3 and 4. The OpenGlut notes on glutMouseWheelFunc state: Due to lack of information about the mouse, it is impossible to implement this correctly on X at this time. Use of this function limits the portability … Read more

GLUT exit redefinition error

Cause: The stdlib.h which ships with the recent versions of Visual Studio has a different (and conflicting) definition of the exit() function. It clashes with the definition in glut.h. Solution: Override the definition in glut.h with that in stdlib.h. Place the stdlib.h line above the glut.h line in your code. #include <stdlib.h> #include <GL/glut.h>

how to enable vertical sync in opengl?

On Windows there is OpenGL extension method wglSwapIntervalEXT. From the post by b2b3 If you are working on Windows you have to use extensions to use wglSwapIntervalExt function. It is defined in wglext.h. You will also want to download glext.h file. In wglext file all entry points for Windows specific extensions are declared. All … Read more

How to compile GLUT + OpenGL project with CMake and Kdevelop in linux?

find_package(OpenGL) will find the package for you, but it doesn’t link the package to the target. To link to a library, you can use target_link_libraries(<target> <item>). In addition, you also need to set the include directory, so that the linker knows where to look for things. This is done with the include_directories. An example CMakeLists.txt … Read more

Why is my OBJ parser rendering meshes like this?

I haven’t downloaded your project. What people mostly struggle with when writing OBJ import code for rendering with OpenGL is the indices. And as @ratched_freak also suspects in his comment, that’s very consistent with the visual appearance of your cube. The OBJ format uses separate indices for positions, normals, and texture coordinates. For OpenGL rendering, … Read more

How create a camera on PyOpenGL that can do “perspective rotations” on mouse movements?

You can use glRotate to rotate around an axis, by an amount which is given by the relative mouse movement (pygame.mouse.get_rel()): mouseMove = pygame.mouse.get_rel() glRotatef(mouseMove[0]*0.1, 0.0, 1.0, 0.0) But that won’t satisfy you, because the solution won’t work any more, if the mouse leaves the window. You’ve to center the mouse in the middle of … Read more