Jump to content

  • Log In with Google      Sign In   
  • Create Account

João Martins

Member Since 31 Mar 2012
Offline Last Active Apr 04 2012 02:46 PM

Topics I've Started

Answer some NOOB question xD

31 March 2012 - 07:45 PM

Hi all,

I'm relatively new to OpenGL and GLSL, and I have some work to be delivered by Monday, and I'm having a trouble that I can't figure out, and hope you guys could help.

So I have two meshes, a spaceship and a sun, loaded, two different VAO (I know, lame, but for now I can't do different), and in my display func, I'm doing some matrix transformations to these 2 meshes, different to booth. They're good for each of the meshs but when I put the two together, the spaceship got's translated somewhere near the sun, and it is supposed to be at the origin. I know this is probably by my vertex shader, I will paste the code:

layout (location=0) in vec4 vertex;
layout (location=1) in vec3 color;
layout (location=2) in vec4 vertex2;
layout (location=2) in vec3 color2;
out vec4 color_vf;
out vec4 color_vf2;
uniform mat4 pMatrix;
uniform mat4 vMatrix;
uniform mat4 mMatrixSpaceship;
uniform mat4 mMatrixSun;
void main()
color_vf = vec4(color,1.0f);
color_vf2 = vec4(0.5f , 0.5f ,0.0f ,1.0f);

gl_Position =(pMatrix * vMatrix * mMatrixSun * vertex2) + (pMatrix * vMatrix * mMatrixSpaceship * vertex)  ;


The vertex is the spaceship, vertex2 the sun. pMatrix perspective, and vMatrix view, the rest I think is fairly obvious.
I've tried to render the two separately, but I can't find any USEFUL documentation in the net (at least the way I'm learning, wich is kind onorthodox :/)

So I would appreciate if any of you guys didn't mind helping a bit, I would be very thankful, and I think this is a good comunity to be, maybe one day I'll answer some of my one :)