【发布时间】:2020-04-27 06:22:50
【问题描述】:
我知道之前有人问过这个问题,但大多数时候答案只是添加延迟或事件循环。但是我添加了一个事件循环并且窗口没有显示。只有控制台。我在 Visual Studio 2019 中运行这个程序。
#include <iostream>
#include "GL/glew.h"
#define SDL_MAIN_HANDLED
#include "SDL.h"
int main() {
SDL_Window* window;
SDL_Init(SDL_INIT_EVERYTHING);
//fenster erstellen
window = SDL_CreateWindow("C++ OpenGL", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_UNDEFINED, 800, 600, SDL_WINDOW_OPENGL);
//opengl context setzen
SDL_GLContext glContext = SDL_GL_CreateContext(window);
bool close = false;
while (!close) {
SDL_Event event;
while (SDL_PollEvent(&event)) {
if (event.type == SDL_QUIT) {
close = true;
}
}
if (close) {
break;
}
}
return 0;
}
【问题讨论】: