mirror of
https://github.com/MichaelFisher1997/opengl-cpp.git
synced 2025-04-27 14:13:10 +00:00
pre opengl
This commit is contained in:
parent
71968a3b42
commit
18298f046a
14
src/sdl.cpp
14
src/sdl.cpp
@ -7,13 +7,13 @@ SdlWindow::SdlWindow(const char* title, int width, int height)
|
|||||||
m_isRunning(false),
|
m_isRunning(false),
|
||||||
m_isFullscreen(false),
|
m_isFullscreen(false),
|
||||||
m_width(width),
|
m_width(width),
|
||||||
m_height(height)
|
m_height(height),
|
||||||
|
m_glContect(nullptr)
|
||||||
{
|
{
|
||||||
// 1. Initialize SDL
|
// 1. Set attributes
|
||||||
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
|
||||||
std::cerr << "Failed to init SDL2: " << SDL_GetError() << std::endl;
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
|
||||||
return;
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
|
||||||
}
|
|
||||||
|
|
||||||
// 2. Create the window
|
// 2. Create the window
|
||||||
m_window = SDL_CreateWindow(
|
m_window = SDL_CreateWindow(
|
||||||
@ -22,7 +22,7 @@ SdlWindow::SdlWindow(const char* title, int width, int height)
|
|||||||
SDL_WINDOWPOS_CENTERED,
|
SDL_WINDOWPOS_CENTERED,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
SDL_WINDOW_SHOWN
|
SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE
|
||||||
);
|
);
|
||||||
if (!m_window) {
|
if (!m_window) {
|
||||||
std::cerr << "Failed to create window: " << SDL_GetError() << std::endl;
|
std::cerr << "Failed to create window: " << SDL_GetError() << std::endl;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user