Skip to content

Commit

Permalink
add gl hook
Browse files Browse the repository at this point in the history
  • Loading branch information
JayFoxRox committed Dec 16, 2019
1 parent 80ea8a2 commit ff0a818
Showing 1 changed file with 84 additions and 0 deletions.
84 changes: 84 additions & 0 deletions xbox/xbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,74 @@ GL_API void GL_APIENTRY glPixelStorei (GLenum pname, GLint param) {




// SDL GL hooks

//#include "../../SDL_internal.h"

#include <SDL.h>
#include <./../src/video/SDL_sysvideo.h>
#include <stdlib.h>
#include <string.h>

#include "SDL_error.h"

int GL_LoadLibrary(_THIS, const char *path)
{
unimplemented("%s", path);
return 0;
}

void * GL_GetProcAddress(_THIS, const char *proc)
{
unimplemented("%s", proc);
return NULL;
}

void GL_UnloadLibrary(_THIS)
{
return;
}

SDL_GLContext GL_CreateContext(_THIS, SDL_Window * window)
{

// SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
return (SDL_GLContext)1;
}

int GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
{
return 0;
}

int GL_SetSwapInterval(_THIS, int interval)
{
/* Failed to set swap interval */
return SDL_SetError("Unable to set the EGL swap interval");
}

int GL_GetSwapInterval(_THIS)
{
return 0;
}

int GL_SwapWindow(_THIS, SDL_Window * window)
{
unimplemented(); //FIXME
assert(0);
return 0;
}

void GL_DeleteContext(_THIS, SDL_GLContext context)
{
return;
}





//FIXME: Use stuff like `ptr = MmAllocateContiguousMemoryEx(size, 0, 0x3ffb000, 0, 0x404);` to alloc buffer / tex

// Initialization
Expand Down Expand Up @@ -1146,6 +1214,22 @@ __attribute__((constructor)) static void setup_xbox(void) {
pb_show_debug_screen();
#endif

// Pre-Init SDL so we can hijack some GL routines
//FIXME: This breaks if the app initializes SDL after uninitializing
int ret = SDL_InitSubSystem(SDL_INIT_VIDEO);
assert(ret == 0);
SDL_VideoDevice* device = SDL_GetVideoDevice();
assert(device != NULL);
device->GL_LoadLibrary = GL_LoadLibrary;
device->GL_GetProcAddress = GL_GetProcAddress;
device->GL_UnloadLibrary = GL_UnloadLibrary;
device->GL_CreateContext = GL_CreateContext;
device->GL_MakeCurrent = GL_MakeCurrent;
device->GL_SetSwapInterval = GL_SetSwapInterval;
device->GL_GetSwapInterval = GL_GetSwapInterval;
device->GL_SwapWindow = GL_SwapWindow;
device->GL_DeleteContext = GL_DeleteContext;

// Retrieve created size
//FIXME: why? - probably not needed
int width = pb_back_buffer_width();
Expand Down

0 comments on commit ff0a818

Please sign in to comment.