Change software renderer backend API
This commit is contained in:
parent
7ca33677f8
commit
8524d1e349
3 changed files with 27 additions and 14 deletions
|
@ -24,7 +24,7 @@ static float framebuffer_y_ratio;
|
|||
|
||||
static GLuint screen_texture_id;
|
||||
|
||||
unsigned char* WindowBackend_Software_CreateWindow(const char *window_title, int screen_width, int screen_height, bool fullscreen, size_t *pitch)
|
||||
bool WindowBackend_Software_CreateWindow(const char *window_title, int screen_width, int screen_height, bool fullscreen)
|
||||
{
|
||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 1);
|
||||
|
@ -81,18 +81,16 @@ unsigned char* WindowBackend_Software_CreateWindow(const char *window_title, int
|
|||
|
||||
framebuffer = (unsigned char*)malloc(framebuffer_width * framebuffer_height * 3);
|
||||
|
||||
*pitch = framebuffer_width * 3;
|
||||
|
||||
Backend_PostWindowCreation();
|
||||
|
||||
return framebuffer;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Backend_ShowMessageBox("Fatal error (OpenGL rendering backend)", "Could not create window");
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
void WindowBackend_Software_DestroyWindow(void)
|
||||
|
@ -102,6 +100,13 @@ void WindowBackend_Software_DestroyWindow(void)
|
|||
glfwDestroyWindow(window);
|
||||
}
|
||||
|
||||
unsigned char* WindowBackend_Software_GetFramebuffer(size_t *pitch)
|
||||
{
|
||||
*pitch = framebuffer_width * 3;
|
||||
|
||||
return framebuffer;
|
||||
}
|
||||
|
||||
void WindowBackend_Software_Display(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
|
|
@ -33,19 +33,22 @@ static RenderBackend_Surface *glyph_destination_surface;
|
|||
|
||||
RenderBackend_Surface* RenderBackend_Init(const char *window_title, int screen_width, int screen_height, bool fullscreen)
|
||||
{
|
||||
size_t pitch;
|
||||
framebuffer.pixels = WindowBackend_Software_CreateWindow(window_title, screen_width, screen_height, fullscreen, &pitch);
|
||||
framebuffer.width = screen_width;
|
||||
framebuffer.height = screen_height;
|
||||
framebuffer.pitch = pitch;
|
||||
if (WindowBackend_Software_CreateWindow(window_title, screen_width, screen_height, fullscreen))
|
||||
{
|
||||
size_t pitch;
|
||||
framebuffer.pixels = WindowBackend_Software_GetFramebuffer(&pitch);
|
||||
framebuffer.width = screen_width;
|
||||
framebuffer.height = screen_height;
|
||||
framebuffer.pitch = pitch;
|
||||
|
||||
if (framebuffer.pixels == NULL)
|
||||
return &framebuffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
Backend_PrintError("Failed to create window");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return &framebuffer;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void RenderBackend_Deinit(void)
|
||||
|
@ -56,6 +59,10 @@ void RenderBackend_Deinit(void)
|
|||
void RenderBackend_DrawScreen(void)
|
||||
{
|
||||
WindowBackend_Software_Display();
|
||||
|
||||
size_t pitch;
|
||||
framebuffer.pixels = WindowBackend_Software_GetFramebuffer(&pitch);
|
||||
framebuffer.pitch = pitch;
|
||||
}
|
||||
|
||||
RenderBackend_Surface* RenderBackend_CreateSurface(unsigned int width, unsigned int height)
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
#include <stddef.h>
|
||||
|
||||
unsigned char* WindowBackend_Software_CreateWindow(const char *window_title, int screen_width, int screen_height, bool fullscreen, size_t *pitch);
|
||||
bool WindowBackend_Software_CreateWindow(const char *window_title, int screen_width, int screen_height, bool fullscreen);
|
||||
void WindowBackend_Software_DestroyWindow(void);
|
||||
unsigned char* WindowBackend_Software_GetFramebuffer(size_t *pitch);
|
||||
void WindowBackend_Software_Display(void);
|
||||
void WindowBackend_Software_HandleWindowResize(unsigned int width, unsigned int height);
|
||||
|
|
Loading…
Add table
Reference in a new issue