opengl

Cg: Proper way to write/read from a floating point texture

I currently have a R8G8B8 floating point render target and want to use it as a R24 target. The code //cg out = float4(v, v, v, v); seems to clamp out between 0 and 1. What's the proper way to write/read to a floating point texture in Cg? ...

Is there a lint tool for OpenGL Shading Language?

I've started working with OpenGL and writing shaders. My app checks for errors after loading and compiling shader programs, and if there is a problem it prints out the info log. This is great for catching errors (and I'm a newbie so I'm making a lot), but what I'd really like is to catch these errors at build time. If I had a lint tool ...

glColor3i only drawing black

Why does this only draw black? glPushMatrix(); // Check the current color glColor3i(255, 0, 255); GLint currentColor[4]; glGetIntegerv(GL_CURRENT_COLOR, currentColor); //currentColor[0] = 254, 1 = 0, 2 = 254, 3 = doesn't matter glBegin(GL_QUADS); glLineWidth(1); glVertex2f(0, 0); glVertex2f(WINDOW_WIDTH * .1, 0); glVertex...

What's the counterpart to glGetMatrix() (and why isn't glSetMatrix() it?!!!) ?

Ok, I've been convinced that quaternions are The Way To Go, rather than trying to make pitch, yaw, roll rotations work out. So now I've got code that looks something like this (obj-C, but it shouldn't matter): [quaternion makeIdentity]; [quaternion setPitch: rotation.x yaw: rotation.y roll: rotation.z]; GLfloat matrix[16]; [quaternion...

OpenGL: getting clipping planes that will bound the entire scene

Hello, I am looking for a way to display my entire scene on the screen. This involves a call to glOrtho() with my clipping plane bounds. However, the size of my scene is dynamic and as such, I need to find a way to determine a projection box that will contain the whole scene. Any suggestions? ...

What do I have to learn to create Mafia 3 ?

I am a newbie C++ developer for Ubuntu and Windows. I want to know, what other things ( what 3d engine for example ) I have to learn to create a game like Mafia 2 or GTA IV. ...

How to use libpng with OpenGL for a 2D game?

I am beginning with OpenGL, and I want to make a very simple game with airplanes. Now I have a PNG of an airplane seen from above, and I want to draw this on the screen. Currently I only know how to draw triangles that rotate: float angle = 0.0f; void renderScene(void) { glClear(GL_COLOR_BUFFER_BIT); glPushMatrix(); glRotatef(angl...

How to draw a texture using indices

Hi! I'm drawing a simple cube using 8 vertices and 36 indices. No problem as long as I don't try to texture it. However I want to texture it. Can I do that with only 8 vertices? It seems like I get some strange texture behaviour. Do I need to set up the cube with 24 vertices and 36 indices to be able to texture the cube correctly? ...

Opengl Mirror transform backface culling

In openGL, I've got an object that I scale by -1 along an axis... this results in the object not rendering properly because all the front faces are now back faces. Short of disabling culling, how would I get this object to render right? Is there a way to do it without modifying the textured normal vertices that make up my model? ...

glGenLists(1) return 0 outside OnPaint() with wxThread

Hi there, Currently, I am trying to separate the display list from the OnPaint(), but glGenLists(1) return 0. Is there any prerequisite on using display list? Is function glGenLists(1) only survive inside OnXxx() event thread? Thank you! ...

Quaternion -> matrix[16] -- ok, now what? (How to display object from quaternion?)

I have my object's rotation and translation in a quaternion, which I've converted to a matrix[16]. How do I feed that matrix to OpenGL? I'd-a thought I could just glLoadMatrix() with my new, fancy-pants matrix and all would be good, but I'm getting a blank screen. (I'm a bit of a GL n00b, so type slowly and use small words ;) My code...

OpenGL Lighting struggles

I'm in the middle of a project teaching the basics of OpenGL. I've got most of the requirements working fine in terms of camera rotation, translation etc. However I'm struggling a lot with the lighting. This picture is a comparison of my current program (left) vs the sample solution (right). In case you can't tell, I'm getting very mo...

Getting the correct mouse position in SFML with OpenGL

My problem is related to getting the correct mouse co-ordinates from SFML while using OpenGL. Basically I am making a polygon rotate on the Z axis to look at the current cursor position. You can also move the polygon around the screen with the WASD keys. If the polygon stays in the center of the screen everything works great, but my p...

glutHideWindow and glReadPixels on OS X

On a MAC OS X machine, I am using FBO, depth RBO and texture RBO with freeglut to render a 3D scene to FBO and doing a render to texture. All using standard glut functions and glutMainLoop at the end. I am using glReadPixels to read from the FBO. I can see that the pixels are being read correctly. However When I hide the glut window us...

How to rotate model not camera in OpenGL ?

Hello! I have the same qustion as in the title :/ I make something like: glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0.0f, 0, -zoom); glRotatef(yr*20+moveYr*20, 0.0f, 1.0f, 0.0f); glRotatef(zr*20+moveZr*20, 1.0f, 0.0f, 0.0f); //Here model render :/ And in my app camera is rotating not model :/ ...

Get current color

Im using glColor4f(1.0f, 1.0f, 1.0f, alpha_); to set transparency to primitives I'm drawing. However I'd like to be able to read the current opengl alpha value. Is that possible? e.g. float current_alpha = glGetAlpha(); //??? glColor4f(1.0f, 1.0f, 1.0f, alpha_*current_alpha); ...

Drawing Normals to Surfaces

I am trying to draw the normal vectors to a mesh file so I can see how the normal vectors bounce from their respected face. In the draw function, it takes in each face and draws a line from the center point of the face to the (center + normal vector). When I run it, however, I do not see any red lines bouncing off each face. What am I do...

mdi child form don't work via opengl app in .NET

Hi all, This is my first question. I start to computer graphics programming with opengl via Tao Framework. Everything going well but today I tried to work with MDI forms. My application crashed. It is a bit difficult to describe my problem. So I captured 5 images and I added my questions on them. I could not add this images because of ...

Big QPixmaps crashes with OpenGL

Hello! I'm programming a QGraphicsView that has a lot of images. But when I display a JPEG with resolution 8528 x 1128 px (a panorama image), the QGraphicsPixmapItem does not render. It just displays a black square. Images of "normal" size renders good. I have not tried to find the "magick limit" for what sizes the problem occures on. ...

Mesh deformation and VBOs

In my current project I render a series of basically cubic 3D models arranged in a grid. These 3D tiles form the walls of a dungeon level in a game, so they're not perfectly cubic, but I pay special attention to be certain all the edges line up and everything tiles correctly. I'm interested in implementing a height-map deformation, whi...