Jump to content

  • Log In with Google      Sign In   
  • Create Account

SetsudanHana

Member Since 11 Apr 2014
Offline Last Active Jul 04 2014 01:16 PM

#5164555 opengl camera direction calculation for lookat

Posted by SetsudanHana on 03 July 2014 - 06:49 AM

The way i'm doing lookat for my camera:

void Camera::update()
{
	double sinAlfa = glm::sin(m_alfa * DAG2RAD);
	double sinBeta = glm::sin(m_beta * DAG2RAD);
	double cosAlfa = glm::cos(m_alfa * DAG2RAD);
	double cosBeta = glm::cos(m_beta * DAG2RAD);

	m_viewMatrix = glm::lookAt( m_position, glm::vec3(m_position.x + sinAlfa*cosBeta, m_position.y - sinBeta, m_position.z - cosAlfa*cosBeta), glm::vec3(0.0f, 1.0f, 0.0f));
}

just counting sin and cos function for each of angles of your camera, and with little math you can count point your camera is looking at. DAG2RAD is just pi/180 to convert my angle to radiants. I dont know if it solves your problem, but i hope it will help.




#5146313 GLSL weird '<' syntax error in vertex shader

Posted by SetsudanHana on 11 April 2014 - 09:52 AM

it works, i knew that it is something so simple... I'm just dumb




#5146235 GLSL weird '<' syntax error in vertex shader

Posted by SetsudanHana on 11 April 2014 - 07:05 AM

Ok, so i'm starting my adventure with openGL 4 and shaders. And i occured weird syntax error while compiling vertext shader.

Even when i take simple vertex shader:

#version 400
in vec3 vector_position;
void main()
{
    gl_Position = vec4(vector_position, 1.0);
}

i do get this error:

 

 

 

Vertex shader failed to compile with the following errors: ERROR: 0:1: error(#132) Syntax error: '<' parse error ERROR: error(#273) 1 compilation errors. No code generated

 

 

What is weird about this, my fragment shader is compiling without errors:

#version 400
out vec4 color;
void main()
{
    color = vec4(1.0, 0.0, 0.0, 1.0);
}

and gives this message:

 

 

 

compiler_log: Fragment shader was successfully compiled to run on hardware.

 

 

I tried testing those shaders by putting them as const char* in code, and they work fine.

To make it easier here are some additional informations:

 

  • using SDL 2.0
  • initializing OpenGL by SDL2.0
  • using GLEW to load extensions
  • reading text files by this function:

std::ifstream file(path);

if(!file.good())
{
    OutputDebugStringA("File not found");
    return nullptr;
}

std::stringstream stream ;
stream << file.rdbuf();

file.close();

return stream.str();

Thank you for fast answer.




PARTNERS