mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-18 20:15:35 -04:00
Allow window backends to override window scale dimension units, e.g. for PS2
This commit is contained in:
parent
f5bed6ff69
commit
924a19e078
@ -29,8 +29,8 @@ static struct Texture touchBgTex;
|
||||
*----------------------------------------------------------Gui------------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
static CC_NOINLINE int GetWindowScale(void) {
|
||||
float widthScale = Window_Main.Width / 640.0f;
|
||||
float heightScale = Window_Main.Height / 480.0f;
|
||||
float widthScale = Window_Main.Width * Window_Main.UIScaleX;
|
||||
float heightScale = Window_Main.Height * Window_Main.UIScaleY;
|
||||
|
||||
/* Use larger UI scaling on mobile */
|
||||
/* TODO move this DPI scaling elsewhere.,. */
|
||||
@ -63,7 +63,8 @@ float Gui_GetChatScale(void) {
|
||||
}
|
||||
|
||||
float Gui_GetCrosshairScale(void) {
|
||||
return Gui_Scale((Window_Main.Height / 480.0f)) * Gui.RawCrosshairScale;
|
||||
float heightScale = Window_Main.Height * Window_Main.UIScaleY;
|
||||
return Gui_Scale(heightScale) * Gui.RawCrosshairScale;
|
||||
}
|
||||
|
||||
|
||||
|
@ -86,8 +86,14 @@ struct _WindowData {
|
||||
cc_bool Inactive;
|
||||
/* Whether input should be ignored due to soft keyboard being open */
|
||||
cc_bool SoftKeyboardFocus;
|
||||
/* Scale factors specifically for some in-game elements (e.g. chat) */
|
||||
/* that vary their elements based on the window dimensions */
|
||||
float UIScaleX, UIScaleY;
|
||||
};
|
||||
|
||||
#define DEFAULT_UI_SCALE_X (1.0f / 640)
|
||||
#define DEFAULT_UI_SCALE_Y (1.0f / 480)
|
||||
|
||||
/* Data for the game/launcher window */
|
||||
CC_VAR extern struct _WindowData WindowInfo; /* Named WindowInfo for backwards compatibility */
|
||||
#define Window_Main WindowInfo
|
||||
|
@ -44,7 +44,10 @@ void Window_Init(void) {
|
||||
Window_Main.Width = top_width;
|
||||
Window_Main.Height = top_height;
|
||||
Window_Main.Focused = true;
|
||||
|
||||
Window_Main.Exists = true;
|
||||
Window_Main.UIScaleX = DEFAULT_UI_SCALE_X;
|
||||
Window_Main.UIScaleY = DEFAULT_UI_SCALE_Y;
|
||||
|
||||
Window_Main.SoftKeyboard = SOFT_KEYBOARD_RESIZE;
|
||||
Input_SetTouchMode(true);
|
||||
|
@ -327,6 +327,9 @@ static void RemakeWindowSurface(void) {
|
||||
|
||||
static void DoCreateWindow(void) {
|
||||
Window_Main.Exists = true;
|
||||
Window_Main.UIScaleX = DEFAULT_UI_SCALE_X;
|
||||
Window_Main.UIScaleY = DEFAULT_UI_SCALE_Y;
|
||||
|
||||
RemakeWindowSurface();
|
||||
/* always start as fullscreen */
|
||||
Window_EnterFullscreen();
|
||||
|
@ -351,6 +351,8 @@ static void DoCreateWindow(int width, int height) {
|
||||
|
||||
Window_Main.Exists = true;
|
||||
Window_Main.Handle = win_handle;
|
||||
Window_Main.UIScaleX = DEFAULT_UI_SCALE_X;
|
||||
Window_Main.UIScaleY = DEFAULT_UI_SCALE_Y;
|
||||
|
||||
frame = win_handle->Bounds();
|
||||
Window_Main.Width = frame.IntegerWidth() + 1;
|
||||
|
@ -40,7 +40,10 @@ void Window_Init(void) {
|
||||
Window_Main.Width = vid_mode->width;
|
||||
Window_Main.Height = vid_mode->height;
|
||||
Window_Main.Focused = true;
|
||||
|
||||
Window_Main.Exists = true;
|
||||
Window_Main.UIScaleX = DEFAULT_UI_SCALE_X;
|
||||
Window_Main.UIScaleY = DEFAULT_UI_SCALE_Y;
|
||||
|
||||
Input.Sources = INPUT_SOURCE_GAMEPAD;
|
||||
DisplayInfo.ContentOffsetX = 10;
|
||||
|
@ -73,7 +73,10 @@ void Window_Init(void) {
|
||||
Window_Main.Width = rmode->fbWidth;
|
||||
Window_Main.Height = rmode->xfbHeight;
|
||||
Window_Main.Focused = true;
|
||||
|
||||
Window_Main.Exists = true;
|
||||
Window_Main.UIScaleX = DEFAULT_UI_SCALE_X;
|
||||
Window_Main.UIScaleY = DEFAULT_UI_SCALE_Y;
|
||||
|
||||
Input.Sources = INPUT_SOURCE_GAMEPAD;
|
||||
DisplayInfo.ContentOffsetX = 10;
|
||||
|
@ -207,7 +207,10 @@ static void DoCreateWindow(int width, int height) {
|
||||
Window_Main.Width = r.right - r.left;
|
||||
Window_Main.Height = r.bottom - r.top;
|
||||
Window_Main.Focused = true;
|
||||
|
||||
Window_Main.Exists = true;
|
||||
Window_Main.UIScaleX = DEFAULT_UI_SCALE_X;
|
||||
Window_Main.UIScaleY = DEFAULT_UI_SCALE_Y;
|
||||
}
|
||||
|
||||
void Window_Create2D(int width, int height) { DoCreateWindow(width, height); }
|
||||
|
@ -31,7 +31,10 @@ void Window_Init(void) {
|
||||
Window_Main.Width = DisplayInfo.Width;
|
||||
Window_Main.Height = DisplayInfo.Height;
|
||||
Window_Main.Focused = true;
|
||||
|
||||
Window_Main.Exists = true;
|
||||
Window_Main.UIScaleX = DEFAULT_UI_SCALE_X;
|
||||
Window_Main.UIScaleY = DEFAULT_UI_SCALE_Y;
|
||||
|
||||
Input.Sources = INPUT_SOURCE_GAMEPAD;
|
||||
DisplayInfo.ContentOffsetX = 10;
|
||||
|
@ -150,7 +150,10 @@ void Window_Init(void) {
|
||||
Window_Main.Width = DisplayInfo.Width;
|
||||
Window_Main.Height = DisplayInfo.Height;
|
||||
Window_Main.Focused = true;
|
||||
|
||||
Window_Main.Exists = true;
|
||||
Window_Main.UIScaleX = DEFAULT_UI_SCALE_X;
|
||||
Window_Main.UIScaleY = DEFAULT_UI_SCALE_Y;
|
||||
|
||||
Window_Main.SoftKeyboard = SOFT_KEYBOARD_RESIZE;
|
||||
Input_SetTouchMode(true);
|
||||
|
@ -39,7 +39,10 @@ void Window_Init(void) {
|
||||
Window_Main.Width = DisplayInfo.Width;
|
||||
Window_Main.Height = DisplayInfo.Height;
|
||||
Window_Main.Focused = true;
|
||||
|
||||
Window_Main.Exists = true;
|
||||
Window_Main.UIScaleX = DEFAULT_UI_SCALE_X;
|
||||
Window_Main.UIScaleY = DEFAULT_UI_SCALE_Y;
|
||||
|
||||
Input.Sources = INPUT_SOURCE_GAMEPAD;
|
||||
DisplayInfo.ContentOffsetX = 10;
|
||||
|
@ -47,7 +47,10 @@ void Window_Init(void) {
|
||||
Window_Main.Width = DisplayInfo.Width;
|
||||
Window_Main.Height = DisplayInfo.Height;
|
||||
Window_Main.Focused = true;
|
||||
|
||||
Window_Main.Exists = true;
|
||||
Window_Main.UIScaleX = DEFAULT_UI_SCALE_X;
|
||||
Window_Main.UIScaleY = 1.0f / Window_Main.Height;
|
||||
|
||||
Input.Sources = INPUT_SOURCE_GAMEPAD;
|
||||
DisplayInfo.ContentOffsetX = 10;
|
||||
|
@ -55,7 +55,10 @@ void Window_Init(void) {
|
||||
Window_Main.Width = resolution.width;
|
||||
Window_Main.Height = resolution.height;
|
||||
Window_Main.Focused = true;
|
||||
|
||||
Window_Main.Exists = true;
|
||||
Window_Main.UIScaleX = DEFAULT_UI_SCALE_X;
|
||||
Window_Main.UIScaleY = DEFAULT_UI_SCALE_Y;
|
||||
|
||||
Input.Sources = INPUT_SOURCE_GAMEPAD;
|
||||
DisplayInfo.ContentOffsetX = 20;
|
||||
|
@ -38,7 +38,10 @@ void Window_Init(void) {
|
||||
Window_Main.Width = SCREEN_WIDTH;
|
||||
Window_Main.Height = SCREEN_HEIGHT;
|
||||
Window_Main.Focused = true;
|
||||
|
||||
Window_Main.Exists = true;
|
||||
Window_Main.UIScaleX = DEFAULT_UI_SCALE_X;
|
||||
Window_Main.UIScaleY = DEFAULT_UI_SCALE_Y;
|
||||
|
||||
Input.Sources = INPUT_SOURCE_GAMEPAD;
|
||||
sceDisplaySetMode(0, SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||
|
@ -45,7 +45,10 @@ void Window_Init(void) {
|
||||
Window_Main.Width = DISPLAY_WIDTH;
|
||||
Window_Main.Height = DISPLAY_HEIGHT;
|
||||
Window_Main.Focused = true;
|
||||
|
||||
Window_Main.Exists = true;
|
||||
Window_Main.UIScaleX = DEFAULT_UI_SCALE_X;
|
||||
Window_Main.UIScaleY = DEFAULT_UI_SCALE_Y;
|
||||
|
||||
Window_Main.SoftKeyboard = SOFT_KEYBOARD_RESIZE;
|
||||
Input_SetTouchMode(true);
|
||||
|
@ -92,6 +92,8 @@ static void DoCreateWindow(int width, int height, int flags) {
|
||||
RefreshWindowBounds();
|
||||
Window_Main.Exists = true;
|
||||
Window_Main.Handle = win_handle;
|
||||
Window_Main.UIScaleX = DEFAULT_UI_SCALE_X;
|
||||
Window_Main.UIScaleY = DEFAULT_UI_SCALE_Y;
|
||||
ApplyIcon();
|
||||
/* TODO grab using SDL_SetWindowGrab? seems to be unnecessary on Linux at least */
|
||||
}
|
||||
|
@ -75,6 +75,8 @@ static void DoCreateWindow(int width, int height, int flags) {
|
||||
RefreshWindowBounds();
|
||||
Window_Main.Exists = true;
|
||||
Window_Main.Handle = win_handle;
|
||||
Window_Main.UIScaleX = DEFAULT_UI_SCALE_X;
|
||||
Window_Main.UIScaleY = DEFAULT_UI_SCALE_Y;
|
||||
ApplyIcon();
|
||||
/* TODO grab using SDL_SetWindowGrab? seems to be unnecessary on Linux at least */
|
||||
}
|
||||
|
@ -38,7 +38,10 @@ void Window_Init(void) {
|
||||
Window_Main.Width = DisplayInfo.Width;
|
||||
Window_Main.Height = DisplayInfo.Height;
|
||||
Window_Main.Focused = true;
|
||||
|
||||
Window_Main.Exists = true;
|
||||
Window_Main.UIScaleX = DEFAULT_UI_SCALE_X;
|
||||
Window_Main.UIScaleY = DEFAULT_UI_SCALE_Y;
|
||||
|
||||
Input.Sources = INPUT_SOURCE_GAMEPAD;
|
||||
DisplayInfo.ContentOffsetX = 10;
|
||||
|
@ -69,6 +69,8 @@ void Window_Init(void) {
|
||||
Window_Main.Focused = true;
|
||||
Window_Main.Exists = true;
|
||||
Window_Main.Handle = nwindowGetDefault();
|
||||
Window_Main.UIScaleX = DEFAULT_UI_SCALE_X;
|
||||
Window_Main.UIScaleY = DEFAULT_UI_SCALE_Y;
|
||||
|
||||
Window_Main.SoftKeyboard = SOFT_KEYBOARD_RESIZE;
|
||||
Input_SetTouchMode(true);
|
||||
|
@ -427,6 +427,9 @@ static void DoCreateWindow(int width, int height) {
|
||||
Window_Main.Exists = true;
|
||||
Window_Main.Handle = (void*)1;
|
||||
Window_Main.Focused = true;
|
||||
|
||||
Window_Main.UIScaleX = DEFAULT_UI_SCALE_X;
|
||||
Window_Main.UIScaleY = DEFAULT_UI_SCALE_Y;
|
||||
}
|
||||
void Window_Create2D(int width, int height) { DoCreateWindow(width, height); }
|
||||
void Window_Create3D(int width, int height) { DoCreateWindow(width, height); }
|
||||
|
@ -419,6 +419,9 @@ extern void interop_InitContainer(void);
|
||||
static void DoCreateWindow(void) {
|
||||
Window_Main.Exists = true;
|
||||
Window_Main.Focused = true;
|
||||
Window_Main.UIScaleX = DEFAULT_UI_SCALE_X;
|
||||
Window_Main.UIScaleY = DEFAULT_UI_SCALE_Y;
|
||||
|
||||
HookEvents();
|
||||
/* Let the webpage decide on initial bounds */
|
||||
Window_Main.Width = interop_CanvasWidth();
|
||||
|
@ -92,7 +92,10 @@ void Window_Init(void) {
|
||||
Window_Main.Width = DisplayInfo.Width;
|
||||
Window_Main.Height = DisplayInfo.Height;
|
||||
Window_Main.Focused = true;
|
||||
|
||||
Window_Main.Exists = true;
|
||||
Window_Main.UIScaleX = DEFAULT_UI_SCALE_X;
|
||||
Window_Main.UIScaleY = DEFAULT_UI_SCALE_Y;
|
||||
|
||||
Input.Sources = INPUT_SOURCE_GAMEPAD;
|
||||
DisplayInfo.ContentOffsetX = 10;
|
||||
|
@ -396,6 +396,9 @@ static void DoCreateWindow(int width, int height) {
|
||||
|
||||
Window_Main.Exists = true;
|
||||
Window_Main.Handle = win_handle;
|
||||
Window_Main.UIScaleX = DEFAULT_UI_SCALE_X;
|
||||
Window_Main.UIScaleY = DEFAULT_UI_SCALE_Y;
|
||||
|
||||
grabCursor = Options_GetBool(OPT_GRAB_CURSOR, false);
|
||||
}
|
||||
void Window_Create2D(int width, int height) { DoCreateWindow(width, height); }
|
||||
|
@ -373,6 +373,8 @@ static void DoCreateWindow(int width, int height) {
|
||||
RefreshWindowBounds(width, height);
|
||||
Window_Main.Exists = true;
|
||||
Window_Main.Handle = (void*)win_handle;
|
||||
Window_Main.UIScaleX = DEFAULT_UI_SCALE_X;
|
||||
Window_Main.UIScaleY = DEFAULT_UI_SCALE_Y;
|
||||
grabCursor = Options_GetBool(OPT_GRAB_CURSOR, false);
|
||||
|
||||
/* So right name appears in e.g. Ubuntu Unity launchbar */
|
||||
|
@ -73,7 +73,10 @@ void Window_Init(void) {
|
||||
Window_Main.Width = mode.width;
|
||||
Window_Main.Height = mode.height;
|
||||
Window_Main.Focused = true;
|
||||
|
||||
Window_Main.Exists = true;
|
||||
Window_Main.UIScaleX = DEFAULT_UI_SCALE_X;
|
||||
Window_Main.UIScaleY = DEFAULT_UI_SCALE_Y;
|
||||
|
||||
Input.Sources = INPUT_SOURCE_GAMEPAD;
|
||||
DisplayInfo.ContentOffsetX = 10;
|
||||
|
@ -36,7 +36,10 @@ void Window_Init(void) {
|
||||
Window_Main.Width = DisplayInfo.Width;
|
||||
Window_Main.Height = DisplayInfo.Height;
|
||||
Window_Main.Focused = true;
|
||||
|
||||
Window_Main.Exists = true;
|
||||
Window_Main.UIScaleX = DEFAULT_UI_SCALE_X;
|
||||
Window_Main.UIScaleY = DEFAULT_UI_SCALE_Y;
|
||||
|
||||
Input.Sources = INPUT_SOURCE_GAMEPAD;
|
||||
|
||||
|
@ -380,6 +380,8 @@ static void DoCreateWindow(int width, int height) {
|
||||
|
||||
Window_Main.Exists = true;
|
||||
Window_Main.Handle = winHandle;
|
||||
Window_Main.UIScaleX = DEFAULT_UI_SCALE_X;
|
||||
Window_Main.UIScaleY = DEFAULT_UI_SCALE_Y;
|
||||
// CGAssociateMouseAndMouseCursorPosition implicitly grabs cursor
|
||||
|
||||
del = [CCWindowDelegate alloc];
|
||||
|
@ -471,6 +471,9 @@ static CGRect DoCreateWindow(void) {
|
||||
win_handle.rootViewController = cc_controller;
|
||||
win_handle.backgroundColor = CalcBackgroundColor();
|
||||
Window_Main.Exists = true;
|
||||
Window_Main.UIScaleX = DEFAULT_UI_SCALE_X;
|
||||
Window_Main.UIScaleY = DEFAULT_UI_SCALE_Y;
|
||||
|
||||
Window_Main.Width = bounds.size.width;
|
||||
Window_Main.Height = bounds.size.height;
|
||||
|
||||
|
75
third_party/gldc/src/aligned_vector.h
vendored
75
third_party/gldc/src/aligned_vector.h
vendored
@ -61,12 +61,9 @@ AV_FORCE_INLINE void *AV_MEMCPY4(void *dest, const void *src, size_t len)
|
||||
typedef struct {
|
||||
uint32_t size;
|
||||
uint32_t capacity;
|
||||
} __attribute__((aligned(32))) AlignedVectorHeader;
|
||||
|
||||
typedef struct {
|
||||
AlignedVectorHeader hdr;
|
||||
uint32_t padding[6];
|
||||
uint8_t* data;
|
||||
} AlignedVector;
|
||||
} __attribute__((aligned(32))) AlignedVector;
|
||||
|
||||
#define ALIGNED_VECTOR_CHUNK_SIZE 256u
|
||||
|
||||
@ -76,16 +73,14 @@ typedef struct {
|
||||
|
||||
|
||||
AV_FORCE_INLINE void* aligned_vector_at(const AlignedVector* vector, const uint32_t index) {
|
||||
const AlignedVectorHeader* hdr = &vector->hdr;
|
||||
assert(index < hdr->size);
|
||||
assert(index < vector->size);
|
||||
return vector->data + (index * AV_ELEMENT_SIZE);
|
||||
}
|
||||
|
||||
AV_FORCE_INLINE void* aligned_vector_reserve(AlignedVector* vector, uint32_t element_count) {
|
||||
AlignedVectorHeader* hdr = &vector->hdr;
|
||||
uint32_t original_byte_size = (hdr->size * AV_ELEMENT_SIZE);
|
||||
uint32_t original_byte_size = (vector->size * AV_ELEMENT_SIZE);
|
||||
|
||||
if(element_count < hdr->capacity) {
|
||||
if(element_count < vector->capacity) {
|
||||
return vector->data + original_byte_size;
|
||||
}
|
||||
|
||||
@ -101,28 +96,10 @@ AV_FORCE_INLINE void* aligned_vector_reserve(AlignedVector* vector, uint32_t ele
|
||||
AV_MEMCPY4(vector->data, original_data, original_byte_size);
|
||||
free(original_data);
|
||||
|
||||
hdr->capacity = element_count;
|
||||
vector->capacity = element_count;
|
||||
return vector->data + original_byte_size;
|
||||
}
|
||||
|
||||
AV_FORCE_INLINE AlignedVectorHeader* aligned_vector_header(const AlignedVector* vector) {
|
||||
return (AlignedVectorHeader*) &vector->hdr;
|
||||
}
|
||||
|
||||
AV_FORCE_INLINE uint32_t aligned_vector_size(const AlignedVector* vector) {
|
||||
const AlignedVectorHeader* hdr = &vector->hdr;
|
||||
return hdr->size;
|
||||
}
|
||||
|
||||
AV_FORCE_INLINE uint32_t aligned_vector_capacity(const AlignedVector* vector) {
|
||||
const AlignedVectorHeader* hdr = &vector->hdr;
|
||||
return hdr->capacity;
|
||||
}
|
||||
|
||||
AV_FORCE_INLINE void* aligned_vector_front(const AlignedVector* vector) {
|
||||
return vector->data;
|
||||
}
|
||||
|
||||
#define av_assert(x) \
|
||||
do {\
|
||||
if(!(x)) {\
|
||||
@ -135,27 +112,26 @@ AV_FORCE_INLINE void* aligned_vector_front(const AlignedVector* vector) {
|
||||
AV_FORCE_INLINE void* aligned_vector_resize(AlignedVector* vector, const uint32_t element_count) {
|
||||
void* ret = NULL;
|
||||
|
||||
AlignedVectorHeader* hdr = &vector->hdr;
|
||||
uint32_t previous_count = hdr->size;
|
||||
if(hdr->capacity <= element_count) {
|
||||
uint32_t previous_count = vector->size;
|
||||
if(vector->capacity <= element_count) {
|
||||
/* If we didn't have capacity, increase capacity (slow) */
|
||||
|
||||
aligned_vector_reserve(vector, element_count);
|
||||
hdr->size = element_count;
|
||||
vector->size = element_count;
|
||||
|
||||
ret = aligned_vector_at(vector, previous_count);
|
||||
|
||||
av_assert(hdr->size == element_count);
|
||||
av_assert(hdr->size <= hdr->capacity);
|
||||
av_assert(vector->size == element_count);
|
||||
av_assert(vector->size <= vector->capacity);
|
||||
} else if(previous_count < element_count) {
|
||||
/* So we grew, but had the capacity, just get a pointer to
|
||||
* where we were */
|
||||
hdr->size = element_count;
|
||||
av_assert(hdr->size < hdr->capacity);
|
||||
vector->size = element_count;
|
||||
av_assert(vector->size < vector->capacity);
|
||||
ret = aligned_vector_at(vector, previous_count);
|
||||
} else if(hdr->size != element_count) {
|
||||
hdr->size = element_count;
|
||||
av_assert(hdr->size < hdr->capacity);
|
||||
} else if(vector->size != element_count) {
|
||||
vector->size = element_count;
|
||||
av_assert(vector->size < vector->capacity);
|
||||
}
|
||||
|
||||
return ret;
|
||||
@ -163,41 +139,36 @@ AV_FORCE_INLINE void* aligned_vector_resize(AlignedVector* vector, const uint32_
|
||||
|
||||
AV_FORCE_INLINE void* aligned_vector_push_back(AlignedVector* vector, const void* objs, uint32_t count) {
|
||||
/* Resize enough room */
|
||||
AlignedVectorHeader* hdr = &vector->hdr;
|
||||
|
||||
assert(count);
|
||||
#ifndef NDEBUG
|
||||
uint32_t initial_size = hdr->size;
|
||||
uint32_t initial_size = vector->size;
|
||||
#endif
|
||||
|
||||
uint8_t* dest = (uint8_t*) aligned_vector_resize(vector, hdr->size + count);
|
||||
uint8_t* dest = (uint8_t*) aligned_vector_resize(vector, vector->size + count);
|
||||
assert(dest);
|
||||
|
||||
/* Copy the objects in */
|
||||
AV_MEMCPY4(dest, objs, count * AV_ELEMENT_SIZE);
|
||||
|
||||
assert(hdr->size == initial_size + count);
|
||||
assert(vector->size == initial_size + count);
|
||||
return dest;
|
||||
}
|
||||
|
||||
|
||||
AV_FORCE_INLINE void* aligned_vector_extend(AlignedVector* vector, const uint32_t additional_count) {
|
||||
AlignedVectorHeader* hdr = &vector->hdr;
|
||||
void* ret = aligned_vector_resize(vector, hdr->size + additional_count);
|
||||
void* ret = aligned_vector_resize(vector, vector->size + additional_count);
|
||||
assert(ret); // Should always return something
|
||||
return ret;
|
||||
}
|
||||
|
||||
AV_FORCE_INLINE void aligned_vector_clear(AlignedVector* vector){
|
||||
AlignedVectorHeader* hdr = &vector->hdr;
|
||||
hdr->size = 0;
|
||||
vector->size = 0;
|
||||
}
|
||||
|
||||
AV_FORCE_INLINE void aligned_vector_init(AlignedVector* vector) {
|
||||
/* Now initialize the header*/
|
||||
AlignedVectorHeader* const hdr = &vector->hdr;
|
||||
hdr->size = 0;
|
||||
hdr->capacity = 0;
|
||||
vector->size = 0;
|
||||
vector->capacity = 0;
|
||||
vector->data = NULL;
|
||||
}
|
||||
|
||||
|
33
third_party/gldc/src/flush.c
vendored
33
third_party/gldc/src/flush.c
vendored
@ -6,18 +6,7 @@ PolyList OP_LIST;
|
||||
PolyList PT_LIST;
|
||||
PolyList TR_LIST;
|
||||
|
||||
/**
|
||||
* FAST_MODE will use invW for all Z coordinates sent to the
|
||||
* GPU.
|
||||
*
|
||||
* This will break orthographic mode so default is FALSE
|
||||
**/
|
||||
|
||||
#define FAST_MODE GL_FALSE
|
||||
|
||||
void glKosInit() {
|
||||
TRACE();
|
||||
|
||||
_glInitContext();
|
||||
_glInitTextures();
|
||||
|
||||
@ -36,31 +25,29 @@ void glKosInit() {
|
||||
|
||||
|
||||
void glKosSwapBuffers() {
|
||||
TRACE();
|
||||
_glApplyScissor(true);
|
||||
|
||||
pvr_scene_begin();
|
||||
if(aligned_vector_size(&OP_LIST.vector) > 2) {
|
||||
if(OP_LIST.vector.size > 2) {
|
||||
pvr_list_begin(PVR_LIST_OP_POLY);
|
||||
SceneListSubmit((Vertex*) aligned_vector_front(&OP_LIST.vector), aligned_vector_size(&OP_LIST.vector));
|
||||
SceneListSubmit((Vertex*)OP_LIST.vector.data, OP_LIST.vector.size);
|
||||
pvr_list_finish();
|
||||
}
|
||||
|
||||
if(aligned_vector_size(&PT_LIST.vector) > 2) {
|
||||
if(PT_LIST.vector.size > 2) {
|
||||
pvr_list_begin(PVR_LIST_PT_POLY);
|
||||
SceneListSubmit((Vertex*) aligned_vector_front(&PT_LIST.vector), aligned_vector_size(&PT_LIST.vector));
|
||||
SceneListSubmit((Vertex*)PT_LIST.vector.data, PT_LIST.vector.size);
|
||||
pvr_list_finish();
|
||||
}
|
||||
|
||||
if(aligned_vector_size(&TR_LIST.vector) > 2) {
|
||||
if(TR_LIST.vector.size > 2) {
|
||||
pvr_list_begin(PVR_LIST_TR_POLY);
|
||||
SceneListSubmit((Vertex*) aligned_vector_front(&TR_LIST.vector), aligned_vector_size(&TR_LIST.vector));
|
||||
SceneListSubmit((Vertex*)TR_LIST.vector.data, TR_LIST.vector.size);
|
||||
pvr_list_finish();
|
||||
}
|
||||
pvr_scene_finish();
|
||||
|
||||
aligned_vector_clear(&OP_LIST.vector);
|
||||
aligned_vector_clear(&PT_LIST.vector);
|
||||
aligned_vector_clear(&TR_LIST.vector);
|
||||
|
||||
_glApplyScissor(true);
|
||||
OP_LIST.vector.size = 0;
|
||||
PT_LIST.vector.size = 0;
|
||||
TR_LIST.vector.size = 0;
|
||||
}
|
||||
|
34
third_party/gldc/src/sh4.c
vendored
34
third_party/gldc/src/sh4.c
vendored
@ -14,24 +14,12 @@ GL_FORCE_INLINE float _glFastInvert(float x) {
|
||||
}
|
||||
|
||||
GL_FORCE_INLINE void _glPerspectiveDivideVertex(Vertex* vertex) {
|
||||
TRACE();
|
||||
|
||||
const float f = _glFastInvert(vertex->w);
|
||||
|
||||
/* Convert to NDC and apply viewport */
|
||||
vertex->xyz[0] = (vertex->xyz[0] * f * VIEWPORT.hwidth) + VIEWPORT.x_plus_hwidth;
|
||||
vertex->xyz[1] = (vertex->xyz[1] * f * VIEWPORT.hheight) + VIEWPORT.y_plus_hheight;
|
||||
|
||||
/* Orthographic projections need to use invZ otherwise we lose
|
||||
the depth information. As w == 1, and clip-space range is -w to +w
|
||||
we add 1.0 to the Z to bring it into range. We add a little extra to
|
||||
avoid a divide by zero.
|
||||
*/
|
||||
if(vertex->w == 1.0f) {
|
||||
vertex->xyz[2] = _glFastInvert(1.0001f + vertex->xyz[2]);
|
||||
} else {
|
||||
vertex->xyz[2] = f;
|
||||
}
|
||||
vertex->x = (vertex->x * f * VIEWPORT.hwidth) + VIEWPORT.x_plus_hwidth;
|
||||
vertex->y = (vertex->y * f * VIEWPORT.hheight) + VIEWPORT.y_plus_hheight;
|
||||
vertex->z = f;
|
||||
}
|
||||
|
||||
|
||||
@ -62,17 +50,17 @@ static inline void _glPushHeaderOrVertex(Vertex* v) {
|
||||
}
|
||||
|
||||
static void _glClipEdge(const Vertex* const v1, const Vertex* const v2, Vertex* vout) {
|
||||
const float d0 = v1->w + v1->xyz[2];
|
||||
const float d1 = v2->w + v2->xyz[2];
|
||||
const float t = (fabs(d0) * MATH_fsrra((d1 - d0) * (d1 - d0))) + 0.000001f;
|
||||
const float d0 = v1->w + v1->z;
|
||||
const float d1 = v2->w + v2->z;
|
||||
const float t = (fabsf(d0) * MATH_fsrra((d1 - d0) * (d1 - d0))) + 0.000001f;
|
||||
const float invt = 1.0f - t;
|
||||
|
||||
vout->xyz[0] = invt * v1->xyz[0] + t * v2->xyz[0];
|
||||
vout->xyz[1] = invt * v1->xyz[1] + t * v2->xyz[1];
|
||||
vout->xyz[2] = invt * v1->xyz[2] + t * v2->xyz[2];
|
||||
vout->x = invt * v1->x + t * v2->x;
|
||||
vout->y = invt * v1->y + t * v2->y;
|
||||
vout->z = invt * v1->z + t * v2->z;
|
||||
|
||||
vout->uv[0] = invt * v1->uv[0] + t * v2->uv[0];
|
||||
vout->uv[1] = invt * v1->uv[1] + t * v2->uv[1];
|
||||
vout->u = invt * v1->u + t * v2->u;
|
||||
vout->v = invt * v1->v + t * v2->v;
|
||||
|
||||
vout->w = invt * v1->w + t * v2->w;
|
||||
|
||||
|
8
third_party/gldc/src/state.c
vendored
8
third_party/gldc/src/state.c
vendored
@ -87,14 +87,10 @@ void glScissor(int x, int y, int width, int height) {
|
||||
*/
|
||||
void _glApplyScissor(int force) {
|
||||
/* Don't do anyting if clipping is disabled */
|
||||
if(!SCISSOR_TEST_ENABLED) {
|
||||
return;
|
||||
}
|
||||
if (!SCISSOR_TEST_ENABLED) return;
|
||||
|
||||
/* Don't apply if we already applied - nothing changed */
|
||||
if(scissor_rect.applied && !force) {
|
||||
return;
|
||||
}
|
||||
if (scissor_rect.applied && !force) return;
|
||||
|
||||
PVRTileClipCommand c;
|
||||
|
||||
|
4
third_party/gldc/src/types.h
vendored
4
third_party/gldc/src/types.h
vendored
@ -5,8 +5,8 @@
|
||||
typedef struct {
|
||||
/* Same 32 byte layout as pvr_vertex_t */
|
||||
uint32_t flags;
|
||||
float xyz[3];
|
||||
float uv[2];
|
||||
float x, y, z;
|
||||
float u, v;
|
||||
uint8_t bgra[4];
|
||||
|
||||
/* In the pvr_vertex_t structure, this next 4 bytes is oargb
|
||||
|
Loading…
x
Reference in New Issue
Block a user