diff --git a/ClassicalSharp/GraphicsAPI/OpenGLApi.cs b/ClassicalSharp/GraphicsAPI/OpenGLApi.cs index a052a6ab2..1f7849314 100644 --- a/ClassicalSharp/GraphicsAPI/OpenGLApi.cs +++ b/ClassicalSharp/GraphicsAPI/OpenGLApi.cs @@ -548,7 +548,7 @@ namespace ClassicalSharp.GraphicsAPI { GL.GetIntegerv(GetPName.DepthBits, &depthBits); ApiInfo = new string[] { - "--Using OpenGL --", + "-- Using OpenGL --", "Vendor: " + vendor, "Renderer: " + renderer, "GL version: " + version, diff --git a/src/Client/D3D9Api.c b/src/Client/D3D9Api.c index 023388182..6f9ec78e4 100644 --- a/src/Client/D3D9Api.c +++ b/src/Client/D3D9Api.c @@ -606,12 +606,9 @@ void Gfx_BeginFrame(void) { void Gfx_EndFrame(void) { IDirect3DDevice9_EndScene(device); - ReturnCode code = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); - if ((Int32)code >= 0) return; - - if (code != D3DERR_DEVICELOST) { - ErrorHandler_FailWithCode(code, "D3D9_EndFrame"); - } + ReturnCode result = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); + if ((Int32)result >= 0) return; + if (result != D3DERR_DEVICELOST) ErrorHandler_FailWithCode(result, "D3D9_EndFrame"); /* TODO: Make sure this actually works on all graphics cards.*/ GfxCommon_LoseContext(" (Direct3D9 device lost)"); @@ -619,6 +616,46 @@ void Gfx_EndFrame(void) { D3D9_RecreateDevice(); } +const UChar* D3D9_StrFlags(void) { + if (createFlags & D3DCREATE_HARDWARE_VERTEXPROCESSING) return "HardwareVertexProcessing"; + if (createFlags & D3DCREATE_MIXED_VERTEXPROCESSING) return "MixedVertexProcessing"; + if (createFlags & D3DCREATE_SOFTWARE_VERTEXPROCESSING) return "SoftwareVertexProcessing"; + return "(none)"; +} + +const UChar* D3D9_StrFormat(D3DFORMAT format) { + switch (format) { + case D3DFMT_D32: return "D32"; + case D3DFMT_D24X8: return "D24X8"; + case D3DFMT_D24S8: return "D24S8"; + case D3DFMT_D24X4S4: return "D24X4S4"; + case D3DFMT_D16: return "D16"; + case D3DFMT_D15S1: return "D15S1"; + + case D3DFMT_X8R8G8B8: return "X8R8G8B8"; + case D3DFMT_R8G8B8: return "R8G8B8"; + case D3DFMT_R5G6B5: return "R5G6B5"; + case D3DFMT_X1R5G5B5: return "X1R5G5B5"; + } + return "(unknown)"; +} + +void Gfx_MakeApiInfo(void) { + D3DADAPTER_IDENTIFIER9 adapter; + ReturnCode result = IDirect3D9_GetAdapterIdentifier(d3d, D3DADAPTER_DEFAULT, 0, &adapter); + ErrorHandler_CheckOrFail(result, "D3D9_GetAdapterDetails"); + UInt32 texMemBytes = IDirect3DDevice9_GetAvailableTextureMem(device); + Real32 texMem = texMemBytes / (1024.0f * 1024.0f); + + String_AppendConst(&Gfx_ApiInfo[0],"-- Using Direct3D9 --"); + String_Format1(&Gfx_ApiInfo[1], "Adapter: %c", adapter.Description); + String_Format1(&Gfx_ApiInfo[2], "Mode: %c", D3D9_StrFlags()); + String_Format1(&Gfx_ApiInfo[3], "Texture memory: %f2 MB", &texMem); + String_Format1(&Gfx_ApiInfo[4], "Max 2D texture dimensions: %i", &Gfx_MaxTextureDimensions); + String_Format1(&Gfx_ApiInfo[5], "Depth buffer format: %c", D3D9_StrFormat(d3d9_depthFormat)); + String_Format1(&Gfx_ApiInfo[6], "Back buffer format: %c", D3D9_StrFormat(d3d9_viewFormat)); +} + void Gfx_OnWindowResize(void) { GfxCommon_LoseContext(" (resizing window)"); D3D9_RecreateDevice(); diff --git a/src/Client/Game.c b/src/Client/Game.c index 86fc307bc..21d1bb96e 100644 --- a/src/Client/Game.c +++ b/src/Client/Game.c @@ -765,8 +765,6 @@ void Audio_SetMusic(Int32 volume) { } void Audio_SetSounds(Int32 volume) { } void Audio_PlayDigSound(UInt8 type) { } void Audio_PlayStepSound(UInt8 type) { } - -void Gfx_MakeApiInfo(void) { } void AdvLightingBuilder_SetActive(void) { } /* TODO: Initalise Shell, see https://msdn.microsoft.com/en-us/library/windows/desktop/bb762153(v=vs.85).aspx diff --git a/src/Client/GraphicsCommon.c b/src/Client/GraphicsCommon.c index b5bde8651..f26b144c8 100644 --- a/src/Client/GraphicsCommon.c +++ b/src/Client/GraphicsCommon.c @@ -7,12 +7,12 @@ #include "ExtMath.h" #include "Texture.h" -UChar Gfx_ApiBuffer[8][String_BufferSize(STRING_SIZE)]; -String Gfx_ApiInfo[8] = { +UChar Gfx_ApiBuffer[7][String_BufferSize(STRING_SIZE)]; +String Gfx_ApiInfo[7] = { { Gfx_ApiBuffer[0], 0, STRING_SIZE }, { Gfx_ApiBuffer[1], 0, STRING_SIZE }, { Gfx_ApiBuffer[2], 0, STRING_SIZE }, { Gfx_ApiBuffer[3], 0, STRING_SIZE }, { Gfx_ApiBuffer[4], 0, STRING_SIZE }, { Gfx_ApiBuffer[5], 0, STRING_SIZE }, - { Gfx_ApiBuffer[6], 0, STRING_SIZE }, { Gfx_ApiBuffer[7], 0, STRING_SIZE }, + { Gfx_ApiBuffer[6], 0, STRING_SIZE }, }; void GfxCommon_Init(void) { diff --git a/src/Client/GraphicsCommon.h b/src/Client/GraphicsCommon.h index 062aae7fb..6a1b77089 100644 --- a/src/Client/GraphicsCommon.h +++ b/src/Client/GraphicsCommon.h @@ -8,7 +8,7 @@ */ struct Texture; -extern String Gfx_ApiInfo[8]; +extern String Gfx_ApiInfo[7]; GfxResourceID GfxCommon_defaultIb; void GfxCommon_Init(void); diff --git a/src/Client/OpenGLApi.c b/src/Client/OpenGLApi.c index 8a933cb7e..40b5643c2 100644 --- a/src/Client/OpenGLApi.c +++ b/src/Client/OpenGLApi.c @@ -539,6 +539,21 @@ void Gfx_TakeScreenshot(struct Stream* output, Int32 width, Int32 height) { Platform_MemFree(&bmp.Scan0); } +void Gfx_MakeApiInfo(void) { + const UChar* vendor = glGetString(GL_VENDOR); + const UChar* renderer = glGetString(GL_RENDERER); + const UChar* version = glGetString(GL_VERSION); + Int32 depthBits = 0; + glGetIntegerv(GL_DEPTH_BITS, &depthBits); + + String_AppendConst(&Gfx_ApiInfo[0],"-- Using OpenGL --"); + String_Format1(&Gfx_ApiInfo[1], "Vendor: %c", vendor); + String_Format1(&Gfx_ApiInfo[2], "Renderer: %c", renderer); + String_Format1(&Gfx_ApiInfo[3], "GL version: %c", version); + String_Format1(&Gfx_ApiInfo[4], "Max 2D texture dimensions: %i", &Gfx_MaxTextureDimensions); + String_Format1(&Gfx_ApiInfo[5], "Depth buffer bits: %i", &depthBits); +} + bool Gfx_WarnIfNecessary(void) { #if CC_BUILD_GL11 Chat_AddRaw(tmp1, "&cYou are using the very outdated OpenGL backend."); diff --git a/src/Client/Typedefs.h b/src/Client/Typedefs.h index 55ee99a46..302f029d7 100644 --- a/src/Client/Typedefs.h +++ b/src/Client/Typedefs.h @@ -59,7 +59,7 @@ struct FontDesc { void* Handle; UInt16 Size, Style; }; #define UInt32_MaxValue ((UInt32)4294967295UL) #define CC_BUILD_GL11 false -#define CC_BUILD_D3D9 false +#define CC_BUILD_D3D9 true #define CC_BUILD_WIN true #define CC_BUILD_OSX false