Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions Inc/XOpenGL.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
#endif
#else
#define SDL2BUILD 1
#define FALSE 0
#define TRUE 1
extern "C"
{
#include "glad.h"
Expand Down Expand Up @@ -320,7 +322,7 @@ inline int CheckGLError(const char* file, int line)
case GL_STACK_UNDERFLOW: Msg = TEXT("GL_STACK_UNDERFLOW"); break;
case GL_OUT_OF_MEMORY: Msg = TEXT("GL_OUT_OF_MEMORY"); break;
};
GWarn->Logf(TEXT("XOpenGL Error: %ls (%i) file %ls at line %i"), Msg, glErr, appFromAnsi(file), line);
GWarn->Logf(TEXT("XOpenGL Error: %s (%i) file %s at line %i"), Msg, glErr, appFromAnsi(file), line);
}
return 1;
}
Expand Down Expand Up @@ -1263,7 +1265,7 @@ class UXOpenGLRenderDevice : public URenderDevice
INT NumTextureSamplers;
GLenum DrawMode;
INT NumVertexAttributes;
BOOL UseSSBOParametersBuffer;
UBOOL UseSSBOParametersBuffer;
const DrawCallParameterInfo* ParametersInfo;
ShaderWriterFunc* VertexShaderFunc;
ShaderWriterFunc* GeoShaderFunc;
Expand Down Expand Up @@ -1694,7 +1696,7 @@ class UXOpenGLRenderDevice : public URenderDevice
static void BuildGeometryShader(GLuint ShaderType, UXOpenGLRenderDevice* GL, FShaderWriterX& Out);
static void BuildFragmentShader(GLuint ShaderType, UXOpenGLRenderDevice* GL, FShaderWriterX& Out);

BOOL DepthTesting;
UBOOL DepthTesting;
};

// Used for ES _and_ for Core (w/ geo shaders disabled)!
Expand All @@ -1710,7 +1712,7 @@ class UXOpenGLRenderDevice : public URenderDevice
static void BuildVertexShader(GLuint ShaderType, UXOpenGLRenderDevice* GL, FShaderWriterX& Out);
static void BuildFragmentShader(GLuint ShaderType, UXOpenGLRenderDevice* GL, FShaderWriterX& Out);

BOOL DepthTesting;
UBOOL DepthTesting;
};

//
Expand Down Expand Up @@ -1911,16 +1913,16 @@ class UXOpenGLRenderDevice : public URenderDevice
//
// Textures/Sampler Management
//
static BOOL WillBlendStateChange(DWORD OldPolyFlags, DWORD NewPolyFlags);
BOOL WillTextureStateChange(INT Multi, FTextureInfo& Info, DWORD PolyFlags);
FCachedTexture* GetCachedTextureInfo(INT Multi, FTextureInfo& Info, DWORD PolyFlags, BOOL& IsResidentBindlessTexture, BOOL& IsBoundToTMU, BOOL& IsTextureDataStale, BOOL ShouldResetStaleState);
static UBOOL WillBlendStateChange(DWORD OldPolyFlags, DWORD NewPolyFlags);
UBOOL WillTextureStateChange(INT Multi, FTextureInfo& Info, DWORD PolyFlags);
FCachedTexture* GetCachedTextureInfo(INT Multi, FTextureInfo& Info, DWORD PolyFlags, UBOOL& IsResidentBindlessTexture, UBOOL& IsBoundToTMU, UBOOL& IsTextureDataStale, UBOOL ShouldResetStaleState);
void SetTexture(INT Multi, FTextureInfo& Info, DWORD PolyFlags, FLOAT PanBias);
void SetNoTexture(INT Multi);
DWORD GetPolyFlagsAndShaderOptions(DWORD PolyFlags, DWORD& Options, BOOL RemoveOccludeIfSolid);
DWORD GetPolyFlagsAndShaderOptions(DWORD PolyFlags, DWORD& Options, UBOOL RemoveOccludeIfSolid);
void SetBlend(DWORD PolyFlags);
DWORD SetDepth(DWORD LineFlags);
void SetSampler(GLuint Sampler, FTextureInfo& Info, UBOOL SkipMipmaps, UBOOL IsLightOrFogMap, UBOOL NoSmooth);
BOOL UploadTexture(FTextureInfo& Info, FCachedTexture* Bind, DWORD PolyFlags, BOOL IsFirstUpload, BOOL IsBindlessTexture, BOOL PartialUpload=FALSE, INT U=0, INT V=0, INT UL=0, INT VL=0, BYTE* TextureData=nullptr);
UBOOL UploadTexture(FTextureInfo& Info, FCachedTexture* Bind, DWORD PolyFlags, UBOOL IsFirstUpload, UBOOL IsBindlessTexture, UBOOL PartialUpload=0, INT U=0, INT V=0, INT UL=0, INT VL=0, BYTE* TextureData=nullptr);
void GenerateTextureAndSampler(FCachedTexture* Bind);
void BindTextureAndSampler(INT Multi, FCachedTexture* Bind);

Expand Down
2 changes: 1 addition & 1 deletion Src/CheckExtensions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ UBOOL UXOpenGLRenderDevice::GLExtensionSupported(FString ExtensionName)
#if SDL2BUILD
return SDL_GL_ExtensionSupported(appToAnsi(*ExtensionName));
#else
return AllExtensions.InStr(*FString::Printf(TEXT("%ls "), *ExtensionName)) != -1;
return AllExtensions.InStr(*FString::Printf(TEXT("%s "), *ExtensionName)) != -1;
#endif
}

Expand Down
8 changes: 4 additions & 4 deletions Src/DebugLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@ void UXOpenGLRenderDevice::DebugCallback(unsigned int source, unsigned int type,
{
case GL_DEBUG_SEVERITY_LOW:
if (LogLevel >= 2)
debugf(TEXT("XOpenGL DebugLog: In source %ls, type %ls, id %i, severity : LOW, message %ls "),*SourceMessage, *TypeMessage, id, appFromAnsi(message));
debugf(TEXT("XOpenGL DebugLog: In source %s, type %s, id %i, severity : LOW, message %s "),*SourceMessage, *TypeMessage, id, appFromAnsi(message));
break;
case GL_DEBUG_SEVERITY_MEDIUM:
if (LogLevel >= 1)
debugf(TEXT("XOpenGL DebugLog: In source %ls, type %ls, id %i, severity : MEDIUM, message %ls "),*SourceMessage, *TypeMessage, id, appFromAnsi(message));
debugf(TEXT("XOpenGL DebugLog: In source %s, type %s, id %i, severity : MEDIUM, message %s "),*SourceMessage, *TypeMessage, id, appFromAnsi(message));
break;
case GL_DEBUG_SEVERITY_HIGH:
if (LogLevel >= 0)
debugf(TEXT("XOpenGL DebugLog: In source %ls, type %ls, id %i, severity : HIGH, message %ls "),*SourceMessage, *TypeMessage, id, appFromAnsi(message));
debugf(TEXT("XOpenGL DebugLog: In source %s, type %s, id %i, severity : HIGH, message %s "),*SourceMessage, *TypeMessage, id, appFromAnsi(message));
break;
default:
if (LogLevel >= 3)
debugf(TEXT("XOpenGL DebugLog: In source %ls, type %ls, id %i, severity : NONE, message %ls "),*SourceMessage, *TypeMessage, id, appFromAnsi(message));
debugf(TEXT("XOpenGL DebugLog: In source %s, type %s, id %i, severity : NONE, message %s "),*SourceMessage, *TypeMessage, id, appFromAnsi(message));
break;
}
}
20 changes: 10 additions & 10 deletions Src/SetTexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ UXOpenGLRenderDevice::GetCachedTextureInfo
INT Multi,
FTextureInfo& Info,
DWORD PolyFlags,
BOOL& IsResidentBindlessTexture,
BOOL& IsBoundToTMU,
BOOL& IsTextureDataStale,
BOOL ShouldResetStaleState
UBOOL& IsResidentBindlessTexture,
UBOOL& IsBoundToTMU,
UBOOL& IsTextureDataStale,
UBOOL ShouldResetStaleState
)
{
FixCacheID(Info, PolyFlags);
Expand Down Expand Up @@ -96,9 +96,9 @@ UXOpenGLRenderDevice::GetCachedTextureInfo
return Result;
}

BOOL UXOpenGLRenderDevice::WillTextureStateChange(INT Multi, FTextureInfo& Info, DWORD PolyFlags)
UBOOL UXOpenGLRenderDevice::WillTextureStateChange(INT Multi, FTextureInfo& Info, DWORD PolyFlags)
{
BOOL IsResidentBindlessTexture = FALSE, IsBoundToTMU = FALSE, IsTextureDataStale = FALSE;
UBOOL IsResidentBindlessTexture = FALSE, IsBoundToTMU = FALSE, IsTextureDataStale = FALSE;
GetCachedTextureInfo(Multi, Info, PolyFlags, IsResidentBindlessTexture, IsBoundToTMU, IsTextureDataStale, FALSE);

// We need to re-upload a texture we're currently using
Expand Down Expand Up @@ -254,7 +254,7 @@ void UXOpenGLRenderDevice::SetSampler(GLuint Sampler, FTextureInfo& Info, UBOOL
static FName UserInterface = FName(TEXT("UserInterface"), FNAME_Intrinsic);
#endif

BOOL UXOpenGLRenderDevice::UploadTexture(FTextureInfo& Info, FCachedTexture* Bind, DWORD PolyFlags, BOOL IsFirstUpload, BOOL IsBindlessTexture, BOOL PartialUpload, INT U, INT V, INT UL, INT VL, BYTE* TextureData)
UBOOL UXOpenGLRenderDevice::UploadTexture(FTextureInfo& Info, FCachedTexture* Bind, DWORD PolyFlags, UBOOL IsFirstUpload, UBOOL IsBindlessTexture, UBOOL PartialUpload, INT U, INT V, INT UL, INT VL, BYTE* TextureData)
{
bool UnsupportedTexture = false;

Expand Down Expand Up @@ -732,7 +732,7 @@ void UXOpenGLRenderDevice::SetTexture(INT Multi, FTextureInfo& Info, DWORD PolyF
STAT(clockFast(Stats.BindCycles));

// Check if the texture is already bound to the correct TMU
BOOL IsResidentBindlessTexture = FALSE, IsBoundToTMU = FALSE, IsTextureDataStale = FALSE;
UBOOL IsResidentBindlessTexture = FALSE, IsBoundToTMU = FALSE, IsTextureDataStale = FALSE;
FCachedTexture* Bind = GetCachedTextureInfo(Multi, Info, PolyFlags, IsResidentBindlessTexture, IsBoundToTMU, IsTextureDataStale, TRUE);

// Bail out early if the texture is fully up-to-date
Expand Down Expand Up @@ -804,7 +804,7 @@ void UXOpenGLRenderDevice::SetTexture(INT Multi, FTextureInfo& Info, DWORD PolyF
unguard;
}

DWORD UXOpenGLRenderDevice::GetPolyFlagsAndShaderOptions(DWORD PolyFlags, DWORD& Options, BOOL RemoveOccludeIfSolid)
DWORD UXOpenGLRenderDevice::GetPolyFlagsAndShaderOptions(DWORD PolyFlags, DWORD& Options, UBOOL RemoveOccludeIfSolid)
{
if ((PolyFlags & (PF_RenderFog | PF_Translucent)) != PF_RenderFog)
PolyFlags &= ~PF_RenderFog;
Expand Down Expand Up @@ -942,7 +942,7 @@ void UXOpenGLRenderDevice::SetBlend(DWORD PolyFlags)
unguard;
}

BOOL UXOpenGLRenderDevice::WillBlendStateChange(DWORD OldPolyFlags, DWORD NewPolyFlags)
UBOOL UXOpenGLRenderDevice::WillBlendStateChange(DWORD OldPolyFlags, DWORD NewPolyFlags)
{
// stijn: returns true if the polyflag switch will cause a change in the blending mode
return ((OldPolyFlags ^ NewPolyFlags) & (PF_TwoSided | PF_RenderHint | PF_Translucent | PF_Modulated | PF_Invisible | PF_AlphaBlend | PF_Occlude | PF_Highlighted | PF_RenderFog | PF_Selected)) ? TRUE : FALSE;
Expand Down
36 changes: 18 additions & 18 deletions Src/ShaderProgram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ static void GetTypeInfo(const char* TypeName, INT& SizeBytes, INT& Components)
Components = 1;
}
else
appErrorf(TEXT("Unknown GLSL type: %ls"), appFromAnsi(TypeName));
appErrorf(TEXT("Unknown GLSL type: %s"), appFromAnsi(TypeName));
}

INT UXOpenGLRenderDevice::ShaderProgram::GetMaximumUniformBufferSize(const DrawCallParameterInfo* Info) const
Expand Down Expand Up @@ -403,9 +403,9 @@ void UXOpenGLRenderDevice::ShaderProgram::BindUniform(ShaderSpecialization* Spec
const GLuint BlockIndex = glGetUniformBlockIndex(Specialization->ShaderProgramObject, Name);
if (BlockIndex == GL_INVALID_INDEX)
{
debugf(NAME_DevGraphics, TEXT("XOpenGL: invalid or unused shader var (UniformBlockIndex) %ls in %ls"), appFromAnsi(Name), ShaderName);
debugf(NAME_DevGraphics, TEXT("XOpenGL: invalid or unused shader var (UniformBlockIndex) %s in %s"), appFromAnsi(Name), ShaderName);
if (RenDev->UseOpenGLDebug && LogLevel >= 2)
debugf(TEXT("XOpenGL: invalid or unused shader var (UniformBlockIndex) %ls in %ls"), appFromAnsi(Name), ShaderName);
debugf(TEXT("XOpenGL: invalid or unused shader var (UniformBlockIndex) %s in %s"), appFromAnsi(Name), ShaderName);
}
glUniformBlockBinding(Specialization->ShaderProgramObject, BlockIndex, BindingIndex);
}
Expand All @@ -415,9 +415,9 @@ void UXOpenGLRenderDevice::ShaderProgram::GetUniformLocation(ShaderSpecializatio
Uniform = glGetUniformLocation(Specialization->ShaderProgramObject, Name);
if (Uniform == GL_INVALID_INDEX)
{
debugf(NAME_DevGraphics, TEXT("XOpenGL: invalid or unused shader var (UniformLocation) %ls in %ls"), appFromAnsi(Name), ShaderName);
debugf(NAME_DevGraphics, TEXT("XOpenGL: invalid or unused shader var (UniformLocation) %s in %s"), appFromAnsi(Name), ShaderName);
if (RenDev->UseOpenGLDebug && LogLevel >= 2)
debugf(TEXT("XOpenGL: invalid or unused shader var (UniformLocation) %ls in %ls"), appFromAnsi(Name), ShaderName);
debugf(TEXT("XOpenGL: invalid or unused shader var (UniformLocation) %s in %s"), appFromAnsi(Name), ShaderName);
}
}

Expand Down Expand Up @@ -446,7 +446,7 @@ static void DumpShader(const char* Source, bool AddLineNumbers)
if (Line.InStr(TEXT("#line 1")) == 0)
LineNum = 0;
if (AddLineNumbers)
Lines.AddItem(FString::Printf(TEXT("%03d:\t%ls"), LineNum++, *Line));
Lines.AddItem(FString::Printf(TEXT("%03d:\t%s"), LineNum++, *Line));
else
Lines.AddItem(*Line);
if (NewLine == -1)
Expand All @@ -455,7 +455,7 @@ static void DumpShader(const char* Source, bool AddLineNumbers)
}
debugf(TEXT("XOpenGL: Shader Source:"));
for (INT i = 0; i < Lines.Num(); ++i)
debugf(TEXT("%ls"), *Lines(i));
debugf(TEXT("%s"), *Lines(i));
}

bool UXOpenGLRenderDevice::ShaderProgram::CompileShaderFunction(GLuint ShaderFunctionObject, GLuint FunctionType, ShaderOptions Options, ShaderWriterFunc Func, bool HaveGeoShader)
Expand All @@ -481,13 +481,13 @@ bool UXOpenGLRenderDevice::ShaderProgram::CompileShaderFunction(GLuint ShaderFun
glGetShaderiv(ShaderFunctionObject, GL_COMPILE_STATUS, &IsCompiled);
if (!IsCompiled)
{
GWarn->Logf(TEXT("XOpenGL: Failed compiling %ls %ls Shader (Options %ls)"), ShaderName, ShaderTypeString(FunctionType), *Options.GetShortString());
GWarn->Logf(TEXT("XOpenGL: Failed compiling %s %s Shader (Options %s)"), ShaderName, ShaderTypeString(FunctionType), *Options.GetShortString());
glGetShaderiv(ShaderFunctionObject, GL_INFO_LOG_LENGTH, &blen);
if (blen > 1)
{
GLchar* compiler_log = new GLchar[blen + 1];
glGetShaderInfoLog(ShaderFunctionObject, blen, &slen, compiler_log);
debugf(TEXT("XOpenGL: ErrorLog compiling %ls %ls"), ShaderName, appFromAnsi(compiler_log));
debugf(TEXT("XOpenGL: ErrorLog compiling %s %s"), ShaderName, appFromAnsi(compiler_log));
delete[] compiler_log;
}

Expand All @@ -501,10 +501,10 @@ bool UXOpenGLRenderDevice::ShaderProgram::CompileShaderFunction(GLuint ShaderFun
{
GLchar* compiler_log = new GLchar[blen + 1];
glGetShaderInfoLog(ShaderFunctionObject, blen, &slen, compiler_log);
debugf(NAME_DevGraphics, TEXT("XOpenGL: Log compiling %ls %ls"), ShaderName, appFromAnsi(compiler_log));
debugf(NAME_DevGraphics, TEXT("XOpenGL: Log compiling %s %s"), ShaderName, appFromAnsi(compiler_log));
delete[] compiler_log;
}
else debugf(NAME_DevGraphics, TEXT("XOpenGL: No compiler messages for %ls %ls Shader (Options %ls)"), ShaderName, ShaderTypeString(FunctionType), *Options.GetShortString());
else debugf(NAME_DevGraphics, TEXT("XOpenGL: No compiler messages for %s %s Shader (Options %s)"), ShaderName, ShaderTypeString(FunctionType), *Options.GetShortString());
}

return Result;
Expand All @@ -523,7 +523,7 @@ bool UXOpenGLRenderDevice::ShaderProgram::LinkShaderProgram(GLuint ShaderProgram

if (!IsLinked)
{
GWarn->Logf(TEXT("XOpenGL: Failed linking %ls"), ShaderName);
GWarn->Logf(TEXT("XOpenGL: Failed linking %s"), ShaderName);
Result = false;
}

Expand All @@ -532,10 +532,10 @@ bool UXOpenGLRenderDevice::ShaderProgram::LinkShaderProgram(GLuint ShaderProgram
{
GLchar* linker_log = new GLchar[blen + 1];
glGetProgramInfoLog(ShaderProgramObject, blen, &slen, linker_log);
debugf(TEXT("XOpenGL: Log linking %ls %ls"), ShaderName, appFromAnsi(linker_log));
debugf(TEXT("XOpenGL: Log linking %s %s"), ShaderName, appFromAnsi(linker_log));
delete[] linker_log;
}
else debugf(NAME_DevGraphics, TEXT("XOpenGL: No linker messages for %ls"), ShaderName);
else debugf(NAME_DevGraphics, TEXT("XOpenGL: No linker messages for %s"), ShaderName);

CHECK_GL_ERROR();
return Result;
Expand Down Expand Up @@ -652,7 +652,7 @@ void UXOpenGLRenderDevice::ShaderProgram::BindShaderState(ShaderSpecialization*
BindUniform(Specialization, EditorStateIndex, "EditorState");

if (!UseSSBOParametersBuffer)
BindUniform(Specialization, ParametersBufferBindingIndex, appToAnsi(*FString::Printf(TEXT("All%lsShaderDrawParams"), ShaderName)));
BindUniform(Specialization, ParametersBufferBindingIndex, appToAnsi(*FString::Printf(TEXT("All%sShaderDrawParams"), ShaderName)));

// Bind regular texture samplers to their respective TMUs
check(NumTextureSamplers >= 0 && NumTextureSamplers < 9);
Expand Down Expand Up @@ -689,7 +689,7 @@ void UXOpenGLRenderDevice::ShaderProgram::SelectShaderSpecialization(ShaderOptio
Specializations.Set(Options, Specialization);

Specialization->Options = Options;
Specialization->SpecializationName = FString::Printf(TEXT("%ls%ls"), ShaderName, *Options.GetShortString());
Specialization->SpecializationName = FString::Printf(TEXT("%s%s"), ShaderName, *Options.GetShortString());

check(BuildShaderProgram(Specialization, VertexShaderFunc, GeoShaderFunc, FragmentShaderFunc));

Expand Down Expand Up @@ -771,7 +771,7 @@ FString UXOpenGLRenderDevice::ShaderOptions::GetStringHelper(void (*AddOptionFun
{
FString Result;
#define ADD_OPTION(x) \
AddOptionFunc(Result, L ## #x, (OptionsMask & x) ? true : false);
AddOptionFunc(Result, TEXT(#x), (OptionsMask & x) ? true : false);

ADD_OPTION(OPT_DiffuseTexture)
ADD_OPTION(OPT_LightMap)
Expand Down Expand Up @@ -812,7 +812,7 @@ FString UXOpenGLRenderDevice::ShaderOptions::GetShortString() const
FString UXOpenGLRenderDevice::ShaderOptions::GetPreprocessorString() const
{
return GetStringHelper([](FString& Result, const TCHAR* OptionName, bool IsSet) {
Result += FString::Printf(TEXT("#define %ls %d\n"), OptionName, IsSet ? 1 : 0);
Result += FString::Printf(TEXT("#define %s %d\n"), OptionName, IsSet ? 1 : 0);
});
}

Expand Down
Loading