我有点麻烦让我的灵魂去工作.当我初始化glew时,我收到一个错误:缺少GL版本.我也无法创建上下文:OpenGL未初始化.这是我的代码:
#include <GL\glew.h>
#include <GL\GLU.h>
#include <SDL2\SDL.h>
#include <SDL2\SDL_opengl.h>
#include <iostream>
#undef main
SDL_GLContext context;
SDL_Renderer * renderer;
SDL_Window * window;
int main(int argc, char *argv[]) {
//init SDL
if (SDL_Init(SDL_INIT_EVERYTHING) != 0) {
fprintf(stderr, "\n> Unable to initialize SDL: %s\n", SDL_GetError());
}
window = SDL_CreateWindow("Cri Engine 3D", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 800, 600, SDL_WINDOW_SHOWN);
if (window == nullptr)
{
printf("> Window could not be created! SDL Error: %s\n", SDL_GetError());
}
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
context = SDL_GL_CreateContext(window);
SDL_GL_MakeCurrent(window, context); …Run Code Online (Sandbox Code Playgroud)