Compare commits

...

5 Commits

Author SHA1 Message Date
frank dc2141c2c4 Merge branch 'pudding' into cuckoo 2022-08-09 18:30:39 -04:00
frank 21e1e7e707 set GL attributes before creating a window 2022-08-06 18:43:12 -04:00
ohsqueezy 9fd3ee282e change default keys for screenshot and video 2022-07-26 17:28:56 -04:00
ohsqueezy a3fba9c38a adjust pre tag 2022-07-23 19:34:11 -04:00
ohsqueezy 6956688430 add title to README 2022-07-23 19:30:39 -04:00
3 changed files with 18 additions and 14 deletions

View File

@ -1,3 +1,6 @@
SPACE BOX
=========
<pre>
/\ +------------------------------------------------------------+
____/ \____ /| zlib/MIT/Unlicenced game framework licensed to freely use, |
@ -7,8 +10,7 @@
| ~~~~~~~~~~~~ | +------------------------------------------------------------+
| SPACE ~~~~~ | /
| ~~~~~~~ BOX |/
+--------------+
</pre>
+--------------+ </pre>
[SPACE BOX] is a C++ framework that facilitates the creation of SDL + OpenGL projects through the use of generic objects that can be used and extended by the programmer. It focuses on game projects but its usefulness is not limited to games.

View File

@ -27,9 +27,9 @@ Configuration::Configuration(Node *parent, fs::path path) : Node(parent)
void Configuration::set_defaults()
{
sys_config["keys"] = {
{"record", {"CTRL", "SHIFT", "f10"}},
{"record", {"CTRL", "SHIFT", "i"}},
{"save-current-stash", {"CTRL", "SHIFT", "v"}},
{"screenshot", "f9"},
{"screenshot", {"CTRL", "i"}},
{"action", "space"},
{"up", "up"},
{"right", "right"},

View File

@ -50,6 +50,17 @@ Game::Game()
log_message << "GLEW " << glewGetString(GLEW_VERSION);
sb::Log::log(log_message.str());
glm::ivec2 window_size = configuration()["display"]["dimensions"].get<glm::ivec2>();
/* Set these before creating a window (see SDL_GLattr.html) */
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1);
/* Create a window with dimensions set in the config, centered, and flagged to be usable in OpenGL context */
_window = SDL_CreateWindow(
configuration()["display"]["title"].get_ref<const std::string&>().c_str(), SDL_WINDOWPOS_CENTERED,
@ -171,16 +182,7 @@ void Game::load_gl_context()
SDL_DestroyRenderer(renderer);
renderer = nullptr;
}
#ifndef __EMSCRIPTEN__
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
#endif
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
if ((glcontext = SDL_GL_CreateContext(_window)) == nullptr)
if ((glcontext = SDL_GL_CreateContext(window())) == nullptr)
{
sb::Log::sdl_error("Could not get GL context");
flag_to_end();