c++ - OpenGL项目崩溃
问题描述
屏幕截图 此代码编译时没有错误或警告,但无法运行,应用程序立即崩溃。
#include <GL/glut.h>
int WinWidth = 640,
WinHeight = 480;
int WinFar = 10;
void DrawPoint(float x, float y)
{
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_POINTS);
glVertex2f(x, y);
glEnd();
}
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
//Draws
DrawPoint(0, 0);
//
glFlush();
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(WinWidth, WinHeight);
glutInitWindowPosition(150, 150);
glutCreateWindow("Lesson 01");
glClearColor(0, 0, 0, 1.0);
glOrtho(-WinWidth/2, WinWidth/2, WinHeight/2, -WinHeight/2, -WinFar/2, WinFar/2);
glutDisplayFunc(display);
glutMainLoop();
return 0;
}
它以返回值 3221225477 崩溃。我做错了什么?
程序收到信号 SIGEGV,当我在调试模式下运行时出现分段错误
解决方案
推荐阅读
- github-api - 使用 api 获取 github repo 目录中每个文件的内容
- c# - 如何使用 .NET MAUI Preview 7 创建 DataGrid?
- javascript - 在 32 位 Linux 上安装 Node.js
- node.js - 当我使用_moduleAliases 时,pkg 找不到模块'@...?
- python - Django url 模式不是注册的视图函数或模式
- c - 我想在 C 中为二维数组创建一个通用选择器
- c# - 如何在词位上拆分字符串?
- java - 注销后,我可以单击浏览器返回按钮返回站点
- python - python - 如何在python中创建一个如果引发异常则通过的测试用例?
- visual-studio-code - 为什么 VS Code 中的 LiveServer 扩展无法打开正确的 HTML?