Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Help me Problem with Shader

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2017
    Posts
    1

    Help me Problem with Shader

    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
    Code :
    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();
    }

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    4,167
    Have you checked for GL errors?

    Why are you culling both front and back faces (see 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.

  3. #3
    Senior Member OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,728
    Quote Originally Posted by connan View Post
    I'm using the last version available for glfw, glew and glm on a Windows 10, x64 machine
    And what graphics hardware have you?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •