我的OPENGL GLFW窗口没有随时间更新颜色

时间:2018-06-21 19:42:57

标签: c++ opengl time graphics glfw

我正在遵循openGL精湛圣经第七版。

在我正在查看的项目中,应该使背景色在创建的窗口中随时间变化。 https://github.com/openglsuperbible/sb7code上提供了所有项目的源文件和我使用的设置。我正在Visual Studio 2017的发行版上运行它。

下面是输出窗口的输出:

'singlepoint.exe' (Win32): Loaded 'C:\Users\Danie\OneDrive\Documents\sb7code-master\sb7code-master\bin\singlepoint.exe'. Module was built without symbols.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntdll.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\KernelBase.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\user32.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\win32u.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\gdi32.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\gdi32full.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp_win.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ucrtbase.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\opengl32.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcrt.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\advapi32.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sechost.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\rpcrt4.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sspicli.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cryptbase.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\bcryptprimitives.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\vcruntime140.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\glu32.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\imm32.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\uxtheme.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\combase.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\winmm.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\winmmbase.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cfgmgr32.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\winmmbase.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\winmmbase.dll'
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\winmmbase.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\winmmbase.dll'
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\dwmapi.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msctf.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\oleaut32.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\System32\DriverStore\FileRepository\nvhm.inf_amd64_ebea877f10dfbbc7\nvinit.dll'. Cannot find or open the PDB file.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\version.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ig8icd32.dll'. Cannot find or open the PDB file.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\shell32.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\SHCore.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\windows.storage.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\shlwapi.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel.appcore.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\profapi.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\powrprof.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\fltLib.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\igdusc32.dll'. Cannot find or open the PDB file.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\wtsapi32.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\version.dll'
'singlepoint.exe' (Win32): Unloaded 'C:\Windows\System32\DriverStore\FileRepository\nvhm.inf_amd64_ebea877f10dfbbc7\nvinit.dll'
The thread 0x169c has exited with code 0 (0x0).
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\version.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\version.dll'
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\dxgi.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\d3d11.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ResourcePolicyClient.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\ResourcePolicyClient.dll'
'singlepoint.exe' (Win32): Loaded 'C:\Windows\System32\DriverStore\FileRepository\nvhm.inf_amd64_ebea877f10dfbbc7\nvinit.dll'. Cannot find or open the PDB file.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\version.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\igd10iumd32.dll'. Cannot find or open the PDB file.
'singlepoint.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\igd10iumd32.dll'
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\igd10iumd32.dll'. Cannot find or open the PDB file.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ncrypt.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\bcrypt.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\bcrypt.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\bcrypt.dll'
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntasn1.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\version.dll'
'singlepoint.exe' (Win32): Unloaded 'C:\Windows\System32\DriverStore\FileRepository\nvhm.inf_amd64_ebea877f10dfbbc7\nvinit.dll'
The thread 0x3168 has exited with code 0 (0x0).
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\TextInputFramework.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\CoreUIComponents.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\CoreMessaging.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntmarta.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\WinTypes.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\WinTypes.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\WinTypes.dll'
'singlepoint.exe' (Win32): Loaded 'C:\Windows\SysWOW64\WinTypes.dll'. Symbols loaded.
'singlepoint.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\WinTypes.dll'

我知道这些符号在输出中不必打印出来,因为它们主要用于调试DLL中是否有错误。但是我觉得问题的根源是这一行: 'singlepoint.exe'(Win32):已加载'C:\ Windows \ System32 \ DriverStore \ FileRepository \ nvhm.inf_amd64_ebea877f10dfbbc7 \ nvinit.dll'。找不到或打开PDB文件。 我可能完全错了,但这是我目前看不到的唯一一件事。

此项目的源cpp文件:

 /*
      Copyright © 2012-2015 Graham Sellers

      Permission is hereby granted, free of charge, to any person obtaining a
     copy of this software and associated documentation files (the "Software"),
      to deal in the Software without restriction, including without limitation
      the rights to use, copy, modify, merge, publish, distribute, sublicense,
      and/or sell copies of the Software, and to permit persons to whom the
      Software is furnished to do so, subject to the following conditions:

      The above copyright notice and this permission notice (including the next
      paragraph) shall be included in all copies or substantial portions of the
      Software.

      THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
      IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
      DEALINGS IN THE SOFTWARE.
     */
 #include <sb7.h>

class simpleclear_app : public sb7::application
{
    void init()
    {
        static const char title[] = "OpenGL SuperBible - Simple Clear";

        sb7::application::init();

        memcpy(info.title, title, sizeof(title));
    }

    virtual void render(double currentTime)
    {
        static const GLfloat color[] = { (float)sin(currentTime*20)*2.5f+.5f,
                                         (float)cos(currentTime*20)*2.5f+.5f,
                                         0.0f, 
                                         1.0f};
        glClearBufferfv(GL_COLOR, 0, color);
    }
};

DECLARE_MAIN(simpleclear_app)

1 个答案:

答案 0 :(得分:1)

virtual void render(double currentTime)
{
    static const GLfloat color[] = { (float)sin(currentTime*20)*2.5f+.5f,
                                     (float)cos(currentTime*20)*2.5f+.5f,
                                     0.0f, 
                                     1.0f};
    glClearBufferfv(GL_COLOR, 0, color);
}

您已将color标记为static。这意味着它将仅在第一次调用此函数时接收一个值,并且永远不会再次更新(并且因为它被标记为const,所以初始化后就不能更改它,而无需依赖未定义的行为)。删除static关键字,此功能应按您期望的方式运行。

此外,“无法找到或打开PDB文件”错误是不相关的,与您的问题无关。这样做的唯一结果是,在调试器中单步执行某些功能会更加困难。