-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add first NOT-WORKING (WIP) pass on OpenGL renderer in win32
- Loading branch information
Showing
14 changed files
with
604 additions
and
373 deletions.
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
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.