What does glLoadIdentity() do in OpenGL?

The identity matrix, in terms of the projection and modelview matrices, essentially resets the matrix back to its default state. As you hopefully know, glTranslate and glRotate are always relative to the matrix’s current state. So for instance, if you call glTranslate, you are translating from the matrix’s current ‘position’, not from the origin. But … 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

SDL2: Fast Pixel Manipulation

SDL_CreateTexture() w/SDL_TEXTUREACCESS_STREAMING + SDL_UpdateTexture() seems to work well enough with the right pixel format. On my system using the default renderer: Renderer name: direct3d Texture formats: SDL_PIXELFORMAT_ARGB8888 SDL_PIXELFORMAT_YV12 SDL_PIXELFORMAT_IYUV (though the opengl info is the same:) Renderer name: opengl Texture formats: SDL_PIXELFORMAT_ARGB8888 SDL_PIXELFORMAT_YV12 SDL_PIXELFORMAT_IYUV SDL_PIXELFORMAT_ARGB8888 gives me ~1ms/frame: // g++ main.cpp `pkg-config –cflags –libs sdl2` … Read more

Easy framework for OpenGL Shaders in C/C++

First of all, I’d avoid using glut — it’s buggy, hasn’t been updated in roughly a decade, and its design doesn’t really fit very well with what most people want today (e.g., though you can use it for animations, it’s really intended primarily to produce a static display). I pointed out a number of alternatives … Read more