Results 1 to 3 of 3

Thread: Help me Problem with Shader

  1. #1
    Newbie 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
    Join Date
    Oct 2004
    Posts
    4,651
    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
    Newbie OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,789
    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?

Similar Threads

  1. Shader problem
    By bobjamin in forum OpenGL: GLSL
    Replies: 1
    Last Post: 03-26-2013, 03:25 AM
  2. Shader problem
    By bobjamin in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 03-22-2013, 09:40 AM
  3. Shader Problem
    By glfreak in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 01-11-2011, 07:07 AM
  4. A problem about Cg shader
    By CGDeveloper in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 11-01-2006, 05:12 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean