mirror of
https://github.com/GayPizzaSpecifications/padlab.git
synced 2026-05-07 12:40:18 +00:00
complete SDL3 transition
This commit is contained in:
@@ -21,7 +21,7 @@ function (common_setup _TARGET)
|
|||||||
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||||
get_property(SDL3_IMPORTED_LOCATION TARGET SDL3::SDL3 PROPERTY IMPORTED_LOCATION)
|
get_property(SDL3_IMPORTED_LOCATION TARGET SDL3::SDL3 PROPERTY IMPORTED_LOCATION)
|
||||||
if (SDL3_IMPORTED_LOCATION MATCHES "^/Library/Frameworks/")
|
if (SDL3_IMPORTED_LOCATION MATCHES "^/Library/Frameworks/")
|
||||||
target_link_options(${_TARGET} PRIVATE -Wl,-rpath,/Library/Frameworks)
|
set_property(TARGET ${_TARGET} PROPERTY BUILD_RPATH "/Library/Frameworks")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ int SDL_AppEvent(const SDL_Event* event)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case (SDL_EVENT_MOUSE_BUTTON_DOWN):
|
case (SDL_EVENT_MOUSE_BUTTON_DOWN):
|
||||||
if (SDL_BUTTON(event->button.button) & (SDL_BUTTON_LMASK | SDL_BUTTON_RMASK))
|
if (SDL_BUTTON_MASK(event->button.button) & (SDL_BUTTON_LMASK | SDL_BUTTON_RMASK))
|
||||||
side = (event->button.x > winw / 2) ? 1 : 0;
|
side = (event->button.x > winw / 2) ? 1 : 0;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "draw.h"
|
#include "draw.h"
|
||||||
#include "maths.h"
|
#include "maths.h"
|
||||||
#include <SDL_render.h>
|
#include <SDL3/SDL_render.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
@@ -10,8 +10,8 @@ void DrawWindowHints(void) {}
|
|||||||
|
|
||||||
int InitDraw(SDL_Window* window)
|
int InitDraw(SDL_Window* window)
|
||||||
{
|
{
|
||||||
const int rendflags = SDL_RENDERER_PRESENTVSYNC;
|
rend = SDL_CreateRenderer(window, NULL);
|
||||||
rend = SDL_CreateRenderer(window, NULL, rendflags);
|
SDL_SetRenderVSync(rend, 1);
|
||||||
return (rend == NULL) ? -1 : 0;
|
return (rend == NULL) ? -1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
#include "draw.h"
|
#include "draw.h"
|
||||||
#include "maths.h"
|
#include "maths.h"
|
||||||
#include <SDL_video.h>
|
#include <SDL3/SDL_video.h>
|
||||||
#include <SDL_opengl.h>
|
#include <SDL3/SDL_opengl.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
|
||||||
static SDL_GLContext* ctx = NULL;
|
static SDL_GLContext ctx = NULL;
|
||||||
static SDL_Window* window = NULL;
|
static SDL_Window* window = NULL;
|
||||||
static uint32_t colour = 0x00000000;
|
static uint32_t colour = 0x00000000;
|
||||||
static uint32_t clrColour = 0x00000000;
|
static uint32_t clrColour = 0x00000000;
|
||||||
@@ -62,7 +62,7 @@ int InitDraw(SDL_Window* w)
|
|||||||
|
|
||||||
void QuitDraw(void)
|
void QuitDraw(void)
|
||||||
{
|
{
|
||||||
SDL_GL_DeleteContext(ctx);
|
SDL_GL_DestroyContext(ctx);
|
||||||
ctx = NULL;
|
ctx = NULL;
|
||||||
window = NULL;
|
window = NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include "glslShaders.h"
|
#include "glslShaders.h"
|
||||||
#include "maths.h"
|
#include "maths.h"
|
||||||
#include <GL/gl3w.h>
|
#include <GL/gl3w.h>
|
||||||
#include <SDL_video.h>
|
#include <SDL3/SDL_video.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -20,7 +20,7 @@ static const char* const attribNames[] =
|
|||||||
#define OPENGL_VERSION_MAJOR 3
|
#define OPENGL_VERSION_MAJOR 3
|
||||||
#define OPENGL_VERSION_MINOR 3
|
#define OPENGL_VERSION_MINOR 3
|
||||||
|
|
||||||
static SDL_GLContext* ctx = NULL;
|
static SDL_GLContext ctx = NULL;
|
||||||
static SDL_Window* window = NULL;
|
static SDL_Window* window = NULL;
|
||||||
static uint32_t
|
static uint32_t
|
||||||
colour = 0x00000000,
|
colour = 0x00000000,
|
||||||
@@ -133,7 +133,7 @@ int InitDraw(SDL_Window* _window)
|
|||||||
{
|
{
|
||||||
window = _window;
|
window = _window;
|
||||||
ctx = SDL_GL_CreateContext(window);
|
ctx = SDL_GL_CreateContext(window);
|
||||||
if (ctx == NULL || window == NULL || SDL_GL_MakeCurrent(window, ctx))
|
if (ctx == NULL || window == NULL || !SDL_GL_MakeCurrent(window, ctx))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s\n", SDL_GetError());
|
fprintf(stderr, "%s\n", SDL_GetError());
|
||||||
return -1;
|
return -1;
|
||||||
@@ -259,7 +259,7 @@ void QuitDraw(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
SDL_GL_MakeCurrent(window, NULL);
|
SDL_GL_MakeCurrent(window, NULL);
|
||||||
SDL_GL_DeleteContext(ctx);
|
SDL_GL_DestroyContext(ctx);
|
||||||
ctx = NULL;
|
ctx = NULL;
|
||||||
window = NULL;
|
window = NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user