Jump to content

  • Log In with Google      Sign In   
  • Create Account


Sponji

Member Since 14 Jan 2011
Offline Last Active Today, 06:47 AM
-----

Posts I've Made

In Topic: GLSL Lighting

27 February 2014 - 12:20 AM


glm::mat3* MV = new glm::mat3 (modelview[16]);
setUniform(m_shader, "normalMatrix", -glm::transpose(glm::inverse(*MV)));

 

Is there a reason you are using new there? You are also passing just one float to the mat3's constructor, and it's out of bounds.

I would suggest doing something like glm::transpose(glm::inverse(glm::mat3(modelview))). Also, I think you should normalize your normals after the loop where you calculate them.

 

You can use &matrix[0][0] or glm::value_ptr(matrix) to access a glm matrix, you don't have to use your own float arrays. But if you really want to, you can convert a float array to mat3 or mat4 with make_mat3 and make_mat4. Just include glm/gtc/type_ptr.hpp to get access to those functions.

 

Edit. I meant that modelview is glm::mat4. Also, maybe a better example code:

glm::mat4 modelview_matrix; 
glGetFloatv(GL_MODELVIEW_MATRIX, &modelview_matrix[0][0]);
glm::mat3 normal_matrix = glm::transpose(glm::inverse(glm::mat3(modelview_matrix)));
const float *pointer = glm::value_ptr(normal_matrix);

In Topic: C++ IDEs for Linux

25 February 2014 - 06:11 AM

My vote goes for KDevelop, it's just awesome.

 

One thing that sucks about IDEs for Linux is the autocompletion/intellisense thingie for macros and function pointers. It's sometimes quite annoying to program OpenGL related stuff if you've got used to get the information about function's parameters from the IDE. I've tried a lot of IDEs for Linux and all of them seem to have problems with the same thing. Visual Studio might be the the only one that handles this well. Of course, please tell if you know/find one which handles this well.


In Topic: Help with GLFW?

20 February 2014 - 03:57 AM

I think it's impossible to just link newer OpenGL functions into your program, because those have to be asked from the driver.

 

Few links about this stuff:

https://www.opengl.org/wiki/Load_OpenGL_Functions

https://www.opengl.org/wiki/OpenGL_Loading_Library


In Topic: Help with GLFW?

20 February 2014 - 12:17 AM

Normally you have to ask the needed function pointers from the driver with wglGetProcAddress/glXGetProcAddress/whatever, but it's much easier to use somekind of library to do that for you. I'd use GLEW to do that, just include glew.h and call glewInit() after you've initialized your OpenGL context.


In Topic: drawing model issue

19 February 2014 - 04:51 AM

Just convert quads to triangles when you're loading the model.


PARTNERS