• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

113 Neutral

About sufimaster

  • Rank
  1. OpenGL Orthographic matrix not working

    I managed to figure this out - apparently I was not accessing the matrix elements correctly - transposing their accessors = m03 instead of m30 for example for the translation matrix.  All is well now! Thanks everyone. 
  2. OpenGL Orthographic matrix not working

    This is how I send it to the shader: I know this part works since the perspective projection matrix works, but the ortho produces wierd results.    As for my previous projection matrix - this is my first projection matrix - so I am not multiplying it by anything before sending it tothe shader. Should I be? ///upload matrices to uniform varis in shader         GL20.glUseProgram(shaderObject.pId);                  projectionMatrix.store(matrix44Buffer);matrix44Buffer.flip();                     GL20.glUniformMatrix4(projectionMatrixLocation, false, matrix44Buffer);                  viewMatrix.store(matrix44Buffer);matrix44Buffer.flip();         GL20.glUniformMatrix4(viewMatrixLocation, false, matrix44Buffer);                  modelMatrix.store(matrix44Buffer);matrix44Buffer.flip();         GL20.glUniformMatrix4(modelMatrixLocation, false, matrix44Buffer);                           GL20.glUseProgram(0);  
  3. OpenGL Orthographic matrix not working

    Bump - anyone? This is super frustrating.  Is my ortho matrix still messed up?
  4. OpenGL Orthographic matrix not working

    Ok- so i used Shogun's method, I messed around with the camera position and near and far plane.   Now: near plane is 1f, far plane is 100f (though I dont see why this matters in an ortho projection) Camera is located at 0,0,-1   Sprite is at 0,0,0 dim: 10x10 pixels.   I can actually see it on the screen now, but it seems like everything is vanishing at the origin point, as attached:   This is supposed to be a quad, but the perspective is all wonky. Any idea what's going on now?
  5. OpenGL Orthographic matrix not working

    Ok, so I have a sprite with x,y,z (10,10,0)  with w/h 10fx10f   I have left as 0 and right as 680 top as as 480, bottom as 0   Still I see nothing.   Also, I am using lwjgl, in which if you have a matrix4f, I think m23 means 2nd column, 3rd row.                           Sprite sprite = new Sprite("assets/texture/redman.png", 50f, 50f, 10f, 10f );   projectionMatrix.m00 = 2/WIDTH;         projectionMatrix.m11 = 2/HEIGHT;         projectionMatrix.m22 = -2/(far_plane - near_plane);         projectionMatrix.m30 = -1;         projectionMatrix.m31 = -1;         projectionMatrix.m32 = -((far_plane + near_plane)/(far_plane - near_plane));         projectionMatrix.m33 = 1;          cameraPos = new Vector3f(0,0,-1); ...     //Translate camera         Matrix4f.translate(cameraPos, viewMatrix, viewMatrix);         //Scale, translate and rotate model         Matrix4f.scale(modelScale, modelMatrix, modelMatrix);         Matrix4f.translate(modelPos, modelMatrix, modelMatrix);         Matrix4f.rotate((float)Math.toRadians(modelAngle.z), new Vector3f(0,0,1), modelMatrix, modelMatrix);         Matrix4f.rotate((float)Math.toRadians(modelAngle.y), new Vector3f(0,1,0), modelMatrix, modelMatrix);         Matrix4f.rotate((float)Math.toRadians(modelAngle.x), new Vector3f(1,0,0), modelMatrix, modelMatrix);       ..
  6. OpenGL Orthographic matrix not working

    Well right now all I am trying to do is get a 40 pixel by 40 sprite displayed on the screen.  I have tried messing around with the size of the sprite to no avail.  Once I get home I will take a look at the code and give you some more details about it, but I have a feeling you ar right about the scaling/size/etc.
  7. OpenGL Orthographic matrix not working

    Thanks Shogun - but isn't that matrix the same as the one I have, if I have 0 as left and 680 as right for example (and same for top/bottom/height)?
  8. Hi all,   I am having trouble creating an orthographic projection in opengl (without using glOrtho).  And before anyone tells me to use glOrtho, lets just pretend I'm using opengl 3.0 as an exercise.  Here is the way I have set up my matrix:   projectionMatrix.m00 = 2/WIDTH; projectionMatrix.m11 = 2/HEIGHT; projectionMatrix.m22 = -2/(far_plane - near_plane); projectionMatrix.m32 = -((far_plane + near_plane)/(far_plane - near_plane)); projectionMatrix.m33 = 1; This is your typical ortho projection matrix, taken straight from the opengl spec def. for glOrtho.    When I set up a frustrum and use a perspective matrix, this works fine, but I can't use my regular screen coordinates properly.  But when I use the glOrtho matrix above, I see nothing but my background color. Anyone know what's going on? Is my matrix wrong?   My shader looks like this:     #version 150 core uniform mat4 projectionMatrix; uniform mat4 viewMatrix; uniform mat4 modelMatrix; in vec4 in_Position; in vec4 in_Color; in vec2 in_TextureCoord; out vec4 pass_Color; out vec2 pass_TextureCoord; void main(void){     gl_Position = in_Position;          //override gl position with new calculated position     gl_Position = projectionMatrix * viewMatrix * modelMatrix * in_Position;          pass_Color = in_Color;     pass_TextureCoord = in_TextureCoord; }   Any help appreciated.   Thanks!      
  • Advertisement