opengl

Qt 4.6 OpenGL GLSL

I'm trying to find like NeHe's tutorials for Qt that are all in GLSL. Because lets face it, OpenGL in the old days are dead and Shaders are the only way now. And with Qt-4.6 they introduced the QMatrix4x4, QVector3, and the Shader classes. But I cannot find any tutorials for this. All the ones I do find, all use crappy SDL and/or GLUT (...

Camera video stream inside CAOpenGLLayer

What I'm trying to achieve is to get the uncompressed camera video stream and to convert it into an OpenGL texture, to show it inside an CAOpenGLLayer. Is it the right flow? I thought to use a tecnique similar to the one proposed here to show movie video frames, but the following snippet is not working, at the end the tex coords are all...

Rotating in OpenGL relative to the viewport

I'm trying to display an object in the view which can be rotated naturally by dragging the cursor/touchscreen. At the moment I've got X and Y rotation of an object like this glRotatef(rotateX, 0f, 1f, 0f); // Dragging along X, so spin around Y axis glRotatef(rotateY, 1f, 0f, 0f); I understand why this doesn't do what I want it to do (...

Calculate lookat vector from position and Euler angles

I've implemented an FPS style camera, with the camera consisting of a position vector, and Euler angles pitch and yaw (x and y rotations). After setting up the projection matrix, I then translate to camera coordinates by rotating, then translating to the inverse of the camera position: // Load projection matrix glMatrixMode(GL_PROJECTIO...

Orthogonal projection and texture coordinates in opengl

I'm writing a 2D game in Opengl. I already set up the orthogonal projection so I can easily know where a quad will end up on screen. The problem is, I also want to be able to map pixels directly to texture coords, so I also applied an orthogonal transformation (using gluOrtho2d) to the texture. Now I can map pixels directly using integer...

Can't get my object to point at the mouse.

I'm using a combination of SDL and OpenGL in a sort of crash course project to teach myself how this all works. I'm really only interested in OpenGL as a way to use acceleration in 2D games so I just need this to work in a 2D plane. I have been having a lot of problems today with my current issue, I would like an object to point toward...

OpenGL Cheat Sheet?

First of all, I need to clarify that I'm not after the OpenGL Quick Reference Sheet. Has anyone come by a flow-chart-like cheat sheet for OpenGL rendering pipeline? I'm talking about the sheets like these: http://4.bp.blogspot.com/_2YU3pmPHKN4/S1KhDSPmotI/AAAAAAAAAcw/d38b4oA_DxM/s1600-h/DX11.JPG http://3.bp.blogspot.com/_2YU3pmPHKN4/S...

Rendering decals on 3d meshes

As in question, what are the best techniques for rendering lots (lots!) of decals on multiple meshes (which can move) and on terrain? ...

Performance considerations when mixing C++ and Objective-C in same file

I have some high-performance C++ that I need to interface with Objective-C, is there any performance penalty to just dumping this code into a .mm file that contains my Objective-C code vs. leaving this code in a separate .cpp file and extern-ing all the functions I need to call from the .mm file? ...

Transform shape built of contour splines to simple polygons

I've dumped glyphs from truetype file so I can play with them. They have shape contours that consist from quadratic bezier curves and lines. I want to output triangles for such shapes so I can visualize them for the user. Traditionally I might use libfreetype or scan-rasterise this kind of contours. But I want to produce extruded 3D mes...

OpenGL Pixel Format Attributes (NSOpenGLPixelFormatAttibutes) explanation?

Hi, I am not new to OpenGL, but not an expert. Many tutorials teach how to draw, 3D, 2D, projections, orthogonal, etc, but How about setting a the view? (NSOpenGLView in Cocoa, Macs). For example I have this: - (id) initWithFrame: (NSRect) frame { GLuint attribs[] = { //PF: PixelAttibutes NSOpenGLPFANoRecovery, ...

How to get Yaw, Pitch and Roll from a 3D vector

Hi all, I have a direction vector that applied to a position gives me the point at which the camera should look. How can I get from that yaw, pitch and roll in order to use glRotatef properly? Thanks in advance ...

What is the correct behavior when both a 1D and a 2D texture are bound in OpenGL?

Say you have something like this: glBindTexture(GL_TEXTURE_2D, my2dTex); glBindTexture(GL_TEXTURE_1D, my1dTex); glBegin... What is the correct OpenGL behavior? To draw the 1d texture, the 2d or both? For each active texture are there actually multiple textures that can be bound to it at the same time (i.e. a 1d, 2d, 3d cube map, etc.)...

OpenGL antialiasing not working

I'v been trying to anti alias with OGL. I found a code chunk that is supposed to do this but I see no antialiasing. I also reset my settings in Nvidia Control Panel but no luck. Does this code in fact antialias the cube? GLboolean polySmooth = GL_TRUE; static void init(void) { glCullFace (GL_BACK); glEnable (GL_CULL_FACE); glB...

Drawing and loading a GL_DEPTH_COMPONENT texture

I'm trying to load a depthbuffer from a file and copy it to the depth buffer instead of clearing it every frame. anyway, i'm a bit new to opengl, so i just tried to load my texture like this: glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, width, height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, DepthData); and i try to draw it lik...

Texture mapping an NGon?

I'm not sure how to go about figuring out how to map texture cooridnates for a 2D NGon (N sided polygon) How can this be done? The effect i'm trying to achieve is for the texture to fit on the polygon and stretch out accordingly so the whole texture fits on it. Thanks ...

flood fill algorithm

i want to implement the flood fill algorthm...so that when i get the x and y co-od of a point...it should start flooding from that point and fill till it finds a boundary but it is not filling the entire region...say a pentagon this is the code i am using void setpixel(struct fill fillcolor,int x,int y) { glColor3f(fillcolor.r,fill...

Preserving the GLBlendFunc

I need to preserve the current GlBlendFunc so can restore it after I do some work. It seems that this is not one of the attributes that can be saved with GLPushAttrib, is there some other similar method I can use to preserve the state? ...

GLSL shader render to texture not saving alpha value

UPDATE: Danvil solved it in a comment below. My texture format was GL_RGB not GL_RGBA which of course means that the alpha values aren't kept. Don't know why I didn't realize... Thanks Danvil. I am rendering to a texture using a GLSL shader and then sending that texture as input to a second shader. For the first texture I am using RGB c...

Easy framework for OpenGL Shaders in C/C++

I just wanted to try out some shaders on a flat image. Turns out that writing a C program, which just takes a picture as a texture and applies, let's say a gaussian blur, as a fragment shader on it is not that easy: You have to initialize OpenGL which are like 100 lines of code, then understanding the GLBuffers, etc.. Also to communicate...