-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(WIP) First, bad, groundwork implementation of OpenGL backend #183
Merged
+624
−380
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b132e62
Fix nullpointer crash
JaceCear 997dec5
Add first NOT-WORKING (WIP) pass on OpenGL renderer in win32
JaceCear 5128b35
Merge branch 'main' into win32_tests
JaceCear dd3ec07
Address #ifdef comment
JaceCear 9451f7f
Fix capitalization
JaceCear File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#ifndef GUARD_PLATFORM_SHARED_INPUT_H | ||
#define GUARD_PLATFORM_SHARED_INPUT_H | ||
|
||
#include "sprite.h" // for Sprite | ||
|
||
u16 GetXInputKeys(); | ||
|
||
#endif // GUARD_PLATFORM_SHARED_INPUT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#ifndef GUARD_PLATFORM_SHARED_OPENGL_H | ||
#define GUARD_PLATFORM_SHARED_OPENGL_H | ||
|
||
#include "sprite.h" // for Sprite | ||
|
||
void OpenGL_OnInit(); | ||
void OpenGL_DisplaySprite(Sprite *sprite, u8 oamPaletteNum); | ||
void OpenGL_Render(void *tempBufferPixels, int windowWidth, int windowHeight); | ||
|
||
#endif // GUARD_PLATFORM_SHARED_OPENGL_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#ifdef _WIN32 | ||
#include <windows.h> | ||
#include <xinput.h> | ||
#include "gba/io_reg.h" | ||
#include "gba/types.h" | ||
|
||
#define STICK_THRESHOLD 0.5f | ||
u16 GetXInputKeys() | ||
{ | ||
XINPUT_STATE state; | ||
ZeroMemory(&state, sizeof(XINPUT_STATE)); | ||
|
||
DWORD dwResult = XInputGetState(0, &state); | ||
u16 xinputKeys = 0; | ||
|
||
if (dwResult == ERROR_SUCCESS) { | ||
/* A */ xinputKeys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_A) >> 12; | ||
/* B */ xinputKeys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_X) >> 13; | ||
/* Start */ xinputKeys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_START) >> 1; | ||
/* Select */ xinputKeys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_BACK) >> 3; | ||
/* L */ xinputKeys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_SHOULDER) << 1; | ||
/* R */ xinputKeys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_SHOULDER) >> 1; | ||
/* Up */ xinputKeys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_UP) << 6; | ||
/* Down */ xinputKeys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN) << 6; | ||
/* Left */ xinputKeys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT) << 3; | ||
/* Right */ xinputKeys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT) << 1; | ||
|
||
/* Control Stick */ | ||
float xAxis = (float)state.Gamepad.sThumbLX / (float)SHRT_MAX; | ||
float yAxis = (float)state.Gamepad.sThumbLY / (float)SHRT_MAX; | ||
|
||
if (xAxis < -STICK_THRESHOLD) | ||
xinputKeys |= DPAD_LEFT; | ||
else if (xAxis > STICK_THRESHOLD) | ||
xinputKeys |= DPAD_RIGHT; | ||
if (yAxis < -STICK_THRESHOLD) | ||
xinputKeys |= DPAD_DOWN; | ||
else if (yAxis > STICK_THRESHOLD) | ||
xinputKeys |= DPAD_UP; | ||
} | ||
|
||
return xinputKeys; | ||
} | ||
#endif // _WIN32 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might as well be consistent and do
if (RENDERER == RENDERER_SOFTWARE)
around the whole thing?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For such a big function? I'd rather keep it with a short
#ifdef
.