PDA

View Full Version : Help me Problem with Shader



connan
06-09-2017, 02:37 AM
Hi,

I can't run properly the following code with shaders. If a activate the "old" opengl approach it work just fine.
I can move the camera around and everything work as it should be (Is a simply square in the plane XY with lengths 2000).

I'm using the last version available for glfw, glew and glm on a Windows 10, x64 machine

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor(1, 1, 1, 1);
glEnable(GL_DEPTH_TEST);
glCullFace(GL_FRONT_AND_BACK);
glDrawBuffer(GL_FRONT_AND_BACK);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

m_perspective = glm::perspective(5.0f, m_sizeEvent.width() / (float)m_sizeEvent.height(), 10.0f, 10000.0f);
m_lookAt = glm::lookAt(m_camera.position(), m_camera.lookingAt(), glm::vec3(0.0f, 0.0f, -1.0f));;

if (true)
{
//new opengl
glm::mat4 transformation = m_perspective * m_lookAt;

for (Meshes::Item &mesh : m_meshes)
mesh->render(transformation);
}
else
{
// old opengl
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMultMatrixf(&m_perspective[0][0]);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glMultMatrixf(&m_lookAt[0][0]);

for (Meshes::Item &mesh : m_meshes)
mesh->oldRender();
}

Dark Photon
06-09-2017, 05:20 AM
Have you checked for GL errors (https://www.khronos.org/opengl/wiki/OpenGL_Error)?

Why are you culling both front and back faces (see glCullFace (https://www.khronos.org/opengl/wiki/GLAPI/glCullFace)).

Also, in the future when something doesn't work, it'd be good to state in detail 1) what specifically doesn't work (what are you seeing), and 2) what you've tried to diagnose the problem.

mhagain
06-09-2017, 08:36 AM
I'm using the last version available for glfw, glew and glm on a Windows 10, x64 machine

And what graphics hardware have you?