mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 00:24:40 +00:00
Merge branch 'development' of https://github.com/TorqueGameEngines/Torque3D into development
This commit is contained in:
commit
e5ac88e914
16 changed files with 303 additions and 114 deletions
|
|
@ -229,12 +229,12 @@ bool SubScene::evaluateCondition()
|
||||||
if (objectName != NULL)
|
if (objectName != NULL)
|
||||||
objectName = getIdString();
|
objectName = getIdString();
|
||||||
|
|
||||||
StringTableEntry groupName = getGroup()->getName();
|
StringTableEntry groupName = getGroup() ? getGroup()->getName() : NULL;
|
||||||
if (groupName != NULL)
|
if (groupName != NULL)
|
||||||
groupName = getGroup()->getIdString();
|
groupName = getGroup()->getIdString();
|
||||||
|
|
||||||
String context = String::ToString("%s\nGroup: %s, Object: %s", getFilename(), groupName, objectName);
|
String context = String::ToString("%s\nGroup: %s, Object: %s", getFilename(), groupName, objectName);
|
||||||
Con::evaluate(command.c_str(), false, context);
|
Con::evaluate(command.c_str(), false, context.c_str());
|
||||||
return Con::getBoolVariable(resVar.c_str());
|
return Con::getBoolVariable(resVar.c_str());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -372,12 +372,12 @@ bool SpawnSphere::testCondition()
|
||||||
if (objectName != NULL)
|
if (objectName != NULL)
|
||||||
objectName = getIdString();
|
objectName = getIdString();
|
||||||
|
|
||||||
StringTableEntry groupName = getGroup()->getName();
|
StringTableEntry groupName = getGroup() ? getGroup()->getName() : NULL;
|
||||||
if (groupName != NULL)
|
if (groupName != NULL)
|
||||||
groupName = getGroup()->getIdString();
|
groupName = getGroup()->getIdString();
|
||||||
|
|
||||||
String context = String::ToString("%s\nGroup: %s, Object: %s", getFilename(), groupName, objectName);
|
String context = String::ToString("%s\nGroup: %s, Object: %s", getFilename(), groupName, objectName);
|
||||||
Con::evaluate(command.c_str(), false, context);
|
Con::evaluate(command.c_str(), false, context.c_str());
|
||||||
if (Con::getBoolVariable(resVar.c_str()) == 1)
|
if (Con::getBoolVariable(resVar.c_str()) == 1)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -711,12 +711,12 @@ bool Trigger::testCondition()
|
||||||
if (objectName != NULL)
|
if (objectName != NULL)
|
||||||
objectName = getIdString();
|
objectName = getIdString();
|
||||||
|
|
||||||
StringTableEntry groupName = getGroup()->getName();
|
StringTableEntry groupName = getGroup() ? getGroup()->getName() : NULL;
|
||||||
if (groupName != NULL)
|
if (groupName != NULL)
|
||||||
groupName = getGroup()->getIdString();
|
groupName = getGroup()->getIdString();
|
||||||
|
|
||||||
String context = String::ToString("%s\nGroup: %s, Object: %s", getFilename(), groupName, objectName);
|
String context = String::ToString("%s\nGroup: %s, Object: %s", getFilename(), groupName, objectName);
|
||||||
Con::evaluate(command.c_str(), false, context);
|
Con::evaluate(command.c_str(), false, context.c_str());
|
||||||
if (Con::getBoolVariable(resVar.c_str()) == 1)
|
if (Con::getBoolVariable(resVar.c_str()) == 1)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -817,7 +817,7 @@ void Trigger::processTick(const Move* move)
|
||||||
if (objectName != NULL)
|
if (objectName != NULL)
|
||||||
objectName = getIdString();
|
objectName = getIdString();
|
||||||
|
|
||||||
StringTableEntry groupName = getGroup()->getName();
|
StringTableEntry groupName = getGroup() ? getGroup()->getName() : NULL;
|
||||||
if (groupName != NULL)
|
if (groupName != NULL)
|
||||||
groupName = getGroup()->getIdString();
|
groupName = getGroup()->getIdString();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -611,7 +611,7 @@ Con::EvalResult CodeBlock::compileExec(StringTableEntry fileName, const char *in
|
||||||
Script::gStatementList = NULL;
|
Script::gStatementList = NULL;
|
||||||
|
|
||||||
// we are an eval compile if we don't have a file name associated (no exec)
|
// we are an eval compile if we don't have a file name associated (no exec)
|
||||||
gIsEvalCompile = fileName == NULL;
|
gIsEvalCompile = fileName == NULL || setFrame == 0;
|
||||||
gFuncVars = gIsEvalCompile ? &gEvalFuncVars : &gGlobalScopeFuncVars;
|
gFuncVars = gIsEvalCompile ? &gEvalFuncVars : &gGlobalScopeFuncVars;
|
||||||
|
|
||||||
// Set up the parser.
|
// Set up the parser.
|
||||||
|
|
|
||||||
|
|
@ -38,8 +38,10 @@ namespace TorqueScript
|
||||||
if (fileName)
|
if (fileName)
|
||||||
fileName = StringTable->insert(fileName);
|
fileName = StringTable->insert(fileName);
|
||||||
|
|
||||||
|
bool fileExec = Torque::FS::IsFile(fileName);
|
||||||
|
|
||||||
CodeBlock* newCodeBlock = new CodeBlock();
|
CodeBlock* newCodeBlock = new CodeBlock();
|
||||||
return (newCodeBlock->compileExec(fileName, string, false, fileName ? -1 : 0));
|
return (newCodeBlock->compileExec(fileName, string, false, fileExec ? -1 : 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
Con::EvalResult TorqueScriptRuntime::evaluate(const char* script, S32 frame, bool echo, const char* fileName)
|
Con::EvalResult TorqueScriptRuntime::evaluate(const char* script, S32 frame, bool echo, const char* fileName)
|
||||||
|
|
|
||||||
|
|
@ -91,19 +91,74 @@ void loadGLExtensions(void *context)
|
||||||
GL::gglPerformExtensionBinds(context);
|
GL::gglPerformExtensionBinds(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
void STDCALL glDebugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length,
|
void APIENTRY glDebugCallback(
|
||||||
const GLchar *message, const void *userParam)
|
GLenum source,
|
||||||
|
GLenum type,
|
||||||
|
GLuint id,
|
||||||
|
GLenum severity,
|
||||||
|
GLsizei length,
|
||||||
|
const GLchar* message,
|
||||||
|
const void* userParam)
|
||||||
{
|
{
|
||||||
// JTH [11/24/2016]: This is a temporary fix so that we do not get spammed for redundant fbo changes.
|
// Ignore non-significant notifications (optional)
|
||||||
// This only happens on Intel cards. This should be looked into sometime in the near future.
|
if (severity == GL_DEBUG_SEVERITY_NOTIFICATION)
|
||||||
if (dStrStartsWith(message, "API_ID_REDUNDANT_FBO"))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
const char* srcStr = "UNKNOWN";
|
||||||
|
const char* typeStr = "UNKNOWN";
|
||||||
|
const char* sevStr = "UNKNOWN";
|
||||||
|
|
||||||
|
switch (source)
|
||||||
|
{
|
||||||
|
case GL_DEBUG_SOURCE_API: srcStr = "API"; break;
|
||||||
|
case GL_DEBUG_SOURCE_WINDOW_SYSTEM: srcStr = "WINDOW"; break;
|
||||||
|
case GL_DEBUG_SOURCE_SHADER_COMPILER: srcStr = "SHADER"; break;
|
||||||
|
case GL_DEBUG_SOURCE_THIRD_PARTY: srcStr = "THIRD_PARTY"; break;
|
||||||
|
case GL_DEBUG_SOURCE_APPLICATION: srcStr = "APP"; break;
|
||||||
|
case GL_DEBUG_SOURCE_OTHER: srcStr = "OTHER"; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case GL_DEBUG_TYPE_ERROR: typeStr = "ERROR"; break;
|
||||||
|
case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: typeStr = "DEPRECATED"; break;
|
||||||
|
case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR: typeStr = "UNDEFINED"; break;
|
||||||
|
case GL_DEBUG_TYPE_PORTABILITY: typeStr = "PORTABILITY"; break;
|
||||||
|
case GL_DEBUG_TYPE_PERFORMANCE: typeStr = "PERFORMANCE"; break;
|
||||||
|
case GL_DEBUG_TYPE_MARKER: typeStr = "MARKER"; break;
|
||||||
|
case GL_DEBUG_TYPE_PUSH_GROUP: typeStr = "PUSH"; break;
|
||||||
|
case GL_DEBUG_TYPE_POP_GROUP: typeStr = "POP"; break;
|
||||||
|
case GL_DEBUG_TYPE_OTHER: typeStr = "OTHER"; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (severity)
|
||||||
|
{
|
||||||
|
case GL_DEBUG_SEVERITY_HIGH: sevStr = "HIGH"; break;
|
||||||
|
case GL_DEBUG_SEVERITY_MEDIUM: sevStr = "MEDIUM"; break;
|
||||||
|
case GL_DEBUG_SEVERITY_LOW: sevStr = "LOW"; break;
|
||||||
|
case GL_DEBUG_SEVERITY_NOTIFICATION: sevStr = "NOTIFY"; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filter known noisy IDs here if needed
|
||||||
|
// Example:
|
||||||
|
// if (id == 131185) return;
|
||||||
|
|
||||||
if (severity == GL_DEBUG_SEVERITY_HIGH)
|
if (severity == GL_DEBUG_SEVERITY_HIGH)
|
||||||
Con::errorf("OPENGL: %s", message);
|
{
|
||||||
|
Con::errorf("OPENGL [%s][%s][%s][%u]: %s",
|
||||||
|
sevStr, srcStr, typeStr, id, message);
|
||||||
|
AssertFatal(false, "OpenGL HIGH severity error.");
|
||||||
|
}
|
||||||
else if (severity == GL_DEBUG_SEVERITY_MEDIUM)
|
else if (severity == GL_DEBUG_SEVERITY_MEDIUM)
|
||||||
Con::warnf("OPENGL: %s", message);
|
{
|
||||||
else if (severity == GL_DEBUG_SEVERITY_LOW)
|
Con::warnf("OPENGL [%s][%s][%s][%u]: %s",
|
||||||
Con::printf("OPENGL: %s", message);
|
sevStr, srcStr, typeStr, id, message);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Con::printf("OPENGL [%s][%s][%s][%u]: %s",
|
||||||
|
sevStr, srcStr, typeStr, id, message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void STDCALL glAmdDebugCallback(GLuint id, GLenum category, GLenum severity, GLsizei length,
|
void STDCALL glAmdDebugCallback(GLuint id, GLenum category, GLenum severity, GLsizei length,
|
||||||
|
|
@ -157,27 +212,34 @@ void GFXGLDevice::initGLState()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if TORQUE_DEBUG
|
#if TORQUE_DEBUG
|
||||||
if( gglHasExtension(ARB_debug_output) )
|
|
||||||
{
|
bool debugInitialized = false;
|
||||||
glEnable(GL_DEBUG_OUTPUT);
|
int flags;
|
||||||
glDebugMessageCallbackARB(glDebugCallback, NULL);
|
glGetIntegerv(GL_CONTEXT_FLAGS, &flags);
|
||||||
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
|
if (flags & GL_CONTEXT_FLAG_DEBUG_BIT)
|
||||||
GLuint unusedIds = 0;
|
{
|
||||||
glDebugMessageControlARB(GL_DONT_CARE,
|
glEnable(GL_DEBUG_OUTPUT);
|
||||||
GL_DONT_CARE,
|
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
|
||||||
GL_DONT_CARE,
|
|
||||||
0,
|
glDebugMessageCallback(glDebugCallback, nullptr);
|
||||||
&unusedIds,
|
|
||||||
GL_TRUE);
|
glDebugMessageControl(
|
||||||
}
|
GL_DONT_CARE,
|
||||||
else if(gglHasExtension(AMD_debug_output))
|
GL_DONT_CARE,
|
||||||
{
|
GL_DONT_CARE,
|
||||||
glEnable(GL_DEBUG_OUTPUT);
|
0,
|
||||||
glDebugMessageCallbackAMD(glAmdDebugCallback, NULL);
|
nullptr,
|
||||||
//glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
|
GL_TRUE);
|
||||||
GLuint unusedIds = 0;
|
|
||||||
glDebugMessageEnableAMD(GL_DONT_CARE, GL_DONT_CARE, 0,&unusedIds, GL_TRUE);
|
Con::printf("OpenGL debug output enabled.");
|
||||||
}
|
debugInitialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!debugInitialized)
|
||||||
|
{
|
||||||
|
Con::warnf("OpenGL debug output NOT available.");
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PlatformGL::setVSync(smEnableVSync);
|
PlatformGL::setVSync(smEnableVSync);
|
||||||
|
|
|
||||||
|
|
@ -175,7 +175,7 @@ void GFXGLTextureManager::innerCreateTexture( GFXGLTextureObject *retTex,
|
||||||
//calculate num mipmaps
|
//calculate num mipmaps
|
||||||
if(retTex->mMipLevels == 0)
|
if(retTex->mMipLevels == 0)
|
||||||
retTex->mMipLevels = getMaxMipmaps(width, height, 1);
|
retTex->mMipLevels = getMaxMipmaps(width, height, 1);
|
||||||
|
|
||||||
glTexParameteri(binding, GL_TEXTURE_MAX_LEVEL, retTex->mMipLevels-1 );
|
glTexParameteri(binding, GL_TEXTURE_MAX_LEVEL, retTex->mMipLevels-1 );
|
||||||
|
|
||||||
bool hasTexStorage = false;
|
bool hasTexStorage = false;
|
||||||
|
|
@ -364,34 +364,83 @@ void GFXGLTextureManager::innerCreateTexture( GFXGLTextureObject *retTex,
|
||||||
// loadTexture - GBitmap
|
// loadTexture - GBitmap
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
static void _textureUpload(const S32 width, const S32 height,const S32 bytesPerPixel,const GFXGLTextureObject* texture, const GFXFormat fmt, const U8* data,const S32 mip=0, const U32 face = 0, Swizzle<U8, 4> *pSwizzle = NULL)
|
static void _textureUpload(
|
||||||
|
const S32 width,
|
||||||
|
const S32 height,
|
||||||
|
const S32 bytesPerPixel,
|
||||||
|
const GFXGLTextureObject* texture,
|
||||||
|
const GFXFormat fmt,
|
||||||
|
const U8* data,
|
||||||
|
const S32 mip = 0,
|
||||||
|
const U32 face = 0,
|
||||||
|
Swizzle<U8, 4>* pSwizzle = NULL)
|
||||||
{
|
{
|
||||||
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, texture->getBuffer());
|
const GLenum target = texture->getBinding();
|
||||||
U32 bufSize = width * height * bytesPerPixel;
|
|
||||||
glBufferData(GL_PIXEL_UNPACK_BUFFER, bufSize, NULL, GL_STREAM_DRAW);
|
|
||||||
|
|
||||||
if(pSwizzle)
|
// Save pixel store state
|
||||||
{
|
GLint prevUnpackAlign;
|
||||||
PROFILE_SCOPE(Swizzle32_Upload);
|
glGetIntegerv(GL_UNPACK_ALIGNMENT, &prevUnpackAlign);
|
||||||
U8* pboMemory = (U8*)dMalloc(bufSize);
|
|
||||||
pSwizzle->ToBuffer(pboMemory, data, bufSize);
|
|
||||||
glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, bufSize, pboMemory);
|
|
||||||
dFree(pboMemory);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
PROFILE_SCOPE(SwizzleNull_Upload);
|
|
||||||
glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, bufSize, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(texture->getBinding() == GL_TEXTURE_CUBE_MAP)
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||||
glTexSubImage2D(GFXGLFaceType[face], mip, 0, 0, width, height, GFXGLTextureFormat[fmt], GFXGLTextureType[fmt], NULL);
|
|
||||||
else if (texture->getBinding() == GL_TEXTURE_2D)
|
|
||||||
glTexSubImage2D(texture->getBinding(), mip, 0, 0, width, height, GFXGLTextureFormat[fmt], GFXGLTextureType[fmt], NULL);
|
|
||||||
else
|
|
||||||
glTexSubImage1D(texture->getBinding(), mip, 0, (width > 1 ? width : height), GFXGLTextureFormat[fmt], GFXGLTextureType[fmt], NULL);
|
|
||||||
|
|
||||||
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
|
const U32 bufSize = width * height * bytesPerPixel;
|
||||||
|
|
||||||
|
const U8* uploadPtr = data;
|
||||||
|
U8* tempBuffer = nullptr;
|
||||||
|
|
||||||
|
if (pSwizzle)
|
||||||
|
{
|
||||||
|
tempBuffer = (U8*)dMalloc(bufSize);
|
||||||
|
pSwizzle->ToBuffer(tempBuffer, data, bufSize);
|
||||||
|
uploadPtr = tempBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (target == GL_TEXTURE_CUBE_MAP)
|
||||||
|
{
|
||||||
|
glTexSubImage2D(
|
||||||
|
GFXGLFaceType[face],
|
||||||
|
mip,
|
||||||
|
0, 0,
|
||||||
|
width, height,
|
||||||
|
GFXGLTextureFormat[fmt],
|
||||||
|
GFXGLTextureType[fmt],
|
||||||
|
uploadPtr
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if (target == GL_TEXTURE_2D)
|
||||||
|
{
|
||||||
|
glTexSubImage2D(
|
||||||
|
GL_TEXTURE_2D,
|
||||||
|
mip,
|
||||||
|
0, 0,
|
||||||
|
width, height,
|
||||||
|
GFXGLTextureFormat[fmt],
|
||||||
|
GFXGLTextureType[fmt],
|
||||||
|
uploadPtr
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if (target == GL_TEXTURE_1D)
|
||||||
|
{
|
||||||
|
glTexSubImage1D(
|
||||||
|
GL_TEXTURE_1D,
|
||||||
|
mip,
|
||||||
|
0,
|
||||||
|
width,
|
||||||
|
GFXGLTextureFormat[fmt],
|
||||||
|
GFXGLTextureType[fmt],
|
||||||
|
uploadPtr
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tempBuffer)
|
||||||
|
dFree(tempBuffer);
|
||||||
|
|
||||||
|
// Restore state
|
||||||
|
glPixelStorei(GL_UNPACK_ALIGNMENT, prevUnpackAlign);
|
||||||
|
|
||||||
|
#ifdef TORQUE_DEBUG
|
||||||
|
glCheckErrors();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GFXGLTextureManager::_loadTexture(GFXTextureObject *aTexture, GBitmap *pDL)
|
bool GFXGLTextureManager::_loadTexture(GFXTextureObject *aTexture, GBitmap *pDL)
|
||||||
|
|
|
||||||
|
|
@ -102,36 +102,79 @@ GFXLockedRect* GFXGLTextureObject::lock(U32 mipLevel /*= 0*/, RectI* inRect /*=
|
||||||
|
|
||||||
void GFXGLTextureObject::unlock(U32 mipLevel /*= 0*/, U32 faceIndex /*= 0*/)
|
void GFXGLTextureObject::unlock(U32 mipLevel /*= 0*/, U32 faceIndex /*= 0*/)
|
||||||
{
|
{
|
||||||
if(!mLockedRect.bits)
|
if (!mLockedRect.bits)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// I know this is in unlock, but in GL we actually do our submission in unlock.
|
PROFILE_SCOPE(GFXGLTextureObject_unlock);
|
||||||
PROFILE_SCOPE(GFXGLTextureObject_lockRT);
|
|
||||||
|
|
||||||
PRESERVE_TEXTURE(mBinding);
|
PRESERVE_TEXTURE(mBinding);
|
||||||
glBindTexture(mBinding, mHandle);
|
glBindTexture(mBinding, mHandle);
|
||||||
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, mBuffer);
|
|
||||||
glBufferData(GL_PIXEL_UNPACK_BUFFER, (mLockedRectRect.extent.x + 1) * (mLockedRectRect.extent.y + 1) * mBytesPerTexel, mFrameAllocatorPtr, GL_STREAM_DRAW);
|
|
||||||
S32 z = getDepth();
|
|
||||||
if (mBinding == GL_TEXTURE_3D)
|
|
||||||
glTexSubImage3D(mBinding, mipLevel, mLockedRectRect.point.x, mLockedRectRect.point.y, z,
|
|
||||||
mLockedRectRect.extent.x, mLockedRectRect.extent.y, z, GFXGLTextureFormat[mFormat], GFXGLTextureType[mFormat], NULL);
|
|
||||||
else if(mBinding == GL_TEXTURE_2D)
|
|
||||||
glTexSubImage2D(mBinding, mipLevel, mLockedRectRect.point.x, mLockedRectRect.point.y,
|
|
||||||
mLockedRectRect.extent.x, mLockedRectRect.extent.y, GFXGLTextureFormat[mFormat], GFXGLTextureType[mFormat], NULL);
|
|
||||||
else if(mBinding == GL_TEXTURE_1D)
|
|
||||||
glTexSubImage1D(mBinding, mipLevel, (mLockedRectRect.point.x > 1 ? mLockedRectRect.point.x : mLockedRectRect.point.y),
|
|
||||||
(mLockedRectRect.extent.x > 1 ? mLockedRectRect.extent.x : mLockedRectRect.extent.y), GFXGLTextureFormat[mFormat], GFXGLTextureType[mFormat], NULL);
|
|
||||||
|
|
||||||
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
|
// --- Save pixel store state ---
|
||||||
|
GLint prevUnpackAlign;
|
||||||
|
glGetIntegerv(GL_UNPACK_ALIGNMENT, &prevUnpackAlign);
|
||||||
|
|
||||||
mLockedRect.bits = NULL;
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||||
#if TORQUE_DEBUG
|
|
||||||
AssertFatal(mFrameAllocatorMarkGuard == FrameAllocator::getWaterMark(), "");
|
const U32 width = mLockedRectRect.extent.x;
|
||||||
|
const U32 height = mLockedRectRect.extent.y;
|
||||||
|
const U32 depth = getDepth();
|
||||||
|
|
||||||
|
if (mBinding == GL_TEXTURE_3D)
|
||||||
|
{
|
||||||
|
glTexSubImage3D(
|
||||||
|
mBinding,
|
||||||
|
mipLevel,
|
||||||
|
mLockedRectRect.point.x,
|
||||||
|
mLockedRectRect.point.y,
|
||||||
|
0,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
depth,
|
||||||
|
GFXGLTextureFormat[mFormat],
|
||||||
|
GFXGLTextureType[mFormat],
|
||||||
|
mLockedRect.bits
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if (mBinding == GL_TEXTURE_2D)
|
||||||
|
{
|
||||||
|
glTexSubImage2D(
|
||||||
|
mBinding,
|
||||||
|
mipLevel,
|
||||||
|
mLockedRectRect.point.x,
|
||||||
|
mLockedRectRect.point.y,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
GFXGLTextureFormat[mFormat],
|
||||||
|
GFXGLTextureType[mFormat],
|
||||||
|
mLockedRect.bits
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if (mBinding == GL_TEXTURE_1D)
|
||||||
|
{
|
||||||
|
glTexSubImage1D(
|
||||||
|
mBinding,
|
||||||
|
mipLevel,
|
||||||
|
mLockedRectRect.point.x,
|
||||||
|
width,
|
||||||
|
GFXGLTextureFormat[mFormat],
|
||||||
|
GFXGLTextureType[mFormat],
|
||||||
|
mLockedRect.bits
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Restore state ---
|
||||||
|
glPixelStorei(GL_UNPACK_ALIGNMENT, prevUnpackAlign);
|
||||||
|
|
||||||
|
mLockedRect.bits = NULL;
|
||||||
|
|
||||||
|
FrameAllocator::setWaterMark(mFrameAllocatorMark);
|
||||||
|
mFrameAllocatorMark = 0;
|
||||||
|
mFrameAllocatorPtr = NULL;
|
||||||
|
|
||||||
|
#ifdef TORQUE_DEBUG
|
||||||
|
glCheckErrors();
|
||||||
#endif
|
#endif
|
||||||
FrameAllocator::setWaterMark(mFrameAllocatorMark);
|
|
||||||
mFrameAllocatorMark = 0;
|
|
||||||
mFrameAllocatorPtr = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GFXGLTextureObject::release()
|
void GFXGLTextureObject::release()
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,32 @@
|
||||||
#include "gfx/gl/gfxGLStateCache.h"
|
#include "gfx/gl/gfxGLStateCache.h"
|
||||||
#include "gfx/bitmap/imageUtils.h"
|
#include "gfx/bitmap/imageUtils.h"
|
||||||
|
|
||||||
|
inline const char* glGetErrorString(GLenum error)
|
||||||
|
{
|
||||||
|
switch (error)
|
||||||
|
{
|
||||||
|
case GL_NO_ERROR: return "No Error";
|
||||||
|
case GL_INVALID_ENUM: return "Invalid Enum";
|
||||||
|
case GL_INVALID_VALUE: return "Invalid Value";
|
||||||
|
case GL_INVALID_OPERATION: return "Invalid Operation";
|
||||||
|
case GL_INVALID_FRAMEBUFFER_OPERATION: return "Invalid Framebuffer Operation";
|
||||||
|
case GL_OUT_OF_MEMORY: return "Out of Memory";
|
||||||
|
case GL_STACK_UNDERFLOW: return "Stack Underflow";
|
||||||
|
case GL_STACK_OVERFLOW: return "Stack Overflow";
|
||||||
|
case GL_CONTEXT_LOST: return "Context Lost";
|
||||||
|
default: return "Unknown Error";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void _glCheckErrors(const char *filename, int line)
|
||||||
|
{
|
||||||
|
GLenum err;
|
||||||
|
while ((err = glGetError()) != GL_NO_ERROR)
|
||||||
|
Con::printf("OpenGL Error: %s (%d) [%u] %s\n", filename, line, err, glGetErrorString(err));
|
||||||
|
}
|
||||||
|
|
||||||
|
#define glCheckErrors() _glCheckErrors(__FILE__, __LINE__)
|
||||||
|
|
||||||
inline U32 getMaxMipmaps(U32 width, U32 height, U32 depth)
|
inline U32 getMaxMipmaps(U32 width, U32 height, U32 depth)
|
||||||
{
|
{
|
||||||
return getMax( getBinLog2(depth), getMax(getBinLog2(width), getBinLog2(height))) + 1;
|
return getMax( getBinLog2(depth), getMax(getBinLog2(width), getBinLog2(height))) + 1;
|
||||||
|
|
|
||||||
|
|
@ -103,9 +103,17 @@ void GFXGLDevice::enumerateAdapters( Vector<GFXAdapter*> &adapterList )
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_ClearError();
|
SDL_ClearError();
|
||||||
|
U32 debugFlag = 0;
|
||||||
|
#ifdef TORQUE_DEBUG
|
||||||
|
debugFlag |= SDL_GL_CONTEXT_DEBUG_FLAG;
|
||||||
|
#endif
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, debugFlag);
|
||||||
SDL_GL_SetAttribute(SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, 1);
|
SDL_GL_SetAttribute(SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, 1);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
|
||||||
|
#ifdef TORQUE_GL_SOFTWARE
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 0);
|
||||||
|
#endif
|
||||||
SDL_GLContext tempContext = SDL_GL_CreateContext( tempWindow );
|
SDL_GLContext tempContext = SDL_GL_CreateContext( tempWindow );
|
||||||
if( !tempContext )
|
if( !tempContext )
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -976,7 +976,7 @@ void GuiGameListMenuCtrl::doScriptCommand(StringTableEntry command)
|
||||||
setThisControl();
|
setThisControl();
|
||||||
StringTableEntry objectName = getName() != StringTable->EmptyString() ? getName() : getInternalName();
|
StringTableEntry objectName = getName() != StringTable->EmptyString() ? getName() : getInternalName();
|
||||||
String context = String::ToString("%s\nObject: %s", Platform::makeRelativePathName(getFilename(), NULL), objectName);
|
String context = String::ToString("%s\nObject: %s", Platform::makeRelativePathName(getFilename(), NULL), objectName);
|
||||||
Con::evaluate(command, false, context);
|
Con::evaluate(command, false, context.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1541,7 +1541,7 @@ StringTableEntry GuiListBoxCtrl::_makeMirrorItemName( SimObject *inObj )
|
||||||
|
|
||||||
StringTableEntry objectName = getName() != StringTable->EmptyString() ? getName() : getInternalName();
|
StringTableEntry objectName = getName() != StringTable->EmptyString() ? getName() : getInternalName();
|
||||||
String context = String::ToString("%s, Object: %s", Platform::makeRelativePathName(getFilename(), NULL), objectName);
|
String context = String::ToString("%s, Object: %s", Platform::makeRelativePathName(getFilename(), NULL), objectName);
|
||||||
outName = StringTable->insert( Con::evaluate( mMakeNameCallback, false, context).value, true );
|
outName = StringTable->insert( Con::evaluate( mMakeNameCallback, false, context.c_str()).value, true );
|
||||||
}
|
}
|
||||||
else if ( inObj->getName() )
|
else if ( inObj->getName() )
|
||||||
outName = StringTable->insert( inObj->getName() );
|
outName = StringTable->insert( inObj->getName() );
|
||||||
|
|
|
||||||
|
|
@ -2496,14 +2496,15 @@ const char* GuiControl::evaluate( const char* str )
|
||||||
{
|
{
|
||||||
smThisControl = this;
|
smThisControl = this;
|
||||||
StringTableEntry objectName = getName();
|
StringTableEntry objectName = getName();
|
||||||
if (getName() == NULL)
|
if (objectName != NULL)
|
||||||
objectName = getInternalName();
|
objectName = getIdString();
|
||||||
StringTableEntry fileName = getFilename();
|
|
||||||
if (fileName != NULL)
|
|
||||||
fileName = Platform::makeRelativePathName(fileName, NULL);
|
|
||||||
|
|
||||||
String context = String::ToString("%s\nObject: %s", fileName, objectName);
|
StringTableEntry groupName = getGroup() ? getGroup()->getName() : NULL;
|
||||||
const char* result = Con::evaluate(str, false, context).value;
|
if (groupName != NULL)
|
||||||
|
groupName = getGroup()->getIdString();
|
||||||
|
|
||||||
|
String context = String::ToString("%s\nGroup: %s, Object: %s", getFilename(), groupName, objectName);
|
||||||
|
const char* result = Con::evaluate(str, false, context.c_str()).value;
|
||||||
smThisControl = NULL;
|
smThisControl = NULL;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
||||||
|
|
@ -19,12 +19,10 @@ namespace PlatformGL
|
||||||
#ifdef TORQUE_DEBUG
|
#ifdef TORQUE_DEBUG
|
||||||
debugFlag |= SDL_GL_CONTEXT_DEBUG_FLAG;
|
debugFlag |= SDL_GL_CONTEXT_DEBUG_FLAG;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, majorOGL);
|
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, minorOGL);
|
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, debugFlag);
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, debugFlag);
|
||||||
SDL_GL_SetAttribute(SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, 1);
|
SDL_GL_SetAttribute(SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, 1);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
|
||||||
#ifdef TORQUE_GL_SOFTWARE
|
#ifdef TORQUE_GL_SOFTWARE
|
||||||
SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 0);
|
SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -178,9 +178,9 @@ SurfaceToLight createSurfaceToLight(in Surface surface, in vec3 L)
|
||||||
surfaceToLight.Lu = L;
|
surfaceToLight.Lu = L;
|
||||||
surfaceToLight.L = normalize(L);
|
surfaceToLight.L = normalize(L);
|
||||||
surfaceToLight.H = normalize(surface.V + surfaceToLight.L);
|
surfaceToLight.H = normalize(surface.V + surfaceToLight.L);
|
||||||
surfaceToLight.NdotL = saturate(dot(surfaceToLight.L, surface.N));
|
surfaceToLight.NdotL = saturate(dot(surface.N,surfaceToLight.L));
|
||||||
surfaceToLight.HdotV = saturate(dot(surfaceToLight.H, surface.V));
|
surfaceToLight.HdotV = saturate(dot(surfaceToLight.H,surface.V));
|
||||||
surfaceToLight.NdotH = saturate(dot(surfaceToLight.H, surface.N));
|
surfaceToLight.NdotH = saturate(dot(surface.N,surfaceToLight.H));
|
||||||
return surfaceToLight;
|
return surfaceToLight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -243,12 +243,12 @@ vec3 evaluateStandardBRDF(Surface surface, SurfaceToLight surfaceToLight)
|
||||||
float denominator = 4.0 * max(surface.NdotV, 0.0) * max(surfaceToLight.NdotL, 0.0) + 0.0001;
|
float denominator = 4.0 * max(surface.NdotV, 0.0) * max(surfaceToLight.NdotL, 0.0) + 0.0001;
|
||||||
vec3 specularBRDF = numerator / denominator;
|
vec3 specularBRDF = numerator / denominator;
|
||||||
|
|
||||||
vec3 diffuseBRDF = surface.baseColor.rgb * M_1OVER_PI_F * surface.ao;
|
vec3 diffuseBRDF = surface.baseColor.rgb * surface.ao * M_HALFPI_F;
|
||||||
|
|
||||||
// Final output combining all terms
|
// Final output combining all terms
|
||||||
vec3 kS = F; // Specular reflectance
|
vec3 kS = F; // Specular reflectance
|
||||||
vec3 kD = (1.0 - kS) * (1.0 - surface.metalness); // Diffuse reflectance
|
vec3 kD = (1.0 - kS) * (1.0 - surface.metalness); // Diffuse reflectance
|
||||||
vec3 returnBRDF = kD * (diffuseBRDF) + specularBRDF;
|
vec3 returnBRDF = kD * diffuseBRDF + specularBRDF;
|
||||||
|
|
||||||
if(isCapturing == 1)
|
if(isCapturing == 1)
|
||||||
return lerp(returnBRDF ,surface.albedo.rgb,surface.metalness);
|
return lerp(returnBRDF ,surface.albedo.rgb,surface.metalness);
|
||||||
|
|
|
||||||
|
|
@ -177,9 +177,9 @@ inline SurfaceToLight createSurfaceToLight(in Surface surface, in float3 L)
|
||||||
surfaceToLight.Lu = L;
|
surfaceToLight.Lu = L;
|
||||||
surfaceToLight.L = normalize(L);
|
surfaceToLight.L = normalize(L);
|
||||||
surfaceToLight.H = normalize(surface.V + surfaceToLight.L);
|
surfaceToLight.H = normalize(surface.V + surfaceToLight.L);
|
||||||
surfaceToLight.NdotL = saturate(dot(surfaceToLight.L, surface.N));
|
surfaceToLight.NdotL = saturate(dot(surface.N, surfaceToLight.L));
|
||||||
surfaceToLight.HdotV = saturate(dot(surfaceToLight.H, surface.V));
|
surfaceToLight.HdotV = saturate(dot(surfaceToLight.H, surface.V));
|
||||||
surfaceToLight.NdotH = saturate(dot(surfaceToLight.H, surface.N));
|
surfaceToLight.NdotH = saturate(dot(surface.N, surfaceToLight.H));
|
||||||
|
|
||||||
return surfaceToLight;
|
return surfaceToLight;
|
||||||
}
|
}
|
||||||
|
|
@ -243,12 +243,12 @@ float3 evaluateStandardBRDF(Surface surface, SurfaceToLight surfaceToLight)
|
||||||
float denominator = 4.0 * max(surface.NdotV, 0.0) * max(surfaceToLight.NdotL, 0.0) + 0.0001;
|
float denominator = 4.0 * max(surface.NdotV, 0.0) * max(surfaceToLight.NdotL, 0.0) + 0.0001;
|
||||||
float3 specularBRDF = numerator / denominator;
|
float3 specularBRDF = numerator / denominator;
|
||||||
|
|
||||||
float3 diffuseBRDF = surface.baseColor.rgb * M_1OVER_PI_F * surface.ao;
|
float3 diffuseBRDF = surface.baseColor.rgb * surface.ao* M_HALFPI_F;
|
||||||
|
|
||||||
// Final output combining all terms
|
// Final output combining all terms
|
||||||
float3 kS = F; // Specular reflectance
|
float3 kS = F; // Specular reflectance
|
||||||
float3 kD = (1.0 - kS) * (1.0 - surface.metalness); // Diffuse reflectance
|
float3 kD = (1.0 - kS) * (1.0 - surface.metalness); // Diffuse reflectance
|
||||||
float3 returnBRDF = kD * (diffuseBRDF) + specularBRDF;
|
float3 returnBRDF = kD*diffuseBRDF + specularBRDF;
|
||||||
|
|
||||||
if(isCapturing == 1)
|
if(isCapturing == 1)
|
||||||
return lerp(returnBRDF ,surface.albedo.rgb,surface.metalness);
|
return lerp(returnBRDF ,surface.albedo.rgb,surface.metalness);
|
||||||
|
|
@ -277,8 +277,8 @@ float3 getPunctualLight(Surface surface, SurfaceToLight surfaceToLight, float3 l
|
||||||
if(isCapturing != 1)
|
if(isCapturing != 1)
|
||||||
lightfloor = 0.0;
|
lightfloor = 0.0;
|
||||||
|
|
||||||
float attenuation = getDistanceAtt(surfaceToLight.Lu, radius);
|
float attenuation = getDistanceAtt(surfaceToLight.Lu, radius);
|
||||||
|
|
||||||
// Calculate both specular and diffuse lighting in one BRDF evaluation
|
// Calculate both specular and diffuse lighting in one BRDF evaluation
|
||||||
float3 directLighting = evaluateStandardBRDF(surface, surfaceToLight);
|
float3 directLighting = evaluateStandardBRDF(surface, surfaceToLight);
|
||||||
|
|
||||||
|
|
@ -297,7 +297,7 @@ float3 getSpotlight(Surface surface, SurfaceToLight surfaceToLight, float3 light
|
||||||
float attenuation = 1.0f;
|
float attenuation = 1.0f;
|
||||||
attenuation *= getDistanceAtt(surfaceToLight.Lu, radius);
|
attenuation *= getDistanceAtt(surfaceToLight.Lu, radius);
|
||||||
attenuation *= getSpotAngleAtt(-surfaceToLight.L, lightDir, lightSpotParams.xy);
|
attenuation *= getSpotAngleAtt(-surfaceToLight.L, lightDir, lightSpotParams.xy);
|
||||||
|
|
||||||
// Calculate both specular and diffuse lighting in one BRDF evaluation
|
// Calculate both specular and diffuse lighting in one BRDF evaluation
|
||||||
float3 directLighting = evaluateStandardBRDF(surface, surfaceToLight);
|
float3 directLighting = evaluateStandardBRDF(surface, surfaceToLight);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue