# Tagged Questions

86 views

### What types of matrices are needed for game and graphics programming?

I am writing a 3D math library for general game development and want to know what type of Matrix classes I should include. Is just a 4x4 matrix enough, or must I provide 3x4 and dedicated rotational ...
98 views

### GLM/OpenGL: How Can I Prevent Vector Magnitude From Increasing While Rotating Bones in Skeletal Rig?

ANSWER AT THE BOTTOM OF THIS QUESTION I have been reading tutorials, articles, questions on StackExchange and books all with the subject of skeletal rigging. I have boiled my program down to just the ...
143 views

### OpenGL - Calculating camera view matrix

Problem I am calculating the model, view and projection matrices independently to be used in my shader as follows: gl_Position = projection * view * model * vec4(in_Position, 1.0); When I try to ...
139 views

### How to achieve cavalier projection using OpenGL fixed pipeline?

I want to make a quick demo program showing a cube, or a user loaded model, rotating in screen rendered with one of three projections: perspective, isometric and cavalier. Using the fixed pipeline, ...
90 views

### How do I check why is no output on screen?

I'm using OpenGL 3.3+, and I'm trying to create an orthographic projection to draw on screen. I have the model data in a buffer: X Y 0, 0 50, 100 100, 0 And I create my Model-View-Projection ...
278 views

### GLSL: can i use matrix transformation functions in vertex shader?

I have a working OpenGL code where i render a terrain with some trees. I am doing all the matrix mathematics on the client side. Because of which the frame rate of my app is very low, around 25-30 ...
84 views

### What dimensions should you use for a perspective projection frustum?

What dimensions should you use for a perspective projection frustum? Initially I created a perspective matrix based on the width and height of the screen, with a calculated zNear value based on a ...
128 views

### OpenGL: glRotatef cause performance drop while rotating -x and -y

I have made a rotating cube and I got some performance drops while using two glRotatef calls. So basically this code is giving me 80FPS: //code 1 GLrotate_x += 0.4f; GLrotate_y += 0.4f; ...
81 views

### Distorted LookAt When Looking Up or Down?

I have a weird problem and I have no idea what's going on with it. Recently started doing some OpenGL programming, going pretty well, hit some rough spots but worked my way through them and otherwise ...
1k views

### Why do we use 4x4 matrices to transform things in 3D?

To translate a vector by 10 unit in the X direction, why do we have to use a matrix? We can just add 10 to the mat[0][0], and we got the same result too.
111 views

### Alter a model-view-projection matrix

I have a model-view-projection matrix created based upon my camera. Is it possible to make alterations to it after it was computed to affect the corners of the resulting camera frustrum? For example, ...
349 views

### Screen space decals, converting world to decal space

I'm trying to do screen space deferred decals following the presentation made by Pope Kim about SSDs in WH40K: Space Marine (link). I've gotten to the point where I can render a decal if the bounding ...
1k views

### What does a matrix represent?

I began learning OpenGL recently and am having problems visualizing what matrices are and their role in computer graphics. Given the template of a 4x4 matrix like this: I would assume that each ...
584 views

### Identity matrix. Confusion. What does it really do

I understand identity matrix is like multiplying to 1. But i can't really understand why would you multiply an a matrix that will only result to the same. Also im messing up with an OpenGL code and ...
114 views

### Why my camera sees what is behind it?

I am building a minimal opengl viewer and I am puzzled by what I see : the camera see the (test) object that is behind her. the front and back of the camera looks reverted. I am wondering what could ...
366 views

### switching from third person view to first person view

I have done a scene in opengl where I'm using a third person camera (that I can control with the mouse). Then, inside it, it has the camera of the first view (that I called thirdpersonCamera, see the ...
1k views

### Replace glTranslatef and glRotatef with matrixes

I'm not an opengl expert, and, as a novice, I prefer to practice a little bit with the old opengl just to be sure to understand correctly the basic concept of computer graphics before deal with ...
1k views

### Combining rotation,scaling around a pivot with translation into a matrix

In short: I need to combine rotation (in the form of a quaternion), scaling around a pivot point along with translation into a transformation matrix. The long: I am trying to implement a proprietary ...
129 views

### Matrix array doesn't seem to get populated

I'm trying to stream an array of matrices to a vertex shader, but it seems that only the first matrix works. What could be the problem? I suspect that I upload the matrices in a wrong way. C# ...
82 views

### Rotate view matrix based on touch coordinates

I'm working on an Android game where I need to rotate the camera around the origin based on the user dragging their finger. My view matrix has initial position of sitting on the negative z and facing ...
426 views

### How to do directional per fragment lighting in world space?

I am attempting to create a GLSL shader for simple, per-fragment directional light. So far, after following many tutorials, I have continually ran into the issue: my light is specified in world ...
230 views

### Is this Rotation Matrix correct?

I'm having heavly troubles with setting up a View Matrix and a Projection Matrix. It simply doesnt work. So I think my problem is related to my rotationMatrix function. I'm using this tutorial to ...
126 views

### Manual GLU.gluUnproject

Before I used GLU.gluUnproject to calculate my picking ray in my OpenGL game. Recently I switched to my own calculated matrices, and now I can forget the gluUnproject. How can I calculate the picking ...
3k views

### OpenGL - Understanding the relationship between Model, View and World Matrix

I am having a bit of trouble understanding how these matrixes work and how to set them up in relation to one another to get a proper system running. In my understanding the Model Matrix is the matrix ...
149 views

### OpenGL Calculate Matrices

Im trying to switch from the glTranslate etc to my own Matrices, but for some reason it does not work. Here are my 2 functions to create the view- and projection matrix: public Matrix4f ...
158 views

### Translating Viewmatrix is inverted, why?

So I've defined a Projectionmatrix, Viewmatrix and a Modelmatrix using OpenGL (LWJGL). But when I translate my Viewmatrix to +X it moves my object to the right (hence my camera is moving to the ...
175 views

### Camera not strafing (GLSL)

I use this code in my GLSL vertex shader, where v_position is the vertex position: gl_Position = v_position * u_camera; and set u_camera as follows: meshShader.setUniformMatrix("u_camera", ...
190 views

### Box2D OpenGL debug renderer convert box2d coordinates to world space

I made an OpenGL 3.x renderer for Box2D's debug draw (b2Draw base class). Unfortunately I've tried for a while now to convert the box2D units, which are meters to my internal units which are pixels. I ...
249 views

### Directional light and matrix issues

I'm trying to implement basic directional lightning in OpenGL 3.3 by emulating the logic shown in this guide: http://www.arcsynthesis.org/gltut/Illumination/Tutorial%2009.html I do not understand ...
222 views

### Ways to “invert Z-axis” in shader-based core-profile OpenGL?

In my hobbyist shader-based (non-FFP) GL (3.2+ core) "engine", everything in world-space and model-space is by design "left-handed" (and to stay that way), so X-axis goes from -1 ("left") to 1 ...
209 views

### Y Axis inverted on vertex output

I've got my project running and somehow it seems my vertex y components are inverted. 10 in the positive on Y goes down and 10 negative on the Y axis goes up. I can't find anything with the ...
318 views

### How should I organize my matrices in a 3D game engine?

I'm working with a group of people from around the world to create a game engine (and hopefully a game with it) within the next upcoming years. My first task is to write a camera class for the engine ...
984 views

### How can I generate a view or projection matrix for OpenGL 3.+

I'm transitioning from OpenGL 2 to OpenGL 3.+ and to GLSL 1.5. I'm trying to avoid using the deprecated features. My question how do we now generate the view or projection matrix. I was using the ...
1k views

### The purpose of using invert and transpose

In openGl ES and the World of 3D - why use the invers matrix? The thing is that I dont have any intuition to, why it is used, therefore please correct me: As fare as I understand, it is used in ...
208 views

### How do I convert my matrix from OpenGL to Marmalade?

I am using a third party rendering API, Marmalade, on top of OpenGL code and I cannot get my matrices correct. One of the API's authors states this: We're right handed by default, and we treat y ...
7k views

### How does gluLookAt work?

From my understanding, gluLookAt( eye_x, eye_y, eye_z, center_x, center_y, center_z, up_x, up_y, up_z ); is equivalent to: glRotatef(B, 0.0, 0.0, 1.0); ...
14k views

### Why do we move the world instead of the camera?

I heard that in an OpenGL game what we do to let the player move is not to move the camera but to move the whole world around. For example here is an extract of this tutorial: OpenGL View matrix ...
891 views

### OpenGL, objects disappear at a certain z distance

I'm writing a managed OpenGL library in C++, and I'm having a pretty annoying problem. Whenever I set an objects Z coordinate to -2.0 or lower, the object disappears. And at coordinates 0 through ...
425 views

### Correct Rotation and Translation with a 4x4 matrix

I am using a 4x4 matrix to transform verts in a shader. I multiply an identity matrix by a rotation matrix by a translation matrix. I am trying to first rotate the verts and then translate them, ...
1k views

### OpenGL matrix vs DirectX matrix

I'm working on an animation and model exporter from Maya to use within my game. Currently, models work perfectly, and animations have some issues with the joints. Since Maya works in an OpenGL ...
216 views

### Why doesn't my MatrixStack class work? [closed]

I've been trying to get openGLES2 to work on my Android device and this is starting to drive me insane. I've spent well over ten hours now trying to get this to work. I just don't understand anymore. ...
418 views

### Finding a suitable axis-angle to avoid gimbal lock

In OpenGL the camera faces the -z axis with the +y axis pointing up. I am using quaternions to represent the orientation of my objects (which works well) and am trying to do the same for the camera. I ...
957 views

### Multiplication for MVP matrices: Any benefits to doing so within the vertex shader?

I'd like to understand under what circumstances (if any) it is worth doing MVP matrix multiplication inside a vertex shader. The vertex shader is run once per vertex, and a single mesh typically ...
1k views

I have a Collada file with a rigged mesh. I've read the node tags in the library_visual_scenes tag and extracted the matrix for each node and stored everything in a hierarchical bone structure. My ...
1k views

### Should the modelview and projection matrices be calculated in the shader or on the CPU?

At minimum I would have a camera with rotation and world position; projections parameters such as angle of view and perspective vs. orthographic; and meshes with scale, angle, and world position. ...
178 views

### Rotation going wrong

I'm calculating matrices by hand. Translations are fine: void Translate (float x, float y, float z, float[4][4] m) { Identity (m); m[3][0] = x; m[3][1] = y; m[3][2] = z; } If ...
149 views

### Calculate vertex coordinates

Newbie here! I need to know the effective coordinates of a triangle after applying transformations (rotations & translations) to the current (MODELVIEW) matrix. That is, given a vertex P, I ...
316 views

### Translation from one coordinate system to another having Z-offset issues

I'm using ARToolkit to do an augmented reality application, but my problem is really with the 3D coordinates. In this application, I use my webcam to generate the scene. I have two markers (printed ...