opengl

c++ sorting by depth using only a matrix. Possible?

If I have a std::vector of objects containing a rotated / translates matrix, is there a way I can use that matrix to calculate a Z position so that I can sort the objects by depth? ...

Apply hue/saturation filters to image with OpenGL

I have an image in OpenGL that I am attempting to apply a simple HSB filter to. The user selects a hue value, I shade the image appropriately, display it, and everyone is happy. The problem I am running into is that the code I have inherited that worked on a previous system (Solaris, presuming OpenGL 2.1) does not work on our current sys...

OpenGL: How to select correct mipmapping method automatically?

I'm having problem at mipmapping the textures on different hardware. I use the following code: char *exts = (char *)glGetString(GL_EXTENSIONS); if(strstr(exts, "SGIS_generate_mipmap") == NULL){ // use gluBuild2DMipmaps() }else{ // use GL_GENERATE_MIPMAP } But on some cards it says GL_GENERATE_MIPMAP is supported when its not,...

Implementing a Fixed Coordinate system in OpenGL

The simple version of my project is rotating a sphere based on user input. However my rotations get weird after multiple rotations in certain situations due to openGL's local coordinate system. What I really need is to rotate based on a world/fixed coordinate system. Such that when I rotate the sphere once its rotation axes are not rota...

Why does culling remove faces of this cube which are not occluded?

The following code is a modified version of XCode's iPhone square example, to draw a cube. But when I use culling, the cube renders with faces missing. Can anyone tell me what I'm doing wrong? #import "ES1Renderer.h" @implementation ES1Renderer // Create an OpenGL ES 1.1 context - (id)init { if ((self = [super init])) { ...

How to create textured wall which continuously updated while player is moving up in opengl?

Hi, I was wondering how to create wall in opengl and it is continuously appears from up and disappers at down screen. I am able to construct wall by GL_QUADS with texture mapping. but do not know how to generate it dynamically whenever player climbs up. ...

SDL/OpenGL Texture Transparency

So I have a seemingly simple problem, and I've searched around, but none of the solutions I've found have worked (though I probably applied them incorrectly). I'm just wondering how I can convert an SDL_Surface (loaded from a png via IMG_Load) and stick it on a quad. Here is what I have (mostly just copy pasted from a tutorial I found). ...

UI utility library for OpenGL 3+, or is Xlib ok?

I want to write some OpenGL 3.2, likely also OpenGL 4 stuff on Linux, and I just saw that libsdl 1.2 (the latest stable release) supports only 2.x. LibSDL 1.3 (which is in development) should support it, but it'll be a while before it gets into mainstream distributions. Is there any library out there right now which allows me to create a...

c++ Segmentation fault occurs when executing simple opengl tutorial

I am trying to use opengl to render objects. Although the simple tutorial example http://www.videotutorialsrock.com/opengl_tutorial/get_opengl_setup_linux/text.phpcompiles without error when I attempt to execute the program it crashes i.e. the dreaded segmentation fault. System Suse Linux 11.2 64 bit g++ (SUSE Linux) 4.4.1 [gcc-4_4-br...

How do I determine available device memory in OpenCL?

I would like to know how much free memory there is on my device before allocating buffers. Is this possible? I know there's CL_DEVICE_GLOBAL_MEM_SIZE for total memory, and CL_DEVICE_MAX_MEM_ALLOC_SIZE for max size of a single object, but I would like to know the current memory state. As it stands I'm probably going to have to use OpenGL...

Multiple textures in GLSL - only one works

Hi, There's been similar threads before, but I could not find a solution in them. My problem is getting more than one texture accessible in a GLSL shader. Here's what I'm doing: Shader: uniform sampler2D sampler0; uniform sampler2D sampler1; uniform float blend; void main( void ) { vec2 coords = gl_TexCoord[0]; vec4 col = textu...

What is the right process to get compatibility or at least a workaround for the 'Threaded optimization' feature of NVIDIA?

It's peculiar this issue is not well understood on NVIDIA forums and project forums. For example, the well known ioquake3 project based on id tech 3 requires to force 'Threaded optimization' off on the NVIDIA settings or there are severe FPS drops. Do you know what a programmer has to do to acquire compatibility with the feature or at ...

How OpenGL handles the texture border when using GL_REPEAT?

I understand that GL_REPEAT parameter will ignore the integer portion of the texture coordinate, only the fractional part is used when doing texture mapping. The question is how OpenGL handles the texture border? For instance, if the texcoord is 2.0, the return value should be the same as the return value at texcoord 0.0 or at 1.0? I ass...

Tools for converting 3d model files (3ds/obj/whatever if it's an open format) to C arrays.

Hello, I found here a script which converts obj files into C header files with information required to render the model with OpenGL. I'd like something like this but I will need texture coordinates as well. The tool apparently doesn't do that. Such a tool will save me a lot of time because I'd have to make my own program to extract data...

Dynamic arrays as parameters to API functions and Delphi

In my application (Delphi 2010, OpenGL, windows XP), I need to read back the pixels of variable portions of the framebuffer. The area of interest is input by the user through a selection rectangle (x1, y1, x2, y2). With this coordinates I do this: var pixels : PGLUByte; //pointer to unsigned bytes begin [Transformation of...

Rubik's Cube OpenGL Implementation

What is the "easiest" solution to code a Rubik's Cube with the following features in Opengl: "Camera" moves to let user see the cube from any point of view Smooth display of cube moves in response to user clicks when playing I started with a solution drawing the cube "Face by Face" but I am not sure it's a good solution (I am facing ...

OpenGL key down and key up on CTRL key

I've found a lot of information about using GLUT to detect whether the control key is pressed using the GLUT_ACTIVE_CTRL macro. This macro only works, apparently, within a keyboard or mouse callback function. I need to know whether or not the control key is pressed at a point in my main loop, but GLUT_ACTIVE_CTRL doesn't seem to work in ...

Add to part of image in OpenGL instead of full redraw?

Hi, I have a simulation that uses OpenGL for drawing. While it is running, I would like to plot some things on top of my simulation in real time, but every iteration I only want to add few lines to that graph, instead of always re-drawing it from scratch (that would be too costly). How could I create some surface to which I can always ...

Which of these is faster ?

I was wondering if it was faster to render a single quad the size of the window with a texture the size of a window than to draw the bitmap directly to the window using double buffering coupled with the platform specific way of drawing to a window. ...

OpenGL lights limit

As I was reading RedBook I stayed quite confused, that openGL can have maximum 8 lights in scene (number depending on implementation, but should be arround 8). But I can imagine number of situations that would need more lights, so I think there's a trick arround this in game dev. For example, you have very long street with 50 strretl...