Fix headless build

Several rendering changes have resulted in a non-rendering build that
failed to build from source. Dummy out all of these functions to make it
work again.

Cherry-picked.
Author:    Nicolas Hake <isilkor@openclonk.org>
Date:      Wed Jun 17 21:30:56 2015 +0200
Conflicts:
	src/lib/StdMesh.h
stable-6.1
Nicolas Hake 2015-06-17 21:30:56 +02:00 committed by Julius Michaelis
parent 07f02800ef
commit 652c7e43e2
23 changed files with 198 additions and 21 deletions

View File

@ -22,7 +22,7 @@ CStdNoGfx::CStdNoGfx()
Default(); Default();
} }
bool CStdNoGfx::CreatePrimarySurfaces(bool Fullscreen, unsigned int iXRes, unsigned int iYRes, int iColorDepth, unsigned int iMonitor) bool CStdNoGfx::CreatePrimarySurfaces(unsigned int iXRes, unsigned int iYRes, int iColorDepth, unsigned int iMonitor)
{ {
Log("Graphics disabled."); Log("Graphics disabled.");
// Save back color depth // Save back color depth

View File

@ -41,8 +41,12 @@ public:
virtual bool InvalidateDeviceObjects() { return true; } virtual bool InvalidateDeviceObjects() { return true; }
virtual bool DeleteDeviceObjects() { return true; } virtual bool DeleteDeviceObjects() { return true; }
virtual bool DeviceReady() { return true; } virtual bool DeviceReady() { return true; }
virtual bool CreatePrimarySurfaces(bool, unsigned int, unsigned int, int, unsigned int); virtual bool CreatePrimarySurfaces(unsigned int, unsigned int, int, unsigned int);
virtual bool SetOutputAdapter(unsigned int) { return true; } virtual bool SetOutputAdapter(unsigned int) { return true; }
virtual void PerformMultiPix(C4Surface *, const C4BltVertex *, unsigned int) {}
virtual void PerformMultiLines(C4Surface *, const C4BltVertex *, unsigned int, float) {}
virtual void PerformMultiTris(C4Surface *, const C4BltVertex *, unsigned int, const C4BltTransform *, C4TexRef *, C4TexRef *, C4TexRef *, DWORD) {}
}; };
#endif #endif

View File

@ -186,6 +186,7 @@ bool C4GraphicsResource::Init()
return false; return false;
} }
#ifndef USE_CONSOLE
// Pre-load all shader files // Pre-load all shader files
Files.PreCacheEntries(C4CFN_ShaderFiles); Files.PreCacheEntries(C4CFN_ShaderFiles);
if (!pGL->InitShaders(&Files)) if (!pGL->InitShaders(&Files))
@ -193,6 +194,7 @@ bool C4GraphicsResource::Init()
LogFatal(LoadResStr("IDS_ERR_GFX_INITSHADERS")); LogFatal(LoadResStr("IDS_ERR_GFX_INITSHADERS"));
return false; return false;
} }
#endif
Game.SetInitProgress(11.0f); Game.SetInitProgress(11.0f);
ProgressStart = 12.0f; ProgressIncrement = 0.35f; // TODO: This should be changed so that it stops at 25%, no matter how many graphics we load. ProgressStart = 12.0f; ProgressIncrement = 0.35f; // TODO: This should be changed so that it stops at 25%, no matter how many graphics we load.

View File

@ -39,8 +39,10 @@ C4ShaderPosName C4SH_PosNames[] = {
C4Shader::C4Shader() C4Shader::C4Shader()
: iTexCoords(0) : iTexCoords(0)
#ifndef USE_CONSOLE
, hVert(0), hFrag(0), hProg(0) , hVert(0), hFrag(0), hProg(0)
, pUniforms(NULL) , pUniforms(NULL)
#endif
{ {
} }
@ -260,6 +262,7 @@ void C4Shader::AddVertexDefaults()
AddVertexSlice(C4Shader_Vertex_PositionPos, "gl_Position = ftransform();\n"); AddVertexSlice(C4Shader_Vertex_PositionPos, "gl_Position = ftransform();\n");
} }
#ifndef USE_CONSOLE
GLenum C4Shader::AddTexCoord(const char *szName) GLenum C4Shader::AddTexCoord(const char *szName)
{ {
// Make sure we have enough space // Make sure we have enough space
@ -275,6 +278,7 @@ GLenum C4Shader::AddTexCoord(const char *szName)
return GL_TEXTURE0 + iTexCoords++; return GL_TEXTURE0 + iTexCoords++;
} }
#endif
void C4Shader::ClearSlices() void C4Shader::ClearSlices()
{ {
@ -285,6 +289,7 @@ void C4Shader::ClearSlices()
void C4Shader::Clear() void C4Shader::Clear()
{ {
#ifndef USE_CONSOLE
if (!hProg) return; if (!hProg) return;
// Need to be detached, then deleted // Need to be detached, then deleted
glDetachObjectARB(hProg, hFrag); glDetachObjectARB(hProg, hFrag);
@ -296,11 +301,12 @@ void C4Shader::Clear()
// Clear uniform data // Clear uniform data
delete[] pUniforms; pUniforms = NULL; delete[] pUniforms; pUniforms = NULL;
iUniformCount = 0; iUniformCount = 0;
#endif
} }
bool C4Shader::Init(const char *szWhat, const char **szUniforms) bool C4Shader::Init(const char *szWhat, const char **szUniforms)
{ {
#ifndef USE_CONSOLE
// No support? // No support?
if(!GLEW_ARB_fragment_program) if(!GLEW_ARB_fragment_program)
{ {
@ -310,6 +316,7 @@ bool C4Shader::Init(const char *szWhat, const char **szUniforms)
// Clear old shader first // Clear old shader first
if (hProg) Clear(); if (hProg) Clear();
#endif
// Dump // Dump
if (C4Shader::IsLogging()) if (C4Shader::IsLogging())
@ -320,6 +327,7 @@ bool C4Shader::Init(const char *szWhat, const char **szUniforms)
ShaderLog(Build(FragmentSlices, true).getData()); ShaderLog(Build(FragmentSlices, true).getData());
} }
#ifndef USE_CONSOLE
// Attempt to create shaders // Attempt to create shaders
StdStrBuf VertexShader = Build(VertexSlices), StdStrBuf VertexShader = Build(VertexSlices),
FragmentShader = Build(FragmentSlices); FragmentShader = Build(FragmentSlices);
@ -363,6 +371,7 @@ bool C4Shader::Init(const char *szWhat, const char **szUniforms)
// because the respective uniforms got optimized out! // because the respective uniforms got optimized out!
for (int i = 0; i < iUniformCount; i++) for (int i = 0; i < iUniformCount; i++)
pUniforms[i] = glGetUniformLocationARB(hProg, szUniforms[i]); pUniforms[i] = glGetUniformLocationARB(hProg, szUniforms[i]);
#endif
return true; return true;
} }
@ -420,9 +429,13 @@ StdStrBuf C4Shader::Build(const ShaderSliceList &Slices, bool fDebug)
// At the start of the shader set the #version and number of // At the start of the shader set the #version and number of
// available uniforms // available uniforms
StdStrBuf Buf; StdStrBuf Buf;
#ifndef USE_CONSOLE
GLint iMaxFrags = 0, iMaxVerts = 0; GLint iMaxFrags = 0, iMaxVerts = 0;
glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB, &iMaxFrags); glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB, &iMaxFrags);
glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, &iMaxVerts); glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, &iMaxVerts);
#else
int iMaxFrags = INT_MAX, iMaxVerts = INT_MAX;
#endif
Buf.Format("#version %d\n" Buf.Format("#version %d\n"
"#define MAX_FRAGMENT_UNIFORM_COMPONENTS %d\n" "#define MAX_FRAGMENT_UNIFORM_COMPONENTS %d\n"
"#define MAX_VERTEX_UNIFORM_COMPONENTS %d\n", "#define MAX_VERTEX_UNIFORM_COMPONENTS %d\n",
@ -468,6 +481,7 @@ StdStrBuf C4Shader::Build(const ShaderSliceList &Slices, bool fDebug)
return Buf; return Buf;
} }
#ifndef USE_CONSOLE
GLhandleARB C4Shader::Create(GLenum iShaderType, const char *szWhat, const char *szShader) GLhandleARB C4Shader::Create(GLenum iShaderType, const char *szWhat, const char *szShader)
{ {
// Create shader // Create shader
@ -515,9 +529,11 @@ int C4Shader::GetObjectStatus(GLhandleARB hObj, GLenum type)
glGetObjectParameterivARB(hObj, type, &iStatus); glGetObjectParameterivARB(hObj, type, &iStatus);
return iStatus; return iStatus;
} }
#endif
bool C4Shader::IsLogging() { return !!Application.isEditor; } bool C4Shader::IsLogging() { return !!Application.isEditor; }
#ifndef USE_CONSOLE
GLint C4ShaderCall::AllocTexUnit(int iUniform, GLenum iType) GLint C4ShaderCall::AllocTexUnit(int iUniform, GLenum iType)
{ {
// Want to bind uniform automatically? If not, the caller will take // Want to bind uniform automatically? If not, the caller will take
@ -550,7 +566,6 @@ void C4ShaderCall::Start()
// Activate shader // Activate shader
glUseProgramObjectARB(pShader->hProg); glUseProgramObjectARB(pShader->hProg);
fStarted = true; fStarted = true;
} }
void C4ShaderCall::Finish() void C4ShaderCall::Finish()
@ -569,3 +584,5 @@ void C4ShaderCall::Finish()
iUnits = 0; iUnits = 0;
fStarted = false; fStarted = false;
} }
#endif

View File

@ -68,11 +68,13 @@ private:
// Used texture coordinates // Used texture coordinates
int iTexCoords; int iTexCoords;
#ifndef USE_CONSOLE
// shaders // shaders
GLhandleARB hVert, hFrag, hProg; GLhandleARB hVert, hFrag, hProg;
// shader variables // shader variables
int iUniformCount; int iUniformCount;
GLint *pUniforms; GLint *pUniforms;
#endif
public: public:
enum VertexAttribIndex enum VertexAttribIndex
@ -93,15 +95,35 @@ public:
VAI_BoneIndicesMax = VAI_BoneIndices + VAI_BoneWeightsMax - VAI_BoneWeights VAI_BoneIndicesMax = VAI_BoneIndices + VAI_BoneWeightsMax - VAI_BoneWeights
}; };
bool Initialised() const { return hVert != 0; } bool Initialised() const
{
#ifndef USE_CONSOLE
return hVert != 0;
#else
return true;
#endif
}
// Uniform getters // Uniform getters
GLint GetUniform(int iUniform) const { #ifndef USE_CONSOLE
GLint GetUniform(int iUniform) const
{
return iUniform >= 0 && iUniform < iUniformCount ? pUniforms[iUniform] : -1; return iUniform >= 0 && iUniform < iUniformCount ? pUniforms[iUniform] : -1;
} }
bool HaveUniform(int iUniform) const { bool HaveUniform(int iUniform) const
{
return GetUniform(iUniform) != GLint(-1); return GetUniform(iUniform) != GLint(-1);
} }
#else
int GetUniform(int iUniform) const
{
return -1;
}
bool HaveUniform(int iUniform) const
{
return false;
}
#endif
// Shader is composed from various slices // Shader is composed from various slices
void AddVertexSlice(int iPos, const char *szText); void AddVertexSlice(int iPos, const char *szText);
@ -113,10 +135,12 @@ public:
// Add default vertex code (2D - no transformation) // Add default vertex code (2D - no transformation)
void AddVertexDefaults(); void AddVertexDefaults();
#ifndef USE_CONSOLE
// Allocate a texture coordinate, returning its ID to be used with glMultiTexCoord. // Allocate a texture coordinate, returning its ID to be used with glMultiTexCoord.
// The texture coordinate will be visible to both shaders under the given name. // The texture coordinate will be visible to both shaders under the given name.
// Note that in contrast to uniforms, these will not disappear if not used! // Note that in contrast to uniforms, these will not disappear if not used!
GLenum AddTexCoord(const char *szName); GLenum AddTexCoord(const char *szName);
#endif
// Assemble and link the shader. Should be called again after new slices are added. // Assemble and link the shader. Should be called again after new slices are added.
bool Init(const char *szWhat, const char **szUniforms); bool Init(const char *szWhat, const char **szUniforms);
@ -131,18 +155,22 @@ private:
int ParsePosition(const char *szWhat, const char **ppPos); int ParsePosition(const char *szWhat, const char **ppPos);
StdStrBuf Build(const ShaderSliceList &Slices, bool fDebug = false); StdStrBuf Build(const ShaderSliceList &Slices, bool fDebug = false);
#ifndef USE_CONSOLE
GLhandleARB Create(GLenum iShaderType, const char *szWhat, const char *szShader); GLhandleARB Create(GLenum iShaderType, const char *szWhat, const char *szShader);
void DumpInfoLog(const char *szWhat, GLhandleARB hShader); void DumpInfoLog(const char *szWhat, GLhandleARB hShader);
int GetObjectStatus(GLhandleARB hObj, GLenum type); int GetObjectStatus(GLhandleARB hObj, GLenum type);
#endif
public: public:
static bool IsLogging(); static bool IsLogging();
}; };
#ifndef USE_CONSOLE
class C4ShaderCall class C4ShaderCall
{ {
public: public:
C4ShaderCall(const C4Shader *pShader) C4ShaderCall(const C4Shader *pShader)
: fStarted(false), pShader(pShader), iUnits(0) : fStarted(false), pShader(pShader), iUnits(0)
{ } { }
~C4ShaderCall() { Finish(); } ~C4ShaderCall() { Finish(); }
@ -210,5 +238,6 @@ public:
void Start(); void Start();
void Finish(); void Finish();
}; };
#endif
#endif // INC_C4Shader #endif // INC_C4Shader

View File

@ -26,6 +26,7 @@ C4FoW::C4FoW()
C4Shader *C4FoW::GetFramebufShader() C4Shader *C4FoW::GetFramebufShader()
{ {
#ifndef USE_CONSOLE
// Not created yet? // Not created yet?
if (!FramebufShader.Initialised()) if (!FramebufShader.Initialised())
{ {
@ -46,10 +47,14 @@ C4Shader *C4FoW::GetFramebufShader()
} }
return &FramebufShader; return &FramebufShader;
#else
return NULL;
#endif
} }
void C4FoW::Add(C4Object *pObj) void C4FoW::Add(C4Object *pObj)
{ {
#ifndef USE_CONSOLE
// No view range? Probably want to remove instead // No view range? Probably want to remove instead
if(!pObj->lightRange && !pObj->lightFadeoutRange) if(!pObj->lightRange && !pObj->lightFadeoutRange)
{ {
@ -77,10 +82,12 @@ void C4FoW::Add(C4Object *pObj)
pLight->pNext = pLights; pLight->pNext = pLights;
pLights = pLight; pLights = pLight;
} }
#endif
} }
void C4FoW::Remove(C4Object *pObj) void C4FoW::Remove(C4Object *pObj)
{ {
#ifndef USE_CONSOLE
// Look for matching light // Look for matching light
C4FoWLight *pPrev = NULL, *pLight; C4FoWLight *pPrev = NULL, *pLight;
for (pLight = pLights; pLight; pPrev = pLight, pLight = pLight->getNext()) for (pLight = pLights; pLight; pPrev = pLight, pLight = pLight->getNext())
@ -92,24 +99,31 @@ void C4FoW::Remove(C4Object *pObj)
// Remove // Remove
(pPrev ? pPrev->pNext : pLights) = pLight->getNext(); (pPrev ? pPrev->pNext : pLights) = pLight->getNext();
delete pLight; delete pLight;
#endif
} }
void C4FoW::Invalidate(C4Rect r) void C4FoW::Invalidate(C4Rect r)
{ {
#ifndef USE_CONSOLE
for (C4FoWLight *pLight = pLights; pLight; pLight = pLight->getNext()) for (C4FoWLight *pLight = pLights; pLight; pLight = pLight->getNext())
pLight->Invalidate(r); pLight->Invalidate(r);
#endif
} }
void C4FoW::Update(C4Rect r, C4Player *pPlr) void C4FoW::Update(C4Rect r, C4Player *pPlr)
{ {
#ifndef USE_CONSOLE
for (C4FoWLight *pLight = pLights; pLight; pLight = pLight->getNext()) for (C4FoWLight *pLight = pLights; pLight; pLight = pLight->getNext())
if (pLight->IsVisibleForPlayer(pPlr)) if (pLight->IsVisibleForPlayer(pPlr))
pLight->Update(r); pLight->Update(r);
#endif
} }
void C4FoW::Render(C4FoWRegion *pRegion, const C4TargetFacet *pOnScreen, C4Player *pPlr) void C4FoW::Render(C4FoWRegion *pRegion, const C4TargetFacet *pOnScreen, C4Player *pPlr)
{ {
#ifndef USE_CONSOLE
for (C4FoWLight *pLight = pLights; pLight; pLight = pLight->getNext()) for (C4FoWLight *pLight = pLights; pLight; pLight = pLight->getNext())
if (pLight->IsVisibleForPlayer(pPlr)) if (pLight->IsVisibleForPlayer(pPlr))
pLight->Render(pRegion, pOnScreen); pLight->Render(pRegion, pOnScreen);
#endif
} }

View File

@ -99,8 +99,10 @@ public:
void Render(class C4FoWRegion *pRegion, const C4TargetFacet *pOnScreen, C4Player *pPlr); void Render(class C4FoWRegion *pRegion, const C4TargetFacet *pOnScreen, C4Player *pPlr);
private: private:
#ifndef USE_CONSOLE
// Shader for updating the frame buffer // Shader for updating the frame buffer
C4Shader FramebufShader; C4Shader FramebufShader;
#endif
}; };
#endif // C4FOW_H #endif // C4FOW_H

View File

@ -84,7 +84,10 @@ struct LightMapZoom {
} // anonymous namespace } // anonymous namespace
C4FoWAmbient::C4FoWAmbient() : C4FoWAmbient::C4FoWAmbient() :
Tex(0), Resolution(0.), Radius(0.), FullCoverage(0.), #ifndef USE_CONSOLE
Tex(0),
#endif
Resolution(0.), Radius(0.), FullCoverage(0.),
SizeX(0), LandscapeX(0), SizeY(0), LandscapeY(0), SizeX(0), LandscapeX(0), SizeY(0), LandscapeY(0),
Brightness(1.) Brightness(1.)
{ {
@ -97,8 +100,10 @@ C4FoWAmbient::~C4FoWAmbient()
void C4FoWAmbient::Clear() void C4FoWAmbient::Clear()
{ {
#ifndef USE_CONSOLE
if(Tex != 0) glDeleteTextures(1, &Tex); if(Tex != 0) glDeleteTextures(1, &Tex);
Tex = 0; Tex = 0;
#endif
Resolution = Radius = FullCoverage = 0.; Resolution = Radius = FullCoverage = 0.;
SizeX = SizeY = 0; SizeX = SizeY = 0;
LandscapeX = LandscapeY = 0; LandscapeX = LandscapeY = 0;
@ -112,7 +117,7 @@ void C4FoWAmbient::CreateFromLandscape(const C4Landscape& landscape, double reso
assert(full_coverage > 0 && full_coverage <= 1.); assert(full_coverage > 0 && full_coverage <= 1.);
// Clear old map // Clear old map
if(Tex != 0) Clear(); Clear();
Resolution = resolution; Resolution = resolution;
Radius = radius; Radius = radius;
@ -124,6 +129,7 @@ void C4FoWAmbient::CreateFromLandscape(const C4Landscape& landscape, double reso
SizeX = Min<unsigned int>(static_cast<unsigned int>(ceil(LandscapeX / resolution)), pDraw->MaxTexSize); SizeX = Min<unsigned int>(static_cast<unsigned int>(ceil(LandscapeX / resolution)), pDraw->MaxTexSize);
SizeY = Min<unsigned int>(static_cast<unsigned int>(ceil(LandscapeY / resolution)), pDraw->MaxTexSize); SizeY = Min<unsigned int>(static_cast<unsigned int>(ceil(LandscapeY / resolution)), pDraw->MaxTexSize);
#ifndef USE_CONSOLE
glGenTextures(1, &Tex); glGenTextures(1, &Tex);
glBindTexture(GL_TEXTURE_2D, Tex); glBindTexture(GL_TEXTURE_2D, Tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
@ -136,10 +142,12 @@ void C4FoWAmbient::CreateFromLandscape(const C4Landscape& landscape, double reso
UpdateFromLandscape(landscape, C4Rect(0, 0, landscape.Width, landscape.Height)); UpdateFromLandscape(landscape, C4Rect(0, 0, landscape.Width, landscape.Height));
uint32_t dt = C4TimeMilliseconds::Now() - begin; uint32_t dt = C4TimeMilliseconds::Now() - begin;
LogF("Created %ux%u ambient map in %g secs", SizeX, SizeY, dt / 1000.); LogF("Created %ux%u ambient map in %g secs", SizeX, SizeY, dt / 1000.);
#endif
} }
void C4FoWAmbient::UpdateFromLandscape(const C4Landscape& landscape, const C4Rect& update) void C4FoWAmbient::UpdateFromLandscape(const C4Landscape& landscape, const C4Rect& update)
{ {
#ifndef USE_CONSOLE
// Nothing to do? // Nothing to do?
if(update.Wdt == 0 || update.Hgt == 0) return; if(update.Wdt == 0 || update.Hgt == 0) return;
@ -191,6 +199,7 @@ void C4FoWAmbient::UpdateFromLandscape(const C4Landscape& landscape, const C4Rec
glBindTexture(GL_TEXTURE_2D, Tex); glBindTexture(GL_TEXTURE_2D, Tex);
glTexSubImage2D(GL_TEXTURE_2D, 0, left, top, (right - left), (bottom - top), GL_RED, GL_FLOAT, ambient); glTexSubImage2D(GL_TEXTURE_2D, 0, left, top, (right - left), (bottom - top), GL_RED, GL_FLOAT, ambient);
delete[] ambient; delete[] ambient;
#endif
} }
void C4FoWAmbient::GetFragTransform(const FLOAT_RECT& vpRect, const C4Rect& clipRect, const C4Rect& outRect, float ambientTransform[6]) const void C4FoWAmbient::GetFragTransform(const FLOAT_RECT& vpRect, const C4Rect& clipRect, const C4Rect& outRect, float ambientTransform[6]) const

View File

@ -28,7 +28,9 @@ public:
C4FoWAmbient(); C4FoWAmbient();
~C4FoWAmbient(); ~C4FoWAmbient();
#ifndef USE_CONSOLE
GLuint Tex; GLuint Tex;
#endif
private: private:
// Parameters // Parameters

View File

@ -14,6 +14,8 @@
*/ */
#include "C4Include.h" #include "C4Include.h"
#ifndef USE_CONSOLE
#include "C4FoWBeam.h" #include "C4FoWBeam.h"
// Maximum error allowed while merging beams. // Maximum error allowed while merging beams.
@ -48,7 +50,7 @@ bool C4FoWBeam::MergeRight(int32_t x, int32_t y)
// Calculate error. Note that simply summing up errors is not correct, // Calculate error. Note that simply summing up errors is not correct,
// strictly speaking (as new and old error surfaces might overlap). Still, // strictly speaking (as new and old error surfaces might overlap). Still,
// this is quite elaborate already, no need to make it even more // this is quite elaborate already, no need to make it even more
int32_t iErr = getDoubleTriangleSurface( int32_t iErr = getDoubleTriangleSurface(
getLeftEndX(), iLeftEndY, getLeftEndX(), iLeftEndY,
getRightEndX(), iRightEndY, getRightEndX(), iRightEndY,
@ -193,3 +195,5 @@ void C4FoWBeam::CompileFunc(StdCompiler *pComp)
pComp->Value(mkNamingAdapt(iError, "iError")); pComp->Value(mkNamingAdapt(iError, "iError"));
pComp->Value(mkNamingAdapt(fDirty, "fDirty")); pComp->Value(mkNamingAdapt(fDirty, "fDirty"));
} }
#endif

View File

@ -16,6 +16,7 @@
#ifndef C4FOWBEAM_H #ifndef C4FOWBEAM_H
#define C4FOWBEAM_H #define C4FOWBEAM_H
#ifndef USE_CONSOLE
#include "StdBuf.h" #include "StdBuf.h"
/** This class represents one beam. A beam is a triangle spanned by two rays: one going from the origin to the /** This class represents one beam. A beam is a triangle spanned by two rays: one going from the origin to the
@ -133,4 +134,6 @@ public:
}; };
#endif // C4FOWBEAM #endif
#endif // C4FOWBEAM

View File

@ -14,6 +14,9 @@
*/ */
#include "C4Include.h" #include "C4Include.h"
#ifndef USE_CONSOLE
#include "C4FoWDrawStrategy.h" #include "C4FoWDrawStrategy.h"
#include "C4FoWLight.h" #include "C4FoWLight.h"
#include "C4FoWRegion.h" #include "C4FoWRegion.h"
@ -151,3 +154,4 @@ void C4FoWDrawWireframeStrategy::DrawLightVertex(float x, float y)
DrawVertex(x, y); DrawVertex(x, y);
} }
#endif

View File

@ -16,6 +16,8 @@
#ifndef C4FOWDRAWSTRATEGY_H #ifndef C4FOWDRAWSTRATEGY_H
#define C4FOWDRAWSTRATEGY_H #define C4FOWDRAWSTRATEGY_H
#ifndef USE_CONSOLE
#include "C4DrawGL.h" #include "C4DrawGL.h"
#include <list> #include <list>
@ -122,3 +124,5 @@ private:
}; };
#endif #endif
#endif

View File

@ -14,6 +14,9 @@
*/ */
#include "C4Include.h" #include "C4Include.h"
#ifndef USE_CONSOLE
#include "C4FoWLight.h" #include "C4FoWLight.h"
#include "C4FoWLightSection.h" #include "C4FoWLightSection.h"
#include "C4FoWBeamTriangle.h" #include "C4FoWBeamTriangle.h"
@ -344,3 +347,5 @@ bool C4FoWLight::IsVisibleForPlayer(C4Player *player) const
if (!pObj || !player) return true; if (!pObj || !player) return true;
return !::Hostile(pObj->Owner,player->Number); return !::Hostile(pObj->Owner,player->Number);
} }
#endif

View File

@ -15,6 +15,8 @@
#ifndef C4FOWLIGHT_H #ifndef C4FOWLIGHT_H
#define C4FOWLIGHT_H #define C4FOWLIGHT_H
#ifndef USE_CONSOLE
#include "C4Object.h" #include "C4Object.h"
#include "C4Surface.h" #include "C4Surface.h"
#include "C4FacetEx.h" #include "C4FacetEx.h"
@ -95,4 +97,6 @@ private:
}; };
#endif #endif
#endif

View File

@ -14,6 +14,9 @@
*/ */
#include "C4Include.h" #include "C4Include.h"
#ifndef USE_CONSOLE
#include "C4FoWLightSection.h" #include "C4FoWLightSection.h"
#include "C4FoWBeamTriangle.h" #include "C4FoWBeamTriangle.h"
#include "C4FoWBeam.h" #include "C4FoWBeam.h"
@ -856,3 +859,5 @@ void C4FoWLightSection::CompileFunc(StdCompiler *pComp)
} }
} }
} }
#endif

View File

@ -16,6 +16,8 @@
#ifndef C4FOWLIGHTSECTION_H #ifndef C4FOWLIGHTSECTION_H
#define C4FOWLIGHTSECTION_H #define C4FOWLIGHTSECTION_H
#ifndef USE_CONSOLE
#include "C4Rect.h" #include "C4Rect.h"
#include <list> #include <list>
@ -134,4 +136,6 @@ public:
}; };
#endif #endif
#endif

View File

@ -16,6 +16,7 @@
#include "C4Include.h" #include "C4Include.h"
#include "C4FoWRegion.h" #include "C4FoWRegion.h"
#ifndef USE_CONSOLE
bool glCheck() { bool glCheck() {
if (int err = glGetError()) { if (int err = glGetError()) {
LogF("GL error %d: %s", err, gluErrorString(err)); LogF("GL error %d: %s", err, gluErrorString(err));
@ -23,6 +24,7 @@ bool glCheck() {
} }
return true; return true;
} }
#endif
C4FoWRegion::~C4FoWRegion() C4FoWRegion::~C4FoWRegion()
{ {
@ -31,7 +33,7 @@ C4FoWRegion::~C4FoWRegion()
bool C4FoWRegion::BindFramebuf() bool C4FoWRegion::BindFramebuf()
{ {
#ifndef USE_CONSOLE
// Flip texture // Flip texture
C4Surface *pSfc = pSurface; C4Surface *pSfc = pSurface;
pSurface = pBackSurface; pSurface = pBackSurface;
@ -79,6 +81,7 @@ bool C4FoWRegion::BindFramebuf()
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
return false; return false;
} }
#endif
// Worked! // Worked!
return true; return true;
@ -86,11 +89,13 @@ bool C4FoWRegion::BindFramebuf()
void C4FoWRegion::Clear() void C4FoWRegion::Clear()
{ {
#ifndef USE_CONSOLE
if (hFrameBufDraw) { if (hFrameBufDraw) {
glDeleteFramebuffersEXT(1, &hFrameBufDraw); glDeleteFramebuffersEXT(1, &hFrameBufDraw);
glDeleteFramebuffersEXT(1, &hFrameBufRead); glDeleteFramebuffersEXT(1, &hFrameBufRead);
} }
hFrameBufDraw = hFrameBufRead = 0; hFrameBufDraw = hFrameBufRead = 0;
#endif
delete pSurface; pSurface = NULL; delete pSurface; pSurface = NULL;
delete pBackSurface; pBackSurface = NULL; delete pBackSurface; pBackSurface = NULL;
} }
@ -104,6 +109,7 @@ void C4FoWRegion::Update(C4Rect r, const FLOAT_RECT& vp)
void C4FoWRegion::Render(const C4TargetFacet *pOnScreen) void C4FoWRegion::Render(const C4TargetFacet *pOnScreen)
{ {
#ifndef USE_CONSOLE
// Update FoW at interesting location // Update FoW at interesting location
pFoW->Update(Region, pPlayer); pFoW->Update(Region, pPlayer);
@ -199,7 +205,7 @@ void C4FoWRegion::Render(const C4TargetFacet *pOnScreen)
glCheck(); glCheck();
OldRegion = Region; OldRegion = Region;
#endif
} }
void C4FoWRegion::GetFragTransform(const C4Rect& clipRect, const C4Rect& outRect, float lightTransform[6]) const void C4FoWRegion::GetFragTransform(const C4Rect& clipRect, const C4Rect& outRect, float lightTransform[6]) const
@ -229,7 +235,9 @@ void C4FoWRegion::GetFragTransform(const C4Rect& clipRect, const C4Rect& outRect
C4FoWRegion::C4FoWRegion(C4FoW *pFoW, C4Player *pPlayer) C4FoWRegion::C4FoWRegion(C4FoW *pFoW, C4Player *pPlayer)
: pFoW(pFoW) : pFoW(pFoW)
, pPlayer(pPlayer) , pPlayer(pPlayer)
#ifndef USE_CONSOLE
, hFrameBufDraw(0), hFrameBufRead(0) , hFrameBufDraw(0), hFrameBufRead(0)
#endif
, Region(0,0,0,0), OldRegion(0,0,0,0) , Region(0,0,0,0), OldRegion(0,0,0,0)
, pSurface(NULL), pBackSurface(NULL) , pSurface(NULL), pBackSurface(NULL)
{ {

View File

@ -31,10 +31,13 @@ public:
private: private:
C4FoW *pFoW; C4FoW *pFoW;
C4Player *pPlayer; C4Player *pPlayer;
C4Surface *pSurface, *pBackSurface;
C4Rect Region, OldRegion; C4Rect Region, OldRegion;
FLOAT_RECT ViewportRegion; // Region covered by visible viewport FLOAT_RECT ViewportRegion; // Region covered by visible viewport
C4Surface *pSurface, *pBackSurface;
#ifndef USE_CONSOLE
GLuint hFrameBufDraw, hFrameBufRead; GLuint hFrameBufDraw, hFrameBufRead;
#endif
public: public:
const C4FoW* getFoW() const { return pFoW; } const C4FoW* getFoW() const { return pFoW; }

View File

@ -534,7 +534,11 @@ StdSubMesh::StdSubMesh() :
{ {
} }
StdMesh::StdMesh() : Skeleton(new StdMeshSkeleton), vbo(0) StdMesh::StdMesh() :
Skeleton(new StdMeshSkeleton)
#ifndef USE_CONSOLE
, vbo(0)
#endif
{ {
BoundingBox.x1 = BoundingBox.y1 = BoundingBox.z1 = 0.0f; BoundingBox.x1 = BoundingBox.y1 = BoundingBox.z1 = 0.0f;
BoundingBox.x2 = BoundingBox.y2 = BoundingBox.z2 = 0.0f; BoundingBox.x2 = BoundingBox.y2 = BoundingBox.z2 = 0.0f;
@ -543,17 +547,22 @@ StdMesh::StdMesh() : Skeleton(new StdMeshSkeleton), vbo(0)
StdMesh::~StdMesh() StdMesh::~StdMesh()
{ {
#ifndef USE_CONSOLE
if (vbo) if (vbo)
glDeleteBuffers(1, &vbo); glDeleteBuffers(1, &vbo);
#endif
} }
void StdMesh::PostInit() void StdMesh::PostInit()
{ {
#ifndef USE_CONSOLE
// Order submeshes so that opaque submeshes come before non-opaque ones // Order submeshes so that opaque submeshes come before non-opaque ones
std::sort(SubMeshes.begin(), SubMeshes.end(), StdMeshSubMeshVisibilityCmpPred()); std::sort(SubMeshes.begin(), SubMeshes.end(), StdMeshSubMeshVisibilityCmpPred());
UpdateVBO(); UpdateVBO();
#endif
} }
#ifndef USE_CONSOLE
void StdMesh::UpdateVBO() void StdMesh::UpdateVBO()
{ {
// We're only uploading vertices once, so there shouldn't be a VBO so far // We're only uploading vertices once, so there shouldn't be a VBO so far
@ -603,18 +612,21 @@ void StdMesh::UpdateVBO()
// Unbind the buffer so following rendering calls do not use it // Unbind the buffer so following rendering calls do not use it
glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ARRAY_BUFFER, 0);
} }
#endif
StdSubMeshInstance::StdSubMeshInstance(StdMeshInstance& instance, const StdSubMesh& submesh, float completion): StdSubMeshInstance::StdSubMeshInstance(StdMeshInstance& instance, const StdSubMesh& submesh, float completion):
base(&submesh), Material(NULL), CurrentFaceOrdering(FO_Fixed) base(&submesh), Material(NULL), CurrentFaceOrdering(FO_Fixed)
{ {
#ifndef USE_CONSOLE
LoadFacesForCompletion(instance, submesh, completion); LoadFacesForCompletion(instance, submesh, completion);
#endif
SetMaterial(submesh.GetMaterial()); SetMaterial(submesh.GetMaterial());
} }
void StdSubMeshInstance::LoadFacesForCompletion(StdMeshInstance& instance, const StdSubMesh& submesh, float completion) void StdSubMeshInstance::LoadFacesForCompletion(StdMeshInstance& instance, const StdSubMesh& submesh, float completion)
{ {
#ifndef USE_CONSOLE
// First: Copy all faces // First: Copy all faces
Faces.resize(submesh.GetNumFaces()); Faces.resize(submesh.GetNumFaces());
for (unsigned int i = 0; i < submesh.GetNumFaces(); ++i) for (unsigned int i = 0; i < submesh.GetNumFaces(); ++i)
@ -637,12 +649,14 @@ void StdSubMeshInstance::LoadFacesForCompletion(StdMeshInstance& instance, const
assert(submesh.GetNumFaces() >= 1); assert(submesh.GetNumFaces() >= 1);
Faces.resize(Clamp<unsigned int>(static_cast<unsigned int>(completion * submesh.GetNumFaces() + 0.5), 1, submesh.GetNumFaces())); Faces.resize(Clamp<unsigned int>(static_cast<unsigned int>(completion * submesh.GetNumFaces() + 0.5), 1, submesh.GetNumFaces()));
} }
#endif
} }
void StdSubMeshInstance::SetMaterial(const StdMeshMaterial& material) void StdSubMeshInstance::SetMaterial(const StdMeshMaterial& material)
{ {
Material = &material; Material = &material;
#ifndef USE_CONSOLE
// Setup initial texture animation data // Setup initial texture animation data
assert(Material->BestTechniqueIndex >= 0); assert(Material->BestTechniqueIndex >= 0);
const StdMeshMaterialTechnique& technique = Material->Techniques[Material->BestTechniqueIndex]; const StdMeshMaterialTechnique& technique = Material->Techniques[Material->BestTechniqueIndex];
@ -664,10 +678,12 @@ void StdSubMeshInstance::SetMaterial(const StdMeshMaterial& material)
} }
// TODO: Reset face ordering // TODO: Reset face ordering
#endif
} }
void StdSubMeshInstance::SetFaceOrdering(const StdSubMesh& submesh, FaceOrdering ordering) void StdSubMeshInstance::SetFaceOrdering(const StdSubMesh& submesh, FaceOrdering ordering)
{ {
#ifndef USE_CONSOLE
if (CurrentFaceOrdering != ordering) if (CurrentFaceOrdering != ordering)
{ {
CurrentFaceOrdering = ordering; CurrentFaceOrdering = ordering;
@ -677,10 +693,12 @@ void StdSubMeshInstance::SetFaceOrdering(const StdSubMesh& submesh, FaceOrdering
Faces[i] = submesh.GetFace(i); Faces[i] = submesh.GetFace(i);
} }
} }
#endif
} }
void StdSubMeshInstance::SetFaceOrderingForClrModulation(const StdSubMesh& submesh, uint32_t clrmod) void StdSubMeshInstance::SetFaceOrderingForClrModulation(const StdSubMesh& submesh, uint32_t clrmod)
{ {
#ifndef USE_CONSOLE
bool opaque = Material->IsOpaque(); bool opaque = Material->IsOpaque();
if(!opaque) if(!opaque)
@ -689,6 +707,7 @@ void StdSubMeshInstance::SetFaceOrderingForClrModulation(const StdSubMesh& subme
SetFaceOrdering(submesh, FO_NearestToFarthest); SetFaceOrdering(submesh, FO_NearestToFarthest);
else else
SetFaceOrdering(submesh, FO_Fixed); SetFaceOrdering(submesh, FO_Fixed);
#endif
} }
void StdSubMeshInstance::CompileFunc(StdCompiler* pComp) void StdSubMeshInstance::CompileFunc(StdCompiler* pComp)
@ -1050,6 +1069,7 @@ StdMeshInstance::~StdMeshInstance()
void StdMeshInstance::SetFaceOrdering(FaceOrdering ordering) void StdMeshInstance::SetFaceOrdering(FaceOrdering ordering)
{ {
#ifndef USE_CONSOLE
for (unsigned int i = 0; i < Mesh->GetNumSubMeshes(); ++i) for (unsigned int i = 0; i < Mesh->GetNumSubMeshes(); ++i)
SubMeshInstances[i]->SetFaceOrdering(Mesh->GetSubMesh(i), ordering); SubMeshInstances[i]->SetFaceOrdering(Mesh->GetSubMesh(i), ordering);
@ -1058,10 +1078,12 @@ void StdMeshInstance::SetFaceOrdering(FaceOrdering ordering)
for (AttachedMeshIter iter = AttachChildren.begin(); iter != AttachChildren.end(); ++iter) for (AttachedMeshIter iter = AttachChildren.begin(); iter != AttachChildren.end(); ++iter)
if ((*iter)->OwnChild) if ((*iter)->OwnChild)
(*iter)->Child->SetFaceOrdering(ordering); (*iter)->Child->SetFaceOrdering(ordering);
#endif
} }
void StdMeshInstance::SetFaceOrderingForClrModulation(uint32_t clrmod) void StdMeshInstance::SetFaceOrderingForClrModulation(uint32_t clrmod)
{ {
#ifndef USE_CONSOLE
for (unsigned int i = 0; i < Mesh->GetNumSubMeshes(); ++i) for (unsigned int i = 0; i < Mesh->GetNumSubMeshes(); ++i)
SubMeshInstances[i]->SetFaceOrderingForClrModulation(Mesh->GetSubMesh(i), clrmod); SubMeshInstances[i]->SetFaceOrderingForClrModulation(Mesh->GetSubMesh(i), clrmod);
@ -1070,16 +1092,19 @@ void StdMeshInstance::SetFaceOrderingForClrModulation(uint32_t clrmod)
for (AttachedMeshIter iter = AttachChildren.begin(); iter != AttachChildren.end(); ++iter) for (AttachedMeshIter iter = AttachChildren.begin(); iter != AttachChildren.end(); ++iter)
if ((*iter)->OwnChild) if ((*iter)->OwnChild)
(*iter)->Child->SetFaceOrderingForClrModulation(clrmod); (*iter)->Child->SetFaceOrderingForClrModulation(clrmod);
#endif
} }
void StdMeshInstance::SetCompletion(float completion) void StdMeshInstance::SetCompletion(float completion)
{ {
Completion = completion; Completion = completion;
#ifndef USE_CONSOLE
// TODO: Load all submesh faces and then determine the ones to use from the // TODO: Load all submesh faces and then determine the ones to use from the
// full pool. // full pool.
for(unsigned int i = 0; i < Mesh->GetNumSubMeshes(); ++i) for(unsigned int i = 0; i < Mesh->GetNumSubMeshes(); ++i)
SubMeshInstances[i]->LoadFacesForCompletion(*this, Mesh->GetSubMesh(i), completion); SubMeshInstances[i]->LoadFacesForCompletion(*this, Mesh->GetSubMesh(i), completion);
#endif
} }
StdMeshInstance::AnimationNode* StdMeshInstance::PlayAnimation(const StdStrBuf& animation_name, int slot, AnimationNode* sibling, ValueProvider* position, ValueProvider* weight) StdMeshInstance::AnimationNode* StdMeshInstance::PlayAnimation(const StdStrBuf& animation_name, int slot, AnimationNode* sibling, ValueProvider* position, ValueProvider* weight)
@ -1210,6 +1235,7 @@ void StdMeshInstance::ExecuteAnimation(float dt)
if(!ExecuteAnimationNode(AnimationStack[i-1])) if(!ExecuteAnimationNode(AnimationStack[i-1]))
StopAnimation(AnimationStack[i-1]); StopAnimation(AnimationStack[i-1]);
#ifndef USE_CONSOLE
// Update animated textures // Update animated textures
for (unsigned int i = 0; i < SubMeshInstances.size(); ++i) for (unsigned int i = 0; i < SubMeshInstances.size(); ++i)
{ {
@ -1240,6 +1266,7 @@ void StdMeshInstance::ExecuteAnimation(float dt)
} }
} }
} }
#endif
// Update animation for attached meshes // Update animation for attached meshes
for (AttachedMeshList::iterator iter = AttachChildren.begin(); iter != AttachChildren.end(); ++iter) for (AttachedMeshList::iterator iter = AttachChildren.begin(); iter != AttachChildren.end(); ++iter)
@ -1321,7 +1348,9 @@ void StdMeshInstance::SetMaterial(size_t i, const StdMeshMaterial& material)
{ {
assert(i < SubMeshInstances.size()); assert(i < SubMeshInstances.size());
SubMeshInstances[i]->SetMaterial(material); SubMeshInstances[i]->SetMaterial(material);
#ifndef USE_CONSOLE
std::stable_sort(SubMeshInstancesOrdered.begin(), SubMeshInstancesOrdered.end(), StdMeshSubMeshInstanceVisibilityCmpPred()); std::stable_sort(SubMeshInstancesOrdered.begin(), SubMeshInstancesOrdered.end(), StdMeshSubMeshInstanceVisibilityCmpPred());
#endif
} }
const StdMeshMatrix& StdMeshInstance::GetBoneTransform(size_t i) const const StdMeshMatrix& StdMeshInstance::GetBoneTransform(size_t i) const
@ -1433,6 +1462,7 @@ bool StdMeshInstance::UpdateBoneTransforms()
void StdMeshInstance::ReorderFaces(StdMeshMatrix* global_trans) void StdMeshInstance::ReorderFaces(StdMeshMatrix* global_trans)
{ {
#ifndef USE_CONSOLE
for (unsigned int i = 0; i < SubMeshInstances.size(); ++i) for (unsigned int i = 0; i < SubMeshInstances.size(); ++i)
{ {
StdSubMeshInstance& inst = *SubMeshInstances[i]; StdSubMeshInstance& inst = *SubMeshInstances[i];
@ -1450,6 +1480,7 @@ void StdMeshInstance::ReorderFaces(StdMeshMatrix* global_trans)
} }
// TODO: Also reorder submeshes, attached meshes and include AttachTransformation for attached meshes... // TODO: Also reorder submeshes, attached meshes and include AttachTransformation for attached meshes...
#endif
} }
void StdMeshInstance::CompileFunc(StdCompiler* pComp, AttachedMesh::DenumeratorFactoryFunc Factory) void StdMeshInstance::CompileFunc(StdCompiler* pComp, AttachedMesh::DenumeratorFactoryFunc Factory)

View File

@ -197,11 +197,15 @@ public:
void PostInit(); void PostInit();
const GLuint GetVBO() const { return vbo; } #ifndef USE_CONSOLE
GLuint GetVBO() const { return vbo; }
#endif
private: private:
#ifndef USE_CONSOLE
GLuint vbo; GLuint vbo;
void UpdateVBO(); void UpdateVBO();
#endif
StdMesh(const StdMesh& other); // non-copyable StdMesh(const StdMesh& other); // non-copyable
StdMesh& operator=(const StdMesh& other); // non-assignable StdMesh& operator=(const StdMesh& other); // non-assignable

View File

@ -849,7 +849,9 @@ bool StdMeshMaterialProgram::CompileShader(StdMeshMaterialLoader& loader, C4Shad
shader.AddVertexSlices(VertexShader->GetFilename(), VertexShader->GetCode(), VertexShader->GetFilename()); shader.AddVertexSlices(VertexShader->GetFilename(), VertexShader->GetCode(), VertexShader->GetFilename());
shader.AddFragmentSlices(FragmentShader->GetFilename(), FragmentShader->GetCode(), FragmentShader->GetFilename()); shader.AddFragmentSlices(FragmentShader->GetFilename(), FragmentShader->GetCode(), FragmentShader->GetFilename());
// Construct the list of uniforms // Construct the list of uniforms
std::vector<const char*> uniformNames(C4SSU_Count + ParameterNames.size() + 1); std::vector<const char*> uniformNames;
#ifndef USE_CONSOLE
uniformNames.resize(C4SSU_Count + ParameterNames.size() + 1);
uniformNames[C4SSU_ClrMod] = "clrMod"; uniformNames[C4SSU_ClrMod] = "clrMod";
uniformNames[C4SSU_BaseTex] = "baseTex"; // unused uniformNames[C4SSU_BaseTex] = "baseTex"; // unused
uniformNames[C4SSU_OverlayTex] = "overlayTex"; // unused uniformNames[C4SSU_OverlayTex] = "overlayTex"; // unused
@ -864,25 +866,31 @@ bool StdMeshMaterialProgram::CompileShader(StdMeshMaterialLoader& loader, C4Shad
for (unsigned int i = 0; i < ParameterNames.size(); ++i) for (unsigned int i = 0; i < ParameterNames.size(); ++i)
uniformNames[C4SSU_Count + i] = ParameterNames[i].getData(); uniformNames[C4SSU_Count + i] = ParameterNames[i].getData();
uniformNames[C4SSU_Count + ParameterNames.size()] = NULL; uniformNames[C4SSU_Count + ParameterNames.size()] = NULL;
#endif
// Compile the shader // Compile the shader
StdCopyStrBuf name(Name); StdCopyStrBuf name(Name);
#ifndef USE_CONSOLE
if (ssc != 0) name.Append(":"); if (ssc != 0) name.Append(":");
if (ssc & C4SSC_LIGHT) name.Append("Light"); if (ssc & C4SSC_LIGHT) name.Append("Light");
if (ssc & C4SSC_MOD2) name.Append("Mod2"); if (ssc & C4SSC_MOD2) name.Append("Mod2");
#endif
return shader.Init(name.getData(), &uniformNames[0]); return shader.Init(name.getData(), &uniformNames[0]);
} }
bool StdMeshMaterialProgram::Compile(StdMeshMaterialLoader& loader) bool StdMeshMaterialProgram::Compile(StdMeshMaterialLoader& loader)
{ {
#ifndef USE_CONSOLE
if (!CompileShader(loader, Shader, 0)) return false; if (!CompileShader(loader, Shader, 0)) return false;
if (!CompileShader(loader, ShaderMod2, C4SSC_MOD2)) return false; if (!CompileShader(loader, ShaderMod2, C4SSC_MOD2)) return false;
if (!CompileShader(loader, ShaderLight, C4SSC_LIGHT)) return false; if (!CompileShader(loader, ShaderLight, C4SSC_LIGHT)) return false;
if (!CompileShader(loader, ShaderLightMod2, C4SSC_LIGHT | C4SSC_MOD2)) return false; if (!CompileShader(loader, ShaderLightMod2, C4SSC_LIGHT | C4SSC_MOD2)) return false;
#endif
return true; return true;
} }
const C4Shader* StdMeshMaterialProgram::GetShader(int ssc) const const C4Shader* StdMeshMaterialProgram::GetShader(int ssc) const
{ {
#ifndef USE_CONSOLE
const C4Shader* shaders[4] = { const C4Shader* shaders[4] = {
&Shader, &Shader,
&ShaderMod2, &ShaderMod2,
@ -896,13 +904,20 @@ const C4Shader* StdMeshMaterialProgram::GetShader(int ssc) const
assert(index < 4); assert(index < 4);
return shaders[index]; return shaders[index];
#else
return NULL;
#endif
} }
int StdMeshMaterialProgram::GetParameterIndex(const char* name) const int StdMeshMaterialProgram::GetParameterIndex(const char* name) const
{ {
#ifndef USE_CONSOLE
std::vector<StdCopyStrBuf>::const_iterator iter = std::find(ParameterNames.begin(), ParameterNames.end(), name); std::vector<StdCopyStrBuf>::const_iterator iter = std::find(ParameterNames.begin(), ParameterNames.end(), name);
if(iter == ParameterNames.end()) return -1; if(iter == ParameterNames.end()) return -1;
return C4SSU_Count + std::distance(ParameterNames.begin(), iter); return C4SSU_Count + std::distance(ParameterNames.begin(), iter);
#else
return -1;
#endif
} }
double StdMeshMaterialTextureUnit::Transformation::GetWaveXForm(double t) const double StdMeshMaterialTextureUnit::Transformation::GetWaveXForm(double t) const
@ -1515,12 +1530,14 @@ void StdMeshMatManager::Parse(const char* mat_script, const char* filename, StdM
Materials[material_name] = mat; Materials[material_name] = mat;
#ifndef USE_CONSOLE
// To Gfxspecific setup of the material; choose working techniques // To Gfxspecific setup of the material; choose working techniques
if (!pDraw->PrepareMaterial(*this, loader, Materials[material_name])) if (!pDraw->PrepareMaterial(*this, loader, Materials[material_name]))
{ {
Materials.erase(material_name); Materials.erase(material_name);
ctx.Error(StdCopyStrBuf("No working technique for material '") + material_name + "'"); ctx.Error(StdCopyStrBuf("No working technique for material '") + material_name + "'");
} }
#endif
} }
else if (token_name == "vertex_program") else if (token_name == "vertex_program")
{ {

View File

@ -59,6 +59,7 @@ public:
virtual void AddShaderSlices(C4Shader& shader, int ssc) virtual void AddShaderSlices(C4Shader& shader, int ssc)
{ {
#ifndef USE_CONSOLE
// Add mesh-independent slices // Add mesh-independent slices
shader.AddFragmentSlice(-1, "#define OPENCLONK"); shader.AddFragmentSlice(-1, "#define OPENCLONK");
shader.AddVertexSlice(-1, "#define OPENCLONK"); shader.AddVertexSlice(-1, "#define OPENCLONK");
@ -80,6 +81,7 @@ public:
if (ssc & C4SSC_BASE) shader.LoadSlices(&::GraphicsResource.Files, "SpriteTextureShader.glsl"); if (ssc & C4SSC_BASE) shader.LoadSlices(&::GraphicsResource.Files, "SpriteTextureShader.glsl");
if (ssc & C4SSC_OVERLAY) shader.LoadSlices(&::GraphicsResource.Files, "SpriteOverlayShader.glsl"); if (ssc & C4SSC_OVERLAY) shader.LoadSlices(&::GraphicsResource.Files, "SpriteOverlayShader.glsl");
#endif
} }
private: private: