OpenGL with gl3w
OpenGL with gl3w
我正在努力学习OpenGL。我使用SFML窗口模块作为上下文,使用gl3w作为加载库。我经常使用SFML,所以按照本教程将其设置为OpenGL不是问题:http://www.sfml-dev.org/tutorials/2.0/window-opengl.php
我可以运行示例代码没有任何问题。我链接了所有我需要的OpenGL (opengl32)。Lib和glu32。Lib + sfml*. Lib).
然后我按照这个答案得到了gl3w:如何在Windows上设置gl3w ?
但是现在如果我试着运行这些代码这些代码主要是SFML
中的示例代码#include <SFML/gl3w.h>
#include <SFML/Window.hpp>
static const GLfloat red[] = { 1.0f, 0.f, 0.f, 1.f };
int main()
{
// create the window
sf::Window window(sf::VideoMode(800, 600), "OpenGL", sf::Style::Default, sf::ContextSettings(32));
window.setVerticalSyncEnabled(true);
gl3wInit(); //ignore return value for now
// load resources, initialize the OpenGL states, ...
// run the main loop
bool running = true;
while (running)
{
// handle events
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
{
// end the program
running = false;
}
else if (event.type == sf::Event::Resized)
{
//adjust the viewport when the window is resized
glViewport(0, 0, event.size.width, event.size.height);
}
}
glClearBufferfv(GL_COLOR, 0, red);
// end the current frame (internally swaps the front and back buffers)
window.display();
}
// release resources...
return 0;
}
我得到以下链接器错误。
1>OpenGL.obj : error LNK2019: unresolved external symbol _gl3wInit referenced in function _main
1>OpenGL.obj : error LNK2001: unresolved external symbol _gl3wViewport
1>OpenGL.obj : error LNK2001: unresolved external symbol _gl3wClearBufferfv
我仔细检查了链接库是否正确。
我在Windows 7上使用Visual Studio 2013。
有谁知道我做错了什么吗?您忘记编译gl3w了
假设你已经:
- 抓取python脚本
- 运行它:
python gl3w_gen.py
- 查找
gl3w.h
glcorearb.h
和gl3w.c
文件生成
有两种方法:
第一。只要将这些文件包含在项目中,它就会与您自己的源代码一起编译。注意,您需要保留GL
文件夹或手动修复gl3w.c
中的包含。
第二种方式。创建新项目,将所有三个文件添加其中,并将其编译为静态库。然后将其链接到您的应用程序(或者只是在命令行或makefile中编译)。
编码快乐!
相关文章:
- Problems with std::cin.fail()
- 应用程序崩溃并显示"symbol _ZdlPvm, version Qt_5 not defined in file libQt5Core.so.5 with link time reference"
- 这对"With a stackless coroutine, only the top-level routine may be suspended."意味着什么
- Boost.TEST with CLion: "Test framework quit unexpectedly"
- 避免碎片化的ClientHellos with OpenSSL (DTLS)
- Issues with Win32 ReadProcessMemory API
- Qt with WinAPI MouseProc
- [[maybe_unused]] with structured_binding?
- Issue with WriteProcessMemory
- OpenCV RTP-Stream with FFMPEG
- "Unable to start debugging. No process is associated with this object." - 在Visual Studio Code中使用GDB
- std::adjacent_difference with std::chrono time_point
- DLL Made with CMake 使程序崩溃
- QtCreator with C 库中的链接器问题
- SHBrowseForFolder with BIF_BROWSEFORCOMPUTER and SHGetPathFr
- specialized std::default_delete with QQmlComponent
- VS2019 - Sudo Remote Debugging on Linux with Cmake project
- Inference pytorch C++ with alexnet and cv::imread image
- Pybind11: init<> with lambda
- OpenGL with gl3w