mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-16 00:54:54 +00:00
Merge pull request #1229 from marauder2k9-torque/MASOX-compile-run-fixes
macosx changes
This commit is contained in:
commit
88a43f3137
4 changed files with 163 additions and 18 deletions
|
|
@ -47,6 +47,8 @@
|
||||||
#include "platform/platformAssert.h"
|
#include "platform/platformAssert.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
class ResourceManager;
|
class ResourceManager;
|
||||||
|
|
||||||
// This is a utility class used by the resource manager.
|
// This is a utility class used by the resource manager.
|
||||||
|
|
@ -62,17 +64,18 @@ class ResourceHolderBase
|
||||||
public:
|
public:
|
||||||
static FreeListChunker<ResourceHolderBase> smHolderFactory;
|
static FreeListChunker<ResourceHolderBase> smHolderFactory;
|
||||||
|
|
||||||
ResourceHolderBase() : mRes(NULL) { ; } // @note this is needed for the chunked allocator
|
ResourceHolderBase() = default; // Default constructor
|
||||||
virtual ~ResourceHolderBase() {}
|
virtual ~ResourceHolderBase() {}
|
||||||
|
|
||||||
// Return void pointer to resource data.
|
// Return void pointer to resource data.
|
||||||
void *getResource() const { return mRes; }
|
void* getResource() const { return mRes.get(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Construct a resource holder pointing at 'p'.
|
// Construct a resource holder pointing at 'p'.
|
||||||
ResourceHolderBase(void *p) : mRes(p) {}
|
template<typename T>
|
||||||
|
ResourceHolderBase(T* p) : mRes(p, [](void*) {}) {}
|
||||||
|
|
||||||
void *mRes;
|
std::unique_ptr<void, void(*)(void*)> mRes{ nullptr, [](void*) {} };
|
||||||
};
|
};
|
||||||
|
|
||||||
// All resources are derived from this type. The base type
|
// All resources are derived from this type. The base type
|
||||||
|
|
@ -190,11 +193,17 @@ protected:
|
||||||
// This is a utility class used by resource manager. Classes derived
|
// This is a utility class used by resource manager. Classes derived
|
||||||
// from this template pretty much just know how to delete the template's
|
// from this template pretty much just know how to delete the template's
|
||||||
// type.
|
// type.
|
||||||
template<class T> class ResourceHolder : public ResourceHolderBase
|
template<class T>
|
||||||
|
class ResourceHolder : public ResourceHolderBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ResourceHolder(T *t) : ResourceHolderBase(t) {}
|
ResourceHolder(T* t) : ResourceHolderBase(t) {}
|
||||||
virtual ~ResourceHolder() { delete ((T*)mRes); }
|
virtual ~ResourceHolder() {
|
||||||
|
if (mRes) {
|
||||||
|
T* typedmRes = static_cast<T*>(mRes.get());
|
||||||
|
typedmRes->~T(); // Call the destructor explicitly
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Resource template. When dealing with resources, this is the
|
// Resource template. When dealing with resources, this is the
|
||||||
|
|
|
||||||
97
Engine/source/testing/resourceTest.cpp
Normal file
97
Engine/source/testing/resourceTest.cpp
Normal file
|
|
@ -0,0 +1,97 @@
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Copyright (c) 2014 GarageGames, LLC
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to
|
||||||
|
// deal in the Software without restriction, including without limitation the
|
||||||
|
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||||
|
// sell copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
|
// IN THE SOFTWARE.
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
#include "unitTesting.h"
|
||||||
|
|
||||||
|
#include "platform/platform.h"
|
||||||
|
|
||||||
|
#include "core/util/fourcc.h"
|
||||||
|
#include "console/console.h"
|
||||||
|
#include "core/resourceManager.h"
|
||||||
|
static bool destructorCalled;
|
||||||
|
|
||||||
|
struct TestResource
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
U64 values[4] = { 0,0,0,0 };
|
||||||
|
virtual ~TestResource() { destructorCalled = true; }
|
||||||
|
|
||||||
|
static Resource< TestResource > load(const Torque::Path& path);
|
||||||
|
static ResourceRegisterPostLoadSignal< TestResource > _smAutoLoad;
|
||||||
|
static void _onTestLoaded(Resource< TestResource >& test);
|
||||||
|
};
|
||||||
|
|
||||||
|
template<> ResourceBase::Signature Resource<TestResource>::signature()
|
||||||
|
{
|
||||||
|
return MakeFourCC('T', 'E', 'S', 'T'); // Direct Draw Surface
|
||||||
|
}
|
||||||
|
template<> void* Resource<TestResource>::create(const Torque::Path& path)
|
||||||
|
{
|
||||||
|
TestResource* testRes = new TestResource;
|
||||||
|
|
||||||
|
return testRes;
|
||||||
|
}
|
||||||
|
|
||||||
|
Resource<TestResource> TestResource::load(const Torque::Path& path)
|
||||||
|
{
|
||||||
|
Resource<TestResource> testRes = ResourceManager::get().load(path);
|
||||||
|
|
||||||
|
return testRes;
|
||||||
|
}
|
||||||
|
|
||||||
|
ResourceRegisterPostLoadSignal< TestResource > TestResource::_smAutoLoad(&TestResource::_onTestLoaded);
|
||||||
|
|
||||||
|
void TestResource::_onTestLoaded(Resource<TestResource>& test)
|
||||||
|
{
|
||||||
|
test->values[0] = 1;
|
||||||
|
test->values[1] = 1;
|
||||||
|
test->values[2] = 1;
|
||||||
|
test->values[3] = 1;
|
||||||
|
}
|
||||||
|
TEST(ResourceManagerTests, All_Resource_Functionality)
|
||||||
|
{
|
||||||
|
if (true)
|
||||||
|
{
|
||||||
|
Resource<TestResource> testRes;
|
||||||
|
|
||||||
|
testRes = TestResource::load("empty");
|
||||||
|
|
||||||
|
EXPECT_EQ(testRes.signature(), MakeFourCC('T', 'E', 'S', 'T')) << "Incorrect resource type returned!";
|
||||||
|
|
||||||
|
EXPECT_EQ(testRes.getPath(), "empty") << "Wrong path!";
|
||||||
|
|
||||||
|
U64 postLoadValues[4];
|
||||||
|
postLoadValues[0] = 1;
|
||||||
|
postLoadValues[1] = 1;
|
||||||
|
postLoadValues[2] = 1;
|
||||||
|
postLoadValues[3] = 1;
|
||||||
|
|
||||||
|
for (U32 i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
EXPECT_EQ(testRes->values[i], postLoadValues[i]) << "Array not equal";
|
||||||
|
}
|
||||||
|
|
||||||
|
EXPECT_EQ(destructorCalled, false) << "Destructor true should be false";
|
||||||
|
}
|
||||||
|
|
||||||
|
EXPECT_EQ(destructorCalled, true) << "Destructor false should be true";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -182,7 +182,7 @@ singleton ShaderData( ThickLineGUI )
|
||||||
DXGeometryShaderFile = $Core::CommonShaderPath @ "/fixedFunction/thickLineG.hlsl";
|
DXGeometryShaderFile = $Core::CommonShaderPath @ "/fixedFunction/thickLineG.hlsl";
|
||||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/fixedFunction/thickLineP.hlsl";
|
DXPixelShaderFile = $Core::CommonShaderPath @ "/fixedFunction/thickLineP.hlsl";
|
||||||
|
|
||||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/fixedFunction/gl/colorV.glsl";
|
OGLVertexShaderFile = $Core::CommonShaderPath @ "/fixedFunction/gl/thickLineV.glsl";
|
||||||
OGLGeometryShaderFile = $Core::CommonShaderPath @ "/fixedFunction/gl/thickLineG.glsl";
|
OGLGeometryShaderFile = $Core::CommonShaderPath @ "/fixedFunction/gl/thickLineG.glsl";
|
||||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/fixedFunction/gl/thickLineP.glsl";
|
OGLPixelShaderFile = $Core::CommonShaderPath @ "/fixedFunction/gl/thickLineP.glsl";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Copyright (c) 2012 GarageGames, LLC
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to
|
||||||
|
// deal in the Software without restriction, including without limitation the
|
||||||
|
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||||
|
// sell copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
|
// IN THE SOFTWARE.
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
#include "../../gl/hlslCompat.glsl"
|
||||||
|
|
||||||
|
in vec4 vPosition;
|
||||||
|
in vec4 vColor;
|
||||||
|
|
||||||
|
uniform mat4 modelview;
|
||||||
|
|
||||||
|
out VS_OUT {
|
||||||
|
vec4 color;
|
||||||
|
} vs_out;
|
||||||
|
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = tMul(modelview, vPosition);
|
||||||
|
correctSSP(gl_Position);
|
||||||
|
vs_out.color = vColor;
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue