声明重要的oglplus对象会引发异常oglplus::MissingFunction
Declaring important oglplus objects throws the exception oglplus::MissingFunction
我想使用OpenGL和C++OpenGL包装库oglplus创建C++程序,但我无法使用oglpluss运行程序,因为当我声明某些oglplus::MissingFunction对象时,总是抛出异常。
我的操作系统是archlinux。
我的程序会编译但不会运行。例如:
#include <cassert>
#include <iostream>
#include <GL/glew.h>
#include <GL/glut.h>
#include <oglplus/all.hpp>
int main()
{
oglplus::VertexShader vs;
return 0;
}
这个程序可以编译,但当我运行它时,抛出了异常oglplus::MissingFunction。
由于我的程序是编译的,我相信这意味着我安装了必要的程序包,并链接了正确的库。我只是不明白为什么会抛出异常。异常的描述表明,抛出异常意味着用于调用OpenGL函数的一些指针未初始化。
到目前为止,我已经观察到当我声明类型为的对象时抛出了oglplus::MissingFunction
- oglplus::顶点着色器
- oglplus::FragmentShader
- oglplus::程序
- oglplus::程序
- oglplus::VertexArray
- oglplus::缓冲区
关于如何解决这个问题有什么建议吗?
在使用任何OpenGL资源之前,您需要创建OpenGL上下文。此示例显示如何使用GLUT:设置上下文
https://github.com/matus-chochlik/oglplus/blob/develop/example/standalone/001_hello_glut_glew.cpp
本质上,你需要这个部分:
#include <iostream>
#include <GL/glew.h>
#include <GL/glut.h>
#include <oglplus/all.hpp>
int main(int argc, char* argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA);
GLint width = 800;
GLint height = 150;
glutInitWindowSize(width, height);
glutInitWindowPosition(100,100);
glutCreateWindow("OGLplus+GLUT+GLEW");
if(glewInit() == GLEW_OK) try
{
// Your code goes here.
return 0;
}
catch(oglplus::Error& err)
{
std::cerr << "OGLPlus error." << std::endl;
}
return 1;
}
相关文章:
- 处理多个异常集合的C++方法
- 我在c++代码中生成了一个运行时#3异常
- 孤立代码块在结构中引发异常
- C++中的赋值发生,尽管右侧出现异常
- 从构造函数抛出异常时如何克服内存泄漏
- 异常属于C++中的线程还是进程
- 当类定义不可见时捕获异常
- 引发异常:读取访问冲突**dynamicArray**为0x1118235.发生
- 为什么异常不退出程序?
- 为什么我应该在异常处理中使用std::cerr而不是std::cout
- 如何修复链表类实现的未处理异常0xDDDDDDDD
- 关于:C++中异常对象的范围:为什么我没有得到副本?
- 是什么导致了Unity 3D中的"错误线程异常"?
- 如何将strftime中的格式错误作为异常捕获
- 创建具有 new in 函数和"this is nullptr"异常的对象
- 尝试使用智能指针时引发异常
- 函数如何通知用户它基于函数原型抛出异常?
- 是否值得降低我的代码的可读性,以便在出现内存不足错误时提供异常安全性?
- 当我使用 C++ 中的 C# dll 来使用 Selenium 时,存在异常处理问题
- 声明重要的oglplus对象会引发异常oglplus::MissingFunction