Merge pull request #1072 from UnknownShadow200/MainClosingRewrite

Allow closing back to launcher on consoles
This commit is contained in:
UnknownShadow200 2023-09-29 16:07:59 +10:00 committed by GitHub
commit 0c2b52efe7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 123 additions and 150 deletions

View file

@ -4,6 +4,8 @@ SOURCE_DIRS := src third_party/bearssl/src
C_FILES := $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.c)) C_FILES := $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.c))
OBJS := $(addprefix $(BUILD_DIR)/, $(notdir $(C_FILES:%.c=%.o))) OBJS := $(addprefix $(BUILD_DIR)/, $(notdir $(C_FILES:%.c=%.o)))
CFLAGS :=-g -O1 -pipe -fno-math-errno -Ithird_party/bearssl/inc CFLAGS :=-g -O1 -pipe -fno-math-errno -Ithird_party/bearssl/inc
LDFLAGS=-g
LIBS=-lm
TARGET := ClassiCube-dc TARGET := ClassiCube-dc
@ -24,7 +26,7 @@ $(BUILD_DIR)/%.o: third_party/bearssl/src/%.c
$(TARGET).elf: $(OBJS) $(TARGET).elf: $(OBJS)
kos-cc $^ -o $@ kos-cc $(LDFLAGS) $^ -o $@ $(LIBS)
$(TARGET).bin: $(TARGET).elf $(TARGET).bin: $(TARGET).elf
sh-elf-objcopy -R .stack -O binary $(TARGET).elf $(TARGET).bin sh-elf-objcopy -R .stack -O binary $(TARGET).elf $(TARGET).bin

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

View file

@ -496,7 +496,7 @@
<ClCompile Include="Platform_PSP.c" /> <ClCompile Include="Platform_PSP.c" />
<ClCompile Include="Platform_PSVita.c" /> <ClCompile Include="Platform_PSVita.c" />
<ClCompile Include="Platform_Web.c" /> <ClCompile Include="Platform_Web.c" />
<ClCompile Include="Platform_WinApi.c" /> <ClCompile Include="Platform_Windows.c" />
<ClCompile Include="Platform_Xbox.c" /> <ClCompile Include="Platform_Xbox.c" />
<ClCompile Include="Protocol.c" /> <ClCompile Include="Protocol.c" />
<ClCompile Include="Physics.c" /> <ClCompile Include="Physics.c" />

View file

@ -596,7 +596,7 @@
<ClCompile Include="Platform_3DS.c"> <ClCompile Include="Platform_3DS.c">
<Filter>Source Files\Platform</Filter> <Filter>Source Files\Platform</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="Platform_WinApi.c"> <ClCompile Include="Platform_Windows.c">
<Filter>Source Files\Platform</Filter> <Filter>Source Files\Platform</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="Graphics_3DS.c"> <ClCompile Include="Graphics_3DS.c">

View file

@ -49,6 +49,7 @@ int Game_MaxViewDistance = DEFAULT_MAX_VIEWDIST;
int Game_FpsLimit, Game_Vertices; int Game_FpsLimit, Game_Vertices;
cc_bool Game_SimpleArmsAnim; cc_bool Game_SimpleArmsAnim;
static cc_bool gameRunning;
cc_bool Game_ClassicMode, Game_ClassicHacks; cc_bool Game_ClassicMode, Game_ClassicHacks;
cc_bool Game_AllowCustomBlocks; cc_bool Game_AllowCustomBlocks;
@ -365,7 +366,7 @@ static void LoadPlugins(void) {
} }
#endif #endif
void Game_Free(void* obj); static void Game_Free(void* obj);
static void Game_Load(void) { static void Game_Load(void) {
struct IGameComponent* comp; struct IGameComponent* comp;
Game_UpdateDimensions(); Game_UpdateDimensions();
@ -615,7 +616,7 @@ static void Game_RenderFrame(double delta) {
Gfx_EndFrame(); Gfx_EndFrame();
} }
void Game_Free(void* obj) { static void Game_Free(void* obj) {
struct IGameComponent* comp; struct IGameComponent* comp;
/* Most components will call OnContextLost in their Free functions */ /* Most components will call OnContextLost in their Free functions */
/* Set to false so components will always free managed textures too */ /* Set to false so components will always free managed textures too */
@ -627,6 +628,7 @@ void Game_Free(void* obj) {
if (comp->Free) comp->Free(); if (comp->Free) comp->Free();
} }
gameRunning = false;
Logger_WarnFunc = Logger_DialogWarn; Logger_WarnFunc = Logger_DialogWarn;
Gfx_Free(); Gfx_Free();
Options_SaveIfChanged(); Options_SaveIfChanged();
@ -638,7 +640,7 @@ void Game_Free(void* obj) {
delta = Stopwatch_ElapsedMicroseconds(Game_FrameStart, render) / (1000.0 * 1000.0);\ delta = Stopwatch_ElapsedMicroseconds(Game_FrameStart, render) / (1000.0 * 1000.0);\
\ \
Window_ProcessEvents(delta);\ Window_ProcessEvents(delta);\
if (!WindowInfo.Exists) return;\ if (!gameRunning) return;\
\ \
if (delta > 1.0) delta = 1.0; /* avoid large delta with suspended process */ \ if (delta > 1.0) delta = 1.0; /* avoid large delta with suspended process */ \
if (delta > 0.0) { Game_FrameStart = render; Game_RenderFrame(delta); } if (delta > 0.0) { Game_FrameStart = render; Game_RenderFrame(delta); }
@ -681,6 +683,7 @@ void Game_Run(int width, int height, const cc_string* title) {
Window_Create3D(width, height); Window_Create3D(width, height);
Window_SetTitle(title); Window_SetTitle(title);
Window_Show(); Window_Show();
gameRunning = true;
Game_Load(); Game_Load();
Event_RaiseVoid(&WindowEvents.Resized); Event_RaiseVoid(&WindowEvents.Resized);

View file

@ -125,21 +125,37 @@ static void SetDefaultState(void) {
Gfx_SetAlphaTest(false); Gfx_SetAlphaTest(false);
Gfx_SetDepthWrite(true); Gfx_SetDepthWrite(true);
} }
static void InitCitro3D(void) {
static GfxResourceID white_square;
void Gfx_Create(void) {
Gfx.MaxTexWidth = 512;
Gfx.MaxTexHeight = 512;
Gfx.Created = true;
gfx_vsync = true;
C3D_Init(C3D_DEFAULT_CMDBUF_SIZE); C3D_Init(C3D_DEFAULT_CMDBUF_SIZE);
target = C3D_RenderTargetCreate(240, 400, GPU_RB_RGBA8, GPU_RB_DEPTH24_STENCIL8); target = C3D_RenderTargetCreate(240, 400, GPU_RB_RGBA8, GPU_RB_DEPTH24_STENCIL8);
C3D_RenderTargetSetOutput(target, GFX_TOP, GFX_LEFT, DISPLAY_TRANSFER_FLAGS); C3D_RenderTargetSetOutput(target, GFX_TOP, GFX_LEFT, DISPLAY_TRANSFER_FLAGS);
SetDefaultState(); SetDefaultState();
InitDefaultResources();
AllocShaders(); AllocShaders();
}
static GfxResourceID white_square;
void Gfx_Create(void) {
if (!Gfx.Created) InitCitro3D();
Gfx.MaxTexWidth = 512;
Gfx.MaxTexHeight = 512;
Gfx.Created = true;
gfx_vsync = true;
Gfx_RestoreState();
}
void Gfx_Free(void) {
Gfx_FreeState();
// FreeShaders()
// C3D_Fini()
}
cc_bool Gfx_TryRestoreContext(void) { return true; }
void Gfx_RestoreState(void) {
InitDefaultResources();
// 8x8 dummy white texture // 8x8 dummy white texture
// (textures must be at least 8x8, see C3D_TexInitWithParams source) // (textures must be at least 8x8, see C3D_TexInitWithParams source)
@ -150,16 +166,11 @@ void Gfx_Create(void) {
white_square = Gfx_CreateTexture(&bmp, 0, false); white_square = Gfx_CreateTexture(&bmp, 0, false);
} }
void Gfx_Free(void) { void Gfx_FreeState(void) {
FreeShaders();
FreeDefaultResources(); FreeDefaultResources();
Gfx_DeleteTexture(&white_square); Gfx_DeleteTexture(&white_square);
} }
cc_bool Gfx_TryRestoreContext(void) { return true; }
void Gfx_RestoreState(void) { }
void Gfx_FreeState(void) { }
/*########################################################################################################################* /*########################################################################################################################*
*---------------------------------------------------------Textures--------------------------------------------------------* *---------------------------------------------------------Textures--------------------------------------------------------*
*#########################################################################################################################*/ *#########################################################################################################################*/

View file

@ -19,9 +19,10 @@ static cc_bool renderingDisabled;
*---------------------------------------------------------General---------------------------------------------------------* *---------------------------------------------------------General---------------------------------------------------------*
*#########################################################################################################################*/ *#########################################################################################################################*/
void Gfx_Create(void) { void Gfx_Create(void) {
glKosInit(); if (!Gfx.Created) glKosInit();
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &Gfx.MaxTexWidth); // NOTE: technically 1024 is supported by hardware
Gfx.MaxTexHeight = Gfx.MaxTexWidth; Gfx.MaxTexWidth = 512;
Gfx.MaxTexHeight = 512;
Gfx.Created = true; Gfx.Created = true;
Gfx_RestoreState(); Gfx_RestoreState();
} }
@ -242,9 +243,10 @@ static unsigned Interleave(unsigned x) {
} }
/*static int CalcTwiddledIndex(int x, int y, int w, int h) { /*static int CalcTwiddledIndex(int x, int y, int w, int h) {
// Twiddled index looks like this (starting from lowest numbered bits): // Twiddled index looks like this (lowest numbered bits are leftmost):
// e.g. w > h: yx_yx_xx_xx // - w = h: yxyx yxyx
// e.g. h > w: yx_yx_yy_yy // - w > h: yxyx xxxx
// - h > w: yxyx yyyy
// And can therefore be broken down into two components: // And can therefore be broken down into two components:
// 1) interleaved lower bits // 1) interleaved lower bits
// 2) masked and then shifted higher bits // 2) masked and then shifted higher bits
@ -484,8 +486,6 @@ static CC_NOINLINE void UnshiftTextureCoords(int count) {
static void Gfx_FreeState(void) { FreeDefaultResources(); } static void Gfx_FreeState(void) { FreeDefaultResources(); }
static void Gfx_RestoreState(void) { static void Gfx_RestoreState(void) {
InitDefaultResources(); InitDefaultResources();
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
gfx_format = -1; gfx_format = -1;
glAlphaFunc(GL_GREATER, 0.5f); glAlphaFunc(GL_GREATER, 0.5f);
@ -519,10 +519,8 @@ void Gfx_SetVertexFormat(VertexFormat fmt) {
gfx_stride = strideSizes[fmt]; gfx_stride = strideSizes[fmt];
if (fmt == VERTEX_FORMAT_TEXTURED) { if (fmt == VERTEX_FORMAT_TEXTURED) {
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
} else { } else {
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
} }
} }

View file

@ -48,12 +48,13 @@ static void InitGX(void) {
} }
void Gfx_Create(void) { void Gfx_Create(void) {
if (!Gfx.Created) InitGX();
Gfx.MaxTexWidth = 512; Gfx.MaxTexWidth = 512;
Gfx.MaxTexHeight = 512; Gfx.MaxTexHeight = 512;
Gfx.Created = true; Gfx.Created = true;
gfx_vsync = true; gfx_vsync = true;
InitGX();
Gfx_RestoreState(); Gfx_RestoreState();
} }

View file

@ -72,10 +72,23 @@ static void guInit(void) {
static GfxResourceID white_square; static GfxResourceID white_square;
void Gfx_Create(void) { void Gfx_Create(void) {
if (!Gfx.Created) guInit();
Gfx.MaxTexWidth = 512; Gfx.MaxTexWidth = 512;
Gfx.MaxTexHeight = 512; Gfx.MaxTexHeight = 512;
Gfx.Created = true; Gfx.Created = true;
guInit(); gfx_vsync = true;
Gfx_RestoreState();
}
void Gfx_Free(void) {
Gfx_FreeState();
}
cc_bool Gfx_TryRestoreContext(void) { return true; }
void Gfx_RestoreState(void) {
InitDefaultResources(); InitDefaultResources();
// 1x1 dummy white texture // 1x1 dummy white texture
@ -85,14 +98,11 @@ void Gfx_Create(void) {
white_square = Gfx_CreateTexture(&bmp, 0, false); white_square = Gfx_CreateTexture(&bmp, 0, false);
} }
void Gfx_Free(void) { void Gfx_FreeState(void) {
FreeDefaultResources(); FreeDefaultResources();
Gfx_DeleteTexture(&white_square); Gfx_DeleteTexture(&white_square);
} }
cc_bool Gfx_TryRestoreContext(void) { return true; }
void Gfx_RestoreState(void) { }
void Gfx_FreeState(void) { }
#define GU_Toggle(cap) if (enabled) { sceGuEnable(cap); } else { sceGuDisable(cap); } #define GU_Toggle(cap) if (enabled) { sceGuEnable(cap); } else { sceGuDisable(cap); }
/*########################################################################################################################* /*########################################################################################################################*
@ -424,4 +434,4 @@ void Gfx_DrawIndexedTris_T2fC4b(int verticesCount, int startVertex) {
sceGuDrawArray(GU_TRIANGLES, gfx_fields | GU_INDEX_16BIT, ICOUNT(verticesCount), sceGuDrawArray(GU_TRIANGLES, gfx_fields | GU_INDEX_16BIT, ICOUNT(verticesCount),
gfx_indices, gfx_vertices + startVertex * SIZEOF_VERTEX_TEXTURED); gfx_indices, gfx_vertices + startVertex * SIZEOF_VERTEX_TEXTURED);
} }
#endif #endif

View file

@ -523,11 +523,7 @@ static void SetDefaultStates(void) {
sceGxmSetBackDepthFunc(gxm_context, SCE_GXM_DEPTH_FUNC_LESS_EQUAL); sceGxmSetBackDepthFunc(gxm_context, SCE_GXM_DEPTH_FUNC_LESS_EQUAL);
} }
void Gfx_Create(void) { static void InitGPU(void) {
Gfx.MaxTexWidth = 512;
Gfx.MaxTexHeight = 512;
Gfx.Created = true;
InitGXM(); InitGXM();
AllocRingBuffers(); AllocRingBuffers();
AllocGXMContext(); AllocGXMContext();
@ -547,13 +543,33 @@ void Gfx_Create(void) {
AllocTexturedVertexProgram(1); AllocTexturedVertexProgram(1);
CreateFragmentPrograms(3, gxm_textured_FP, gxm_textured_VP); CreateFragmentPrograms(3, gxm_textured_FP, gxm_textured_VP);
CreateFragmentPrograms(9, gxm_textured_alpha_FP, gxm_textured_VP); CreateFragmentPrograms(9, gxm_textured_alpha_FP, gxm_textured_VP);
}
void Gfx_Create(void) {
if (!Gfx.Created) InitGPU();
Gfx.MaxTexWidth = 512;
Gfx.MaxTexHeight = 512;
Gfx.Created = true;
gfx_vsync = true;
Gfx_SetDepthTest(true); Gfx_SetDepthTest(true);
InitDefaultResources();
Gfx_SetVertexFormat(VERTEX_FORMAT_COLOURED); Gfx_SetVertexFormat(VERTEX_FORMAT_COLOURED);
frontBufferIndex = NUM_DISPLAY_BUFFERS - 1; frontBufferIndex = NUM_DISPLAY_BUFFERS - 1;
backBufferIndex = 0; backBufferIndex = 0;
Gfx_RestoreState();
}
void Gfx_Free(void) {
Gfx_FreeState();
}
cc_bool Gfx_TryRestoreContext(void) { return true; }
void Gfx_RestoreState(void) {
InitDefaultResources();
// 1x1 dummy white texture // 1x1 dummy white texture
struct Bitmap bmp; struct Bitmap bmp;
BitmapCol pixels[1] = { BITMAPCOLOR_WHITE }; BitmapCol pixels[1] = { BITMAPCOLOR_WHITE };
@ -562,15 +578,11 @@ void Gfx_Create(void) {
// TODO // TODO
} }
void Gfx_Free(void) { void Gfx_FreeState(void) {
FreeDefaultResources(); FreeDefaultResources();
Gfx_DeleteTexture(&white_square); Gfx_DeleteTexture(&white_square);
} }
cc_bool Gfx_TryRestoreContext(void) { return true; }
void Gfx_RestoreState(void) { }
void Gfx_FreeState(void) { }
/*########################################################################################################################* /*########################################################################################################################*
*--------------------------------------------------------GPU Textures-----------------------------------------------------* *--------------------------------------------------------GPU Textures-----------------------------------------------------*

View file

@ -70,7 +70,7 @@ void Window_Show(void) { }
void Window_SetSize(int width, int height) { } void Window_SetSize(int width, int height) { }
void Window_Close(void) { void Window_Close(void) {
/* TODO implement */ Event_RaiseVoid(&WindowEvents.Closing);
} }
/*########################################################################################################################* /*########################################################################################################################*

View file

@ -302,7 +302,7 @@ static void RemakeWindowSurface(void) {
/* Loop until window gets created by main UI thread */ /* Loop until window gets created by main UI thread */
/* (i.e. until processSurfaceCreated is received) */ /* (i.e. until processSurfaceCreated is received) */
while (!winCreated) { while (!winCreated) {
Window_ProcessEvents(0.0); Window_ProcessEvents(0.01);
Thread_Sleep(10); Thread_Sleep(10);
} }

View file

@ -60,7 +60,7 @@ void Window_Show(void) { }
void Window_SetSize(int width, int height) { } void Window_SetSize(int width, int height) { }
void Window_Close(void) { void Window_Close(void) {
/* TODO implement */ Event_RaiseVoid(&WindowEvents.Closing);
} }
/*########################################################################################################################* /*########################################################################################################################*

View file

@ -16,6 +16,7 @@
#include <wiikeyboard/keyboard.h> #include <wiikeyboard/keyboard.h>
#endif #endif
static cc_bool needsFBUpdate;
static cc_bool launcherMode; static cc_bool launcherMode;
static void* xfb; static void* xfb;
static GXRModeObj* rmode; static GXRModeObj* rmode;
@ -28,16 +29,10 @@ int Display_ScaleY(int y) { return y; }
static void OnPowerOff(void) { static void OnPowerOff(void) {
Event_RaiseVoid(&WindowEvents.Closing);
WindowInfo.Exists = false; WindowInfo.Exists = false;
Window_Close();
} }
static void InitVideo(void) {
void Window_Init(void) {
// TODO: SYS_SetResetCallback(reload); too? not sure how reset differs on GC/WII
#if defined HW_RVL
SYS_SetPowerCallback(OnPowerOff);
#endif
// Initialise the video system // Initialise the video system
VIDEO_Init(); VIDEO_Init();
@ -61,6 +56,14 @@ void Window_Init(void) {
VIDEO_Flush(); VIDEO_Flush();
// Wait for Video setup to complete // Wait for Video setup to complete
VIDEO_WaitVSync(); VIDEO_WaitVSync();
}
void Window_Init(void) {
// TODO: SYS_SetResetCallback(reload); too? not sure how reset differs on GC/WII
#if defined HW_RVL
SYS_SetPowerCallback(OnPowerOff);
#endif
InitVideo();
DisplayInfo.Width = rmode->fbWidth; DisplayInfo.Width = rmode->fbWidth;
DisplayInfo.Height = rmode->xfbHeight; DisplayInfo.Height = rmode->xfbHeight;
@ -81,11 +84,17 @@ void Window_Init(void) {
PAD_Init(); PAD_Init();
} }
void Window_Create2D(int width, int height) { launcherMode = true; } void Window_Create2D(int width, int height) {
void Window_Create3D(int width, int height) { launcherMode = false; } needsFBUpdate = true;
launcherMode = true;
}
void Window_Create3D(int width, int height) {
launcherMode = false;
}
void Window_Close(void) { void Window_Close(void) {
/* TODO implement */ Event_RaiseVoid(&WindowEvents.Closing);
} }
@ -465,6 +474,13 @@ static u32 CvtRGB (u8 r1, u8 g1, u8 b1, u8 r2, u8 g2, u8 b2)
} }
void Window_DrawFramebuffer(Rect2D r) { void Window_DrawFramebuffer(Rect2D r) {
// When coming back from the 3D game, framebuffer might have changed
if (needsFBUpdate) {
VIDEO_SetNextFramebuffer(xfb);
VIDEO_Flush();
needsFBUpdate = false;
}
VIDEO_WaitVSync(); VIDEO_WaitVSync();
r.X &= ~0x01; // round down to nearest even horizontal index r.X &= ~0x01; // round down to nearest even horizontal index

View file

@ -79,7 +79,7 @@ void Window_Show(void) { }
void Window_SetSize(int width, int height) { } void Window_SetSize(int width, int height) { }
void Window_Close(void) { void Window_Close(void) {
/* TODO implement */ Event_RaiseVoid(&WindowEvents.Closing);
} }

View file

@ -58,7 +58,7 @@ void Window_Show(void) { }
void Window_SetSize(int width, int height) { } void Window_SetSize(int width, int height) { }
void Window_Close(void) { void Window_Close(void) {
/* TODO implement */ Event_RaiseVoid(&WindowEvents.Closing);
} }

View file

@ -61,7 +61,7 @@ void Window_Show(void) { }
void Window_SetSize(int width, int height) { } void Window_SetSize(int width, int height) { }
void Window_Close(void) { void Window_Close(void) {
/* TODO implement */ Event_RaiseVoid(&WindowEvents.Closing);
} }

View file

@ -98,7 +98,7 @@ void Window_Show(void) { }
void Window_SetSize(int width, int height) { } void Window_SetSize(int width, int height) { }
void Window_Close(void) { void Window_Close(void) {
/* TODO implement */ Event_RaiseVoid(&WindowEvents.Closing);
} }

View file

@ -24,5 +24,5 @@ default: $(TARGET)
kos-cc $(C_DEFINES) $(C_INCLUDES) $(C_FLAGS) -c $< -o $@ kos-cc $(C_DEFINES) $(C_INCLUDES) $(C_FLAGS) -c $< -o $@
$(TARGET): $(OBJS) $(TARGET): $(OBJS)
kos-ar cr $@ $< kos-ar cr $@ $^
kos-ranlib $@ kos-ranlib $@

View file

@ -97,11 +97,6 @@ __BEGIN_DECLS
/* Fog */ /* Fog */
#define GL_FOG 0x0004 /* capability bit */ #define GL_FOG 0x0004 /* capability bit */
/* Client state caps */
#define GL_VERTEX_ARRAY 0x8074
#define GL_COLOR_ARRAY 0x8076
#define GL_TEXTURE_COORD_ARRAY 0x8078
#define GL_FRONT_AND_BACK 0x0408 #define GL_FRONT_AND_BACK 0x0408
#define GL_FRONT 0x0404 #define GL_FRONT 0x0404
#define GL_BACK 0x0405 #define GL_BACK 0x0405
@ -126,9 +121,6 @@ __BEGIN_DECLS
#define GL_INVALID_OPERATION 0x0502 #define GL_INVALID_OPERATION 0x0502
#define GL_OUT_OF_MEMORY 0x0505 #define GL_OUT_OF_MEMORY 0x0505
/* GetPName */
#define GL_MAX_TEXTURE_SIZE 0x0D33
/* StringName */ /* StringName */
#define GL_VENDOR 0x1F00 #define GL_VENDOR 0x1F00
#define GL_RENDERER 0x1F01 #define GL_RENDERER 0x1F01
@ -259,9 +251,6 @@ GLAPI void glVertexPointer(GLint size, GLenum type,
GLAPI void glDrawArrays(GLenum mode, GLint first, GLsizei count); GLAPI void glDrawArrays(GLenum mode, GLint first, GLsizei count);
GLAPI void glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices); GLAPI void glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
GLAPI void glEnableClientState(GLenum cap);
GLAPI void glDisableClientState(GLenum cap);
/* Transformation / Matrix Functions */ /* Transformation / Matrix Functions */
GLAPI void glViewport(GLint x, GLint y, GLsizei width, GLsizei height); GLAPI void glViewport(GLint x, GLint y, GLsizei width, GLsizei height);

View file

@ -10,7 +10,6 @@
static void* VERTEX_PTR; static void* VERTEX_PTR;
static GLsizei VERTEX_STRIDE; static GLsizei VERTEX_STRIDE;
static GLuint ENABLED_VERTEX_ATTRIBUTES;
extern GLboolean AUTOSORT_ENABLED; extern GLboolean AUTOSORT_ENABLED;
@ -59,7 +58,7 @@ static void generateQuads(SubmissionTarget* target, const GLsizei first, const G
/* Copy the pos, uv and color directly in one go */ /* Copy the pos, uv and color directly in one go */
const GLubyte* pos = VERTEX_PTR; const GLubyte* pos = VERTEX_PTR;
const GLubyte* uv = (ENABLED_VERTEX_ATTRIBUTES & UV_ENABLED_FLAG) ? VERTEX_PTR : NULL; const GLubyte* uv = TEXTURES_ENABLED ? VERTEX_PTR : NULL;
const GLubyte* col = VERTEX_PTR; const GLubyte* col = VERTEX_PTR;
Vertex* dst = start; Vertex* dst = start;
@ -332,43 +331,7 @@ void APIENTRY glDrawArrays(GLenum mode, GLint first, GLsizei count) {
submitVertices(mode, first, count); submitVertices(mode, first, count);
} }
void APIENTRY glEnableClientState(GLenum cap) {
TRACE();
switch(cap) {
case GL_VERTEX_ARRAY:
ENABLED_VERTEX_ATTRIBUTES |= VERTEX_ENABLED_FLAG;
break;
case GL_COLOR_ARRAY:
ENABLED_VERTEX_ATTRIBUTES |= DIFFUSE_ENABLED_FLAG;
break;
case GL_TEXTURE_COORD_ARRAY:
ENABLED_VERTEX_ATTRIBUTES |= UV_ENABLED_FLAG;
break;
default:
_glKosThrowError(GL_INVALID_ENUM, __func__);
}
}
void APIENTRY glDisableClientState(GLenum cap) {
TRACE();
switch(cap) {
case GL_VERTEX_ARRAY:
ENABLED_VERTEX_ATTRIBUTES &= ~VERTEX_ENABLED_FLAG;
break;
case GL_COLOR_ARRAY:
ENABLED_VERTEX_ATTRIBUTES &= ~DIFFUSE_ENABLED_FLAG;
break;
case GL_TEXTURE_COORD_ARRAY:
ENABLED_VERTEX_ATTRIBUTES &= ~UV_ENABLED_FLAG;
break;
default:
_glKosThrowError(GL_INVALID_ENUM, __func__);
}
}
void APIENTRY glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid * pointer) { void APIENTRY glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid * pointer) {
VERTEX_PTR = pointer; VERTEX_PTR = pointer;
VERTEX_STRIDE = stride; VERTEX_STRIDE = stride;
} }

View file

@ -36,13 +36,6 @@ extern void* memcpy4 (void *dest, const void *src, size_t count);
#define TRACE_ENABLED 0 #define TRACE_ENABLED 0
#define TRACE() if(TRACE_ENABLED) {fprintf(stderr, "%s\n", __func__);} (void) 0 #define TRACE() if(TRACE_ENABLED) {fprintf(stderr, "%s\n", __func__);} (void) 0
#define VERTEX_ENABLED_FLAG (1 << 0)
#define UV_ENABLED_FLAG (1 << 1)
#define ST_ENABLED_FLAG (1 << 2)
#define DIFFUSE_ENABLED_FLAG (1 << 3)
#define MAX_TEXTURE_SIZE 1024
typedef struct { typedef struct {
unsigned int flags; /* Constant PVR_CMD_USERCLIP */ unsigned int flags; /* Constant PVR_CMD_USERCLIP */
unsigned int d1, d2, d3; /* Ignored for this type */ unsigned int d1, d2, d3; /* Ignored for this type */
@ -208,22 +201,6 @@ GLubyte _glInitTextures();
void _glUpdatePVRTextureContext(PolyContext* context, GLshort textureUnit); void _glUpdatePVRTextureContext(PolyContext* context, GLshort textureUnit);
typedef struct {
const void* ptr; // 4
GLenum type; // 4
GLsizei stride; // 4
GLint size; // 4
} AttribPointer;
typedef struct {
AttribPointer vertex; // 16
AttribPointer colour; // 32
AttribPointer uv; // 48
AttribPointer st; // 64
AttribPointer normal; // 80
AttribPointer padding; // 96
} AttribPointerList;
GLboolean _glCheckValidEnum(GLint param, GLint* values, const char* func); GLboolean _glCheckValidEnum(GLint param, GLint* values, const char* func);
GLenum _glGetShadeModel(); GLenum _glGetShadeModel();
@ -289,12 +266,6 @@ GL_FORCE_INLINE void _glKosResetError() {
sprintf(ERROR_FUNCTION, "\n"); sprintf(ERROR_FUNCTION, "\n");
} }
typedef struct {
float n[3]; // 12 bytes
float finalColour[4]; //28 bytes
uint32_t padding; // 32 bytes
} EyeSpaceData;
unsigned char _glIsClippingEnabled(); unsigned char _glIsClippingEnabled();
void _glEnableClipping(unsigned char v); void _glEnableClipping(unsigned char v);

View file

@ -467,9 +467,6 @@ void _glApplyScissor(bool force) {
void APIENTRY glGetIntegerv(GLenum pname, GLint *params) { void APIENTRY glGetIntegerv(GLenum pname, GLint *params) {
switch(pname) { switch(pname) {
case GL_MAX_TEXTURE_SIZE:
*params = MAX_TEXTURE_SIZE;
break;
case GL_TEXTURE_FREE_MEMORY_ATI: case GL_TEXTURE_FREE_MEMORY_ATI:
case GL_FREE_TEXTURE_MEMORY_KOS: case GL_FREE_TEXTURE_MEMORY_KOS:
*params = _glFreeTextureMemory(); *params = _glFreeTextureMemory();