Vertex Shader

Code :

#version 330
in vec3 vertIn;
in vec2 uvIn;
uniform mat4 proj;
uniform mat4 model;
uniform mat4 view;
uniform float scale;
out vec2 uv;
void main()
{
mat4 model_view = view * model;
//settting the rotational part of the matrix to the identy matrix * scale
model_view[0][0] = scale; // 1 * scale
model_view[0][1] = 0;
model_view[0][2] = 0;
model_view[1][0] = 0;
model_view[1][1] = scale; // 1 * scale
model_view[1][2] = 0;
model_view[2][0] = 0;
model_view[2][1] = 0;
model_view[2][2] = scale; // 1 * scale
model_view *= scale;
gl_Position = proj * model_view * vec4(vertIn, 1);
uv = uvIn;
}

I can get a vector from the camera position to the center of the object but from there I don't know where to head. Maybe create a rotation matrix from that???

Here are the images showing the problem.

The first one is the viewing with the sun as the focus, however when I focus other planes, the billboard doesn't point towards the camera.

imgurDOTcom/a/Lp0mZ ( i wish they weren't so restrictive with links and images) ]]>

Code :

Code :

void drawCircle(float cx, float cy, float r, float num_segments){
glBegin(GL_LINE_LOOP);
for(int i = 0; i < num_segments; i++){
float theta = 2.0f * PI * i / num_segments;
float x = r * cosf(theta);
float y = r * sinf(theta);
glVertex2f(x + cx, y + cy);
}
glEnd();
}

This is newbie question but how does above code work? why is this function able to draw a circle?

Where can I learn computer graphical maths such as above? any recommended website/videos?

Code :

glm::mat4 testprojMat = glm::perspective(60.0f, 16.0f/9.0f, 0.001f, 1000.0f);
glm::mat4 testviewMat = glm::lookAt(glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f), glm::vec3(0.0f, 1.0f, 0.0f));
testShader.updateUniform("modelMat", glm::mat4(1.0f));
testShader.updateUniform("viewMat", testviewMat);
testShader.updateUniform("testprojMat", testprojMat);
// Triangle:
std::vector<glm::vec3> testVerts;
std::vector<unsigned short> testInds;
testVerts.push_back(glm::vec3(-1.0f, 0.0f, 1.0f));
testVerts.push_back(glm::vec3(1.0f, 0.0f, 1.0f));
testVerts.push_back(glm::vec3(0.0f, 1.0f, 1.0f));
testInds.push_back(0); testInds.push_back(1); testInds.push_back(2);
glGenVertexArrays(1, &testVao); glBindVertexArray(testVao);
glGenBuffers(1, &testVbo); glGenBuffers(1, &testIbo);
glBindBuffer(GL_ARRAY_BUFFER, testVbo); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, testIbo);
glBufferData(GL_ARRAY_BUFFER, sizeof(glm::vec3)*testVerts.size(), testVerts.data(), GL_STATIC_DRAW);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(unsigned short)*testInds.size(), testInds.data(), GL_STATIC_DRAW);
glEnableVertexAttribArray(0);// positions
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(glm::vec3), (GLvoid*)0);

Code :

//vertex shader
#version 330
//shaderName testShader
layout (location = 0) in vec3 in_Position;
uniform mat4 projMat;
uniform mat4 viewMat;
uniform mat4 modelMat;
out vec3 ex_Pos;
void main(void)
{
ex_Pos = in_Position;
gl_Position = (projMat * viewMat * modelMat) * vec4(in_Position, 1.0);
}
//fragment shader
#version 330
in vec3 ex_Pos;
out vec4 out_Color;
void main(void)
{
out_Color = vec4(1.0, 0.0, 0.0, 1.0);
// Differentiate edge vertices of triangle, to tell which way it's oriented:
if (ex_Pos.x < 0.0){
out_Color = vec4(0.0, 1.0, 0.0, 1.0);
}
}

Switching the up vector in glm::lookat to (0,-1,0) gives the triangle the right way around, but that's contrary to the results the code gave me on my old machine. Was there some shift between OGL 3.1 and 3.3 I'm overlooking? ]]>