mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-01-22 09:01:57 -05:00
Merge pull request #1072 from UnknownShadow200/MainClosingRewrite
Allow closing back to launcher on consoles
This commit is contained in:
commit
0c2b52efe7
24 changed files with 123 additions and 150 deletions
|
@ -4,6 +4,8 @@ SOURCE_DIRS := src third_party/bearssl/src
|
|||
C_FILES := $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.c))
|
||||
OBJS := $(addprefix $(BUILD_DIR)/, $(notdir $(C_FILES:%.c=%.o)))
|
||||
CFLAGS :=-g -O1 -pipe -fno-math-errno -Ithird_party/bearssl/inc
|
||||
LDFLAGS=-g
|
||||
LIBS=-lm
|
||||
|
||||
TARGET := ClassiCube-dc
|
||||
|
||||
|
@ -24,7 +26,7 @@ $(BUILD_DIR)/%.o: third_party/bearssl/src/%.c
|
|||
|
||||
|
||||
$(TARGET).elf: $(OBJS)
|
||||
kos-cc $^ -o $@
|
||||
kos-cc $(LDFLAGS) $^ -o $@ $(LIBS)
|
||||
|
||||
$(TARGET).bin: $(TARGET).elf
|
||||
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 |
|
@ -496,7 +496,7 @@
|
|||
<ClCompile Include="Platform_PSP.c" />
|
||||
<ClCompile Include="Platform_PSVita.c" />
|
||||
<ClCompile Include="Platform_Web.c" />
|
||||
<ClCompile Include="Platform_WinApi.c" />
|
||||
<ClCompile Include="Platform_Windows.c" />
|
||||
<ClCompile Include="Platform_Xbox.c" />
|
||||
<ClCompile Include="Protocol.c" />
|
||||
<ClCompile Include="Physics.c" />
|
||||
|
|
|
@ -596,7 +596,7 @@
|
|||
<ClCompile Include="Platform_3DS.c">
|
||||
<Filter>Source Files\Platform</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Platform_WinApi.c">
|
||||
<ClCompile Include="Platform_Windows.c">
|
||||
<Filter>Source Files\Platform</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Graphics_3DS.c">
|
||||
|
|
|
@ -49,6 +49,7 @@ int Game_MaxViewDistance = DEFAULT_MAX_VIEWDIST;
|
|||
|
||||
int Game_FpsLimit, Game_Vertices;
|
||||
cc_bool Game_SimpleArmsAnim;
|
||||
static cc_bool gameRunning;
|
||||
|
||||
cc_bool Game_ClassicMode, Game_ClassicHacks;
|
||||
cc_bool Game_AllowCustomBlocks;
|
||||
|
@ -365,7 +366,7 @@ static void LoadPlugins(void) {
|
|||
}
|
||||
#endif
|
||||
|
||||
void Game_Free(void* obj);
|
||||
static void Game_Free(void* obj);
|
||||
static void Game_Load(void) {
|
||||
struct IGameComponent* comp;
|
||||
Game_UpdateDimensions();
|
||||
|
@ -615,7 +616,7 @@ static void Game_RenderFrame(double delta) {
|
|||
Gfx_EndFrame();
|
||||
}
|
||||
|
||||
void Game_Free(void* obj) {
|
||||
static void Game_Free(void* obj) {
|
||||
struct IGameComponent* comp;
|
||||
/* Most components will call OnContextLost in their Free functions */
|
||||
/* 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();
|
||||
}
|
||||
|
||||
gameRunning = false;
|
||||
Logger_WarnFunc = Logger_DialogWarn;
|
||||
Gfx_Free();
|
||||
Options_SaveIfChanged();
|
||||
|
@ -638,7 +640,7 @@ void Game_Free(void* obj) {
|
|||
delta = Stopwatch_ElapsedMicroseconds(Game_FrameStart, render) / (1000.0 * 1000.0);\
|
||||
\
|
||||
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 > 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_SetTitle(title);
|
||||
Window_Show();
|
||||
gameRunning = true;
|
||||
|
||||
Game_Load();
|
||||
Event_RaiseVoid(&WindowEvents.Resized);
|
||||
|
|
|
@ -125,21 +125,37 @@ static void SetDefaultState(void) {
|
|||
Gfx_SetAlphaTest(false);
|
||||
Gfx_SetDepthWrite(true);
|
||||
}
|
||||
|
||||
static GfxResourceID white_square;
|
||||
void Gfx_Create(void) {
|
||||
Gfx.MaxTexWidth = 512;
|
||||
Gfx.MaxTexHeight = 512;
|
||||
Gfx.Created = true;
|
||||
gfx_vsync = true;
|
||||
|
||||
static void InitCitro3D(void) {
|
||||
C3D_Init(C3D_DEFAULT_CMDBUF_SIZE);
|
||||
target = C3D_RenderTargetCreate(240, 400, GPU_RB_RGBA8, GPU_RB_DEPTH24_STENCIL8);
|
||||
C3D_RenderTargetSetOutput(target, GFX_TOP, GFX_LEFT, DISPLAY_TRANSFER_FLAGS);
|
||||
|
||||
SetDefaultState();
|
||||
InitDefaultResources();
|
||||
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
|
||||
// (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);
|
||||
}
|
||||
|
||||
void Gfx_Free(void) {
|
||||
FreeShaders();
|
||||
void Gfx_FreeState(void) {
|
||||
FreeDefaultResources();
|
||||
Gfx_DeleteTexture(&white_square);
|
||||
}
|
||||
|
||||
cc_bool Gfx_TryRestoreContext(void) { return true; }
|
||||
void Gfx_RestoreState(void) { }
|
||||
void Gfx_FreeState(void) { }
|
||||
|
||||
/*########################################################################################################################*
|
||||
*---------------------------------------------------------Textures--------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
|
|
|
@ -19,9 +19,10 @@ static cc_bool renderingDisabled;
|
|||
*---------------------------------------------------------General---------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
void Gfx_Create(void) {
|
||||
glKosInit();
|
||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &Gfx.MaxTexWidth);
|
||||
Gfx.MaxTexHeight = Gfx.MaxTexWidth;
|
||||
if (!Gfx.Created) glKosInit();
|
||||
// NOTE: technically 1024 is supported by hardware
|
||||
Gfx.MaxTexWidth = 512;
|
||||
Gfx.MaxTexHeight = 512;
|
||||
Gfx.Created = true;
|
||||
Gfx_RestoreState();
|
||||
}
|
||||
|
@ -242,9 +243,10 @@ static unsigned Interleave(unsigned x) {
|
|||
}
|
||||
|
||||
/*static int CalcTwiddledIndex(int x, int y, int w, int h) {
|
||||
// Twiddled index looks like this (starting from lowest numbered bits):
|
||||
// e.g. w > h: yx_yx_xx_xx
|
||||
// e.g. h > w: yx_yx_yy_yy
|
||||
// Twiddled index looks like this (lowest numbered bits are leftmost):
|
||||
// - w = h: yxyx yxyx
|
||||
// - w > h: yxyx xxxx
|
||||
// - h > w: yxyx yyyy
|
||||
// And can therefore be broken down into two components:
|
||||
// 1) interleaved lower 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_RestoreState(void) {
|
||||
InitDefaultResources();
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
gfx_format = -1;
|
||||
|
||||
glAlphaFunc(GL_GREATER, 0.5f);
|
||||
|
@ -519,10 +519,8 @@ void Gfx_SetVertexFormat(VertexFormat fmt) {
|
|||
gfx_stride = strideSizes[fmt];
|
||||
|
||||
if (fmt == VERTEX_FORMAT_TEXTURED) {
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
} else {
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,12 +48,13 @@ static void InitGX(void) {
|
|||
}
|
||||
|
||||
void Gfx_Create(void) {
|
||||
if (!Gfx.Created) InitGX();
|
||||
|
||||
Gfx.MaxTexWidth = 512;
|
||||
Gfx.MaxTexHeight = 512;
|
||||
Gfx.Created = true;
|
||||
gfx_vsync = true;
|
||||
|
||||
InitGX();
|
||||
Gfx_RestoreState();
|
||||
}
|
||||
|
||||
|
|
|
@ -72,10 +72,23 @@ static void guInit(void) {
|
|||
|
||||
static GfxResourceID white_square;
|
||||
void Gfx_Create(void) {
|
||||
if (!Gfx.Created) guInit();
|
||||
|
||||
Gfx.MaxTexWidth = 512;
|
||||
Gfx.MaxTexHeight = 512;
|
||||
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();
|
||||
|
||||
// 1x1 dummy white texture
|
||||
|
@ -85,14 +98,11 @@ void Gfx_Create(void) {
|
|||
white_square = Gfx_CreateTexture(&bmp, 0, false);
|
||||
}
|
||||
|
||||
void Gfx_Free(void) {
|
||||
void Gfx_FreeState(void) {
|
||||
FreeDefaultResources();
|
||||
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); }
|
||||
|
||||
/*########################################################################################################################*
|
||||
|
@ -424,4 +434,4 @@ void Gfx_DrawIndexedTris_T2fC4b(int verticesCount, int startVertex) {
|
|||
sceGuDrawArray(GU_TRIANGLES, gfx_fields | GU_INDEX_16BIT, ICOUNT(verticesCount),
|
||||
gfx_indices, gfx_vertices + startVertex * SIZEOF_VERTEX_TEXTURED);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -523,11 +523,7 @@ static void SetDefaultStates(void) {
|
|||
sceGxmSetBackDepthFunc(gxm_context, SCE_GXM_DEPTH_FUNC_LESS_EQUAL);
|
||||
}
|
||||
|
||||
void Gfx_Create(void) {
|
||||
Gfx.MaxTexWidth = 512;
|
||||
Gfx.MaxTexHeight = 512;
|
||||
Gfx.Created = true;
|
||||
|
||||
static void InitGPU(void) {
|
||||
InitGXM();
|
||||
AllocRingBuffers();
|
||||
AllocGXMContext();
|
||||
|
@ -547,13 +543,33 @@ void Gfx_Create(void) {
|
|||
AllocTexturedVertexProgram(1);
|
||||
CreateFragmentPrograms(3, gxm_textured_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);
|
||||
InitDefaultResources();
|
||||
Gfx_SetVertexFormat(VERTEX_FORMAT_COLOURED);
|
||||
frontBufferIndex = NUM_DISPLAY_BUFFERS - 1;
|
||||
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
|
||||
struct Bitmap bmp;
|
||||
BitmapCol pixels[1] = { BITMAPCOLOR_WHITE };
|
||||
|
@ -562,15 +578,11 @@ void Gfx_Create(void) {
|
|||
// TODO
|
||||
}
|
||||
|
||||
void Gfx_Free(void) {
|
||||
void Gfx_FreeState(void) {
|
||||
FreeDefaultResources();
|
||||
Gfx_DeleteTexture(&white_square);
|
||||
}
|
||||
|
||||
cc_bool Gfx_TryRestoreContext(void) { return true; }
|
||||
void Gfx_RestoreState(void) { }
|
||||
void Gfx_FreeState(void) { }
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*--------------------------------------------------------GPU Textures-----------------------------------------------------*
|
||||
|
|
|
@ -70,7 +70,7 @@ void Window_Show(void) { }
|
|||
void Window_SetSize(int width, int height) { }
|
||||
|
||||
void Window_Close(void) {
|
||||
/* TODO implement */
|
||||
Event_RaiseVoid(&WindowEvents.Closing);
|
||||
}
|
||||
|
||||
/*########################################################################################################################*
|
||||
|
|
|
@ -302,7 +302,7 @@ static void RemakeWindowSurface(void) {
|
|||
/* Loop until window gets created by main UI thread */
|
||||
/* (i.e. until processSurfaceCreated is received) */
|
||||
while (!winCreated) {
|
||||
Window_ProcessEvents(0.0);
|
||||
Window_ProcessEvents(0.01);
|
||||
Thread_Sleep(10);
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ void Window_Show(void) { }
|
|||
void Window_SetSize(int width, int height) { }
|
||||
|
||||
void Window_Close(void) {
|
||||
/* TODO implement */
|
||||
Event_RaiseVoid(&WindowEvents.Closing);
|
||||
}
|
||||
|
||||
/*########################################################################################################################*
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <wiikeyboard/keyboard.h>
|
||||
#endif
|
||||
|
||||
static cc_bool needsFBUpdate;
|
||||
static cc_bool launcherMode;
|
||||
static void* xfb;
|
||||
static GXRModeObj* rmode;
|
||||
|
@ -28,16 +29,10 @@ int Display_ScaleY(int y) { return y; }
|
|||
|
||||
|
||||
static void OnPowerOff(void) {
|
||||
Event_RaiseVoid(&WindowEvents.Closing);
|
||||
WindowInfo.Exists = false;
|
||||
Window_Close();
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
static void InitVideo(void) {
|
||||
// Initialise the video system
|
||||
VIDEO_Init();
|
||||
|
||||
|
@ -61,6 +56,14 @@ void Window_Init(void) {
|
|||
VIDEO_Flush();
|
||||
// Wait for Video setup to complete
|
||||
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.Height = rmode->xfbHeight;
|
||||
|
@ -81,11 +84,17 @@ void Window_Init(void) {
|
|||
PAD_Init();
|
||||
}
|
||||
|
||||
void Window_Create2D(int width, int height) { launcherMode = true; }
|
||||
void Window_Create3D(int width, int height) { launcherMode = false; }
|
||||
void Window_Create2D(int width, int height) {
|
||||
needsFBUpdate = true;
|
||||
launcherMode = true;
|
||||
}
|
||||
|
||||
void Window_Create3D(int width, int height) {
|
||||
launcherMode = false;
|
||||
}
|
||||
|
||||
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) {
|
||||
// When coming back from the 3D game, framebuffer might have changed
|
||||
if (needsFBUpdate) {
|
||||
VIDEO_SetNextFramebuffer(xfb);
|
||||
VIDEO_Flush();
|
||||
needsFBUpdate = false;
|
||||
}
|
||||
|
||||
VIDEO_WaitVSync();
|
||||
r.X &= ~0x01; // round down to nearest even horizontal index
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ void Window_Show(void) { }
|
|||
void Window_SetSize(int width, int height) { }
|
||||
|
||||
void Window_Close(void) {
|
||||
/* TODO implement */
|
||||
Event_RaiseVoid(&WindowEvents.Closing);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ void Window_Show(void) { }
|
|||
void Window_SetSize(int width, int height) { }
|
||||
|
||||
void Window_Close(void) {
|
||||
/* TODO implement */
|
||||
Event_RaiseVoid(&WindowEvents.Closing);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ void Window_Show(void) { }
|
|||
void Window_SetSize(int width, int height) { }
|
||||
|
||||
void Window_Close(void) {
|
||||
/* TODO implement */
|
||||
Event_RaiseVoid(&WindowEvents.Closing);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ void Window_Show(void) { }
|
|||
void Window_SetSize(int width, int height) { }
|
||||
|
||||
void Window_Close(void) {
|
||||
/* TODO implement */
|
||||
Event_RaiseVoid(&WindowEvents.Closing);
|
||||
}
|
||||
|
||||
|
||||
|
|
2
third_party/gldc/Makefile
vendored
2
third_party/gldc/Makefile
vendored
|
@ -24,5 +24,5 @@ default: $(TARGET)
|
|||
kos-cc $(C_DEFINES) $(C_INCLUDES) $(C_FLAGS) -c $< -o $@
|
||||
|
||||
$(TARGET): $(OBJS)
|
||||
kos-ar cr $@ $<
|
||||
kos-ar cr $@ $^
|
||||
kos-ranlib $@
|
||||
|
|
11
third_party/gldc/include/gldc.h
vendored
11
third_party/gldc/include/gldc.h
vendored
|
@ -97,11 +97,6 @@ __BEGIN_DECLS
|
|||
/* Fog */
|
||||
#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 0x0404
|
||||
#define GL_BACK 0x0405
|
||||
|
@ -126,9 +121,6 @@ __BEGIN_DECLS
|
|||
#define GL_INVALID_OPERATION 0x0502
|
||||
#define GL_OUT_OF_MEMORY 0x0505
|
||||
|
||||
/* GetPName */
|
||||
#define GL_MAX_TEXTURE_SIZE 0x0D33
|
||||
|
||||
/* StringName */
|
||||
#define GL_VENDOR 0x1F00
|
||||
#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 glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
|
||||
|
||||
GLAPI void glEnableClientState(GLenum cap);
|
||||
GLAPI void glDisableClientState(GLenum cap);
|
||||
|
||||
/* Transformation / Matrix Functions */
|
||||
|
||||
GLAPI void glViewport(GLint x, GLint y, GLsizei width, GLsizei height);
|
||||
|
|
41
third_party/gldc/src/draw.c
vendored
41
third_party/gldc/src/draw.c
vendored
|
@ -10,7 +10,6 @@
|
|||
|
||||
static void* VERTEX_PTR;
|
||||
static GLsizei VERTEX_STRIDE;
|
||||
static GLuint ENABLED_VERTEX_ATTRIBUTES;
|
||||
|
||||
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 */
|
||||
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;
|
||||
|
||||
Vertex* dst = start;
|
||||
|
@ -332,43 +331,7 @@ void APIENTRY glDrawArrays(GLenum mode, GLint first, GLsizei 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) {
|
||||
VERTEX_PTR = pointer;
|
||||
VERTEX_STRIDE = stride;
|
||||
}
|
||||
}
|
29
third_party/gldc/src/private.h
vendored
29
third_party/gldc/src/private.h
vendored
|
@ -36,13 +36,6 @@ extern void* memcpy4 (void *dest, const void *src, size_t count);
|
|||
#define TRACE_ENABLED 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 {
|
||||
unsigned int flags; /* Constant PVR_CMD_USERCLIP */
|
||||
unsigned int d1, d2, d3; /* Ignored for this type */
|
||||
|
@ -208,22 +201,6 @@ GLubyte _glInitTextures();
|
|||
|
||||
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);
|
||||
|
||||
GLenum _glGetShadeModel();
|
||||
|
@ -289,12 +266,6 @@ GL_FORCE_INLINE void _glKosResetError() {
|
|||
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();
|
||||
void _glEnableClipping(unsigned char v);
|
||||
|
||||
|
|
3
third_party/gldc/src/state.c
vendored
3
third_party/gldc/src/state.c
vendored
|
@ -467,9 +467,6 @@ void _glApplyScissor(bool force) {
|
|||
|
||||
void APIENTRY glGetIntegerv(GLenum pname, GLint *params) {
|
||||
switch(pname) {
|
||||
case GL_MAX_TEXTURE_SIZE:
|
||||
*params = MAX_TEXTURE_SIZE;
|
||||
break;
|
||||
case GL_TEXTURE_FREE_MEMORY_ATI:
|
||||
case GL_FREE_TEXTURE_MEMORY_KOS:
|
||||
*params = _glFreeTextureMemory();
|
||||
|
|
Loading…
Reference in a new issue