Results 1 to 5 of 5

Thread: Problem while working through learnopengl.com - Why does the rest of the scene turn b

  1. #1
    Newbie Newbie
    Join Date
    Apr 2017
    Posts
    4

    Question Why does the rest of the scene turn black when I try to load a model?

    Hi!
    I'm currently working my way through the tutorials at learnopengl.com. Everything went relatively smoothly up until now.
    I created a scene with two textured boxes, a floor and a single light source - Everything is working as expected.
    Next, I tried to load a model using the provided model.h class from learnopengl.com, which utilizes ASSIMP. Unfortunately, the rest of the scene now turns black when I render the model

    I've uploaded my main.cpp, vertex shader, fragment shader, and model.h+mesh.h here: https://gist.github.com/anonymous/b1...b661509d2df95d

    Can somebody shed some light on what I'm doing wrong?

    Thanks!

    EDIT: Here is a screenshot of the Scene without and with the model:
    h3JMlyS.jpg

    EDIT2: I got the suggestion that I'm probably not resetting all state information after drawing my objects. So I set a breakpoint at the end of the main loop and as it turns out, the first frame is rendered correctly, all subsequent frame fail.
    I have now added a call to glBindTexture(GL_TEXTURE_2D, 0) and glBindVertexArray(0) after every draw() call, but the result stays the same. I also checked the model loader, it too unbinds all textures after the draw call :/

    Which other state information is there to reset?

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Oct 2004
    Posts
    4,649
    Quote Originally Posted by JohannW
    Which other state information is there to reset
    Lots.

    You don't want to just start guessing and trying state. What I'd recommend is to capture a GL call trace of your application. Then you can look and see what state the third party library is setting. apitrace is one easy to use tool that will capture a GL call trace. From that you can dump it to text format, or you can bring it up in a GUI browser, and even replay it.

  3. #3
    Newbie Newbie
    Join Date
    Apr 2017
    Posts
    4
    Quote Originally Posted by Dark Photon View Post
    Lots.

    You don't want to just start guessing and trying state. What I'd recommend is to capture a GL call trace of your application. Then you can look and see what state the third party library is setting. apitrace is one easy to use tool that will capture a GL call trace. From that you can dump it to text format, or you can bring it up in a GUI browser, and even replay it.
    Thanks for your reply, I tried using apitrace, when I look at the frames I get a single white box.
    One of the error messages read:

    Code :
    major shader compiler error 1: SHADER_ID_LINK error has been generated. GLSL link failed for program 3, "": ERROR: Definition for "void main()" not found.

    When I run my application directly, at least the first frame is rendering correctly, therefore I'm not clear why there is a problem linking and compiling my shaders...

  4. #4
    Newbie Newbie
    Join Date
    Apr 2017
    Posts
    4
    Quote Originally Posted by Dark Photon View Post
    Lots.

    You don't want to just start guessing and trying state. What I'd recommend is to capture a GL call trace of your application. Then you can look and see what state the third party library is setting. apitrace is one easy to use tool that will capture a GL call trace. From that you can dump it to text format, or you can bring it up in a GUI browser, and even replay it.

    I tried using apitrace to debug my program, but unfortunately it doesn't show me a single correct frame. One of the first errors is:
    Code :
    major shader compiler error 1: SHADER_ID_LINK error has been generated. GLSL link failed for program 3, "": ERROR: Definition for "void main()" not found.

    As I said, when I'm running my program directly, it at least renders the first frame directly, therefore I'm not sure why running with apitrace produces shader linking errors all of a sudden.

    Very confusing!

    EDIT: I already checked the paths and set the working directory in Visual Studio to the location of the executable, and subsequently adjusted the paths in my program so that starting from within VS and starting the exe directly reference the same working directory.

  5. #5
    Newbie Newbie
    Join Date
    Apr 2017
    Posts
    4
    I just solved my problem - I was missing a call to glActiveTexture() prior to rendering my objects

Similar Threads

  1. Where to go after going through https://learnopengl.com/?
    By nikoniko in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 07-25-2017, 10:25 PM
  2. GLUT_KEY interferring with rest of keyboard
    By hkkho in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 11-15-2007, 08:54 AM
  3. Replies: 1
    Last Post: 09-15-2003, 11:33 AM
  4. fill the rest of a polygon
    By beginner620824 in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 04-17-2003, 05:09 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