Skip to content

Commit

Permalink
Merge branch 'master' into psemek-audio
Browse files Browse the repository at this point in the history
  • Loading branch information
jhasse committed Nov 29, 2023
2 parents 4e3d640 + b32072d commit 710ea5b
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .vscode/build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build
if exist build\build.ninja (
rem file exists
) else (
cmake -Bbuild -GNinja -DJNGL_VIDEO=0 -DCMAKE_BUILD_TYPE=Debug
cmake -Bbuild -G"Ninja Multi-Config" -DJNGL_VIDEO=0
)
cmake --build build
29 changes: 5 additions & 24 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "gdb",
"request": "launch",
"name": "jngl-test (GDB)",
"target": "./build/jngl-test",
"cwd": "${workspaceRoot}",
"valuesFormatting": "prettyPrinters",
"preLaunchTask": "build"
},
{
"type": "gdb",
"request": "launch",
"name": "videoplayer (GDB)",
"target": "./build/videoplayer",
"arguments": "data/verysmall.ogv",
"cwd": "${workspaceRoot}",
"valuesFormatting": "prettyPrinters",
"preLaunchTask": "build"
},
{
"type": "lldb",
"request": "launch",
"name": "jngl-test (LLDB)",
"program": "${workspaceRoot}/build/jngl-test",
"program": "${workspaceRoot}/build/Debug/jngl-test",
"args": [],
"cwd": "${workspaceRoot}",
"preLaunchTask": "build"
Expand All @@ -33,7 +14,7 @@
"type": "lldb",
"request": "launch",
"name": "videoplayer",
"program": "${workspaceRoot}/build/videoplayer",
"program": "${workspaceRoot}/build/Debug/videoplayer",
"args": ["data/verysmall.ogv"],
"cwd": "${workspaceRoot}",
"preLaunchTask": "build"
Expand All @@ -42,7 +23,7 @@
"type": "lldb",
"request": "launch",
"name": "jngl-unittest (LLDB)",
"program": "${workspaceRoot}/build/jngl-unittest",
"program": "${workspaceRoot}/build/Debug/jngl-unittest",
"args": [],
"cwd": "${workspaceRoot}/build",
"preLaunchTask": "build"
Expand All @@ -51,7 +32,7 @@
"name": "jngl-test (C/C++)",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/build/jngl-test",
"program": "${workspaceRoot}/build/Debug/jngl-test",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
Expand All @@ -76,7 +57,7 @@
"name": "jngl-unittest (C/C++)",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/build/jngl-unittest",
"program": "${workspaceRoot}/build/Debug/jngl-unittest",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}/build",
Expand Down
4 changes: 0 additions & 4 deletions src/android/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ bool Window::getKeyDown(const std::string& key) {
}

bool Window::getKeyPressed(const std::string& key) {
if (characterPressed_[key]) {
characterPressed_[key] = false;
return true;
}
return characterPressed_[key];
}

Expand Down
4 changes: 0 additions & 4 deletions src/ios/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ bool Window::getKeyDown(const std::string& key) {
}

bool Window::getKeyPressed(const std::string& key) {
if (characterPressed_[key]) {
characterPressed_[key] = false;
return true;
}
return characterPressed_[key];
}

Expand Down
6 changes: 6 additions & 0 deletions src/jngl/FrameBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,15 @@ FrameBuffer::FrameBuffer(const Pixels width, const Pixels height)

assert(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE);

if (impl->letterboxing) {
glDisable(GL_SCISSOR_TEST);
}
glClearColor(1, 1, 1, 0);
glClear(GL_COLOR_BUFFER_BIT);
clearBackgroundColor();
if (impl->letterboxing) {
glEnable(GL_SCISSOR_TEST);
}

glBindFramebuffer(GL_FRAMEBUFFER, impl->systemFbo);
glBindRenderbuffer(GL_RENDERBUFFER, impl->systemBuffer);
Expand Down
16 changes: 8 additions & 8 deletions src/sdl/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,12 @@ Window::Window(const std::string& title, int width, int height, const bool fulls

impl->context = SDL_GL_CreateContext(impl->sdlWindow);
#ifdef GLAD_GL
gladLoadGL(reinterpret_cast<GLADloadfunc>(SDL_GL_GetProcAddress));
const auto glVersion = gladLoadGL(reinterpret_cast<GLADloadfunc>(SDL_GL_GetProcAddress));
if (glVersion < GLAD_MAKE_VERSION(2, 0)) {
throw std::runtime_error("Your graphics card is missing OpenGL 2.0 support (it supports " +
std::to_string(GLAD_VERSION_MAJOR(glVersion)) + "." +
std::to_string(GLAD_VERSION_MINOR(glVersion)) + ").");
}
#endif

if (isMultisampleSupported_) {
Expand Down Expand Up @@ -219,10 +224,6 @@ bool Window::getKeyDown(const std::string& key) {
}

bool Window::getKeyPressed(const std::string& key) {
if (characterPressed_[key]) {
characterPressed_[key] = false;
return true;
}
return characterPressed_[key];
}

Expand Down Expand Up @@ -337,10 +338,12 @@ void Window::UpdateInput() {
}
characterDown_[tmp] = true;
characterPressed_[tmp] = true;
needToBeSetFalse_.push(&characterPressed_[tmp]);
}
if (event.key.keysym.sym == SDLK_SPACE) {
characterDown_[" "] = true;
characterPressed_[" "] = true;
needToBeSetFalse_.push(&characterPressed_[" "]);
}
anyKeyPressed_ = true;
break;
Expand All @@ -352,14 +355,11 @@ void Window::UpdateInput() {
if (strlen(name) == 1) {
std::string tmp(1, name[0]);
characterDown_[tmp] = false;
characterPressed_[tmp] = false;
tmp[0] = tolower(name[0]);
characterDown_[tmp] = false;
characterPressed_[tmp] = false;
}
if (event.key.keysym.sym == SDLK_SPACE) {
characterDown_[" "] = false;
characterPressed_[" "] = false;
}
break;
}
Expand Down
9 changes: 1 addition & 8 deletions src/win32/windowimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,6 @@ void Window::UpdateInput() {
impl->distinguishLeftRight();
int scanCode = msg.lParam & 0x7f8000;
characterDown_[scanCodeToCharacter[scanCode]] = false;
characterPressed_[scanCodeToCharacter[scanCode]] = false;
} break;
case WM_CHAR: {
std::vector<char> buf(4);
Expand Down Expand Up @@ -466,6 +465,7 @@ void Window::UpdateInput() {
scanCodeToCharacter[scanCode] = character;
characterDown_[character] = true;
characterPressed_[character] = true;
needToBeSetFalse_.push(&characterPressed_[character]);
textInput += character;
} break;
}
Expand All @@ -488,9 +488,6 @@ void Window::UpdateInput() {
for (auto& it : characterDown_) {
it.second = false;
}
for (auto& it : characterPressed_) {
it.second = false;
}
for (auto& b : mouseDown_) {
b = false;
}
Expand Down Expand Up @@ -601,10 +598,6 @@ bool Window::getKeyDown(const std::string& key) {
}

bool Window::getKeyPressed(const std::string& key) {
if (characterPressed_[key]) {
characterPressed_[key] = false;
return true;
}
return characterPressed_[key];
}

Expand Down
3 changes: 3 additions & 0 deletions src/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ void Window::setKeyPressed(const key::KeyType key, bool p) {

void Window::setKeyPressed(const std::string& key, bool p) {
characterPressed_[key] = p;
if (p) {
needToBeSetFalse_.push(&characterPressed_[key]);
}
}

bool keyDown(const char key) {
Expand Down

0 comments on commit 710ea5b

Please sign in to comment.