diff --git a/src/Graphics_3DS.c b/src/Graphics_3DS.c index 36c8d53ec..76a22f8bc 100644 --- a/src/Graphics_3DS.c +++ b/src/Graphics_3DS.c @@ -447,7 +447,7 @@ void Gfx_SetAlphaBlending(cc_bool enabled) { } } -void Gfx_SetAlphaTest(cc_bool enabled) { +static void SetAlphaTest(cc_bool enabled) { C3D_AlphaTest(enabled, GPU_GREATER, 0x7F); } diff --git a/src/Graphics_D3D11.c b/src/Graphics_D3D11.c index 19f57f626..5afd4b395 100644 --- a/src/Graphics_D3D11.c +++ b/src/Graphics_D3D11.c @@ -691,7 +691,7 @@ void Gfx_SetFaceCulling(cc_bool enabled) { static ID3D11SamplerState* ps_samplers[2]; static ID3D11PixelShader* ps_shaders[12]; static ID3D11Buffer* ps_cBuffer; -static cc_bool ps_alphaTesting, ps_mipmaps; +static cc_bool ps_mipmaps; static float ps_fogEnd, ps_fogDensity; static PackedCol ps_fogColor; static int ps_fogMode; @@ -725,7 +725,7 @@ static void PS_CreateShaders(void) { static int PS_CalcShaderIndex(void) { int idx = gfx_format == VERTEX_FORMAT_COLOURED ? 0 : 1; - if (ps_alphaTesting) idx += 2; + if (gfx_alphaTest) idx += 2; if (gfx_fogEnabled) { // uncomment when it works @@ -822,8 +822,7 @@ static void PS_Free(void) { PS_FreeConstants(); } -void Gfx_SetAlphaTest(cc_bool enabled) { - ps_alphaTesting = enabled; +static void SetAlphaTest(cc_bool enabled) { PS_UpdateShader(); } // unnecessary? check if any performance is gained, probably irrelevant diff --git a/src/Graphics_D3D9.c b/src/Graphics_D3D9.c index 8cf140ade..d01d09298 100644 --- a/src/Graphics_D3D9.c +++ b/src/Graphics_D3D9.c @@ -394,7 +394,7 @@ void Gfx_DisableMipmaps(void) { *-----------------------------------------------------State management----------------------------------------------------* *#########################################################################################################################*/ static D3DFOGMODE gfx_fogMode = D3DFOG_NONE; -static cc_bool gfx_alphaTesting, gfx_alphaBlending; +static cc_bool gfx_alphaBlending; static cc_bool gfx_depthTesting, gfx_depthWriting; static PackedCol gfx_clearColor, gfx_fogColor; static float gfx_fogEnd = -1.0f, gfx_fogDensity = -1.0f; @@ -455,10 +455,7 @@ void Gfx_SetFogMode(FogFunc func) { IDirect3DDevice9_SetRenderState(device, D3DRS_FOGTABLEMODE, mode); } -void Gfx_SetAlphaTest(cc_bool enabled) { - if (gfx_alphaTesting == enabled) return; - gfx_alphaTesting = enabled; - +static void SetAlphaTest(cc_bool enabled) { if (Gfx.LostContext) return; IDirect3DDevice9_SetRenderState(device, D3DRS_ALPHATESTENABLE, enabled); } @@ -529,7 +526,7 @@ void Gfx_DepthOnlyRendering(cc_bool depthOnly) { static void D3D9_RestoreRenderStates(void) { union IntAndFloat raw; - IDirect3DDevice9_SetRenderState(device, D3DRS_ALPHATESTENABLE, gfx_alphaTesting); + IDirect3DDevice9_SetRenderState(device, D3DRS_ALPHATESTENABLE, gfx_alphaTest); IDirect3DDevice9_SetRenderState(device, D3DRS_ALPHABLENDENABLE, gfx_alphaBlending); IDirect3DDevice9_SetRenderState(device, D3DRS_FOGENABLE, gfx_fogEnabled); diff --git a/src/Graphics_Dreamcast.c b/src/Graphics_Dreamcast.c index baaa9f0d3..a219baab8 100644 --- a/src/Graphics_Dreamcast.c +++ b/src/Graphics_Dreamcast.c @@ -80,7 +80,7 @@ static void SetColorWrite(cc_bool r, cc_bool g, cc_bool b, cc_bool a) { void Gfx_SetDepthWrite(cc_bool enabled) { glDepthMask(enabled); } void Gfx_SetDepthTest(cc_bool enabled) { gl_Toggle(GL_DEPTH_TEST); } -void Gfx_SetAlphaTest(cc_bool enabled) { gl_Toggle(GL_ALPHA_TEST); } +static void SetAlphaTest(cc_bool enabled) { gl_Toggle(GL_ALPHA_TEST); } void Gfx_DepthOnlyRendering(cc_bool depthOnly) { // don't need a fake second pass in this case diff --git a/src/Graphics_GCWii.c b/src/Graphics_GCWii.c index 923b0cff3..df4074052 100644 --- a/src/Graphics_GCWii.c +++ b/src/Graphics_GCWii.c @@ -409,7 +409,7 @@ void Gfx_SetFogEnd(float value) { void Gfx_SetFogMode(FogFunc func) { } -void Gfx_SetAlphaTest(cc_bool enabled) { +static void SetAlphaTest(cc_bool enabled) { if (enabled) { GX_SetAlphaCompare(GX_GREATER, 127, GX_AOP_AND, GX_ALWAYS, 0); } else { diff --git a/src/Graphics_GL1.c b/src/Graphics_GL1.c index ea26aa58a..97ade43cc 100644 --- a/src/Graphics_GL1.c +++ b/src/Graphics_GL1.c @@ -534,7 +534,7 @@ void Gfx_SetFogMode(FogFunc func) { gfx_fogMode = func; } -void Gfx_SetAlphaTest(cc_bool enabled) { +static void SetAlphaTest(cc_bool enabled) { if (enabled) { glEnable(GL_ALPHA_TEST); } else { glDisable(GL_ALPHA_TEST); } } diff --git a/src/Graphics_GL2.c b/src/Graphics_GL2.c index e1aa6c6dc..6edfc67d9 100644 --- a/src/Graphics_GL2.c +++ b/src/Graphics_GL2.c @@ -202,7 +202,7 @@ void Gfx_SetDynamicVbData(GfxResourceID vb, void* vertices, int vCount) { /* cached uniforms (cached for multiple programs */ static struct Matrix _view, _proj, _mvp; -static cc_bool gfx_alphaTest, gfx_texTransform; +static cc_bool gfx_texTransform; static float _texX, _texY; static PackedCol gfx_fogColor; static float gfx_fogEnd = -1.0f, gfx_fogDensity = -1.0f; @@ -500,7 +500,7 @@ void Gfx_SetFogMode(FogFunc func) { SwitchProgram(); } -void Gfx_SetAlphaTest(cc_bool enabled) { gfx_alphaTest = enabled; SwitchProgram(); } +static void SetAlphaTest(cc_bool enabled) { SwitchProgram(); } void Gfx_DepthOnlyRendering(cc_bool depthOnly) { cc_bool enabled = !depthOnly; diff --git a/src/Graphics_N64.c b/src/Graphics_N64.c index 1b26f0458..a5c7c71f8 100644 --- a/src/Graphics_N64.c +++ b/src/Graphics_N64.c @@ -377,7 +377,7 @@ void Gfx_SetFogEnd(float value) { void Gfx_SetFogMode(FogFunc func) { } -void Gfx_SetAlphaTest(cc_bool enabled) { +static void SetAlphaTest(cc_bool enabled) { if (enabled) { glEnable(GL_ALPHA_TEST); } else { glDisable(GL_ALPHA_TEST); } } diff --git a/src/Graphics_NDS.c b/src/Graphics_NDS.c index ba081eaa5..9d22f36c1 100644 --- a/src/Graphics_NDS.c +++ b/src/Graphics_NDS.c @@ -376,7 +376,7 @@ void Gfx_SetFogEnd(float value) { void Gfx_SetFogMode(FogFunc func) { } -void Gfx_SetAlphaTest(cc_bool enabled) { +static void SetAlphaTest(cc_bool enabled) { if (enabled) { //glEnable(GL_ALPHA_TEST); } else { diff --git a/src/Graphics_PS1.c b/src/Graphics_PS1.c index ce21f156d..9e9a2b413 100644 --- a/src/Graphics_PS1.c +++ b/src/Graphics_PS1.c @@ -288,7 +288,7 @@ void Gfx_SetFaceCulling(cc_bool enabled) { // TODO } -void Gfx_SetAlphaTest(cc_bool enabled) { +static void SetAlphaTest(cc_bool enabled) { } void Gfx_SetAlphaBlending(cc_bool enabled) { diff --git a/src/Graphics_PS2.c b/src/Graphics_PS2.c index 383bd8677..fe4e7bb0b 100644 --- a/src/Graphics_PS2.c +++ b/src/Graphics_PS2.c @@ -244,7 +244,6 @@ void Gfx_DisableMipmaps(void) { } *#########################################################################################################################*/ static int clearR, clearG, clearB; static cc_bool gfx_alphaBlend; -static cc_bool gfx_alphaTest; static cc_bool gfx_depthTest; static cc_bool stateDirty; @@ -274,9 +273,8 @@ void Gfx_SetFaceCulling(cc_bool enabled) { // TODO } -void Gfx_SetAlphaTest(cc_bool enabled) { - gfx_alphaTest = enabled; - stateDirty = true; +static void SetAlphaTest(cc_bool enabled) { + stateDirty = true; } void Gfx_SetAlphaBlending(cc_bool enabled) { diff --git a/src/Graphics_PS3.c b/src/Graphics_PS3.c index 3283ba3dc..2f0a01766 100644 --- a/src/Graphics_PS3.c +++ b/src/Graphics_PS3.c @@ -316,7 +316,7 @@ void Gfx_SetDepthTest(cc_bool enabled) { UpdateDepthState(); } -void Gfx_SetAlphaTest(cc_bool enabled) { +static void SetAlphaTest(cc_bool enabled) { rsxSetAlphaTestEnable(context, enabled); } diff --git a/src/Graphics_PSP.c b/src/Graphics_PSP.c index 82b53a93e..79d641d2b 100644 --- a/src/Graphics_PSP.c +++ b/src/Graphics_PSP.c @@ -377,7 +377,7 @@ void Gfx_SetFogMode(FogFunc func) { /* TODO: Implemen fake exp/exp2 fog */ } -void Gfx_SetAlphaTest(cc_bool enabled) { GU_Toggle(GU_ALPHA_TEST); } +static void SetAlphaTest(cc_bool enabled) { GU_Toggle(GU_ALPHA_TEST); } void Gfx_DepthOnlyRendering(cc_bool depthOnly) { cc_bool enabled = !depthOnly; diff --git a/src/Graphics_PSVita.c b/src/Graphics_PSVita.c index c96a799b6..c9319efa6 100644 --- a/src/Graphics_PSVita.c +++ b/src/Graphics_PSVita.c @@ -8,7 +8,7 @@ // TODO track last frame used on static cc_bool gfx_depthOnly; -static cc_bool gfx_alphaTesting, gfx_alphaBlending; +static cc_bool gfx_alphaBlending; static int frontBufferIndex, backBufferIndex; // Inspired from // https://github.com/xerpi/gxmfun/blob/master/source/main.c @@ -246,7 +246,7 @@ static void FP_SwitchActive(void) { index += 1; } - if (gfx_alphaTesting) index += 2 * 3; + if (gfx_alphaTest) index += 2 * 3; FragmentProgram* FP = &FP_list[index]; if (FP == FP_Active) return; @@ -964,8 +964,7 @@ void Gfx_SetFogMode(FogFunc func) { // TODO } -void Gfx_SetAlphaTest(cc_bool enabled) { - gfx_alphaTesting = enabled; +static void SetAlphaTest(cc_bool enabled) { FP_SwitchActive(); } diff --git a/src/Graphics_Saturn.c b/src/Graphics_Saturn.c index 0949fde19..be4daf902 100644 --- a/src/Graphics_Saturn.c +++ b/src/Graphics_Saturn.c @@ -143,7 +143,7 @@ void Gfx_SetFaceCulling(cc_bool enabled) { // TODO } -void Gfx_SetAlphaTest(cc_bool enabled) { +static void SetAlphaTest(cc_bool enabled) { } void Gfx_SetAlphaBlending(cc_bool enabled) { diff --git a/src/Graphics_SoftGPU.c b/src/Graphics_SoftGPU.c index 5b19f26fe..531968f0e 100644 --- a/src/Graphics_SoftGPU.c +++ b/src/Graphics_SoftGPU.c @@ -11,7 +11,6 @@ static float vp_hwidth, vp_hheight; static int sc_maxX, sc_maxY; static cc_bool alphaBlending; -static cc_bool alphaTest; static PackedCol* colorBuffer; static PackedCol clearColor; @@ -115,8 +114,8 @@ void Gfx_SetFaceCulling(cc_bool enabled) { faceCulling = enabled; } -void Gfx_SetAlphaTest(cc_bool enabled) { - alphaTest = enabled; +static void SetAlphaTest(cc_bool enabled) { + /* Uses value from Gfx_SetAlphaTest */ } void Gfx_SetAlphaBlending(cc_bool enabled) { @@ -401,7 +400,7 @@ static void DrawTriangle(Vector4 frag1, Vector4 frag2, Vector4 frag3, G = (G * A) / 255 + (dstG * (255 - A)) / 255; B = (B * A) / 255 + (dstB * (255 - A)) / 255; } - if (alphaTest && A < 0x80) continue; + if (gfx_alphaTest && A < 0x80) continue; if (depthWrite) depthBuffer[index] = z; colorBuffer[index] = BitmapCol_Make(R, G, B, 0xFF); diff --git a/src/Graphics_WiiU.c b/src/Graphics_WiiU.c index 7cc5991e5..c73854b42 100644 --- a/src/Graphics_WiiU.c +++ b/src/Graphics_WiiU.c @@ -177,7 +177,7 @@ void Gfx_SetFogMode(FogFunc func) { // TODO } -void Gfx_SetAlphaTest(cc_bool enabled) { +static void SetAlphaTest(cc_bool enabled) { GX2SetAlphaTest(enabled, GX2_COMPARE_FUNC_GEQUAL, 0.5f); } diff --git a/src/Graphics_Xbox.c b/src/Graphics_Xbox.c index e4c0d9378..1f6599546 100644 --- a/src/Graphics_Xbox.c +++ b/src/Graphics_Xbox.c @@ -305,7 +305,7 @@ void Gfx_SetAlphaBlending(cc_bool enabled) { pb_end(p); } -void Gfx_SetAlphaTest(cc_bool enabled) { +static void SetAlphaTest(cc_bool enabled) { uint32_t* p = pb_begin(); p = pb_push1(p, NV097_SET_ALPHA_TEST_ENABLE, enabled); pb_end(p); diff --git a/src/Graphics_Xbox360.c b/src/Graphics_Xbox360.c index 745729c02..0b82fcb2d 100644 --- a/src/Graphics_Xbox360.c +++ b/src/Graphics_Xbox360.c @@ -155,7 +155,7 @@ void Gfx_SetFogMode(FogFunc func) { // TODO } -void Gfx_SetAlphaTest(cc_bool enabled) { +static void SetAlphaTest(cc_bool enabled) { Xe_SetAlphaTestEnable(xe, enabled); } diff --git a/src/_GraphicsBase.h b/src/_GraphicsBase.h index b61cedb51..c868db6f5 100644 --- a/src/_GraphicsBase.h +++ b/src/_GraphicsBase.h @@ -31,6 +31,15 @@ static float gfx_minFrameMs; *#########################################################################################################################*/ static cc_bool gfx_colorMask[4] = { true, true, true, true }; cc_bool Gfx_GetFog(void) { return gfx_fogEnabled; } +static cc_bool gfx_alphaTest; + +static void SetAlphaTest(cc_bool enabled); +void Gfx_SetAlphaTest(cc_bool enabled) { + if (gfx_alphaTest == enabled) return; + + gfx_alphaTest = enabled; + SetAlphaTest(enabled); +} /* Initialises/Restores render state */ CC_NOINLINE static void Gfx_RestoreState(void); diff --git a/src/interop_ios.m b/src/interop_ios.m index 0ae0c0dbb..417470632 100644 --- a/src/interop_ios.m +++ b/src/interop_ios.m @@ -76,7 +76,7 @@ static UIInterfaceOrientationMask SupportedOrientations(void) { static cc_bool fullscreen = true; static void UpdateStatusBar(void) { - if (@available(iOS 10.7, *)) { + if ([cc_controller respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) { // setNeedsStatusBarAppearanceUpdate - iOS 7.0 [cc_controller setNeedsStatusBarAppearanceUpdate]; } else { @@ -509,16 +509,16 @@ void ShowDialogCore(const char* title, const char* msg) { NSString* _msg = [NSString stringWithCString:msg encoding:NSASCIIStringEncoding]; alert_completed = false; - if (@available(iOS 10.8, *)) { - UIAlertController* alert = [UIAlertController alertControllerWithTitle:_title message:_msg preferredStyle:UIAlertControllerStyleAlert]; - UIAlertAction* okBtn = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction* act) { alert_completed = true; }]; - [alert addAction:okBtn]; - [cc_controller presentViewController:alert animated:YES completion: Nil]; - } else { - UIAlertView* alert = [UIAlertView alloc]; - alert = [alert initWithTitle:_title message:_msg delegate:cc_controller cancelButtonTitle:@"OK" otherButtonTitles:nil]; - [alert show]; - } +#ifdef TARGET_OS_TV + UIAlertController* alert = [UIAlertController alertControllerWithTitle:_title message:_msg preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction* okBtn = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction* act) { alert_completed = true; }]; + [alert addAction:okBtn]; + [cc_controller presentViewController:alert animated:YES completion: Nil]; +#else + UIAlertView* alert = [UIAlertView alloc]; + alert = [alert initWithTitle:_title message:_msg delegate:cc_controller cancelButtonTitle:@"OK" otherButtonTitles:nil]; + [alert show]; +#endif // TODO clicking outside message box crashes launcher // loop until alert is closed TODO avoid sleeping @@ -651,18 +651,15 @@ cc_result Window_OpenFileDialog(const struct OpenFileDialogArgs* args) { if (utType) [types addObject:utType]; } - if (@available(iOS 10.8, *)) { - UIDocumentPickerViewController* dlg; - dlg = [UIDocumentPickerViewController alloc]; - dlg = [dlg initWithDocumentTypes:types inMode:UIDocumentPickerModeOpen]; - //dlg = [dlg initWithDocumentTypes:types inMode:UIDocumentPickerModeImport]; - - open_dlg_callback = args->Callback; - dlg.delegate = cc_controller; - [cc_controller presentViewController:dlg animated:YES completion: Nil]; - return 0; // TODO still unfinished - } - return ERR_NOT_SUPPORTED; + UIDocumentPickerViewController* dlg; + dlg = [UIDocumentPickerViewController alloc]; + dlg = [dlg initWithDocumentTypes:types inMode:UIDocumentPickerModeOpen]; + //dlg = [dlg initWithDocumentTypes:types inMode:UIDocumentPickerModeImport]; + + open_dlg_callback = args->Callback; + dlg.delegate = cc_controller; + [cc_controller presentViewController:dlg animated:YES completion: Nil]; + return 0; // TODO still unfinished } cc_result Window_SaveFileDialog(const struct SaveFileDialogArgs* args) { @@ -680,16 +677,13 @@ cc_result Window_SaveFileDialog(const struct SaveFileDialogArgs* args) { NSString* str = ToNSString(&save_path); NSURL* url = [NSURL fileURLWithPath:str isDirectory:NO]; - if (@available(iOS 10.8, *)) { - UIDocumentPickerViewController* dlg; - dlg = [UIDocumentPickerViewController alloc]; - dlg = [dlg initWithURL:url inMode:UIDocumentPickerModeExportToService]; - - dlg.delegate = cc_controller; - [cc_controller presentViewController:dlg animated:YES completion: Nil]; - return 0; // TODO still unfinished - } - return ERR_NOT_SUPPORTED; + UIDocumentPickerViewController* dlg; + dlg = [UIDocumentPickerViewController alloc]; + dlg = [dlg initWithURL:url inMode:UIDocumentPickerModeExportToService]; + + dlg.delegate = cc_controller; + [cc_controller presentViewController:dlg animated:YES completion: Nil]; + return 0; } @@ -1841,4 +1835,4 @@ void LBackend_CloseScreen(struct LScreen* s) { { [view removeFromSuperview]; } -} +} \ No newline at end of file