私は現在、OpenGLを使用しているSDLウィンドウを開発中です。エラーチェックを使用したときにSDL_GL_SetAttribute(colours here... r, g, b etc.)
を初期化すると、SDL_GL_GetAttribute()
はアルファ、バッファ、r、g、bについて0を返し、SDLウィンドウで基本的なOpenGL三角形を作成できなくなっていると思います...わかりません。SDL_GL_GetAttribute()はゼロを出力しますか?
この問題を解決する方法についていくつか指示がありました。
ここでOpenGLとSDLを初期化するため、以下のコードスニペットです:
void Window::InitialiseSDL()
{
SDL_Init( SDL_INIT_AUDIO | SDL_INIT_EVENTS | SDL_INIT_GAMECONTROLLER
| SDL_INIT_HAPTIC | SDL_INIT_JOYSTICK | SDL_INIT_TIMER
| SDL_INIT_VIDEO );
Has_SDL_Init = SDL_WasInit(SDL_INIT_EVERYTHING);
if (!(Has_SDL_Init & SDL_INIT_AUDIO)) // You may be thinking wtf here? But! if one sub system were to break, i'd know which one it exactly was.
{
error.Fatal_SDL_Error("Class Window.h ----> InitialiseSystem() ----> SDL_INIT_AUDIO Has failed to initialise.", state);
}
if (!(Has_SDL_Init & SDL_INIT_EVENTS))
{
error.Fatal_SDL_Error("Class Window.h ----> InitialiseSystem() ----> SDL_INIT_EVENTS Has failed to initialise.", state);
}
if (!(Has_SDL_Init & SDL_INIT_GAMECONTROLLER))
{
error.Fatal_SDL_Error("Class Window.h ----> InitialiseSystem() ----> SDL_INIT_GAMECONTROLLER Has failed to initialise.", state);
}
if (!(Has_SDL_Init & SDL_INIT_HAPTIC))
{
error.Fatal_SDL_Error("Class Window.h ----> InitialiseSystem() ----> SDL_INIT_HAPTIC Has failed to initialise.", state);
}
if (!(Has_SDL_Init & SDL_INIT_JOYSTICK))
{
error.Fatal_SDL_Error("Class Window.h ----> InitialiseSystem() ----> SDL_INIT_JOYSTICK Has failed to initialise.", state);
}
if (!(Has_SDL_Init & SDL_INIT_TIMER))
{
error.Fatal_SDL_Error("Class Window.h ----> InitialiseSystem() ----> SDL_INIT_TIMER Has failed to initialise.", state);
}
if (!(Has_SDL_Init & SDL_INIT_VIDEO))
{
error.Fatal_SDL_Error("Class Window.h ----> InitialiseSystem() ----> SDL_INIT_VIDEO Has failed to initialise.", state);
}
int r, g, b, a, minor, major, visual, depthSize, stencil, buffer, dblbuffer;
int core, flagsss;
SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &visual);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_GetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, &major);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
SDL_GL_GetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, &minor);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); // Forces the use of Modern OpenGL.
SDL_GL_GetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, &core);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG);
SDL_GL_GetAttribute(SDL_GL_CONTEXT_FLAGS, &flagsss);
// They all fail from this point below (Only in SDL init method)
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 3);
SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &r);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &g);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &b);
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 1);
SDL_GL_GetAttribute(SDL_GL_ALPHA_SIZE,&a);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &depthSize);
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 5);
SDL_GL_GetAttribute(SDL_GL_STENCIL_SIZE, &stencil);
SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 24);
SDL_GL_GetAttribute(SDL_GL_BUFFER_SIZE, &buffer);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &dblbuffer);
this->GameWindow = SDL_CreateWindow(title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
this->windowWidth, this->windowHeight, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI);
if (!GameWindow)
{
ShutDownSystem();
}
SDL_SetWindowResizable(GameWindow, SDL_TRUE);
}
void Window::InitialiseOpenGL()
{
OpenGL_Context = SDL_GL_CreateContext(GameWindow);
SDL_GL_SetSwapInterval(1);
if (OpenGL_Context == nullptr)
{
error.Fatal_SDL_Error("LegendRenderer ----> InitialiseOpenGL() ----> Failed to create an OpenGL context for SDL.", state);
SetWindowEngineState(*state);
}
glewExperimental = GL_TRUE;
GLenum OpenGLError = glewInit();
if (OpenGLError != GLEW_OK)
{
error.Fatal_SDL_Error("LegendRenderer ----> InitialiseOpenGL() ----> Failed to Initialise GLEW.", state);
SetWindowEngineState(*state);
}
printf("OpenGL loaded\n");
printf("Vendor: %s\n", glGetString(GL_VENDOR));
printf("Renderer: %s\n", glGetString(GL_RENDERER));
printf("Version: %s\n", glGetString(GL_VERSION));
if (SDL_GL_GetSwapInterval < 0)
{
error.Fatal_SDL_Error("LegendRenderer ----> InitialiseOpenGL() ----> Failed to set frame buffer interval for SDL.", state);
SetWindowEngineState(*state);
}
int w, h;
SDL_GetWindowSize(GameWindow, &w, &h);
glViewport(0, 0, w, h);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
}
あなたが割り当てたビット深度は、私にとって奇妙に見えます。私はあなたがr3-g5-b5-a1フォーマットを取得することを非常に疑う。 – BDL