just use the built in bool type instead of a typedef around int32_t
I'd rather use this explicitly and then convert to a specific size data type when the size of the variable really matters (which is rare)
This commit is contained in:
parent
ac3f30e3db
commit
4ce9c3c53a
|
@ -19,20 +19,20 @@ ContentCache::ContentCache(ContentManager *contentManager)
|
||||||
|
|
||||||
ContentCache::~ContentCache()
|
ContentCache::~ContentCache()
|
||||||
{
|
{
|
||||||
m_contentManager->Free<Texture>(m_uiSkin, TRUE);
|
m_contentManager->Free<Texture>(m_uiSkin, true);
|
||||||
m_contentManager->Free<Image>(m_uiSkinImage, TRUE);
|
m_contentManager->Free<Image>(m_uiSkinImage, true);
|
||||||
m_contentManager->Free<SpriteFont>(m_standardFont, TRUE);
|
m_contentManager->Free<SpriteFont>(m_standardFont, true);
|
||||||
m_contentManager->Free<SpriteFont>(m_uiFont, TRUE);
|
m_contentManager->Free<SpriteFont>(m_uiFont, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentCache::OnLoadGame()
|
void ContentCache::OnLoadGame()
|
||||||
{
|
{
|
||||||
m_uiSkinFilename = "assets://ui_skin.png";
|
m_uiSkinFilename = "assets://ui_skin.png";
|
||||||
m_uiSkinImage = m_contentManager->Get<Image>(m_uiSkinFilename, TRUE);
|
m_uiSkinImage = m_contentManager->Get<Image>(m_uiSkinFilename, true);
|
||||||
m_uiSkin = m_contentManager->Get<Texture>(m_uiSkinFilename, TRUE);
|
m_uiSkin = m_contentManager->Get<Texture>(m_uiSkinFilename, true);
|
||||||
m_standardFont = m_contentManager->Get<SpriteFont>("assets://fonts/dlxfont.ttf", SpriteFontParam(8), TRUE);
|
m_standardFont = m_contentManager->Get<SpriteFont>("assets://fonts/dlxfont.ttf", SpriteFontParam(8), true);
|
||||||
m_uiFontFilename = "assets://fonts/dlxfont.ttf";
|
m_uiFontFilename = "assets://fonts/dlxfont.ttf";
|
||||||
m_uiFontSize = 8;
|
m_uiFontSize = 8;
|
||||||
m_uiFont = m_contentManager->Get<SpriteFont>(m_uiFontFilename, SpriteFontParam(m_uiFontSize), TRUE);
|
m_uiFont = m_contentManager->Get<SpriteFont>(m_uiFontFilename, SpriteFontParam(m_uiFontSize), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,16 +28,16 @@ public:
|
||||||
virtual void OnResize() {};
|
virtual void OnResize() {};
|
||||||
virtual void OnUpdate(float delta) {};
|
virtual void OnUpdate(float delta) {};
|
||||||
|
|
||||||
BOOL IsActive() const { return m_isActive; }
|
bool IsActive() const { return m_isActive; }
|
||||||
void MarkInactive();
|
void MarkInactive();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BOOL m_isActive;
|
bool m_isActive;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline Effect::Effect()
|
inline Effect::Effect()
|
||||||
{
|
{
|
||||||
m_isActive = TRUE;
|
m_isActive = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Effect::~Effect()
|
inline Effect::~Effect()
|
||||||
|
@ -46,7 +46,7 @@ inline Effect::~Effect()
|
||||||
|
|
||||||
inline void Effect::MarkInactive()
|
inline void Effect::MarkInactive()
|
||||||
{
|
{
|
||||||
m_isActive = FALSE;
|
m_isActive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include "effectinfo.h"
|
#include "effectinfo.h"
|
||||||
#include "effect.h"
|
#include "effect.h"
|
||||||
|
|
||||||
EffectInfo::EffectInfo(Effect *effect, BOOL isLocal)
|
EffectInfo::EffectInfo(Effect *effect, bool isLocal)
|
||||||
{
|
{
|
||||||
ASSERT(effect != NULL);
|
ASSERT(effect != NULL);
|
||||||
m_effect = effect;
|
m_effect = effect;
|
||||||
|
|
|
@ -8,15 +8,15 @@ class Effect;
|
||||||
class EffectInfo
|
class EffectInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
EffectInfo(Effect *effect, BOOL isLocal);
|
EffectInfo(Effect *effect, bool isLocal);
|
||||||
virtual ~EffectInfo();
|
virtual ~EffectInfo();
|
||||||
|
|
||||||
Effect* GetEffect() const { return m_effect; }
|
Effect* GetEffect() const { return m_effect; }
|
||||||
BOOL IsLocal() const { return m_isLocal; }
|
bool IsLocal() const { return m_isLocal; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Effect *m_effect;
|
Effect *m_effect;
|
||||||
BOOL m_isLocal;
|
bool m_isLocal;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -21,7 +21,7 @@ public:
|
||||||
virtual ~EffectManager();
|
virtual ~EffectManager();
|
||||||
|
|
||||||
template<class T> T* Get() const;
|
template<class T> T* Get() const;
|
||||||
template<class T> T* Add(BOOL isLocalEffect = TRUE);
|
template<class T> T* Add(bool isLocalEffect = true);
|
||||||
template<class T> void Remove();
|
template<class T> void Remove();
|
||||||
void RemoveAll();
|
void RemoveAll();
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ T* EffectManager::Get() const
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
T* EffectManager::Add(BOOL isLocalEffect)
|
T* EffectManager::Add(bool isLocalEffect)
|
||||||
{
|
{
|
||||||
if (Get<T>() != NULL)
|
if (Get<T>() != NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -11,9 +11,9 @@ const Color DEFAULT_FADE_COLOR = COLOR_BLACK;
|
||||||
|
|
||||||
FadeEffect::FadeEffect()
|
FadeEffect::FadeEffect()
|
||||||
{
|
{
|
||||||
m_doneFading = FALSE;
|
m_doneFading = false;
|
||||||
m_fadeSpeed = DEFAULT_FADE_SPEED;
|
m_fadeSpeed = DEFAULT_FADE_SPEED;
|
||||||
m_fadingOut = TRUE;
|
m_fadingOut = true;
|
||||||
m_alpha = 0.0f;
|
m_alpha = 0.0f;
|
||||||
m_color = DEFAULT_FADE_COLOR;
|
m_color = DEFAULT_FADE_COLOR;
|
||||||
m_fadeToAlpha = 0.0f;
|
m_fadeToAlpha = 0.0f;
|
||||||
|
@ -48,7 +48,7 @@ void FadeEffect::OnUpdate(float delta)
|
||||||
if (m_alpha >= m_fadeToAlpha)
|
if (m_alpha >= m_fadeToAlpha)
|
||||||
{
|
{
|
||||||
m_alpha = m_fadeToAlpha;
|
m_alpha = m_fadeToAlpha;
|
||||||
m_doneFading = TRUE;
|
m_doneFading = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -57,7 +57,7 @@ void FadeEffect::OnUpdate(float delta)
|
||||||
if (m_alpha < m_fadeToAlpha)
|
if (m_alpha < m_fadeToAlpha)
|
||||||
{
|
{
|
||||||
m_alpha = m_fadeToAlpha;
|
m_alpha = m_fadeToAlpha;
|
||||||
m_doneFading = TRUE;
|
m_doneFading = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,12 +24,12 @@ public:
|
||||||
FadeEffect* SetFadeOut(float toAlpha = COLOR_ALPHA_OPAQUE);
|
FadeEffect* SetFadeOut(float toAlpha = COLOR_ALPHA_OPAQUE);
|
||||||
FadeEffect* SetFadeIn(float toAlpha = COLOR_ALPHA_TRANSPARENT);
|
FadeEffect* SetFadeIn(float toAlpha = COLOR_ALPHA_TRANSPARENT);
|
||||||
|
|
||||||
BOOL IsDoneFading() const { return m_doneFading; }
|
bool IsDoneFading() const { return m_doneFading; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BOOL m_doneFading;
|
bool m_doneFading;
|
||||||
float m_fadeSpeed;
|
float m_fadeSpeed;
|
||||||
BOOL m_fadingOut;
|
bool m_fadingOut;
|
||||||
float m_alpha;
|
float m_alpha;
|
||||||
Color m_color;
|
Color m_color;
|
||||||
float m_fadeToAlpha;
|
float m_fadeToAlpha;
|
||||||
|
@ -49,7 +49,7 @@ inline FadeEffect* FadeEffect::SetFadeSpeed(float speed)
|
||||||
|
|
||||||
inline FadeEffect* FadeEffect::SetFadeOut(float toAlpha)
|
inline FadeEffect* FadeEffect::SetFadeOut(float toAlpha)
|
||||||
{
|
{
|
||||||
m_fadingOut = TRUE;
|
m_fadingOut = true;
|
||||||
m_alpha = COLOR_ALPHA_TRANSPARENT;
|
m_alpha = COLOR_ALPHA_TRANSPARENT;
|
||||||
m_fadeToAlpha = toAlpha;
|
m_fadeToAlpha = toAlpha;
|
||||||
return this;
|
return this;
|
||||||
|
@ -57,7 +57,7 @@ inline FadeEffect* FadeEffect::SetFadeOut(float toAlpha)
|
||||||
|
|
||||||
inline FadeEffect* FadeEffect::SetFadeIn(float toAlpha)
|
inline FadeEffect* FadeEffect::SetFadeIn(float toAlpha)
|
||||||
{
|
{
|
||||||
m_fadingOut = FALSE;
|
m_fadingOut = false;
|
||||||
m_alpha = COLOR_ALPHA_OPAQUE;
|
m_alpha = COLOR_ALPHA_OPAQUE;
|
||||||
m_fadeToAlpha = toAlpha;
|
m_fadeToAlpha = toAlpha;
|
||||||
return this;
|
return this;
|
||||||
|
|
|
@ -11,7 +11,7 @@ const float DEFAULT_MAX_INTENSITY = 1.0f;
|
||||||
|
|
||||||
FlashEffect::FlashEffect()
|
FlashEffect::FlashEffect()
|
||||||
{
|
{
|
||||||
m_flashingIn = TRUE;
|
m_flashingIn = true;
|
||||||
m_flashInSpeed = DEFAULT_FLASH_SPEED;
|
m_flashInSpeed = DEFAULT_FLASH_SPEED;
|
||||||
m_flashOutSpeed = DEFAULT_FLASH_SPEED;
|
m_flashOutSpeed = DEFAULT_FLASH_SPEED;
|
||||||
m_maximumIntensity = DEFAULT_MAX_INTENSITY;
|
m_maximumIntensity = DEFAULT_MAX_INTENSITY;
|
||||||
|
@ -45,7 +45,7 @@ void FlashEffect::OnUpdate(float delta)
|
||||||
if (m_alpha >= m_maximumIntensity)
|
if (m_alpha >= m_maximumIntensity)
|
||||||
{
|
{
|
||||||
m_alpha = m_maximumIntensity;
|
m_alpha = m_maximumIntensity;
|
||||||
m_flashingIn = FALSE;
|
m_flashingIn = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -55,7 +55,7 @@ void FlashEffect::OnUpdate(float delta)
|
||||||
m_alpha = 0.0f;
|
m_alpha = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_alpha == 0.0f && m_flashingIn == FALSE)
|
if (m_alpha == 0.0f && m_flashingIn == false)
|
||||||
MarkInactive();
|
MarkInactive();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ public:
|
||||||
FlashEffect* SetMaximumIntensity(float maxIntensity);
|
FlashEffect* SetMaximumIntensity(float maxIntensity);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BOOL m_flashingIn;
|
bool m_flashingIn;
|
||||||
float m_flashInSpeed;
|
float m_flashInSpeed;
|
||||||
float m_flashOutSpeed;
|
float m_flashOutSpeed;
|
||||||
float m_maximumIntensity;
|
float m_maximumIntensity;
|
||||||
|
|
|
@ -25,7 +25,7 @@ public:
|
||||||
virtual void OnResize() {}
|
virtual void OnResize() {}
|
||||||
virtual void OnUpdate(float delta) {}
|
virtual void OnUpdate(float delta) {}
|
||||||
|
|
||||||
virtual BOOL Handle(const Event *event);
|
virtual bool Handle(const Event *event);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ComponentSystem(EntityManager *entityManager, EventManager *eventManager);
|
ComponentSystem(EntityManager *entityManager, EventManager *eventManager);
|
||||||
|
@ -46,9 +46,9 @@ inline ComponentSystem::~ComponentSystem()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
inline BOOL ComponentSystem::Handle(const Event *event)
|
inline bool ComponentSystem::Handle(const Event *event)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -15,10 +15,10 @@ public:
|
||||||
template<class T> T* Get() const;
|
template<class T> T* Get() const;
|
||||||
template<class T> T* Add();
|
template<class T> T* Add();
|
||||||
template<class T> void Remove();
|
template<class T> void Remove();
|
||||||
template<class T> BOOL Has() const;
|
template<class T> bool Has() const;
|
||||||
|
|
||||||
template<class T> BOOL WasCreatedUsingPreset() const;
|
template<class T> bool WasCreatedUsingPreset() const;
|
||||||
BOOL WasCreatedUsingPreset(ENTITYPRESET_TYPE type) const;
|
bool WasCreatedUsingPreset(ENTITYPRESET_TYPE type) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
EntityManager *m_entityManager;
|
EntityManager *m_entityManager;
|
||||||
|
@ -43,18 +43,18 @@ inline void Entity::Remove()
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline BOOL Entity::Has() const
|
inline bool Entity::Has() const
|
||||||
{
|
{
|
||||||
return m_entityManager->HasComponent<T>(this);
|
return m_entityManager->HasComponent<T>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline BOOL Entity::WasCreatedUsingPreset() const
|
inline bool Entity::WasCreatedUsingPreset() const
|
||||||
{
|
{
|
||||||
return m_entityManager->WasCreatedUsingPreset<T>(this);
|
return m_entityManager->WasCreatedUsingPreset<T>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline BOOL Entity::WasCreatedUsingPreset(ENTITYPRESET_TYPE type) const
|
inline bool Entity::WasCreatedUsingPreset(ENTITYPRESET_TYPE type) const
|
||||||
{
|
{
|
||||||
return m_entityManager->WasCreatedUsingPreset(this, type);
|
return m_entityManager->WasCreatedUsingPreset(this, type);
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,15 +65,15 @@ Entity* EntityManager::AddUsingPreset(ENTITYPRESET_TYPE preset, EntityPresetArgs
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL EntityManager::WasCreatedUsingPreset(const Entity *entity, ENTITYPRESET_TYPE type) const
|
bool EntityManager::WasCreatedUsingPreset(const Entity *entity, ENTITYPRESET_TYPE type) const
|
||||||
{
|
{
|
||||||
ASSERT(entity != NULL);
|
ASSERT(entity != NULL);
|
||||||
ASSERT(type != NULL);
|
ASSERT(type != NULL);
|
||||||
EntityPresetComponent *preset = entity->Get<EntityPresetComponent>();
|
EntityPresetComponent *preset = entity->Get<EntityPresetComponent>();
|
||||||
if (preset != NULL && preset->preset == type)
|
if (preset != NULL && preset->preset == type)
|
||||||
return TRUE;
|
return true;
|
||||||
else
|
else
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityManager::Remove(Entity *entity)
|
void EntityManager::Remove(Entity *entity)
|
||||||
|
@ -118,17 +118,17 @@ void EntityManager::RemoveAllComponentsFrom(Entity *entity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL EntityManager::IsValid(const Entity *entity) const
|
bool EntityManager::IsValid(const Entity *entity) const
|
||||||
{
|
{
|
||||||
if (entity == NULL)
|
if (entity == NULL)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
// HACK: lol, this cast is aboslutely terrible and I shouldn't be doing this
|
// HACK: lol, this cast is aboslutely terrible and I shouldn't be doing this
|
||||||
EntitySet::const_iterator i = m_entities.find((Entity*)entity);
|
EntitySet::const_iterator i = m_entities.find((Entity*)entity);
|
||||||
if (i == m_entities.end())
|
if (i == m_entities.end())
|
||||||
return FALSE;
|
return false;
|
||||||
else
|
else
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityManager::GetAllComponentsFor(const Entity *entity, ComponentList &list) const
|
void EntityManager::GetAllComponentsFor(const Entity *entity, ComponentList &list) const
|
||||||
|
|
|
@ -47,23 +47,23 @@ public:
|
||||||
Entity* AddUsingPreset(ENTITYPRESET_TYPE type, EntityPresetArgs *args = NULL);
|
Entity* AddUsingPreset(ENTITYPRESET_TYPE type, EntityPresetArgs *args = NULL);
|
||||||
template<class T> Entity* GetWith() const;
|
template<class T> Entity* GetWith() const;
|
||||||
template<class T> void GetAllWith(EntityList &matches) const;
|
template<class T> void GetAllWith(EntityList &matches) const;
|
||||||
template<class T> BOOL WasCreatedUsingPreset(Entity *entity) const;
|
template<class T> bool WasCreatedUsingPreset(Entity *entity) const;
|
||||||
BOOL WasCreatedUsingPreset(const Entity *entity, ENTITYPRESET_TYPE type) const;
|
bool WasCreatedUsingPreset(const Entity *entity, ENTITYPRESET_TYPE type) const;
|
||||||
void Remove(Entity *entity);
|
void Remove(Entity *entity);
|
||||||
void RemoveAll();
|
void RemoveAll();
|
||||||
BOOL IsValid(const Entity *entity) const;
|
bool IsValid(const Entity *entity) const;
|
||||||
uint GetNumEntities() const { return m_entities.size(); }
|
uint GetNumEntities() const { return m_entities.size(); }
|
||||||
|
|
||||||
template<class T> T* AddComponent(Entity *entity);
|
template<class T> T* AddComponent(Entity *entity);
|
||||||
template<class T> T* GetComponent(const Entity *entity) const;
|
template<class T> T* GetComponent(const Entity *entity) const;
|
||||||
template<class T> void RemoveComponent(Entity *entity);
|
template<class T> void RemoveComponent(Entity *entity);
|
||||||
template<class T> BOOL HasComponent(const Entity *entity) const;
|
template<class T> bool HasComponent(const Entity *entity) const;
|
||||||
void GetAllComponentsFor(const Entity *entity, ComponentList &list) const;
|
void GetAllComponentsFor(const Entity *entity, ComponentList &list) const;
|
||||||
|
|
||||||
template<class T> T* AddGlobalComponent();
|
template<class T> T* AddGlobalComponent();
|
||||||
template<class T> T* GetGlobalComponent() const;
|
template<class T> T* GetGlobalComponent() const;
|
||||||
template<class T> void RemoveGlobalComponent();
|
template<class T> void RemoveGlobalComponent();
|
||||||
template<class T> BOOL HasGlobalComponent() const;
|
template<class T> bool HasGlobalComponent() const;
|
||||||
void RemoveAllGlobalComponents();
|
void RemoveAllGlobalComponents();
|
||||||
|
|
||||||
void OnLostContext();
|
void OnLostContext();
|
||||||
|
@ -201,18 +201,18 @@ void EntityManager::RemoveComponent(Entity *entity)
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
BOOL EntityManager::HasComponent(const Entity *entity) const
|
bool EntityManager::HasComponent(const Entity *entity) const
|
||||||
{
|
{
|
||||||
ComponentStore::const_iterator i = m_components.find(T::GetType());
|
ComponentStore::const_iterator i = m_components.find(T::GetType());
|
||||||
if (i == m_components.end())
|
if (i == m_components.end())
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
const EntityComponentsMap &entitiesWithComponent = i->second;
|
const EntityComponentsMap &entitiesWithComponent = i->second;
|
||||||
EntityComponentsMap::const_iterator j = entitiesWithComponent.find(entity);
|
EntityComponentsMap::const_iterator j = entitiesWithComponent.find(entity);
|
||||||
if (j == entitiesWithComponent.end())
|
if (j == entitiesWithComponent.end())
|
||||||
return FALSE;
|
return false;
|
||||||
else
|
else
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
@ -246,13 +246,13 @@ void EntityManager::RemoveGlobalComponent()
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
BOOL EntityManager::HasGlobalComponent() const
|
bool EntityManager::HasGlobalComponent() const
|
||||||
{
|
{
|
||||||
GlobalComponentStore::const_iterator i = m_globalComponents.find(T::GetType());
|
GlobalComponentStore::const_iterator i = m_globalComponents.find(T::GetType());
|
||||||
if (i == m_globalComponents.end())
|
if (i == m_globalComponents.end())
|
||||||
return FALSE;
|
return false;
|
||||||
else
|
else
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
@ -282,7 +282,7 @@ void EntityManager::GetAllWith(EntityList &matches) const
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
BOOL EntityManager::WasCreatedUsingPreset(Entity *entity) const
|
bool EntityManager::WasCreatedUsingPreset(Entity *entity) const
|
||||||
{
|
{
|
||||||
return WasCreatedUsingPreset(entity, T::GetType());
|
return WasCreatedUsingPreset(entity, T::GetType());
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ struct Event;
|
||||||
class EventListener
|
class EventListener
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual BOOL Handle(const Event *event) = 0;
|
virtual bool Handle(const Event *event) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -13,12 +13,12 @@ public:
|
||||||
EventListenerEx(EventManager *eventManager);
|
EventListenerEx(EventManager *eventManager);
|
||||||
virtual ~EventListenerEx();
|
virtual ~EventListenerEx();
|
||||||
|
|
||||||
template<class T> BOOL ListenFor();
|
template<class T> bool ListenFor();
|
||||||
template<class T> BOOL StopListeningFor();
|
template<class T> bool StopListeningFor();
|
||||||
BOOL ListenFor(EVENT_TYPE type);
|
bool ListenFor(EVENT_TYPE type);
|
||||||
BOOL StopListeningFor(EVENT_TYPE type);
|
bool StopListeningFor(EVENT_TYPE type);
|
||||||
|
|
||||||
virtual BOOL Handle(const Event *event) = 0;
|
virtual bool Handle(const Event *event) = 0;
|
||||||
|
|
||||||
EventManager* GetEventManager() const { return m_eventManager; }
|
EventManager* GetEventManager() const { return m_eventManager; }
|
||||||
|
|
||||||
|
@ -36,23 +36,23 @@ inline EventListenerEx::~EventListenerEx()
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline BOOL EventListenerEx::ListenFor()
|
inline bool EventListenerEx::ListenFor()
|
||||||
{
|
{
|
||||||
return m_eventManager->AddListener<T>(this);
|
return m_eventManager->AddListener<T>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline BOOL EventListenerEx::StopListeningFor()
|
inline bool EventListenerEx::StopListeningFor()
|
||||||
{
|
{
|
||||||
return m_eventManager->RemoveListener<T>(this);
|
return m_eventManager->RemoveListener<T>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline BOOL EventListenerEx::ListenFor(EVENT_TYPE type)
|
inline bool EventListenerEx::ListenFor(EVENT_TYPE type)
|
||||||
{
|
{
|
||||||
return m_eventManager->AddListener(this, type);
|
return m_eventManager->AddListener(this, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline BOOL EventListenerEx::StopListeningFor(EVENT_TYPE type)
|
inline bool EventListenerEx::StopListeningFor(EVENT_TYPE type)
|
||||||
{
|
{
|
||||||
return m_eventManager->RemoveListener(this, type);
|
return m_eventManager->RemoveListener(this, type);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,8 @@ EventLogger::~EventLogger()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL EventLogger::Handle(const Event *event)
|
bool EventLogger::Handle(const Event *event)
|
||||||
{
|
{
|
||||||
LOG_INFO("EVENTLOGGER", "Event \"%s\" occurred.\n", event->GetTypeOf());
|
LOG_INFO("EVENTLOGGER", "Event \"%s\" occurred.\n", event->GetTypeOf());
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ public:
|
||||||
EventLogger(EventManager *eventManager);
|
EventLogger(EventManager *eventManager);
|
||||||
virtual ~EventLogger();
|
virtual ~EventLogger();
|
||||||
|
|
||||||
BOOL Handle(const Event *event);
|
bool Handle(const Event *event);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -13,7 +13,7 @@ EventManager::~EventManager()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL EventManager::AddListener(EventListener *listener, EVENT_TYPE type)
|
bool EventManager::AddListener(EventListener *listener, EVENT_TYPE type)
|
||||||
{
|
{
|
||||||
// TODO: validate type
|
// TODO: validate type
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ BOOL EventManager::AddListener(EventListener *listener, EVENT_TYPE type)
|
||||||
{
|
{
|
||||||
// need to register this listener for the given type
|
// need to register this listener for the given type
|
||||||
EventListenerMapIRes result = m_registry.insert(EventListenerMapEnt(type, EventListenerTable()));
|
EventListenerMapIRes result = m_registry.insert(EventListenerMapEnt(type, EventListenerTable()));
|
||||||
ASSERT(result.second != FALSE);
|
ASSERT(result.second != false);
|
||||||
ASSERT(result.first != m_registry.end());
|
ASSERT(result.first != m_registry.end());
|
||||||
|
|
||||||
listenerItor = result.first;
|
listenerItor = result.first;
|
||||||
|
@ -40,19 +40,19 @@ BOOL EventManager::AddListener(EventListener *listener, EVENT_TYPE type)
|
||||||
// also update the list of currently registered event types
|
// also update the list of currently registered event types
|
||||||
m_typeList.insert(type);
|
m_typeList.insert(type);
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL EventManager::RemoveListener(EventListener *listener, EVENT_TYPE type)
|
bool EventManager::RemoveListener(EventListener *listener, EVENT_TYPE type)
|
||||||
{
|
{
|
||||||
BOOL result = FALSE;
|
bool result = false;
|
||||||
|
|
||||||
// TODO: validate type
|
// TODO: validate type
|
||||||
|
|
||||||
// get the list of listeners for the given event type
|
// get the list of listeners for the given event type
|
||||||
EventListenerMap::iterator itor = m_registry.find(type);
|
EventListenerMap::iterator itor = m_registry.find(type);
|
||||||
if (itor == m_registry.end())
|
if (itor == m_registry.end())
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
// check this list for the specified listener
|
// check this list for the specified listener
|
||||||
EventListenerTable &table = itor->second;
|
EventListenerTable &table = itor->second;
|
||||||
|
@ -62,7 +62,7 @@ BOOL EventManager::RemoveListener(EventListener *listener, EVENT_TYPE type)
|
||||||
{
|
{
|
||||||
// found the listener
|
// found the listener
|
||||||
table.erase(j);
|
table.erase(j);
|
||||||
result = TRUE;
|
result = true;
|
||||||
|
|
||||||
// if there are no more listeners for this type, remove the type from the list of registered event types
|
// if there are no more listeners for this type, remove the type from the list of registered event types
|
||||||
if (table.size() == 0)
|
if (table.size() == 0)
|
||||||
|
@ -76,7 +76,7 @@ BOOL EventManager::RemoveListener(EventListener *listener, EVENT_TYPE type)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL EventManager::Trigger(const Event *event) const
|
bool EventManager::Trigger(const Event *event) const
|
||||||
{
|
{
|
||||||
// TODO: validate type
|
// TODO: validate type
|
||||||
|
|
||||||
|
@ -95,9 +95,9 @@ BOOL EventManager::Trigger(const Event *event) const
|
||||||
// find the listener list for the event type
|
// find the listener list for the event type
|
||||||
EventListenerMap::const_iterator itor = m_registry.find(event->GetTypeOf());
|
EventListenerMap::const_iterator itor = m_registry.find(event->GetTypeOf());
|
||||||
if (itor == m_registry.end())
|
if (itor == m_registry.end())
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
BOOL result = FALSE;
|
bool result = false;
|
||||||
|
|
||||||
// trigger the event in each listener
|
// trigger the event in each listener
|
||||||
const EventListenerTable &table = itor->second;
|
const EventListenerTable &table = itor->second;
|
||||||
|
@ -106,15 +106,15 @@ BOOL EventManager::Trigger(const Event *event) const
|
||||||
EventListener *listener = *i;
|
EventListener *listener = *i;
|
||||||
if (listener->Handle(event))
|
if (listener->Handle(event))
|
||||||
{
|
{
|
||||||
// only return TRUE if a listener signals they handled the event
|
// only return true if a listener signals they handled the event
|
||||||
result = TRUE;
|
result = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL EventManager::Queue(const Event *event)
|
bool EventManager::Queue(const Event *event)
|
||||||
{
|
{
|
||||||
ASSERT(m_activeQueue >= 0);
|
ASSERT(m_activeQueue >= 0);
|
||||||
ASSERT(m_activeQueue < NUM_EVENT_QUEUES);
|
ASSERT(m_activeQueue < NUM_EVENT_QUEUES);
|
||||||
|
@ -129,15 +129,15 @@ BOOL EventManager::Queue(const Event *event)
|
||||||
if (wildcardItor == m_registry.end())
|
if (wildcardItor == m_registry.end())
|
||||||
{
|
{
|
||||||
// no wildcard listener either... useless event!
|
// no wildcard listener either... useless event!
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_queues[m_activeQueue].push_back(event);
|
m_queues[m_activeQueue].push_back(event);
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL EventManager::Abort(EVENT_TYPE type, BOOL allOfType)
|
bool EventManager::Abort(EVENT_TYPE type, bool allOfType)
|
||||||
{
|
{
|
||||||
ASSERT(m_activeQueue >= 0);
|
ASSERT(m_activeQueue >= 0);
|
||||||
ASSERT(m_activeQueue < NUM_EVENT_QUEUES);
|
ASSERT(m_activeQueue < NUM_EVENT_QUEUES);
|
||||||
|
@ -146,9 +146,9 @@ BOOL EventManager::Abort(EVENT_TYPE type, BOOL allOfType)
|
||||||
|
|
||||||
EventListenerMap::iterator itor = m_registry.find(type);
|
EventListenerMap::iterator itor = m_registry.find(type);
|
||||||
if (itor == m_registry.end())
|
if (itor == m_registry.end())
|
||||||
return FALSE; // no listeners for this type
|
return false; // no listeners for this type
|
||||||
|
|
||||||
BOOL result = FALSE;
|
bool result = false;
|
||||||
|
|
||||||
EventQueue &queue = m_queues[m_activeQueue];
|
EventQueue &queue = m_queues[m_activeQueue];
|
||||||
for (EventQueue::iterator i = queue.begin(); i != queue.end(); ++i)
|
for (EventQueue::iterator i = queue.begin(); i != queue.end(); ++i)
|
||||||
|
@ -158,7 +158,7 @@ BOOL EventManager::Abort(EVENT_TYPE type, BOOL allOfType)
|
||||||
{
|
{
|
||||||
// found a match, remove it from the queue
|
// found a match, remove it from the queue
|
||||||
i = queue.erase(i);
|
i = queue.erase(i);
|
||||||
result = TRUE;
|
result = true;
|
||||||
|
|
||||||
if (!allOfType)
|
if (!allOfType)
|
||||||
break;
|
break;
|
||||||
|
@ -170,7 +170,7 @@ BOOL EventManager::Abort(EVENT_TYPE type, BOOL allOfType)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL EventManager::ProcessQueue()
|
bool EventManager::ProcessQueue()
|
||||||
{
|
{
|
||||||
EventListenerMap::const_iterator wildcardItor = m_registry.find(EVENT_TYPE_WILDCARD);
|
EventListenerMap::const_iterator wildcardItor = m_registry.find(EVENT_TYPE_WILDCARD);
|
||||||
|
|
||||||
|
@ -227,10 +227,10 @@ BOOL EventManager::ProcessQueue()
|
||||||
m_queues[m_activeQueue].push_front(event);
|
m_queues[m_activeQueue].push_front(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
EventListenerList EventManager::GetListenerList(EVENT_TYPE type) const
|
EventListenerList EventManager::GetListenerList(EVENT_TYPE type) const
|
||||||
|
|
|
@ -23,17 +23,17 @@ public:
|
||||||
EventManager();
|
EventManager();
|
||||||
virtual ~EventManager();
|
virtual ~EventManager();
|
||||||
|
|
||||||
template<class T> BOOL AddListener(EventListener *listener);
|
template<class T> bool AddListener(EventListener *listener);
|
||||||
template<class T> BOOL RemoveListener(EventListener *listener);
|
template<class T> bool RemoveListener(EventListener *listener);
|
||||||
BOOL AddListener(EventListener *listener, EVENT_TYPE type);
|
bool AddListener(EventListener *listener, EVENT_TYPE type);
|
||||||
BOOL RemoveListener(EventListener *listener, EVENT_TYPE type);
|
bool RemoveListener(EventListener *listener, EVENT_TYPE type);
|
||||||
|
|
||||||
BOOL Trigger(const Event *event) const;
|
bool Trigger(const Event *event) const;
|
||||||
BOOL Queue(const Event *event);
|
bool Queue(const Event *event);
|
||||||
template<class T> BOOL Abort(BOOL allOfType = FALSE);
|
template<class T> bool Abort(bool allOfType = false);
|
||||||
BOOL Abort(EVENT_TYPE type, BOOL allOfType = FALSE);
|
bool Abort(EVENT_TYPE type, bool allOfType = false);
|
||||||
|
|
||||||
BOOL ProcessQueue();
|
bool ProcessQueue();
|
||||||
|
|
||||||
template<class T> EventListenerList GetListenerList() const;
|
template<class T> EventListenerList GetListenerList() const;
|
||||||
EventListenerList GetListenerList(EVENT_TYPE type) const;
|
EventListenerList GetListenerList(EVENT_TYPE type) const;
|
||||||
|
@ -41,11 +41,11 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef stl::set<EVENT_TYPE> EventTypeSet;
|
typedef stl::set<EVENT_TYPE> EventTypeSet;
|
||||||
typedef stl::pair<EventTypeSet::iterator, BOOL> EventTypeSetIRes;
|
typedef stl::pair<EventTypeSet::iterator, bool> EventTypeSetIRes;
|
||||||
typedef stl::list<EventListener*> EventListenerTable;
|
typedef stl::list<EventListener*> EventListenerTable;
|
||||||
typedef stl::map<EVENT_TYPE, EventListenerTable> EventListenerMap;
|
typedef stl::map<EVENT_TYPE, EventListenerTable> EventListenerMap;
|
||||||
typedef stl::pair<EVENT_TYPE, EventListenerTable> EventListenerMapEnt;
|
typedef stl::pair<EVENT_TYPE, EventListenerTable> EventListenerMapEnt;
|
||||||
typedef stl::pair<EventListenerMap::iterator, BOOL> EventListenerMapIRes;
|
typedef stl::pair<EventListenerMap::iterator, bool> EventListenerMapIRes;
|
||||||
typedef stl::list<const Event*> EventQueue;
|
typedef stl::list<const Event*> EventQueue;
|
||||||
|
|
||||||
EventTypeSet m_typeList;
|
EventTypeSet m_typeList;
|
||||||
|
@ -55,19 +55,19 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
BOOL EventManager::AddListener(EventListener *listener)
|
bool EventManager::AddListener(EventListener *listener)
|
||||||
{
|
{
|
||||||
return AddListener(listener, T::GetType());
|
return AddListener(listener, T::GetType());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
BOOL EventManager::RemoveListener(EventListener *listener)
|
bool EventManager::RemoveListener(EventListener *listener)
|
||||||
{
|
{
|
||||||
return RemoveListener(listener, T::GetType());
|
return RemoveListener(listener, T::GetType());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
BOOL EventManager::Abort(BOOL allOfType)
|
bool EventManager::Abort(bool allOfType)
|
||||||
{
|
{
|
||||||
return Abort(T::GetType(), allOfType);
|
return Abort(T::GetType(), allOfType);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,12 +18,12 @@ KeyframeMeshInstance::KeyframeMeshInstance(KeyframeMesh *mesh)
|
||||||
|
|
||||||
m_currentSequenceStart = 0;
|
m_currentSequenceStart = 0;
|
||||||
m_currentSequenceEnd = 0;
|
m_currentSequenceEnd = 0;
|
||||||
m_currentSequenceLoop = FALSE;
|
m_currentSequenceLoop = false;
|
||||||
m_thisFrame = 0;
|
m_thisFrame = 0;
|
||||||
m_nextFrame = 0;
|
m_nextFrame = 0;
|
||||||
m_interpolation = 0.0f;
|
m_interpolation = 0.0f;
|
||||||
m_isRunningTempSequence = FALSE;
|
m_isRunningTempSequence = false;
|
||||||
m_oldSequenceLoop = FALSE;
|
m_oldSequenceLoop = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyframeMeshInstance::~KeyframeMeshInstance()
|
KeyframeMeshInstance::~KeyframeMeshInstance()
|
||||||
|
@ -71,7 +71,7 @@ void KeyframeMeshInstance::OnUpdate(float delta)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyframeMeshInstance::SetSequence(uint startFrame, uint endFrame, BOOL loop)
|
void KeyframeMeshInstance::SetSequence(uint startFrame, uint endFrame, bool loop)
|
||||||
{
|
{
|
||||||
m_currentSequenceName.clear();
|
m_currentSequenceName.clear();
|
||||||
m_currentSequenceStart = startFrame;
|
m_currentSequenceStart = startFrame;
|
||||||
|
@ -86,7 +86,7 @@ void KeyframeMeshInstance::SetSequence(uint startFrame, uint endFrame, BOOL loop
|
||||||
m_interpolation = 0.0f;
|
m_interpolation = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyframeMeshInstance::SetSequence(const stl::string &name, BOOL loop)
|
void KeyframeMeshInstance::SetSequence(const stl::string &name, bool loop)
|
||||||
{
|
{
|
||||||
if (m_currentSequenceName == name)
|
if (m_currentSequenceName == name)
|
||||||
return;
|
return;
|
||||||
|
@ -105,14 +105,14 @@ void KeyframeMeshInstance::RunSequenceOnce(const stl::string &name)
|
||||||
m_oldSequenceName = m_currentSequenceName;
|
m_oldSequenceName = m_currentSequenceName;
|
||||||
m_oldSequenceLoop = m_currentSequenceLoop;
|
m_oldSequenceLoop = m_currentSequenceLoop;
|
||||||
|
|
||||||
m_isRunningTempSequence = TRUE;
|
m_isRunningTempSequence = true;
|
||||||
|
|
||||||
SetSequence(name, FALSE);
|
SetSequence(name, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyframeMeshInstance::RecoverFromTempSequence()
|
void KeyframeMeshInstance::RecoverFromTempSequence()
|
||||||
{
|
{
|
||||||
m_isRunningTempSequence = FALSE;
|
m_isRunningTempSequence = false;
|
||||||
SetSequence(m_oldSequenceName, m_oldSequenceLoop);
|
SetSequence(m_oldSequenceName, m_oldSequenceLoop);
|
||||||
m_oldSequenceName.clear();
|
m_oldSequenceName.clear();
|
||||||
m_oldSequenceLoop = false;
|
m_oldSequenceLoop = false;
|
||||||
|
|
|
@ -33,18 +33,18 @@ public:
|
||||||
* Sets the current animation sequence.
|
* Sets the current animation sequence.
|
||||||
* @param startFrame the first frame of the sequence
|
* @param startFrame the first frame of the sequence
|
||||||
* @param endFrame the last frame of the sequence
|
* @param endFrame the last frame of the sequence
|
||||||
* @param loop TRUE to loop the sequence, FALSE to stop when done
|
* @param loop true to loop the sequence, false to stop when done
|
||||||
* and leave the current frame as the end frame
|
* and leave the current frame as the end frame
|
||||||
*/
|
*/
|
||||||
void SetSequence(uint startFrame, uint endFrame, BOOL loop);
|
void SetSequence(uint startFrame, uint endFrame, bool loop);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the current animation sequence.
|
* Sets the current animation sequence.
|
||||||
* @param name the name of the sequence from the mesh's list of sequences
|
* @param name the name of the sequence from the mesh's list of sequences
|
||||||
* @param loop TRUE to loop the sequence, FALSE to stop when done
|
* @param loop true to loop the sequence, false to stop when done
|
||||||
* and leave the current frame as the end frame
|
* and leave the current frame as the end frame
|
||||||
*/
|
*/
|
||||||
void SetSequence(const stl::string &name, BOOL loop);
|
void SetSequence(const stl::string &name, bool loop);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Temporarily override the current animation sequence to run the specified
|
* Temporarily override the current animation sequence to run the specified
|
||||||
|
@ -99,13 +99,13 @@ private:
|
||||||
stl::string m_currentSequenceName;
|
stl::string m_currentSequenceName;
|
||||||
uint m_currentSequenceStart;
|
uint m_currentSequenceStart;
|
||||||
uint m_currentSequenceEnd;
|
uint m_currentSequenceEnd;
|
||||||
BOOL m_currentSequenceLoop;
|
bool m_currentSequenceLoop;
|
||||||
uint m_thisFrame;
|
uint m_thisFrame;
|
||||||
uint m_nextFrame;
|
uint m_nextFrame;
|
||||||
float m_interpolation;
|
float m_interpolation;
|
||||||
BOOL m_isRunningTempSequence;
|
bool m_isRunningTempSequence;
|
||||||
stl::string m_oldSequenceName;
|
stl::string m_oldSequenceName;
|
||||||
BOOL m_oldSequenceLoop;
|
bool m_oldSequenceLoop;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -23,34 +23,34 @@ KeyframeMeshRenderer::~KeyframeMeshRenderer()
|
||||||
|
|
||||||
void KeyframeMeshRenderer::Render(GraphicsDevice *graphicsDevice, KeyframeMeshInstance *instance, VertexLerpShader *shader)
|
void KeyframeMeshRenderer::Render(GraphicsDevice *graphicsDevice, KeyframeMeshInstance *instance, VertexLerpShader *shader)
|
||||||
{
|
{
|
||||||
ASSERT(shader->IsBound() == TRUE);
|
ASSERT(shader->IsBound() == true);
|
||||||
instance->GetRenderState()->Apply();
|
instance->GetRenderState()->Apply();
|
||||||
Render(graphicsDevice, instance->GetMesh(), instance->GetTexture(), instance->GetCurrentFrame(), instance->GetNextFrame(), instance->GetInterpolation(), shader);
|
Render(graphicsDevice, instance->GetMesh(), instance->GetTexture(), instance->GetCurrentFrame(), instance->GetNextFrame(), instance->GetInterpolation(), shader);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyframeMeshRenderer::Render(GraphicsDevice *graphicsDevice, KeyframeMeshInstance *instance, uint frame, VertexLerpShader *shader)
|
void KeyframeMeshRenderer::Render(GraphicsDevice *graphicsDevice, KeyframeMeshInstance *instance, uint frame, VertexLerpShader *shader)
|
||||||
{
|
{
|
||||||
ASSERT(shader->IsBound() == TRUE);
|
ASSERT(shader->IsBound() == true);
|
||||||
instance->GetRenderState()->Apply();
|
instance->GetRenderState()->Apply();
|
||||||
Render(graphicsDevice, instance->GetMesh(), instance->GetTexture(), frame, shader);
|
Render(graphicsDevice, instance->GetMesh(), instance->GetTexture(), frame, shader);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyframeMeshRenderer::Render(GraphicsDevice *graphicsDevice, KeyframeMeshInstance *instance, uint startFrame, uint endFrame, float interpolation, VertexLerpShader *shader)
|
void KeyframeMeshRenderer::Render(GraphicsDevice *graphicsDevice, KeyframeMeshInstance *instance, uint startFrame, uint endFrame, float interpolation, VertexLerpShader *shader)
|
||||||
{
|
{
|
||||||
ASSERT(shader->IsBound() == TRUE);
|
ASSERT(shader->IsBound() == true);
|
||||||
instance->GetRenderState()->Apply();
|
instance->GetRenderState()->Apply();
|
||||||
Render(graphicsDevice, instance->GetMesh(), instance->GetTexture(), instance->GetCurrentFrame(), instance->GetNextFrame(), instance->GetInterpolation(), shader);
|
Render(graphicsDevice, instance->GetMesh(), instance->GetTexture(), instance->GetCurrentFrame(), instance->GetNextFrame(), instance->GetInterpolation(), shader);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyframeMeshRenderer::Render(GraphicsDevice *graphicsDevice, KeyframeMesh *mesh, const Texture *texture, VertexLerpShader *shader)
|
void KeyframeMeshRenderer::Render(GraphicsDevice *graphicsDevice, KeyframeMesh *mesh, const Texture *texture, VertexLerpShader *shader)
|
||||||
{
|
{
|
||||||
ASSERT(shader->IsBound() == TRUE);
|
ASSERT(shader->IsBound() == true);
|
||||||
Render(graphicsDevice, mesh, texture, 0, shader);
|
Render(graphicsDevice, mesh, texture, 0, shader);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyframeMeshRenderer::Render(GraphicsDevice *graphicsDevice, KeyframeMesh *mesh, const Texture *texture, uint frame, VertexLerpShader *shader)
|
void KeyframeMeshRenderer::Render(GraphicsDevice *graphicsDevice, KeyframeMesh *mesh, const Texture *texture, uint frame, VertexLerpShader *shader)
|
||||||
{
|
{
|
||||||
ASSERT(shader->IsBound() == TRUE);
|
ASSERT(shader->IsBound() == true);
|
||||||
SetFrameVertices(mesh, frame);
|
SetFrameVertices(mesh, frame);
|
||||||
|
|
||||||
if (texture != NULL)
|
if (texture != NULL)
|
||||||
|
@ -65,7 +65,7 @@ void KeyframeMeshRenderer::Render(GraphicsDevice *graphicsDevice, KeyframeMesh *
|
||||||
|
|
||||||
void KeyframeMeshRenderer::Render(GraphicsDevice *graphicsDevice, KeyframeMesh *mesh, const Texture *texture, uint startFrame, uint endFrame, float interpolation, VertexLerpShader *shader)
|
void KeyframeMeshRenderer::Render(GraphicsDevice *graphicsDevice, KeyframeMesh *mesh, const Texture *texture, uint startFrame, uint endFrame, float interpolation, VertexLerpShader *shader)
|
||||||
{
|
{
|
||||||
ASSERT(shader->IsBound() == TRUE);
|
ASSERT(shader->IsBound() == true);
|
||||||
SetFrameVertices(mesh, startFrame, endFrame);
|
SetFrameVertices(mesh, startFrame, endFrame);
|
||||||
|
|
||||||
if (texture != NULL)
|
if (texture != NULL)
|
||||||
|
|
|
@ -113,13 +113,13 @@ void SkeletalMesh::FindAndSetRootJointIndex()
|
||||||
}
|
}
|
||||||
|
|
||||||
// ensure it has child joints
|
// ensure it has child joints
|
||||||
BOOL hasChildJoints = FALSE;
|
bool hasChildJoints = false;
|
||||||
for (uint i = 0; i < m_numJoints; ++i)
|
for (uint i = 0; i < m_numJoints; ++i)
|
||||||
{
|
{
|
||||||
int parentIndex = m_joints[i].parentIndex;
|
int parentIndex = m_joints[i].parentIndex;
|
||||||
if (parentIndex == parentlessJoint)
|
if (parentIndex == parentlessJoint)
|
||||||
{
|
{
|
||||||
hasChildJoints = TRUE;
|
hasChildJoints = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,12 +12,12 @@ SkeletalMeshAnimationInstance::SkeletalMeshAnimationInstance(SkeletalMesh *mesh)
|
||||||
{
|
{
|
||||||
m_currentSequenceStart = 0;
|
m_currentSequenceStart = 0;
|
||||||
m_currentSequenceEnd = 0;
|
m_currentSequenceEnd = 0;
|
||||||
m_currentSequenceLoop = FALSE;
|
m_currentSequenceLoop = false;
|
||||||
m_thisFrame = 0;
|
m_thisFrame = 0;
|
||||||
m_nextFrame = 0;
|
m_nextFrame = 0;
|
||||||
m_interpolation = 0.0f;
|
m_interpolation = 0.0f;
|
||||||
m_isRunningTempSequence = FALSE;
|
m_isRunningTempSequence = false;
|
||||||
m_oldSequenceLoop = FALSE;
|
m_oldSequenceLoop = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkeletalMeshAnimationInstance::~SkeletalMeshAnimationInstance()
|
SkeletalMeshAnimationInstance::~SkeletalMeshAnimationInstance()
|
||||||
|
@ -65,7 +65,7 @@ void SkeletalMeshAnimationInstance::OnUpdate(float delta)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkeletalMeshAnimationInstance::SetSequence(uint startFrame, uint endFrame, BOOL loop)
|
void SkeletalMeshAnimationInstance::SetSequence(uint startFrame, uint endFrame, bool loop)
|
||||||
{
|
{
|
||||||
m_currentSequenceName.clear();
|
m_currentSequenceName.clear();
|
||||||
m_currentSequenceStart = startFrame;
|
m_currentSequenceStart = startFrame;
|
||||||
|
@ -80,7 +80,7 @@ void SkeletalMeshAnimationInstance::SetSequence(uint startFrame, uint endFrame,
|
||||||
m_interpolation = 0.0f;
|
m_interpolation = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkeletalMeshAnimationInstance::SetSequence(const stl::string &name, BOOL loop)
|
void SkeletalMeshAnimationInstance::SetSequence(const stl::string &name, bool loop)
|
||||||
{
|
{
|
||||||
if (m_currentSequenceName == name)
|
if (m_currentSequenceName == name)
|
||||||
return;
|
return;
|
||||||
|
@ -98,14 +98,14 @@ void SkeletalMeshAnimationInstance::RunSequenceOnce(const stl::string &name)
|
||||||
m_oldSequenceName = m_currentSequenceName;
|
m_oldSequenceName = m_currentSequenceName;
|
||||||
m_oldSequenceLoop = m_currentSequenceLoop;
|
m_oldSequenceLoop = m_currentSequenceLoop;
|
||||||
|
|
||||||
m_isRunningTempSequence = TRUE;
|
m_isRunningTempSequence = true;
|
||||||
|
|
||||||
SetSequence(name, FALSE);
|
SetSequence(name, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkeletalMeshAnimationInstance::RecoverFromTempSequence()
|
void SkeletalMeshAnimationInstance::RecoverFromTempSequence()
|
||||||
{
|
{
|
||||||
m_isRunningTempSequence = FALSE;
|
m_isRunningTempSequence = false;
|
||||||
SetSequence(m_oldSequenceName, m_oldSequenceLoop);
|
SetSequence(m_oldSequenceName, m_oldSequenceLoop);
|
||||||
m_oldSequenceName.clear();
|
m_oldSequenceName.clear();
|
||||||
m_oldSequenceLoop = false;
|
m_oldSequenceLoop = false;
|
||||||
|
|
|
@ -14,8 +14,8 @@ public:
|
||||||
virtual ~SkeletalMeshAnimationInstance();
|
virtual ~SkeletalMeshAnimationInstance();
|
||||||
|
|
||||||
void OnUpdate(float delta);
|
void OnUpdate(float delta);
|
||||||
void SetSequence(uint startFrame, uint endFrame, BOOL loop);
|
void SetSequence(uint startFrame, uint endFrame, bool loop);
|
||||||
void SetSequence(const stl::string &name, BOOL loop);
|
void SetSequence(const stl::string &name, bool loop);
|
||||||
void RunSequenceOnce(const stl::string &name);
|
void RunSequenceOnce(const stl::string &name);
|
||||||
|
|
||||||
uint GetCurrentFrame() const { return m_thisFrame; }
|
uint GetCurrentFrame() const { return m_thisFrame; }
|
||||||
|
@ -28,13 +28,13 @@ private:
|
||||||
stl::string m_currentSequenceName;
|
stl::string m_currentSequenceName;
|
||||||
uint m_currentSequenceStart;
|
uint m_currentSequenceStart;
|
||||||
uint m_currentSequenceEnd;
|
uint m_currentSequenceEnd;
|
||||||
BOOL m_currentSequenceLoop;
|
bool m_currentSequenceLoop;
|
||||||
uint m_thisFrame;
|
uint m_thisFrame;
|
||||||
uint m_nextFrame;
|
uint m_nextFrame;
|
||||||
float m_interpolation;
|
float m_interpolation;
|
||||||
BOOL m_isRunningTempSequence;
|
bool m_isRunningTempSequence;
|
||||||
stl::string m_oldSequenceName;
|
stl::string m_oldSequenceName;
|
||||||
BOOL m_oldSequenceLoop;
|
bool m_oldSequenceLoop;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -43,8 +43,8 @@ SkeletalMesh* SkeletalMeshFile::CreateMesh()
|
||||||
ASSERT(jointsDesc != NULL);
|
ASSERT(jointsDesc != NULL);
|
||||||
ASSERT(jointsToVerticesDesc != NULL);
|
ASSERT(jointsToVerticesDesc != NULL);
|
||||||
|
|
||||||
BOOL hasNormals = (normalsDesc != NULL ? TRUE : FALSE);
|
bool hasNormals = (normalsDesc != NULL ? true : false);
|
||||||
BOOL hasTexCoords = (texCoordsDesc != NULL ? TRUE : FALSE);
|
bool hasTexCoords = (texCoordsDesc != NULL ? true : false);
|
||||||
|
|
||||||
File *file = GetFile();
|
File *file = GetFile();
|
||||||
SkeletalMesh *mesh = new SkeletalMesh();
|
SkeletalMesh *mesh = new SkeletalMesh();
|
||||||
|
@ -116,12 +116,12 @@ SkeletalMesh* SkeletalMeshFile::CreateMesh()
|
||||||
{
|
{
|
||||||
stl::string name;
|
stl::string name;
|
||||||
stl::string texture;
|
stl::string texture;
|
||||||
BOOL alpha;
|
bool alpha;
|
||||||
uint numTriangles;
|
uint numTriangles;
|
||||||
|
|
||||||
file->ReadString(name);
|
file->ReadString(name);
|
||||||
file->ReadString(texture);
|
file->ReadString(texture);
|
||||||
alpha = file->ReadChar() == 0 ? FALSE : TRUE;
|
alpha = file->ReadChar() == 0 ? false : true;
|
||||||
numTriangles = file->ReadUnsignedInt();
|
numTriangles = file->ReadUnsignedInt();
|
||||||
|
|
||||||
mesh->m_subsets[i].Create(name, numTriangles, alpha);
|
mesh->m_subsets[i].Create(name, numTriangles, alpha);
|
||||||
|
|
|
@ -19,25 +19,25 @@ SkeletalMeshInstance::SkeletalMeshInstance(SkeletalMesh *mesh)
|
||||||
|
|
||||||
m_numSubsets = m_mesh->GetNumSubsets();
|
m_numSubsets = m_mesh->GetNumSubsets();
|
||||||
|
|
||||||
m_enabledSubsets = new BOOL[m_numSubsets];
|
m_enabledSubsets = new bool[m_numSubsets];
|
||||||
m_textures = new Texture*[m_numSubsets];
|
m_textures = new Texture*[m_numSubsets];
|
||||||
|
|
||||||
for (uint i = 0; i < m_numSubsets; ++i)
|
for (uint i = 0; i < m_numSubsets; ++i)
|
||||||
{
|
{
|
||||||
m_enabledSubsets[i] = TRUE;
|
m_enabledSubsets[i] = true;
|
||||||
m_textures[i] = NULL;
|
m_textures[i] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_renderState = new RENDERSTATE_DEFAULT;
|
m_renderState = new RENDERSTATE_DEFAULT;
|
||||||
m_blendState = new BLENDSTATE_DEFAULT;
|
m_blendState = new BLENDSTATE_DEFAULT;
|
||||||
m_alphaBlendState = new BLENDSTATE_ALPHABLEND;
|
m_alphaBlendState = new BLENDSTATE_ALPHABLEND;
|
||||||
m_renderAllSubsetsAlphaBlended = FALSE;
|
m_renderAllSubsetsAlphaBlended = false;
|
||||||
|
|
||||||
m_numJoints = mesh->GetNumJoints();
|
m_numJoints = mesh->GetNumJoints();
|
||||||
m_jointTransformations = new Matrix4x4[m_numJoints];
|
m_jointTransformations = new Matrix4x4[m_numJoints];
|
||||||
m_jointPositions = new Vector3[m_numJoints];
|
m_jointPositions = new Vector3[m_numJoints];
|
||||||
m_jointRotations = new Quaternion[m_numJoints];
|
m_jointRotations = new Quaternion[m_numJoints];
|
||||||
m_rootJointHasFixedTransform = FALSE;
|
m_rootJointHasFixedTransform = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkeletalMeshInstance::~SkeletalMeshInstance()
|
SkeletalMeshInstance::~SkeletalMeshInstance()
|
||||||
|
@ -68,14 +68,14 @@ const Matrix4x4* SkeletalMeshInstance::GetJointTransformation(const stl::string
|
||||||
void SkeletalMeshInstance::SetFixedRootJointTransformation(const Matrix4x4 &transform)
|
void SkeletalMeshInstance::SetFixedRootJointTransformation(const Matrix4x4 &transform)
|
||||||
{
|
{
|
||||||
ASSERT(GetMesh()->GetRootJointIndex() != NO_JOINT);
|
ASSERT(GetMesh()->GetRootJointIndex() != NO_JOINT);
|
||||||
m_rootJointHasFixedTransform = TRUE;
|
m_rootJointHasFixedTransform = true;
|
||||||
m_jointTransformations[GetMesh()->GetRootJointIndex()] = transform;
|
m_jointTransformations[GetMesh()->GetRootJointIndex()] = transform;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkeletalMeshInstance::ClearFixedRootJointTransformation()
|
void SkeletalMeshInstance::ClearFixedRootJointTransformation()
|
||||||
{
|
{
|
||||||
ASSERT(GetMesh()->GetRootJointIndex() != NO_JOINT);
|
ASSERT(GetMesh()->GetRootJointIndex() != NO_JOINT);
|
||||||
m_rootJointHasFixedTransform = FALSE;
|
m_rootJointHasFixedTransform = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkeletalMeshInstance::CalculateJointTransformations(uint frame)
|
void SkeletalMeshInstance::CalculateJointTransformations(uint frame)
|
||||||
|
@ -163,7 +163,7 @@ void SkeletalMeshInstance::BreakDownJointTransformationMatrix(uint jointMatrixIn
|
||||||
m_jointRotations[jointMatrixIndex] = Quaternion::CreateFromRotationMatrix(*jointMatrix);
|
m_jointRotations[jointMatrixIndex] = Quaternion::CreateFromRotationMatrix(*jointMatrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkeletalMeshInstance::EnableSubset(const stl::string &subset, BOOL enable)
|
void SkeletalMeshInstance::EnableSubset(const stl::string &subset, bool enable)
|
||||||
{
|
{
|
||||||
int index = m_mesh->GetIndexOfSubset(subset);
|
int index = m_mesh->GetIndexOfSubset(subset);
|
||||||
ASSERT(index != -1);
|
ASSERT(index != -1);
|
||||||
|
|
|
@ -23,9 +23,9 @@ public:
|
||||||
void CalculateJointTransformations(uint startFrame, uint endFrame, float interpolation);
|
void CalculateJointTransformations(uint startFrame, uint endFrame, float interpolation);
|
||||||
|
|
||||||
uint GetNumSubsets() const { return m_numSubsets; }
|
uint GetNumSubsets() const { return m_numSubsets; }
|
||||||
BOOL IsSubsetEnabled(uint index) const { return m_enabledSubsets[index]; }
|
bool IsSubsetEnabled(uint index) const { return m_enabledSubsets[index]; }
|
||||||
void EnableSubset(const stl::string &subset, BOOL enable);
|
void EnableSubset(const stl::string &subset, bool enable);
|
||||||
void EnableSubset(uint index, BOOL enable) { m_enabledSubsets[index] = enable; }
|
void EnableSubset(uint index, bool enable) { m_enabledSubsets[index] = enable; }
|
||||||
|
|
||||||
Texture** GetTextures() const { return m_textures; }
|
Texture** GetTextures() const { return m_textures; }
|
||||||
void SetTexture(uint index, Texture *texture);
|
void SetTexture(uint index, Texture *texture);
|
||||||
|
@ -43,8 +43,8 @@ public:
|
||||||
BlendState* GetBlendState() const { return m_blendState; }
|
BlendState* GetBlendState() const { return m_blendState; }
|
||||||
BlendState* GetAlphaBlendState() const { return m_alphaBlendState; }
|
BlendState* GetAlphaBlendState() const { return m_alphaBlendState; }
|
||||||
|
|
||||||
BOOL GetRenderAllSubsetsAlphaBlended() const { return m_renderAllSubsetsAlphaBlended; }
|
bool GetRenderAllSubsetsAlphaBlended() const { return m_renderAllSubsetsAlphaBlended; }
|
||||||
void SetRenderAllSubsetsAlphaBlended(BOOL enable) { m_renderAllSubsetsAlphaBlended = enable; }
|
void SetRenderAllSubsetsAlphaBlended(bool enable) { m_renderAllSubsetsAlphaBlended = enable; }
|
||||||
|
|
||||||
SkeletalMesh* GetMesh() const { return m_mesh; }
|
SkeletalMesh* GetMesh() const { return m_mesh; }
|
||||||
|
|
||||||
|
@ -53,18 +53,18 @@ private:
|
||||||
|
|
||||||
SkeletalMesh *m_mesh;
|
SkeletalMesh *m_mesh;
|
||||||
uint m_numSubsets;
|
uint m_numSubsets;
|
||||||
BOOL *m_enabledSubsets;
|
bool *m_enabledSubsets;
|
||||||
Texture **m_textures;
|
Texture **m_textures;
|
||||||
RenderState *m_renderState;
|
RenderState *m_renderState;
|
||||||
BlendState *m_blendState;
|
BlendState *m_blendState;
|
||||||
BlendState *m_alphaBlendState;
|
BlendState *m_alphaBlendState;
|
||||||
BOOL m_renderAllSubsetsAlphaBlended;
|
bool m_renderAllSubsetsAlphaBlended;
|
||||||
|
|
||||||
uint m_numJoints;
|
uint m_numJoints;
|
||||||
Matrix4x4 *m_jointTransformations;
|
Matrix4x4 *m_jointTransformations;
|
||||||
Vector3 *m_jointPositions;
|
Vector3 *m_jointPositions;
|
||||||
Quaternion *m_jointRotations;
|
Quaternion *m_jointRotations;
|
||||||
BOOL m_rootJointHasFixedTransform;
|
bool m_rootJointHasFixedTransform;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -22,13 +22,13 @@ SkeletalMeshRenderer::~SkeletalMeshRenderer()
|
||||||
|
|
||||||
void SkeletalMeshRenderer::Render(GraphicsDevice *graphicsDevice, SkeletalMeshInstance *instance, VertexSkinningShader *shader)
|
void SkeletalMeshRenderer::Render(GraphicsDevice *graphicsDevice, SkeletalMeshInstance *instance, VertexSkinningShader *shader)
|
||||||
{
|
{
|
||||||
ASSERT(shader->IsBound() == TRUE);
|
ASSERT(shader->IsBound() == true);
|
||||||
Render(graphicsDevice, instance, 0, shader);
|
Render(graphicsDevice, instance, 0, shader);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkeletalMeshRenderer::Render(GraphicsDevice *graphicsDevice, SkeletalMeshInstance *instance, uint frame, VertexSkinningShader *shader)
|
void SkeletalMeshRenderer::Render(GraphicsDevice *graphicsDevice, SkeletalMeshInstance *instance, uint frame, VertexSkinningShader *shader)
|
||||||
{
|
{
|
||||||
ASSERT(shader->IsBound() == TRUE);
|
ASSERT(shader->IsBound() == true);
|
||||||
instance->CalculateJointTransformations(frame);
|
instance->CalculateJointTransformations(frame);
|
||||||
shader->SetJointPositions(instance->GetJointPositions(), instance->GetNumJoints());
|
shader->SetJointPositions(instance->GetJointPositions(), instance->GetNumJoints());
|
||||||
shader->SetJointRotations(instance->GetJointRotations(), instance->GetNumJoints());
|
shader->SetJointRotations(instance->GetJointRotations(), instance->GetNumJoints());
|
||||||
|
@ -37,7 +37,7 @@ void SkeletalMeshRenderer::Render(GraphicsDevice *graphicsDevice, SkeletalMeshIn
|
||||||
|
|
||||||
void SkeletalMeshRenderer::Render(GraphicsDevice *graphicsDevice, SkeletalMeshInstance *instance, uint startFrame, uint endFrame, float interpolation, VertexSkinningShader *shader)
|
void SkeletalMeshRenderer::Render(GraphicsDevice *graphicsDevice, SkeletalMeshInstance *instance, uint startFrame, uint endFrame, float interpolation, VertexSkinningShader *shader)
|
||||||
{
|
{
|
||||||
ASSERT(shader->IsBound() == TRUE);
|
ASSERT(shader->IsBound() == true);
|
||||||
instance->CalculateJointTransformations(startFrame, endFrame, interpolation);
|
instance->CalculateJointTransformations(startFrame, endFrame, interpolation);
|
||||||
shader->SetJointPositions(instance->GetJointPositions(), instance->GetNumJoints());
|
shader->SetJointPositions(instance->GetJointPositions(), instance->GetNumJoints());
|
||||||
shader->SetJointRotations(instance->GetJointRotations(), instance->GetNumJoints());
|
shader->SetJointRotations(instance->GetJointRotations(), instance->GetNumJoints());
|
||||||
|
@ -46,7 +46,7 @@ void SkeletalMeshRenderer::Render(GraphicsDevice *graphicsDevice, SkeletalMeshIn
|
||||||
|
|
||||||
void SkeletalMeshRenderer::Render(GraphicsDevice *graphicsDevice, SkeletalMeshAnimationInstance *instance, VertexSkinningShader *shader)
|
void SkeletalMeshRenderer::Render(GraphicsDevice *graphicsDevice, SkeletalMeshAnimationInstance *instance, VertexSkinningShader *shader)
|
||||||
{
|
{
|
||||||
ASSERT(shader->IsBound() == TRUE);
|
ASSERT(shader->IsBound() == true);
|
||||||
Render(graphicsDevice, instance, instance->GetCurrentFrame(), instance->GetNextFrame(), instance->GetInterpolation(), shader);
|
Render(graphicsDevice, instance, instance->GetCurrentFrame(), instance->GetNextFrame(), instance->GetInterpolation(), shader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,14 +55,14 @@ void SkeletalMeshRenderer::RenderAllSubsets(GraphicsDevice *graphicsDevice, Skel
|
||||||
instance->GetRenderState()->Apply();
|
instance->GetRenderState()->Apply();
|
||||||
graphicsDevice->BindVertexBuffer(instance->GetMesh()->GetVertexBuffer());
|
graphicsDevice->BindVertexBuffer(instance->GetMesh()->GetVertexBuffer());
|
||||||
|
|
||||||
BOOL hasAlphaSubsets = FALSE;
|
bool hasAlphaSubsets = false;
|
||||||
|
|
||||||
if (instance->GetRenderAllSubsetsAlphaBlended())
|
if (instance->GetRenderAllSubsetsAlphaBlended())
|
||||||
{
|
{
|
||||||
// this instance has been overridden to have all it's subsets rendered
|
// this instance has been overridden to have all it's subsets rendered
|
||||||
// with alpha blending enabled. don't bother with the first loop to find
|
// with alpha blending enabled. don't bother with the first loop to find
|
||||||
// non-alpha-enabled subsets...
|
// non-alpha-enabled subsets...
|
||||||
hasAlphaSubsets = TRUE;
|
hasAlphaSubsets = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -76,7 +76,7 @@ void SkeletalMeshRenderer::RenderAllSubsets(GraphicsDevice *graphicsDevice, Skel
|
||||||
const SkeletalMeshSubset *subset = &instance->GetMesh()->GetSubsets()[i];
|
const SkeletalMeshSubset *subset = &instance->GetMesh()->GetSubsets()[i];
|
||||||
if (subset->IsAlphaBlended())
|
if (subset->IsAlphaBlended())
|
||||||
// note we have an alpha subset, but don't render it quite yet
|
// note we have an alpha subset, but don't render it quite yet
|
||||||
hasAlphaSubsets = TRUE;
|
hasAlphaSubsets = true;
|
||||||
else
|
else
|
||||||
RenderSubset(graphicsDevice, subset, instance->GetTextures()[i]);
|
RenderSubset(graphicsDevice, subset, instance->GetTextures()[i]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
SkeletalMeshSubset::SkeletalMeshSubset()
|
SkeletalMeshSubset::SkeletalMeshSubset()
|
||||||
{
|
{
|
||||||
m_indices = NULL;
|
m_indices = NULL;
|
||||||
m_alpha = FALSE;
|
m_alpha = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkeletalMeshSubset::~SkeletalMeshSubset()
|
SkeletalMeshSubset::~SkeletalMeshSubset()
|
||||||
|
@ -16,7 +16,7 @@ SkeletalMeshSubset::~SkeletalMeshSubset()
|
||||||
SAFE_DELETE(m_indices);
|
SAFE_DELETE(m_indices);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkeletalMeshSubset::Create(const stl::string &name, uint numTriangles, BOOL alpha)
|
void SkeletalMeshSubset::Create(const stl::string &name, uint numTriangles, bool alpha)
|
||||||
{
|
{
|
||||||
ASSERT(m_indices == NULL);
|
ASSERT(m_indices == NULL);
|
||||||
ASSERT(numTriangles > 0);
|
ASSERT(numTriangles > 0);
|
||||||
|
|
|
@ -12,16 +12,16 @@ public:
|
||||||
SkeletalMeshSubset();
|
SkeletalMeshSubset();
|
||||||
virtual ~SkeletalMeshSubset();
|
virtual ~SkeletalMeshSubset();
|
||||||
|
|
||||||
void Create(const stl::string &name, uint numTriangles, BOOL alpha);
|
void Create(const stl::string &name, uint numTriangles, bool alpha);
|
||||||
|
|
||||||
const stl::string& GetName() const { return m_name; }
|
const stl::string& GetName() const { return m_name; }
|
||||||
IndexBuffer* GetIndices() const { return m_indices; }
|
IndexBuffer* GetIndices() const { return m_indices; }
|
||||||
BOOL IsAlphaBlended() const { return m_alpha; }
|
bool IsAlphaBlended() const { return m_alpha; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
stl::string m_name;
|
stl::string m_name;
|
||||||
IndexBuffer *m_indices;
|
IndexBuffer *m_indices;
|
||||||
BOOL m_alpha;
|
bool m_alpha;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -18,8 +18,8 @@ const uint DEFAULT_MAX_FRAMESKIP = 10;
|
||||||
|
|
||||||
BaseGameApp::BaseGameApp()
|
BaseGameApp::BaseGameApp()
|
||||||
{
|
{
|
||||||
m_stop = FALSE;
|
m_stop = false;
|
||||||
m_isPaused = FALSE;
|
m_isPaused = false;
|
||||||
m_fps = 0;
|
m_fps = 0;
|
||||||
m_frameTime = 0.0f;
|
m_frameTime = 0.0f;
|
||||||
m_numRenders = 0;
|
m_numRenders = 0;
|
||||||
|
@ -29,8 +29,8 @@ BaseGameApp::BaseGameApp()
|
||||||
m_renderTime = 0;
|
m_renderTime = 0;
|
||||||
m_updateTime = 0;
|
m_updateTime = 0;
|
||||||
m_nextUpdateAt = 0;
|
m_nextUpdateAt = 0;
|
||||||
m_isRunningSlowly = FALSE;
|
m_isRunningSlowly = false;
|
||||||
m_isDirty = FALSE;
|
m_isDirty = false;
|
||||||
m_system = NULL;
|
m_system = NULL;
|
||||||
m_window = NULL;
|
m_window = NULL;
|
||||||
m_graphics = NULL;
|
m_graphics = NULL;
|
||||||
|
@ -50,7 +50,7 @@ BaseGameApp::~BaseGameApp()
|
||||||
SAFE_DELETE(m_graphics);
|
SAFE_DELETE(m_graphics);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL BaseGameApp::Start(OperatingSystem *system)
|
bool BaseGameApp::Start(OperatingSystem *system)
|
||||||
{
|
{
|
||||||
m_system = system;
|
m_system = system;
|
||||||
|
|
||||||
|
@ -58,34 +58,34 @@ BOOL BaseGameApp::Start(OperatingSystem *system)
|
||||||
if (!OnInit())
|
if (!OnInit())
|
||||||
{
|
{
|
||||||
LOG_ERROR(LOGCAT_GAMEAPP, "Initialization failed.\n");
|
LOG_ERROR(LOGCAT_GAMEAPP, "Initialization failed.\n");
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
LOG_INFO(LOGCAT_GAMEAPP, "Initialization succeeded.\n");
|
LOG_INFO(LOGCAT_GAMEAPP, "Initialization succeeded.\n");
|
||||||
OnNewContext();
|
OnNewContext();
|
||||||
OnResize();
|
OnResize();
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL BaseGameApp::Initialize(GameWindowParams *windowParams)
|
bool BaseGameApp::Initialize(GameWindowParams *windowParams)
|
||||||
{
|
{
|
||||||
LOG_INFO(LOGCAT_GAMEAPP, "Starting initialization.\n");
|
LOG_INFO(LOGCAT_GAMEAPP, "Starting initialization.\n");
|
||||||
|
|
||||||
if (!m_system->CreateGameWindow(this, windowParams))
|
if (!m_system->CreateGameWindow(this, windowParams))
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
LOG_INFO(LOGCAT_GAMEAPP, "Verifying shader support present.\n");
|
LOG_INFO(LOGCAT_GAMEAPP, "Verifying shader support present.\n");
|
||||||
if (!m_system->HasShaderSupport())
|
if (!m_system->HasShaderSupport())
|
||||||
{
|
{
|
||||||
LOG_ERROR(LOGCAT_GAMEAPP, "No support for shaders detected. Graphics framework requires hardware shader support. Aborting.\n");
|
LOG_ERROR(LOGCAT_GAMEAPP, "No support for shaders detected. Graphics framework requires hardware shader support. Aborting.\n");
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_window = m_system->GetWindow();
|
m_window = m_system->GetWindow();
|
||||||
if (m_window == NULL)
|
if (m_window == NULL)
|
||||||
{
|
{
|
||||||
LOG_ERROR(LOGCAT_GAMEAPP, "Not able to get a GameWindow instance.\n");
|
LOG_ERROR(LOGCAT_GAMEAPP, "Not able to get a GameWindow instance.\n");
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_graphics = new GraphicsDevice();
|
m_graphics = new GraphicsDevice();
|
||||||
|
@ -97,7 +97,7 @@ BOOL BaseGameApp::Initialize(GameWindowParams *windowParams)
|
||||||
|
|
||||||
LOG_INFO(LOGCAT_GAMEAPP, "Initialization finished.\n");
|
LOG_INFO(LOGCAT_GAMEAPP, "Initialization finished.\n");
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseGameApp::Loop()
|
void BaseGameApp::Loop()
|
||||||
|
@ -158,15 +158,15 @@ void BaseGameApp::Loop()
|
||||||
|
|
||||||
// we're "running slowly" if we're more than one update behind
|
// we're "running slowly" if we're more than one update behind
|
||||||
if (currentTime > m_nextUpdateAt + m_ticksPerUpdate)
|
if (currentTime > m_nextUpdateAt + m_ticksPerUpdate)
|
||||||
m_isRunningSlowly = TRUE;
|
m_isRunningSlowly = true;
|
||||||
else
|
else
|
||||||
m_isRunningSlowly = FALSE;
|
m_isRunningSlowly = false;
|
||||||
|
|
||||||
numUpdatesThisFrame = 0;
|
numUpdatesThisFrame = 0;
|
||||||
while (GetTicks() >= m_nextUpdateAt && numUpdatesThisFrame < m_maxFrameSkip)
|
while (GetTicks() >= m_nextUpdateAt && numUpdatesThisFrame < m_maxFrameSkip)
|
||||||
{
|
{
|
||||||
if (numUpdatesThisFrame > 0)
|
if (numUpdatesThisFrame > 0)
|
||||||
m_isRunningSlowly = TRUE;
|
m_isRunningSlowly = true;
|
||||||
|
|
||||||
uint before = GetTicks();
|
uint before = GetTicks();
|
||||||
OnUpdate(m_fixedUpdateInterval);
|
OnUpdate(m_fixedUpdateInterval);
|
||||||
|
@ -178,7 +178,7 @@ void BaseGameApp::Loop()
|
||||||
++m_numUpdates;
|
++m_numUpdates;
|
||||||
|
|
||||||
// just updated, so we need to render the new game state
|
// just updated, so we need to render the new game state
|
||||||
m_isDirty = TRUE;
|
m_isDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_isDirty && m_window->IsActive() && m_window->HasGLContext())
|
if (m_isDirty && m_window->IsActive() && m_window->HasGLContext())
|
||||||
|
@ -191,7 +191,7 @@ void BaseGameApp::Loop()
|
||||||
++m_numRenders;
|
++m_numRenders;
|
||||||
|
|
||||||
// don't render again until we have something new to show
|
// don't render again until we have something new to show
|
||||||
m_isDirty = FALSE;
|
m_isDirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
++numLoops;
|
++numLoops;
|
||||||
|
@ -206,7 +206,7 @@ void BaseGameApp::Quit()
|
||||||
LOG_INFO(LOGCAT_GAMEAPP, "Quit requested.\n");
|
LOG_INFO(LOGCAT_GAMEAPP, "Quit requested.\n");
|
||||||
if (!m_system->IsQuitting())
|
if (!m_system->IsQuitting())
|
||||||
m_system->Quit();
|
m_system->Quit();
|
||||||
m_stop = TRUE;
|
m_stop = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseGameApp::OnAppGainFocus()
|
void BaseGameApp::OnAppGainFocus()
|
||||||
|
@ -222,13 +222,13 @@ void BaseGameApp::OnAppLostFocus()
|
||||||
void BaseGameApp::OnAppPause()
|
void BaseGameApp::OnAppPause()
|
||||||
{
|
{
|
||||||
LOG_INFO(LOGCAT_GAMEAPP, "Paused.\n");
|
LOG_INFO(LOGCAT_GAMEAPP, "Paused.\n");
|
||||||
m_isPaused = TRUE;
|
m_isPaused = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseGameApp::OnAppResume()
|
void BaseGameApp::OnAppResume()
|
||||||
{
|
{
|
||||||
LOG_INFO(LOGCAT_GAMEAPP, "Resumed.\n");
|
LOG_INFO(LOGCAT_GAMEAPP, "Resumed.\n");
|
||||||
m_isPaused = FALSE;
|
m_isPaused = false;
|
||||||
|
|
||||||
// this makes it so that the main loop won't try to "catch up" thinking that
|
// this makes it so that the main loop won't try to "catch up" thinking that
|
||||||
// it's really far behind with updates since m_nextUpdateAt won't have been
|
// it's really far behind with updates since m_nextUpdateAt won't have been
|
||||||
|
@ -290,10 +290,10 @@ void BaseGameApp::SetUpdateFrequency(uint targetFrequency)
|
||||||
m_fixedUpdateInterval = m_ticksPerUpdate / 1000.0f;
|
m_fixedUpdateInterval = m_ticksPerUpdate / 1000.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL BaseGameApp::IsAppFocused() const
|
bool BaseGameApp::IsAppFocused() const
|
||||||
{
|
{
|
||||||
if (m_window != NULL)
|
if (m_window != NULL)
|
||||||
return m_window->IsFocused();
|
return m_window->IsFocused();
|
||||||
else
|
else
|
||||||
return FALSE; // if there's no window, it can't be focused!
|
return false; // if there's no window, it can't be focused!
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,9 +27,9 @@ public:
|
||||||
* Begins application initialization in preparation for running the
|
* Begins application initialization in preparation for running the
|
||||||
* main loop.
|
* main loop.
|
||||||
* @param system pre-initialized operating system class
|
* @param system pre-initialized operating system class
|
||||||
* @return TRUE if successful, FALSE if not
|
* @return true if successful, false if not
|
||||||
*/
|
*/
|
||||||
BOOL Start(OperatingSystem *system);
|
bool Start(OperatingSystem *system);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs the main game loop.
|
* Runs the main game loop.
|
||||||
|
@ -98,10 +98,10 @@ public:
|
||||||
uint GetUpdatesPerSecond() const { return m_updatesPerSecond; }
|
uint GetUpdatesPerSecond() const { return m_updatesPerSecond; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return TRUE if the main loop is running behind
|
* @return true if the main loop is running behind
|
||||||
* (has to update game logic more then once per frame)
|
* (has to update game logic more then once per frame)
|
||||||
*/
|
*/
|
||||||
BOOL IsRunningSlowing() const { return m_isRunningSlowly; }
|
bool IsRunningSlowing() const { return m_isRunningSlowly; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the desired frames per second to run the main loop at.
|
* Sets the desired frames per second to run the main loop at.
|
||||||
|
@ -126,23 +126,23 @@ public:
|
||||||
* will render even if a game logic update has not been run since the last render
|
* will render even if a game logic update has not been run since the last render
|
||||||
* was performed.
|
* was performed.
|
||||||
*/
|
*/
|
||||||
void Invalidate() { m_isDirty = TRUE; }
|
void Invalidate() { m_isDirty = true; }
|
||||||
|
|
||||||
uint GetTicks() const { return m_system->GetTicks(); }
|
uint GetTicks() const { return m_system->GetTicks(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return TRUE if the app currently is active and has input focus
|
* @return true if the app currently is active and has input focus
|
||||||
*/
|
*/
|
||||||
BOOL IsAppFocused() const;
|
bool IsAppFocused() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* Initializes the game window and the graphics and content management
|
* Initializes the game window and the graphics and content management
|
||||||
* sub-systems.
|
* sub-systems.
|
||||||
* @param windowParams window creation parameters specific to the platform being run on
|
* @param windowParams window creation parameters specific to the platform being run on
|
||||||
* @return TRUE if successful, FALSE if not
|
* @return true if successful, false if not
|
||||||
*/
|
*/
|
||||||
BOOL Initialize(GameWindowParams *windowParams);
|
bool Initialize(GameWindowParams *windowParams);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Signals to the main loop that the application should quit as soon as possible.
|
* Signals to the main loop that the application should quit as soon as possible.
|
||||||
|
@ -173,7 +173,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Game-specific initialization (before content loading) callback.
|
* Game-specific initialization (before content loading) callback.
|
||||||
*/
|
*/
|
||||||
virtual BOOL OnInit() = 0;
|
virtual bool OnInit() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initial game load after initialization success callback.
|
* Initial game load after initialization success callback.
|
||||||
|
@ -211,8 +211,8 @@ private:
|
||||||
|
|
||||||
OperatingSystem *m_system;
|
OperatingSystem *m_system;
|
||||||
GameWindow *m_window;
|
GameWindow *m_window;
|
||||||
BOOL m_stop;
|
bool m_stop;
|
||||||
BOOL m_isPaused;
|
bool m_isPaused;
|
||||||
|
|
||||||
uint m_fps;
|
uint m_fps;
|
||||||
float m_frameTime;
|
float m_frameTime;
|
||||||
|
@ -228,9 +228,9 @@ private:
|
||||||
uint m_maxFrameSkip;
|
uint m_maxFrameSkip;
|
||||||
float m_fixedUpdateInterval;
|
float m_fixedUpdateInterval;
|
||||||
uint m_nextUpdateAt;
|
uint m_nextUpdateAt;
|
||||||
BOOL m_isRunningSlowly;
|
bool m_isRunningSlowly;
|
||||||
|
|
||||||
BOOL m_isDirty;
|
bool m_isDirty;
|
||||||
|
|
||||||
GraphicsDevice *m_graphics;
|
GraphicsDevice *m_graphics;
|
||||||
ContentManager *m_content;
|
ContentManager *m_content;
|
||||||
|
|
|
@ -4,12 +4,6 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
#if !defined(TRUE) && !defined(FALSE)
|
|
||||||
typedef int32_t BOOL;
|
|
||||||
const BOOL TRUE = 1;
|
|
||||||
const BOOL FALSE = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef unsigned long ulong;
|
typedef unsigned long ulong;
|
||||||
typedef unsigned int uint;
|
typedef unsigned int uint;
|
||||||
typedef unsigned short ushort;
|
typedef unsigned short ushort;
|
||||||
|
@ -55,10 +49,10 @@ inline T Max(T a, T b)
|
||||||
* Determines if a bit is set in the given bitfield.
|
* Determines if a bit is set in the given bitfield.
|
||||||
* @param bit the bit to check
|
* @param bit the bit to check
|
||||||
* @param bitfield the bit field to check the bit in
|
* @param bitfield the bit field to check the bit in
|
||||||
* @return TRUE if set, FALSE if not
|
* @return true if set, false if not
|
||||||
*/
|
*/
|
||||||
template <class T1, class T2>
|
template <class T1, class T2>
|
||||||
inline BOOL IsBitSet(T1 bit, T2 bitfield)
|
inline bool IsBitSet(T1 bit, T2 bitfield)
|
||||||
{
|
{
|
||||||
return (bitfield & bit) != 0;
|
return (bitfield & bit) != 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,25 +5,25 @@
|
||||||
Content::Content()
|
Content::Content()
|
||||||
{
|
{
|
||||||
m_referenceCount = 0;
|
m_referenceCount = 0;
|
||||||
m_isReferenceCounted = FALSE;
|
m_isReferenceCounted = false;
|
||||||
m_wasLoadedByContentLoader = FALSE;
|
m_wasLoadedByContentLoader = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Content::~Content()
|
Content::~Content()
|
||||||
{
|
{
|
||||||
ASSERT(m_isReferenceCounted == FALSE || m_referenceCount == 0);
|
ASSERT(m_isReferenceCounted == false || m_referenceCount == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Content::Reference()
|
void Content::Reference()
|
||||||
{
|
{
|
||||||
m_isReferenceCounted = TRUE;
|
m_isReferenceCounted = true;
|
||||||
++m_referenceCount;
|
++m_referenceCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Content::ReleaseReference()
|
void Content::ReleaseReference()
|
||||||
{
|
{
|
||||||
ASSERT(m_isReferenceCounted == TRUE);
|
ASSERT(m_isReferenceCounted == true);
|
||||||
ASSERT(IsReferenced() == TRUE);
|
ASSERT(IsReferenced() == true);
|
||||||
if (m_referenceCount > 0)
|
if (m_referenceCount > 0)
|
||||||
--m_referenceCount;
|
--m_referenceCount;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,19 +23,19 @@ public:
|
||||||
virtual ~Content();
|
virtual ~Content();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return TRUE if this content object was created by a ContentLoader
|
* @return true if this content object was created by a ContentLoader
|
||||||
*/
|
*/
|
||||||
BOOL WasLoadedByContentLoader() const { return m_wasLoadedByContentLoader; }
|
bool WasLoadedByContentLoader() const { return m_wasLoadedByContentLoader; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return TRUE if something else is currently referencing this content
|
* @return true if something else is currently referencing this content
|
||||||
*/
|
*/
|
||||||
BOOL IsReferenced() const { return m_referenceCount > 0; }
|
bool IsReferenced() const { return m_referenceCount > 0; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return TRUE if this content is currently being reference counted
|
* @return true if this content is currently being reference counted
|
||||||
*/
|
*/
|
||||||
BOOL IsReferenceCounted() const { return m_isReferenceCounted; }
|
bool IsReferenceCounted() const { return m_isReferenceCounted; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the number of references currently being held for this content
|
* @return the number of references currently being held for this content
|
||||||
|
@ -53,8 +53,8 @@ private:
|
||||||
*/
|
*/
|
||||||
void ReleaseReference();
|
void ReleaseReference();
|
||||||
|
|
||||||
BOOL m_wasLoadedByContentLoader;
|
bool m_wasLoadedByContentLoader;
|
||||||
BOOL m_isReferenceCounted;
|
bool m_isReferenceCounted;
|
||||||
uint m_referenceCount;
|
uint m_referenceCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ template <class T>
|
||||||
struct ContentContainer
|
struct ContentContainer
|
||||||
{
|
{
|
||||||
T *content;
|
T *content;
|
||||||
BOOL isPreLoaded;
|
bool isPreLoaded;
|
||||||
|
|
||||||
ContentContainer();
|
ContentContainer();
|
||||||
};
|
};
|
||||||
|
@ -16,7 +16,7 @@ template<class T>
|
||||||
inline ContentContainer<T>::ContentContainer()
|
inline ContentContainer<T>::ContentContainer()
|
||||||
{
|
{
|
||||||
content = NULL;
|
content = NULL;
|
||||||
isPreLoaded = FALSE;
|
isPreLoaded = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
void ContentLoaderBase::MarkLoadedByContentLoader(Content *content)
|
void ContentLoaderBase::MarkLoadedByContentLoader(Content *content)
|
||||||
{
|
{
|
||||||
ASSERT(content != NULL);
|
ASSERT(content != NULL);
|
||||||
content->m_wasLoadedByContentLoader = TRUE;
|
content->m_wasLoadedByContentLoader = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentLoaderBase::Reference(Content *content)
|
void ContentLoaderBase::Reference(Content *content)
|
||||||
|
|
|
@ -81,21 +81,21 @@ public:
|
||||||
* platform's backing storage.
|
* platform's backing storage.
|
||||||
* @param name the path and filename of the content to retrieve
|
* @param name the path and filename of the content to retrieve
|
||||||
* @param params content-type-specified parameters used during loading or NULL
|
* @param params content-type-specified parameters used during loading or NULL
|
||||||
* @param preload TRUE to mark the content as preloaded after loading it
|
* @param preload true to mark the content as preloaded after loading it
|
||||||
* @param <T> the type of content to load
|
* @param <T> the type of content to load
|
||||||
* @return the loaded content or NULL on failure
|
* @return the loaded content or NULL on failure
|
||||||
*/
|
*/
|
||||||
virtual T* Get(const stl::string &name, const ContentParam *params, BOOL preload = FALSE) = 0;
|
virtual T* Get(const stl::string &name, const ContentParam *params, bool preload = false) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Frees the specified content object. Content is only actually freed
|
* Frees the specified content object. Content is only actually freed
|
||||||
* when it has no more references to it.
|
* when it has no more references to it.
|
||||||
* @param content the content object to be freed
|
* @param content the content object to be freed
|
||||||
* @param preload TRUE to allow this content to be freed even if it has
|
* @param preload true to allow this content to be freed even if it has
|
||||||
* been preloaded
|
* been preloaded
|
||||||
* @param <T> the type of content to be freed
|
* @param <T> the type of content to be freed
|
||||||
*/
|
*/
|
||||||
virtual void Free(T *content, BOOL preload = FALSE) = 0;
|
virtual void Free(T *content, bool preload = false) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Frees the specified content if the content pointed to by the given path
|
* Frees the specified content if the content pointed to by the given path
|
||||||
|
@ -104,11 +104,11 @@ public:
|
||||||
* @param name the path and filename of the content to free
|
* @param name the path and filename of the content to free
|
||||||
* @param params content-type-specific parameters that further describe the
|
* @param params content-type-specific parameters that further describe the
|
||||||
* exact content object to be freed, or NULL
|
* exact content object to be freed, or NULL
|
||||||
* @param preload TRUE to allow this content to be freed even if it has
|
* @param preload true to allow this content to be freed even if it has
|
||||||
* been preloaded
|
* been preloaded
|
||||||
* @param <T> the type of content to be freed
|
* @param <T> the type of content to be freed
|
||||||
*/
|
*/
|
||||||
virtual void Free(const stl::string &name, const ContentParam *params, BOOL preload = FALSE) = 0;
|
virtual void Free(const stl::string &name, const ContentParam *params, bool preload = false) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the path and filename that the given content object was
|
* Returns the path and filename that the given content object was
|
||||||
|
|
|
@ -26,16 +26,16 @@ public:
|
||||||
|
|
||||||
void SetDefaultPath(const stl::string &path);
|
void SetDefaultPath(const stl::string &path);
|
||||||
|
|
||||||
T* Get(const stl::string &name, const ContentParam *params, BOOL preload = FALSE);
|
T* Get(const stl::string &name, const ContentParam *params, bool preload = false);
|
||||||
void Free(T *content, BOOL preload = FALSE);
|
void Free(T *content, bool preload = false);
|
||||||
void Free(const stl::string &name, const ContentParam *params, BOOL preload = FALSE);
|
void Free(const stl::string &name, const ContentParam *params, bool preload = false);
|
||||||
|
|
||||||
void RemoveAllContent();
|
void RemoveAllContent();
|
||||||
|
|
||||||
stl::string GetNameOf(T *content) const;
|
stl::string GetNameOf(T *content) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void Free(ContentStoreItor &itor, BOOL force, BOOL preload);
|
void Free(ContentStoreItor &itor, bool force, bool preload);
|
||||||
|
|
||||||
virtual ContentStoreItor FindContent(const stl::string &file, const ContentParam *params);
|
virtual ContentStoreItor FindContent(const stl::string &file, const ContentParam *params);
|
||||||
virtual T* LoadContent(const stl::string &file, const ContentParam *params) = 0;
|
virtual T* LoadContent(const stl::string &file, const ContentParam *params) = 0;
|
||||||
|
@ -70,7 +70,7 @@ ContentLoaderMapStoreBase<T>::~ContentLoaderMapStoreBase()
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
T* ContentLoaderMapStoreBase<T>::Get(const stl::string &name, const ContentParam *params, BOOL preload)
|
T* ContentLoaderMapStoreBase<T>::Get(const stl::string &name, const ContentParam *params, bool preload)
|
||||||
{
|
{
|
||||||
ContentContainer<T> content;
|
ContentContainer<T> content;
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ T* ContentLoaderMapStoreBase<T>::Get(const stl::string &name, const ContentParam
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void ContentLoaderMapStoreBase<T>::Free(T *content, BOOL preload)
|
void ContentLoaderMapStoreBase<T>::Free(T *content, bool preload)
|
||||||
{
|
{
|
||||||
ASSERT(content != NULL);
|
ASSERT(content != NULL);
|
||||||
|
|
||||||
|
@ -114,27 +114,27 @@ void ContentLoaderMapStoreBase<T>::Free(T *content, BOOL preload)
|
||||||
{
|
{
|
||||||
if (itor->second.content == content)
|
if (itor->second.content == content)
|
||||||
{
|
{
|
||||||
Free(itor, FALSE, preload);
|
Free(itor, false, preload);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void ContentLoaderMapStoreBase<T>::Free(const stl::string &name, const ContentParam *params, BOOL preload)
|
void ContentLoaderMapStoreBase<T>::Free(const stl::string &name, const ContentParam *params, bool preload)
|
||||||
{
|
{
|
||||||
stl::string filename = AddDefaultPathIfNeeded(name);
|
stl::string filename = AddDefaultPathIfNeeded(name);
|
||||||
filename = ProcessFilename(filename, params);
|
filename = ProcessFilename(filename, params);
|
||||||
|
|
||||||
ContentStoreItor itor = FindContent(filename, params);
|
ContentStoreItor itor = FindContent(filename, params);
|
||||||
if (itor != m_content.end())
|
if (itor != m_content.end())
|
||||||
Free(itor, FALSE, preload);
|
Free(itor, false, preload);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void ContentLoaderMapStoreBase<T>::Free(ContentStoreItor &itor, BOOL force, BOOL preload)
|
void ContentLoaderMapStoreBase<T>::Free(ContentStoreItor &itor, bool force, bool preload)
|
||||||
{
|
{
|
||||||
ASSERT(itor->second.content->WasLoadedByContentLoader() == TRUE);
|
ASSERT(itor->second.content->WasLoadedByContentLoader() == true);
|
||||||
|
|
||||||
if (!itor->second.isPreLoaded)
|
if (!itor->second.isPreLoaded)
|
||||||
ContentLoaderBase::ReleaseReference(itor->second.content);
|
ContentLoaderBase::ReleaseReference(itor->second.content);
|
||||||
|
@ -181,7 +181,7 @@ void ContentLoaderMapStoreBase<T>::RemoveAllContent()
|
||||||
itor->second.content->GetNumReferences(),
|
itor->second.content->GetNumReferences(),
|
||||||
(itor->second.isPreLoaded ? ", preloaded" : "")
|
(itor->second.isPreLoaded ? ", preloaded" : "")
|
||||||
);
|
);
|
||||||
Free(itor, TRUE, itor->second.isPreLoaded);
|
Free(itor, true, itor->second.isPreLoaded);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_content.clear();
|
m_content.clear();
|
||||||
|
|
|
@ -53,22 +53,22 @@ public:
|
||||||
* Retrieves the specified content either from a cache or from the
|
* Retrieves the specified content either from a cache or from the
|
||||||
* platform's backing storage.
|
* platform's backing storage.
|
||||||
* @param name the path and filename of the content to retrieve
|
* @param name the path and filename of the content to retrieve
|
||||||
* @param preload TRUE to mark the content as preloaded after loading it
|
* @param preload true to mark the content as preloaded after loading it
|
||||||
* @param <T> the type of content to load
|
* @param <T> the type of content to load
|
||||||
* @return the loaded content or NULL on failure
|
* @return the loaded content or NULL on failure
|
||||||
*/
|
*/
|
||||||
template <class T> T* Get(const stl::string &name, BOOL preload = FALSE);
|
template <class T> T* Get(const stl::string &name, bool preload = false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the specified content either from a cache or from the
|
* Retrieves the specified content either from a cache or from the
|
||||||
* platform's backing storage.
|
* platform's backing storage.
|
||||||
* @param name the path and filename of the content to retrieve
|
* @param name the path and filename of the content to retrieve
|
||||||
* @param params content-type-specified parameters used during loading or NULL
|
* @param params content-type-specified parameters used during loading or NULL
|
||||||
* @param preload TRUE to mark the content as preloaded after loading it
|
* @param preload true to mark the content as preloaded after loading it
|
||||||
* @param <T> the type of content to load
|
* @param <T> the type of content to load
|
||||||
* @return the loaded content or NULL on failure
|
* @return the loaded content or NULL on failure
|
||||||
*/
|
*/
|
||||||
template <class T> T* Get(const stl::string &name, const ContentParam ¶ms, BOOL preload = FALSE);
|
template <class T> T* Get(const stl::string &name, const ContentParam ¶ms, bool preload = false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the content so that it is pre-loaded and subsequent calls to Get()
|
* Loads the content so that it is pre-loaded and subsequent calls to Get()
|
||||||
|
@ -98,11 +98,11 @@ public:
|
||||||
* and filename has been loaded. Content is only actually freed when it has
|
* and filename has been loaded. Content is only actually freed when it has
|
||||||
* no more references to it.
|
* no more references to it.
|
||||||
* @param name the path and filename of the content to free
|
* @param name the path and filename of the content to free
|
||||||
* @param preload TRUE to allow this content to be freed even if it has
|
* @param preload true to allow this content to be freed even if it has
|
||||||
* been preloaded
|
* been preloaded
|
||||||
* @param <T> the type of content to be freed
|
* @param <T> the type of content to be freed
|
||||||
*/
|
*/
|
||||||
template <class T> void Free(const stl::string &name, BOOL preload = FALSE);
|
template <class T> void Free(const stl::string &name, bool preload = false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Frees the specified content if the content pointed to by the given path
|
* Frees the specified content if the content pointed to by the given path
|
||||||
|
@ -111,21 +111,21 @@ public:
|
||||||
* @param name the path and filename of the content to free
|
* @param name the path and filename of the content to free
|
||||||
* @param params content-type-specific parameters that further describe the
|
* @param params content-type-specific parameters that further describe the
|
||||||
* exact content object to be freed, or NULL
|
* exact content object to be freed, or NULL
|
||||||
* @param preload TRUE to allow this content to be freed even if it has
|
* @param preload true to allow this content to be freed even if it has
|
||||||
* been preloaded
|
* been preloaded
|
||||||
* @param <T> the type of content to be freed
|
* @param <T> the type of content to be freed
|
||||||
*/
|
*/
|
||||||
template <class T> void Free(const stl::string &name, const ContentParam ¶ms, BOOL preload = FALSE);
|
template <class T> void Free(const stl::string &name, const ContentParam ¶ms, bool preload = false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Frees the specified content object. Content is only actually freed
|
* Frees the specified content object. Content is only actually freed
|
||||||
* when it has no more references to it.
|
* when it has no more references to it.
|
||||||
* @param content the content object to be freed
|
* @param content the content object to be freed
|
||||||
* @param preload TRUE to allow this content to be freed even if it has
|
* @param preload true to allow this content to be freed even if it has
|
||||||
* been preloaded
|
* been preloaded
|
||||||
* @param <T> the type of content to be freed
|
* @param <T> the type of content to be freed
|
||||||
*/
|
*/
|
||||||
template <class T> void Free(T *content, BOOL preload = FALSE);
|
template <class T> void Free(T *content, bool preload = false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Frees the specified pre-loaded content. This will free the content
|
* Frees the specified pre-loaded content. This will free the content
|
||||||
|
@ -187,7 +187,7 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
T* ContentManager::Get(const stl::string &name, BOOL preload)
|
T* ContentManager::Get(const stl::string &name, bool preload)
|
||||||
{
|
{
|
||||||
ContentLoader<T> *loader = GetLoader<T>();
|
ContentLoader<T> *loader = GetLoader<T>();
|
||||||
T* content = loader->Get(name, NULL, preload);
|
T* content = loader->Get(name, NULL, preload);
|
||||||
|
@ -195,7 +195,7 @@ T* ContentManager::Get(const stl::string &name, BOOL preload)
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
T* ContentManager::Get(const stl::string &name, const ContentParam ¶ms, BOOL preload)
|
T* ContentManager::Get(const stl::string &name, const ContentParam ¶ms, bool preload)
|
||||||
{
|
{
|
||||||
ContentLoader<T> *loader = GetLoader<T>();
|
ContentLoader<T> *loader = GetLoader<T>();
|
||||||
T* content = loader->Get(name, ¶ms, preload);
|
T* content = loader->Get(name, ¶ms, preload);
|
||||||
|
@ -205,31 +205,31 @@ T* ContentManager::Get(const stl::string &name, const ContentParam ¶ms, BOOL
|
||||||
template<class T>
|
template<class T>
|
||||||
T* ContentManager::Load(const stl::string &name)
|
T* ContentManager::Load(const stl::string &name)
|
||||||
{
|
{
|
||||||
return Get<T>(name, TRUE);
|
return Get<T>(name, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
T* ContentManager::Load(const stl::string &name, const ContentParam ¶ms)
|
T* ContentManager::Load(const stl::string &name, const ContentParam ¶ms)
|
||||||
{
|
{
|
||||||
return Get<T>(name, params, TRUE);
|
return Get<T>(name, params, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void ContentManager::Free(const stl::string &name, BOOL preload)
|
void ContentManager::Free(const stl::string &name, bool preload)
|
||||||
{
|
{
|
||||||
ContentLoader<T> *loader = GetLoader<T>();
|
ContentLoader<T> *loader = GetLoader<T>();
|
||||||
loader->Free(name, NULL, preload);
|
loader->Free(name, NULL, preload);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void ContentManager::Free(const stl::string &name, const ContentParam ¶ms, BOOL preload)
|
void ContentManager::Free(const stl::string &name, const ContentParam ¶ms, bool preload)
|
||||||
{
|
{
|
||||||
ContentLoader<T> *loader = GetLoader<T>();
|
ContentLoader<T> *loader = GetLoader<T>();
|
||||||
loader->Free(name, ¶ms, preload);
|
loader->Free(name, ¶ms, preload);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void ContentManager::Free(T *content, BOOL preload)
|
void ContentManager::Free(T *content, bool preload)
|
||||||
{
|
{
|
||||||
ContentLoader<T> *loader = GetLoader<T>();
|
ContentLoader<T> *loader = GetLoader<T>();
|
||||||
loader->Free(content, preload);
|
loader->Free(content, preload);
|
||||||
|
@ -238,19 +238,19 @@ void ContentManager::Free(T *content, BOOL preload)
|
||||||
template <class T>
|
template <class T>
|
||||||
void ContentManager::Unload(const stl::string &name)
|
void ContentManager::Unload(const stl::string &name)
|
||||||
{
|
{
|
||||||
Free<T>(name, TRUE);
|
Free<T>(name, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void ContentManager::Unload(const stl::string &name, const ContentParam ¶ms)
|
void ContentManager::Unload(const stl::string &name, const ContentParam ¶ms)
|
||||||
{
|
{
|
||||||
Free<T>(name, params, TRUE);
|
Free<T>(name, params, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void ContentManager::Unload(T *content)
|
void ContentManager::Unload(T *content)
|
||||||
{
|
{
|
||||||
Free<T>(content, TRUE);
|
Free<T>(content, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
|
|
|
@ -38,7 +38,7 @@ Image* ImageLoader::LoadContent(const stl::string &file, const ContentParam *par
|
||||||
ASSERT(imageFile != NULL);
|
ASSERT(imageFile != NULL);
|
||||||
|
|
||||||
Image *image = new Image();
|
Image *image = new Image();
|
||||||
BOOL success = image->Create(imageFile);
|
bool success = image->Create(imageFile);
|
||||||
|
|
||||||
SAFE_DELETE(imageFile);
|
SAFE_DELETE(imageFile);
|
||||||
|
|
||||||
|
|
|
@ -150,8 +150,8 @@ SpriteFont* SpriteFontLoader::Load(File *file, uint size, SpriteFont *existing)
|
||||||
// general size of each glyph in this font. Uppercase 'W' seems to be a
|
// general size of each glyph in this font. Uppercase 'W' seems to be a
|
||||||
// pretty good glyph to represent this "maximum size".
|
// pretty good glyph to represent this "maximum size".
|
||||||
SpriteFontGlyphMetrics maxMetrics;
|
SpriteFontGlyphMetrics maxMetrics;
|
||||||
BOOL maxMetricResult = GetGlyphMetrics(&fontinfo, 'W', size, &maxMetrics);
|
bool maxMetricResult = GetGlyphMetrics(&fontinfo, 'W', size, &maxMetrics);
|
||||||
ASSERT(maxMetricResult == TRUE);
|
ASSERT(maxMetricResult == true);
|
||||||
|
|
||||||
// if we can't even get this glyph's metrics then stop now
|
// if we can't even get this glyph's metrics then stop now
|
||||||
if (!maxMetricResult)
|
if (!maxMetricResult)
|
||||||
|
@ -161,8 +161,8 @@ SpriteFont* SpriteFontLoader::Load(File *file, uint size, SpriteFont *existing)
|
||||||
// that we're allowing as long as the font pixel size doesn't get too large
|
// that we're allowing as long as the font pixel size doesn't get too large
|
||||||
// this bitmap is *only* going to contain alpha values (not any kind of rgb colour data)
|
// this bitmap is *only* going to contain alpha values (not any kind of rgb colour data)
|
||||||
Image *bitmap = new Image();
|
Image *bitmap = new Image();
|
||||||
BOOL bitmapCreateSuccess = bitmap->Create(FONT_BITMAP_WIDTH, FONT_BITMAP_HEIGHT, IMAGE_FORMAT_ALPHA);
|
bool bitmapCreateSuccess = bitmap->Create(FONT_BITMAP_WIDTH, FONT_BITMAP_HEIGHT, IMAGE_FORMAT_ALPHA);
|
||||||
ASSERT(bitmapCreateSuccess == TRUE);
|
ASSERT(bitmapCreateSuccess == true);
|
||||||
bitmap->Clear();
|
bitmap->Clear();
|
||||||
|
|
||||||
// the texture atlas to store the position/texcoords of each glyph
|
// the texture atlas to store the position/texcoords of each glyph
|
||||||
|
@ -186,8 +186,8 @@ SpriteFont* SpriteFontLoader::Load(File *file, uint size, SpriteFont *existing)
|
||||||
// get metrics for the current glyph
|
// get metrics for the current glyph
|
||||||
char c = (char)(i + LOW_GLYPH);
|
char c = (char)(i + LOW_GLYPH);
|
||||||
SpriteFontGlyphMetrics glyphMetrics;
|
SpriteFontGlyphMetrics glyphMetrics;
|
||||||
BOOL metricResult = GetGlyphMetrics(&fontinfo, c, size, &glyphMetrics);
|
bool metricResult = GetGlyphMetrics(&fontinfo, c, size, &glyphMetrics);
|
||||||
ASSERT(metricResult == TRUE);
|
ASSERT(metricResult == true);
|
||||||
|
|
||||||
// adjust each glyph's rect so that it has it's own space that doesn't
|
// adjust each glyph's rect so that it has it's own space that doesn't
|
||||||
// collide with any of it's neighbour glyphs (neighbour as seen on the
|
// collide with any of it's neighbour glyphs (neighbour as seen on the
|
||||||
|
@ -237,8 +237,8 @@ SpriteFont* SpriteFontLoader::Load(File *file, uint size, SpriteFont *existing)
|
||||||
}
|
}
|
||||||
|
|
||||||
Texture *fontTexture = new Texture();
|
Texture *fontTexture = new Texture();
|
||||||
BOOL textureCreated = fontTexture->Create(GetContentManager()->GetGameApp()->GetGraphicsDevice(), bitmap);
|
bool textureCreated = fontTexture->Create(GetContentManager()->GetGameApp()->GetGraphicsDevice(), bitmap);
|
||||||
ASSERT(textureCreated == TRUE);
|
ASSERT(textureCreated == true);
|
||||||
SAFE_DELETE(bitmap);
|
SAFE_DELETE(bitmap);
|
||||||
if (!textureCreated)
|
if (!textureCreated)
|
||||||
{
|
{
|
||||||
|
@ -271,7 +271,7 @@ void SpriteFontLoader::FreeContent(SpriteFont *content)
|
||||||
SAFE_DELETE(content);
|
SAFE_DELETE(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL SpriteFontLoader::GetGlyphMetrics(stbtt_fontinfo *fontInfo, char glyph, uint size, SpriteFontGlyphMetrics *metrics) const
|
bool SpriteFontLoader::GetGlyphMetrics(stbtt_fontinfo *fontInfo, char glyph, uint size, SpriteFontGlyphMetrics *metrics) const
|
||||||
{
|
{
|
||||||
ASSERT(metrics != NULL);
|
ASSERT(metrics != NULL);
|
||||||
|
|
||||||
|
@ -284,7 +284,7 @@ BOOL SpriteFontLoader::GetGlyphMetrics(stbtt_fontinfo *fontInfo, char glyph, uin
|
||||||
|
|
||||||
metrics->index = stbtt_FindGlyphIndex(fontInfo, glyph);
|
metrics->index = stbtt_FindGlyphIndex(fontInfo, glyph);
|
||||||
if (metrics->index == 0)
|
if (metrics->index == 0)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
stbtt_GetGlyphBox(fontInfo, metrics->index, &metrics->dimensions.left, &metrics->dimensions.top, &metrics->dimensions.right, &metrics->dimensions.bottom);
|
stbtt_GetGlyphBox(fontInfo, metrics->index, &metrics->dimensions.left, &metrics->dimensions.top, &metrics->dimensions.right, &metrics->dimensions.bottom);
|
||||||
stbtt_GetFontVMetrics(fontInfo, &metrics->ascent, &metrics->descent, &metrics->lineGap);
|
stbtt_GetFontVMetrics(fontInfo, &metrics->ascent, &metrics->descent, &metrics->lineGap);
|
||||||
|
@ -310,5 +310,5 @@ BOOL SpriteFontLoader::GetGlyphMetrics(stbtt_fontinfo *fontInfo, char glyph, uin
|
||||||
if (heightDifference != metrics->lineGap && metrics->lineGap == 0)
|
if (heightDifference != metrics->lineGap && metrics->lineGap == 0)
|
||||||
metrics->lineGap = heightDifference;
|
metrics->lineGap = heightDifference;
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ private:
|
||||||
void DecomposeFilename(const stl::string &filename, stl::string &outFilename, uint &outSize) const;
|
void DecomposeFilename(const stl::string &filename, stl::string &outFilename, uint &outSize) const;
|
||||||
SpriteFont* Load(File *file, uint size, SpriteFont *existing) const;
|
SpriteFont* Load(File *file, uint size, SpriteFont *existing) const;
|
||||||
|
|
||||||
BOOL GetGlyphMetrics(stbtt_fontinfo *fontInfo, char glyph, uint size, SpriteFontGlyphMetrics *glyphMetrics) const;
|
bool GetGlyphMetrics(stbtt_fontinfo *fontInfo, char glyph, uint size, SpriteFontGlyphMetrics *glyphMetrics) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -84,7 +84,7 @@ Texture* TextureLoader::Load(const stl::string &file, Texture *existingTexture)
|
||||||
texture = new Texture();
|
texture = new Texture();
|
||||||
|
|
||||||
// load image into it
|
// load image into it
|
||||||
BOOL success = texture->Create(GetContentManager()->GetGameApp()->GetGraphicsDevice(), image);
|
bool success = texture->Create(GetContentManager()->GetGameApp()->GetGraphicsDevice(), image);
|
||||||
|
|
||||||
// don't need to keep the underlying image around if not being used elsewhere
|
// don't need to keep the underlying image around if not being used elsewhere
|
||||||
GetContentManager()->Free<Image>(image);
|
GetContentManager()->Free<Image>(image);
|
||||||
|
|
|
@ -7,8 +7,8 @@ DiskFile::DiskFile()
|
||||||
{
|
{
|
||||||
m_fp = NULL;
|
m_fp = NULL;
|
||||||
m_mode = 0;
|
m_mode = 0;
|
||||||
m_canRead = FALSE;
|
m_canRead = false;
|
||||||
m_canWrite = FALSE;
|
m_canWrite = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
DiskFile::~DiskFile()
|
DiskFile::~DiskFile()
|
||||||
|
@ -16,26 +16,26 @@ DiskFile::~DiskFile()
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL DiskFile::Open(const stl::string &filename, int mode)
|
bool DiskFile::Open(const stl::string &filename, int mode)
|
||||||
{
|
{
|
||||||
ASSERT(IsOpen() == FALSE);
|
ASSERT(IsOpen() == false);
|
||||||
m_filename = filename;
|
m_filename = filename;
|
||||||
|
|
||||||
char fopenMode[3] = { '\0', '\0', '\0' };
|
char fopenMode[3] = { '\0', '\0', '\0' };
|
||||||
if (mode & FILEMODE_READ)
|
if (mode & FILEMODE_READ)
|
||||||
{
|
{
|
||||||
fopenMode[0] = 'r';
|
fopenMode[0] = 'r';
|
||||||
m_canRead = TRUE;
|
m_canRead = true;
|
||||||
}
|
}
|
||||||
else if (mode & FILEMODE_WRITE)
|
else if (mode & FILEMODE_WRITE)
|
||||||
{
|
{
|
||||||
fopenMode[0] = 'w';
|
fopenMode[0] = 'w';
|
||||||
m_canWrite = TRUE;
|
m_canWrite = true;
|
||||||
}
|
}
|
||||||
else if (mode & FILEMODE_APPEND)
|
else if (mode & FILEMODE_APPEND)
|
||||||
{
|
{
|
||||||
fopenMode[0] = 'a';
|
fopenMode[0] = 'a';
|
||||||
m_canWrite = TRUE;
|
m_canWrite = true;
|
||||||
}
|
}
|
||||||
if (mode & FILEMODE_BINARY && fopenMode[0] != '\0')
|
if (mode & FILEMODE_BINARY && fopenMode[0] != '\0')
|
||||||
fopenMode[1] = 'b';
|
fopenMode[1] = 'b';
|
||||||
|
@ -43,23 +43,23 @@ BOOL DiskFile::Open(const stl::string &filename, int mode)
|
||||||
if (fopenMode[0] == '\0')
|
if (fopenMode[0] == '\0')
|
||||||
{
|
{
|
||||||
ASSERT(!"Unrecognized mode.");
|
ASSERT(!"Unrecognized mode.");
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ASSERT(m_canRead == TRUE || m_canWrite == TRUE);
|
ASSERT(m_canRead == true || m_canWrite == true);
|
||||||
|
|
||||||
m_fp = fopen(filename.c_str(), fopenMode);
|
m_fp = fopen(filename.c_str(), fopenMode);
|
||||||
if (m_fp)
|
if (m_fp)
|
||||||
{
|
{
|
||||||
LOG_INFO(LOGCAT_FILEIO, "Opened DiskFile \"%s\", mode = %s\n", filename.c_str(), fopenMode);
|
LOG_INFO(LOGCAT_FILEIO, "Opened DiskFile \"%s\", mode = %s\n", filename.c_str(), fopenMode);
|
||||||
m_mode = mode;
|
m_mode = mode;
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LOG_WARN(LOGCAT_FILEIO, "Failed to open DiskFile \"%s\", mode = %s\n", filename.c_str(), fopenMode);
|
LOG_WARN(LOGCAT_FILEIO, "Failed to open DiskFile \"%s\", mode = %s\n", filename.c_str(), fopenMode);
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,8 +74,8 @@ void DiskFile::Close()
|
||||||
|
|
||||||
m_fp = NULL;
|
m_fp = NULL;
|
||||||
m_mode = 0;
|
m_mode = 0;
|
||||||
m_canRead = FALSE;
|
m_canRead = false;
|
||||||
m_canWrite = FALSE;
|
m_canWrite = false;
|
||||||
m_filename.clear();
|
m_filename.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,7 +328,7 @@ void DiskFile::Seek(size_t offset, FileSeek from)
|
||||||
fseek(m_fp, offset, origin);
|
fseek(m_fp, offset, origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL DiskFile::AtEOF()
|
bool DiskFile::AtEOF()
|
||||||
{
|
{
|
||||||
ASSERT(IsOpen());
|
ASSERT(IsOpen());
|
||||||
return feof(m_fp) != 0;
|
return feof(m_fp) != 0;
|
||||||
|
|
|
@ -17,12 +17,12 @@ public:
|
||||||
DiskFile();
|
DiskFile();
|
||||||
virtual ~DiskFile();
|
virtual ~DiskFile();
|
||||||
|
|
||||||
BOOL Open(const stl::string &filename, int mode);
|
bool Open(const stl::string &filename, int mode);
|
||||||
void Close();
|
void Close();
|
||||||
|
|
||||||
BOOL IsOpen() const { return m_fp != NULL; }
|
bool IsOpen() const { return m_fp != NULL; }
|
||||||
BOOL CanRead() const { return m_canRead; }
|
bool CanRead() const { return m_canRead; }
|
||||||
BOOL CanWrite() const { return m_canWrite; }
|
bool CanWrite() const { return m_canWrite; }
|
||||||
FileType GetFileType() const { return FILETYPE_IO; }
|
FileType GetFileType() const { return FILETYPE_IO; }
|
||||||
|
|
||||||
int8_t ReadChar();
|
int8_t ReadChar();
|
||||||
|
@ -53,7 +53,7 @@ public:
|
||||||
|
|
||||||
size_t Tell();
|
size_t Tell();
|
||||||
void Seek(size_t offset, FileSeek from);
|
void Seek(size_t offset, FileSeek from);
|
||||||
BOOL AtEOF();
|
bool AtEOF();
|
||||||
size_t GetFileSize();
|
size_t GetFileSize();
|
||||||
|
|
||||||
const stl::string& GetFilename() const { return m_filename; }
|
const stl::string& GetFilename() const { return m_filename; }
|
||||||
|
@ -61,8 +61,8 @@ public:
|
||||||
private:
|
private:
|
||||||
FILE *m_fp;
|
FILE *m_fp;
|
||||||
int m_mode;
|
int m_mode;
|
||||||
BOOL m_canRead;
|
bool m_canRead;
|
||||||
BOOL m_canWrite;
|
bool m_canWrite;
|
||||||
stl::string m_filename;
|
stl::string m_filename;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -41,19 +41,19 @@ public:
|
||||||
virtual void Close() = 0;
|
virtual void Close() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return TRUE if the file is currently open
|
* @return true if the file is currently open
|
||||||
*/
|
*/
|
||||||
virtual BOOL IsOpen() const = 0;
|
virtual bool IsOpen() const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return TRUE if this file supports reading
|
* @return true if this file supports reading
|
||||||
*/
|
*/
|
||||||
virtual BOOL CanRead() const = 0;
|
virtual bool CanRead() const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return TRUE if this file supports writing
|
* @return true if this file supports writing
|
||||||
*/
|
*/
|
||||||
virtual BOOL CanWrite() const = 0;
|
virtual bool CanWrite() const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return a type value representing the backing storage where this file's
|
* @return a type value representing the backing storage where this file's
|
||||||
|
@ -250,9 +250,9 @@ public:
|
||||||
virtual void Seek(size_t offset, FileSeek from) = 0;
|
virtual void Seek(size_t offset, FileSeek from) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return TRUE if the current file pointer is at the end of the file
|
* @return true if the current file pointer is at the end of the file
|
||||||
*/
|
*/
|
||||||
virtual BOOL AtEOF() = 0;
|
virtual bool AtEOF() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the size of this file in bytes
|
* @return the size of this file in bytes
|
||||||
|
|
|
@ -9,8 +9,8 @@ MarmaladeFile::MarmaladeFile()
|
||||||
{
|
{
|
||||||
m_fp = NULL;
|
m_fp = NULL;
|
||||||
m_mode = 0;
|
m_mode = 0;
|
||||||
m_canRead = FALSE;
|
m_canRead = false;
|
||||||
m_canWrite = FALSE;
|
m_canWrite = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
MarmaladeFile::~MarmaladeFile()
|
MarmaladeFile::~MarmaladeFile()
|
||||||
|
@ -18,26 +18,26 @@ MarmaladeFile::~MarmaladeFile()
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL MarmaladeFile::Open(const stl::string &filename, int mode)
|
bool MarmaladeFile::Open(const stl::string &filename, int mode)
|
||||||
{
|
{
|
||||||
ASSERT(IsOpen() == FALSE);
|
ASSERT(IsOpen() == false);
|
||||||
m_filename = filename;
|
m_filename = filename;
|
||||||
|
|
||||||
char fopenMode[3] = { '\0', '\0', '\0' };
|
char fopenMode[3] = { '\0', '\0', '\0' };
|
||||||
if (mode & FILEMODE_READ)
|
if (mode & FILEMODE_READ)
|
||||||
{
|
{
|
||||||
fopenMode[0] = 'r';
|
fopenMode[0] = 'r';
|
||||||
m_canRead = TRUE;
|
m_canRead = true;
|
||||||
}
|
}
|
||||||
else if (mode & FILEMODE_WRITE)
|
else if (mode & FILEMODE_WRITE)
|
||||||
{
|
{
|
||||||
fopenMode[0] = 'w';
|
fopenMode[0] = 'w';
|
||||||
m_canWrite = TRUE;
|
m_canWrite = true;
|
||||||
}
|
}
|
||||||
else if (mode & FILEMODE_APPEND)
|
else if (mode & FILEMODE_APPEND)
|
||||||
{
|
{
|
||||||
fopenMode[0] = 'a';
|
fopenMode[0] = 'a';
|
||||||
m_canWrite = TRUE;
|
m_canWrite = true;
|
||||||
}
|
}
|
||||||
if (mode & FILEMODE_BINARY && fopenMode[0] != '\0')
|
if (mode & FILEMODE_BINARY && fopenMode[0] != '\0')
|
||||||
fopenMode[1] = 'b';
|
fopenMode[1] = 'b';
|
||||||
|
@ -45,23 +45,23 @@ BOOL MarmaladeFile::Open(const stl::string &filename, int mode)
|
||||||
if (fopenMode[0] == '\0')
|
if (fopenMode[0] == '\0')
|
||||||
{
|
{
|
||||||
ASSERT(!"Unrecognized mode.");
|
ASSERT(!"Unrecognized mode.");
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ASSERT(m_canRead == TRUE || m_canWrite == TRUE);
|
ASSERT(m_canRead == true || m_canWrite == true);
|
||||||
|
|
||||||
m_fp = s3eFileOpen(filename.c_str(), fopenMode);
|
m_fp = s3eFileOpen(filename.c_str(), fopenMode);
|
||||||
if (m_fp)
|
if (m_fp)
|
||||||
{
|
{
|
||||||
LOG_INFO(LOGCAT_FILEIO, "Opened MarmaladeFile \"%s\", mode = %s\n", filename.c_str(), fopenMode);
|
LOG_INFO(LOGCAT_FILEIO, "Opened MarmaladeFile \"%s\", mode = %s\n", filename.c_str(), fopenMode);
|
||||||
m_mode = mode;
|
m_mode = mode;
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LOG_WARN(LOGCAT_FILEIO, "Failed to open MarmaladeFile \"%s\", mode = %s. Error: %d, %s\n", filename.c_str(), fopenMode, s3eFileGetError(), s3eFileGetErrorString());
|
LOG_WARN(LOGCAT_FILEIO, "Failed to open MarmaladeFile \"%s\", mode = %s. Error: %d, %s\n", filename.c_str(), fopenMode, s3eFileGetError(), s3eFileGetErrorString());
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,8 +76,8 @@ void MarmaladeFile::Close()
|
||||||
|
|
||||||
m_fp = NULL;
|
m_fp = NULL;
|
||||||
m_mode = 0;
|
m_mode = 0;
|
||||||
m_canRead = FALSE;
|
m_canRead = false;
|
||||||
m_canWrite = FALSE;
|
m_canWrite = false;
|
||||||
m_filename.clear();
|
m_filename.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -330,13 +330,13 @@ void MarmaladeFile::Seek(size_t offset, FileSeek from)
|
||||||
s3eFileSeek(m_fp, offset, origin);
|
s3eFileSeek(m_fp, offset, origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL MarmaladeFile::AtEOF()
|
bool MarmaladeFile::AtEOF()
|
||||||
{
|
{
|
||||||
ASSERT(IsOpen());
|
ASSERT(IsOpen());
|
||||||
if (s3eFileEOF(m_fp) == S3E_TRUE)
|
if (s3eFileEOF(m_fp) == S3E_true)
|
||||||
return TRUE;
|
return true;
|
||||||
else
|
else
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t MarmaladeFile::GetFileSize()
|
size_t MarmaladeFile::GetFileSize()
|
||||||
|
|
|
@ -13,12 +13,12 @@ public:
|
||||||
MarmaladeFile();
|
MarmaladeFile();
|
||||||
virtual ~MarmaladeFile();
|
virtual ~MarmaladeFile();
|
||||||
|
|
||||||
BOOL Open(const stl::string &filename, int mode);
|
bool Open(const stl::string &filename, int mode);
|
||||||
void Close();
|
void Close();
|
||||||
|
|
||||||
BOOL IsOpen() const { return m_fp != NULL; }
|
bool IsOpen() const { return m_fp != NULL; }
|
||||||
BOOL CanRead() const { return m_canRead; }
|
bool CanRead() const { return m_canRead; }
|
||||||
BOOL CanWrite() const { return m_canWrite; }
|
bool CanWrite() const { return m_canWrite; }
|
||||||
FileType GetFileType() const { return FILETYPE_IO; }
|
FileType GetFileType() const { return FILETYPE_IO; }
|
||||||
|
|
||||||
int8_t ReadChar();
|
int8_t ReadChar();
|
||||||
|
@ -49,7 +49,7 @@ public:
|
||||||
|
|
||||||
size_t Tell();
|
size_t Tell();
|
||||||
void Seek(size_t offset, FileSeek from);
|
void Seek(size_t offset, FileSeek from);
|
||||||
BOOL AtEOF();
|
bool AtEOF();
|
||||||
size_t GetFileSize();
|
size_t GetFileSize();
|
||||||
|
|
||||||
const stl::string& GetFilename() const { return m_filename; }
|
const stl::string& GetFilename() const { return m_filename; }
|
||||||
|
@ -57,8 +57,8 @@ public:
|
||||||
private:
|
private:
|
||||||
s3eFile *m_fp;
|
s3eFile *m_fp;
|
||||||
int m_mode;
|
int m_mode;
|
||||||
BOOL m_canRead;
|
bool m_canRead;
|
||||||
BOOL m_canWrite;
|
bool m_canWrite;
|
||||||
stl::string m_filename;
|
stl::string m_filename;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -8,11 +8,11 @@
|
||||||
MemoryFile::MemoryFile()
|
MemoryFile::MemoryFile()
|
||||||
{
|
{
|
||||||
m_data = NULL;
|
m_data = NULL;
|
||||||
m_ownData = FALSE;
|
m_ownData = false;
|
||||||
m_length = 0;
|
m_length = 0;
|
||||||
m_position = 0;
|
m_position = 0;
|
||||||
m_canRead = FALSE;
|
m_canRead = false;
|
||||||
m_canWrite = FALSE;
|
m_canWrite = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
MemoryFile::~MemoryFile()
|
MemoryFile::~MemoryFile()
|
||||||
|
@ -20,14 +20,14 @@ MemoryFile::~MemoryFile()
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL MemoryFile::Open(File *srcFile)
|
bool MemoryFile::Open(File *srcFile)
|
||||||
{
|
{
|
||||||
ASSERT(IsOpen() == FALSE);
|
ASSERT(IsOpen() == false);
|
||||||
ASSERT(srcFile->IsOpen());
|
ASSERT(srcFile->IsOpen());
|
||||||
size_t filesize = srcFile->GetFileSize();
|
size_t filesize = srcFile->GetFileSize();
|
||||||
m_data = new int8_t[filesize];
|
m_data = new int8_t[filesize];
|
||||||
ASSERT(m_data != NULL);
|
ASSERT(m_data != NULL);
|
||||||
m_ownData = TRUE;
|
m_ownData = true;
|
||||||
m_length = filesize;
|
m_length = filesize;
|
||||||
m_filename = srcFile->GetFilename();
|
m_filename = srcFile->GetFilename();
|
||||||
|
|
||||||
|
@ -38,15 +38,15 @@ BOOL MemoryFile::Open(File *srcFile)
|
||||||
|
|
||||||
LOG_INFO(LOGCAT_FILEIO, "Create MemoryFile from source file \"%s\"\n", srcFile->GetFilename().c_str());
|
LOG_INFO(LOGCAT_FILEIO, "Create MemoryFile from source file \"%s\"\n", srcFile->GetFilename().c_str());
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL MemoryFile::Open(const void *memory, size_t numBytes, BOOL canRead, BOOL canWrite, BOOL assumeOwnershipOfMemory)
|
bool MemoryFile::Open(const void *memory, size_t numBytes, bool canRead, bool canWrite, bool assumeOwnershipOfMemory)
|
||||||
{
|
{
|
||||||
ASSERT(IsOpen() == FALSE);
|
ASSERT(IsOpen() == false);
|
||||||
ASSERT(memory != NULL);
|
ASSERT(memory != NULL);
|
||||||
ASSERT(numBytes > 0);
|
ASSERT(numBytes > 0);
|
||||||
ASSERT(canRead == TRUE || canWrite == TRUE);
|
ASSERT(canRead == true || canWrite == true);
|
||||||
|
|
||||||
m_data = (int8_t*)memory;
|
m_data = (int8_t*)memory;
|
||||||
m_ownData = assumeOwnershipOfMemory;
|
m_ownData = assumeOwnershipOfMemory;
|
||||||
|
@ -56,7 +56,7 @@ BOOL MemoryFile::Open(const void *memory, size_t numBytes, BOOL canRead, BOOL ca
|
||||||
m_canRead = canRead;
|
m_canRead = canRead;
|
||||||
m_canWrite = canWrite;
|
m_canWrite = canWrite;
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MemoryFile::Close()
|
void MemoryFile::Close()
|
||||||
|
@ -70,11 +70,11 @@ void MemoryFile::Close()
|
||||||
LOG_INFO(LOGCAT_FILEIO, "Free MemoryFile \"%s\"\n", m_filename.c_str());
|
LOG_INFO(LOGCAT_FILEIO, "Free MemoryFile \"%s\"\n", m_filename.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
m_ownData = FALSE;
|
m_ownData = false;
|
||||||
m_length = 0;
|
m_length = 0;
|
||||||
m_position = 0;
|
m_position = 0;
|
||||||
m_canRead = FALSE;
|
m_canRead = false;
|
||||||
m_canWrite = FALSE;
|
m_canWrite = false;
|
||||||
m_filename.clear();
|
m_filename.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -352,7 +352,7 @@ void MemoryFile::Seek(size_t offset, FileSeek from)
|
||||||
m_position += offset;
|
m_position += offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL MemoryFile::AtEOF()
|
bool MemoryFile::AtEOF()
|
||||||
{
|
{
|
||||||
ASSERT(IsOpen());
|
ASSERT(IsOpen());
|
||||||
return m_position >= m_length;
|
return m_position >= m_length;
|
||||||
|
|
|
@ -14,13 +14,13 @@ public:
|
||||||
MemoryFile();
|
MemoryFile();
|
||||||
virtual ~MemoryFile();
|
virtual ~MemoryFile();
|
||||||
|
|
||||||
BOOL Open(File *srcFile);
|
bool Open(File *srcFile);
|
||||||
BOOL Open(const void *memory, size_t numBytes, BOOL canRead, BOOL canWrite, BOOL assumeOwnershipOfMemory = FALSE);
|
bool Open(const void *memory, size_t numBytes, bool canRead, bool canWrite, bool assumeOwnershipOfMemory = false);
|
||||||
void Close();
|
void Close();
|
||||||
|
|
||||||
BOOL IsOpen() const { return m_data != NULL; }
|
bool IsOpen() const { return m_data != NULL; }
|
||||||
BOOL CanRead() const { return m_canRead; }
|
bool CanRead() const { return m_canRead; }
|
||||||
BOOL CanWrite() const { return m_canWrite; }
|
bool CanWrite() const { return m_canWrite; }
|
||||||
FileType GetFileType() const { return FILETYPE_MEMORY; }
|
FileType GetFileType() const { return FILETYPE_MEMORY; }
|
||||||
|
|
||||||
int8_t ReadChar();
|
int8_t ReadChar();
|
||||||
|
@ -51,7 +51,7 @@ public:
|
||||||
|
|
||||||
size_t Tell();
|
size_t Tell();
|
||||||
void Seek(size_t offset, FileSeek from);
|
void Seek(size_t offset, FileSeek from);
|
||||||
BOOL AtEOF();
|
bool AtEOF();
|
||||||
size_t GetFileSize();
|
size_t GetFileSize();
|
||||||
|
|
||||||
const stl::string& GetFilename() const { return m_filename; }
|
const stl::string& GetFilename() const { return m_filename; }
|
||||||
|
@ -60,11 +60,11 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int8_t *m_data;
|
int8_t *m_data;
|
||||||
BOOL m_ownData;
|
bool m_ownData;
|
||||||
size_t m_length;
|
size_t m_length;
|
||||||
size_t m_position;
|
size_t m_position;
|
||||||
BOOL m_canRead;
|
bool m_canRead;
|
||||||
BOOL m_canWrite;
|
bool m_canWrite;
|
||||||
stl::string m_filename;
|
stl::string m_filename;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,8 @@ SDLFile::SDLFile()
|
||||||
{
|
{
|
||||||
m_fp = NULL;
|
m_fp = NULL;
|
||||||
m_mode = 0;
|
m_mode = 0;
|
||||||
m_canRead = FALSE;
|
m_canRead = false;
|
||||||
m_canWrite = FALSE;
|
m_canWrite = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDLFile::~SDLFile()
|
SDLFile::~SDLFile()
|
||||||
|
@ -17,26 +17,26 @@ SDLFile::~SDLFile()
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL SDLFile::Open(const stl::string &filename, int mode)
|
bool SDLFile::Open(const stl::string &filename, int mode)
|
||||||
{
|
{
|
||||||
ASSERT(IsOpen() == FALSE);
|
ASSERT(IsOpen() == false);
|
||||||
m_filename = filename;
|
m_filename = filename;
|
||||||
|
|
||||||
char fopenMode[3] = { '\0', '\0', '\0' };
|
char fopenMode[3] = { '\0', '\0', '\0' };
|
||||||
if (mode & FILEMODE_READ)
|
if (mode & FILEMODE_READ)
|
||||||
{
|
{
|
||||||
fopenMode[0] = 'r';
|
fopenMode[0] = 'r';
|
||||||
m_canRead = TRUE;
|
m_canRead = true;
|
||||||
}
|
}
|
||||||
else if (mode & FILEMODE_WRITE)
|
else if (mode & FILEMODE_WRITE)
|
||||||
{
|
{
|
||||||
fopenMode[0] = 'w';
|
fopenMode[0] = 'w';
|
||||||
m_canWrite = TRUE;
|
m_canWrite = true;
|
||||||
}
|
}
|
||||||
else if (mode & FILEMODE_APPEND)
|
else if (mode & FILEMODE_APPEND)
|
||||||
{
|
{
|
||||||
fopenMode[0] = 'a';
|
fopenMode[0] = 'a';
|
||||||
m_canWrite = TRUE;
|
m_canWrite = true;
|
||||||
}
|
}
|
||||||
if (mode & FILEMODE_BINARY && fopenMode[0] != '\0')
|
if (mode & FILEMODE_BINARY && fopenMode[0] != '\0')
|
||||||
fopenMode[1] = 'b';
|
fopenMode[1] = 'b';
|
||||||
|
@ -44,23 +44,23 @@ BOOL SDLFile::Open(const stl::string &filename, int mode)
|
||||||
if (fopenMode[0] == '\0')
|
if (fopenMode[0] == '\0')
|
||||||
{
|
{
|
||||||
ASSERT(!"Unrecognized mode.");
|
ASSERT(!"Unrecognized mode.");
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ASSERT(m_canRead == TRUE || m_canWrite == TRUE);
|
ASSERT(m_canRead == true || m_canWrite == true);
|
||||||
|
|
||||||
m_fp = SDL_RWFromFile(filename.c_str(), fopenMode);
|
m_fp = SDL_RWFromFile(filename.c_str(), fopenMode);
|
||||||
if (m_fp)
|
if (m_fp)
|
||||||
{
|
{
|
||||||
LOG_INFO(LOGCAT_FILEIO, "Opened SDLFile \"%s\", mode = %s\n", filename.c_str(), fopenMode);
|
LOG_INFO(LOGCAT_FILEIO, "Opened SDLFile \"%s\", mode = %s\n", filename.c_str(), fopenMode);
|
||||||
m_mode = mode;
|
m_mode = mode;
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LOG_WARN(LOGCAT_FILEIO, "Failed to open SDLFile \"%s\", mode = %s\n", filename.c_str(), fopenMode);
|
LOG_WARN(LOGCAT_FILEIO, "Failed to open SDLFile \"%s\", mode = %s\n", filename.c_str(), fopenMode);
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,8 +75,8 @@ void SDLFile::Close()
|
||||||
|
|
||||||
m_fp = NULL;
|
m_fp = NULL;
|
||||||
m_mode = 0;
|
m_mode = 0;
|
||||||
m_canRead = FALSE;
|
m_canRead = false;
|
||||||
m_canWrite = FALSE;
|
m_canWrite = false;
|
||||||
m_filename.clear();
|
m_filename.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -329,15 +329,15 @@ void SDLFile::Seek(size_t offset, FileSeek from)
|
||||||
SDL_RWseek(m_fp, offset, origin);
|
SDL_RWseek(m_fp, offset, origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL SDLFile::AtEOF()
|
bool SDLFile::AtEOF()
|
||||||
{
|
{
|
||||||
ASSERT(IsOpen());
|
ASSERT(IsOpen());
|
||||||
size_t filesize = GetFileSize();
|
size_t filesize = GetFileSize();
|
||||||
size_t currentPos = Tell();
|
size_t currentPos = Tell();
|
||||||
if (filesize == currentPos)
|
if (filesize == currentPos)
|
||||||
return TRUE;
|
return true;
|
||||||
else
|
else
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t SDLFile::GetFileSize()
|
size_t SDLFile::GetFileSize()
|
||||||
|
|
|
@ -14,12 +14,12 @@ public:
|
||||||
SDLFile();
|
SDLFile();
|
||||||
virtual ~SDLFile();
|
virtual ~SDLFile();
|
||||||
|
|
||||||
BOOL Open(const stl::string &filename, int mode);
|
bool Open(const stl::string &filename, int mode);
|
||||||
void Close();
|
void Close();
|
||||||
|
|
||||||
BOOL IsOpen() const { return m_fp != NULL; }
|
bool IsOpen() const { return m_fp != NULL; }
|
||||||
BOOL CanRead() const { return m_canRead; }
|
bool CanRead() const { return m_canRead; }
|
||||||
BOOL CanWrite() const { return m_canWrite; }
|
bool CanWrite() const { return m_canWrite; }
|
||||||
FileType GetFileType() const { return FILETYPE_IO; }
|
FileType GetFileType() const { return FILETYPE_IO; }
|
||||||
|
|
||||||
int8_t ReadChar();
|
int8_t ReadChar();
|
||||||
|
@ -50,7 +50,7 @@ public:
|
||||||
|
|
||||||
size_t Tell();
|
size_t Tell();
|
||||||
void Seek(size_t offset, FileSeek from);
|
void Seek(size_t offset, FileSeek from);
|
||||||
BOOL AtEOF();
|
bool AtEOF();
|
||||||
size_t GetFileSize();
|
size_t GetFileSize();
|
||||||
|
|
||||||
const stl::string& GetFilename() const { return m_filename; }
|
const stl::string& GetFilename() const { return m_filename; }
|
||||||
|
@ -58,8 +58,8 @@ public:
|
||||||
private:
|
private:
|
||||||
SDL_RWops *m_fp;
|
SDL_RWops *m_fp;
|
||||||
int m_mode;
|
int m_mode;
|
||||||
BOOL m_canRead;
|
bool m_canRead;
|
||||||
BOOL m_canWrite;
|
bool m_canWrite;
|
||||||
stl::string m_filename;
|
stl::string m_filename;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ struct OSEvent;
|
||||||
|
|
||||||
struct GameWindowParams
|
struct GameWindowParams
|
||||||
{
|
{
|
||||||
BOOL windowed;
|
bool windowed;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,23 +30,23 @@ public:
|
||||||
/**
|
/**
|
||||||
* Creates the game window.
|
* Creates the game window.
|
||||||
* @param params platform specific window creation parameters
|
* @param params platform specific window creation parameters
|
||||||
* @return TRUE if successful, FALSE if not
|
* @return true if successful, false if not
|
||||||
*/
|
*/
|
||||||
virtual BOOL Create(GameWindowParams *params) = 0;
|
virtual bool Create(GameWindowParams *params) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resizes the window to the given dimensions.
|
* Resizes the window to the given dimensions.
|
||||||
* @param width the new window width
|
* @param width the new window width
|
||||||
* @param height the new window height
|
* @param height the new window height
|
||||||
* @return TRUE if successful, FALSE if not
|
* @return true if successful, false if not
|
||||||
*/
|
*/
|
||||||
virtual BOOL Resize(uint width, uint height) = 0;
|
virtual bool Resize(uint width, uint height) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Toggles between fullscreen and windowed mode.
|
* Toggles between fullscreen and windowed mode.
|
||||||
* @return TRUE if successful, FALSE if not
|
* @return true if successful, false if not
|
||||||
*/
|
*/
|
||||||
virtual BOOL ToggleFullscreen() = 0;
|
virtual bool ToggleFullscreen() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Signals to the underlying system that the window should be closed
|
* Signals to the underlying system that the window should be closed
|
||||||
|
@ -75,9 +75,9 @@ public:
|
||||||
virtual uint GetBPP() const = 0;
|
virtual uint GetBPP() const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return TRUE if the current window is windowed, FALSE if fullscreen
|
* @return true if the current window is windowed, false if fullscreen
|
||||||
*/
|
*/
|
||||||
virtual BOOL IsWindowed() const = 0;
|
virtual bool IsWindowed() const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the current display rotation angle
|
* @return the current display rotation angle
|
||||||
|
@ -85,24 +85,24 @@ public:
|
||||||
virtual SCREEN_ORIENTATION_ANGLE GetScreenOrientation() const = 0;
|
virtual SCREEN_ORIENTATION_ANGLE GetScreenOrientation() const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return TRUE if this window is the currently active one
|
* @return true if this window is the currently active one
|
||||||
*/
|
*/
|
||||||
virtual BOOL IsActive() const = 0;
|
virtual bool IsActive() const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return TRUE if this window currently is active and has input focus
|
* @return true if this window currently is active and has input focus
|
||||||
*/
|
*/
|
||||||
virtual BOOL IsFocused() const = 0;
|
virtual bool IsFocused() const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return TRUE if the window has been signaled that it should close
|
* @return true if the window has been signaled that it should close
|
||||||
*/
|
*/
|
||||||
virtual BOOL IsClosing() const = 0;
|
virtual bool IsClosing() const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return TRUe if the window currently has an active and usable OpenGL context associated with it
|
* @return TRUe if the window currently has an active and usable OpenGL context associated with it
|
||||||
*/
|
*/
|
||||||
virtual BOOL HasGLContext() const = 0;
|
virtual bool HasGLContext() const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs platform specific processing for an event raised by the operating system.
|
* Performs platform specific processing for an event raised by the operating system.
|
||||||
|
|
|
@ -54,10 +54,10 @@ BillboardSpriteBatch::BillboardSpriteBatch(GraphicsDevice *graphicsDevice)
|
||||||
m_blendState = new BLENDSTATE_ALPHABLEND;
|
m_blendState = new BLENDSTATE_ALPHABLEND;
|
||||||
ASSERT(m_blendState != NULL);
|
ASSERT(m_blendState != NULL);
|
||||||
|
|
||||||
m_begunRendering = FALSE;
|
m_begunRendering = false;
|
||||||
|
|
||||||
m_isRenderStateOverridden = FALSE;
|
m_isRenderStateOverridden = false;
|
||||||
m_isBlendStateOverridden = FALSE;
|
m_isBlendStateOverridden = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
BillboardSpriteBatch::~BillboardSpriteBatch()
|
BillboardSpriteBatch::~BillboardSpriteBatch()
|
||||||
|
@ -69,7 +69,7 @@ BillboardSpriteBatch::~BillboardSpriteBatch()
|
||||||
|
|
||||||
void BillboardSpriteBatch::InternalBegin(const RenderState *renderState, const BlendState *blendState, SpriteShader *shader)
|
void BillboardSpriteBatch::InternalBegin(const RenderState *renderState, const BlendState *blendState, SpriteShader *shader)
|
||||||
{
|
{
|
||||||
ASSERT(m_begunRendering == FALSE);
|
ASSERT(m_begunRendering == false);
|
||||||
|
|
||||||
m_cameraPosition = m_graphicsDevice->GetViewContext()->GetCamera()->GetPosition();
|
m_cameraPosition = m_graphicsDevice->GetViewContext()->GetCamera()->GetPosition();
|
||||||
m_cameraForward = m_graphicsDevice->GetViewContext()->GetCamera()->GetForward();
|
m_cameraForward = m_graphicsDevice->GetViewContext()->GetCamera()->GetForward();
|
||||||
|
@ -78,28 +78,28 @@ void BillboardSpriteBatch::InternalBegin(const RenderState *renderState, const B
|
||||||
m_shader = m_graphicsDevice->GetSprite3DShader();
|
m_shader = m_graphicsDevice->GetSprite3DShader();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ASSERT(shader->IsReadyForUse() == TRUE);
|
ASSERT(shader->IsReadyForUse() == true);
|
||||||
m_shader = shader;
|
m_shader = shader;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (renderState != NULL)
|
if (renderState != NULL)
|
||||||
{
|
{
|
||||||
m_isRenderStateOverridden = TRUE;
|
m_isRenderStateOverridden = true;
|
||||||
m_overrideRenderState = *renderState;
|
m_overrideRenderState = *renderState;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_isRenderStateOverridden = FALSE;
|
m_isRenderStateOverridden = false;
|
||||||
|
|
||||||
if (blendState != NULL)
|
if (blendState != NULL)
|
||||||
{
|
{
|
||||||
m_isBlendStateOverridden = TRUE;
|
m_isBlendStateOverridden = true;
|
||||||
m_overrideBlendState = *blendState;
|
m_overrideBlendState = *blendState;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_isBlendStateOverridden = FALSE;
|
m_isBlendStateOverridden = false;
|
||||||
|
|
||||||
m_currentSpritePointer = 0;
|
m_currentSpritePointer = 0;
|
||||||
m_begunRendering = TRUE;
|
m_begunRendering = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BillboardSpriteBatch::Begin(SpriteShader *shader)
|
void BillboardSpriteBatch::Begin(SpriteShader *shader)
|
||||||
|
@ -224,7 +224,7 @@ void BillboardSpriteBatch::Printf(const SpriteFont *font, const Vector3 &positio
|
||||||
|
|
||||||
void BillboardSpriteBatch::AddSprite(BILLBOARDSPRITE_TYPE type, const Texture *texture, const Vector3 &position, float width, float height, uint sourceLeft, uint sourceTop, uint sourceRight, uint sourceBottom, const Color &color)
|
void BillboardSpriteBatch::AddSprite(BILLBOARDSPRITE_TYPE type, const Texture *texture, const Vector3 &position, float width, float height, uint sourceLeft, uint sourceTop, uint sourceRight, uint sourceBottom, const Color &color)
|
||||||
{
|
{
|
||||||
ASSERT(m_begunRendering == TRUE);
|
ASSERT(m_begunRendering == true);
|
||||||
Matrix4x4 transform = GetTransformFor(type, position);
|
Matrix4x4 transform = GetTransformFor(type, position);
|
||||||
|
|
||||||
// zero vector offset as the transform will translate the billboard to
|
// zero vector offset as the transform will translate the billboard to
|
||||||
|
@ -234,7 +234,7 @@ void BillboardSpriteBatch::AddSprite(BILLBOARDSPRITE_TYPE type, const Texture *t
|
||||||
|
|
||||||
void BillboardSpriteBatch::AddSprite(BILLBOARDSPRITE_TYPE type, const Texture *texture, const Vector3 &position, float width, float height, float texCoordLeft, float texCoordTop, float texCoordRight, float texCoordBottom, const Color &color)
|
void BillboardSpriteBatch::AddSprite(BILLBOARDSPRITE_TYPE type, const Texture *texture, const Vector3 &position, float width, float height, float texCoordLeft, float texCoordTop, float texCoordRight, float texCoordBottom, const Color &color)
|
||||||
{
|
{
|
||||||
ASSERT(m_begunRendering == TRUE);
|
ASSERT(m_begunRendering == true);
|
||||||
Matrix4x4 transform = GetTransformFor(type, position);
|
Matrix4x4 transform = GetTransformFor(type, position);
|
||||||
|
|
||||||
// zero vector offset as the transform will translate the billboard to
|
// zero vector offset as the transform will translate the billboard to
|
||||||
|
@ -244,7 +244,7 @@ void BillboardSpriteBatch::AddSprite(BILLBOARDSPRITE_TYPE type, const Texture *t
|
||||||
|
|
||||||
void BillboardSpriteBatch::AddSprite(BILLBOARDSPRITE_TYPE type, const Matrix4x4 &transform, const Texture *texture, const Vector3 &offset, float width, float height, uint sourceLeft, uint sourceTop, uint sourceRight, uint sourceBottom, const Color &color)
|
void BillboardSpriteBatch::AddSprite(BILLBOARDSPRITE_TYPE type, const Matrix4x4 &transform, const Texture *texture, const Vector3 &offset, float width, float height, uint sourceLeft, uint sourceTop, uint sourceRight, uint sourceBottom, const Color &color)
|
||||||
{
|
{
|
||||||
ASSERT(m_begunRendering == TRUE);
|
ASSERT(m_begunRendering == true);
|
||||||
|
|
||||||
uint sourceWidth = sourceRight - sourceLeft;
|
uint sourceWidth = sourceRight - sourceLeft;
|
||||||
ASSERT(sourceWidth > 0);
|
ASSERT(sourceWidth > 0);
|
||||||
|
@ -262,7 +262,7 @@ void BillboardSpriteBatch::AddSprite(BILLBOARDSPRITE_TYPE type, const Matrix4x4
|
||||||
|
|
||||||
void BillboardSpriteBatch::AddSprite(BILLBOARDSPRITE_TYPE type, const Matrix4x4 &transform, const Texture *texture, const Vector3 &offset, float width, float height, float texCoordLeft, float texCoordTop, float texCoordRight, float texCoordBottom, const Color &color)
|
void BillboardSpriteBatch::AddSprite(BILLBOARDSPRITE_TYPE type, const Matrix4x4 &transform, const Texture *texture, const Vector3 &offset, float width, float height, float texCoordLeft, float texCoordTop, float texCoordRight, float texCoordBottom, const Color &color)
|
||||||
{
|
{
|
||||||
ASSERT(m_begunRendering == TRUE);
|
ASSERT(m_begunRendering == true);
|
||||||
CheckForNewSpriteSpace();
|
CheckForNewSpriteSpace();
|
||||||
SetSpriteInfo(m_currentSpritePointer, type, transform, texture, offset, width, height, texCoordLeft, texCoordTop, texCoordRight, texCoordBottom, color);
|
SetSpriteInfo(m_currentSpritePointer, type, transform, texture, offset, width, height, texCoordLeft, texCoordTop, texCoordRight, texCoordBottom, color);
|
||||||
++m_currentSpritePointer;
|
++m_currentSpritePointer;
|
||||||
|
@ -318,7 +318,7 @@ void BillboardSpriteBatch::SetSpriteInfo(uint spriteIndex, BILLBOARDSPRITE_TYPE
|
||||||
|
|
||||||
void BillboardSpriteBatch::End()
|
void BillboardSpriteBatch::End()
|
||||||
{
|
{
|
||||||
ASSERT(m_begunRendering == TRUE);
|
ASSERT(m_begunRendering == true);
|
||||||
|
|
||||||
if (m_isRenderStateOverridden)
|
if (m_isRenderStateOverridden)
|
||||||
m_overrideRenderState.Apply();
|
m_overrideRenderState.Apply();
|
||||||
|
@ -335,7 +335,7 @@ void BillboardSpriteBatch::End()
|
||||||
RenderQueue();
|
RenderQueue();
|
||||||
m_graphicsDevice->UnbindShader();
|
m_graphicsDevice->UnbindShader();
|
||||||
|
|
||||||
m_begunRendering = FALSE;
|
m_begunRendering = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BillboardSpriteBatch::RenderQueue()
|
void BillboardSpriteBatch::RenderQueue()
|
||||||
|
|
|
@ -201,9 +201,9 @@ private:
|
||||||
SpriteShader *m_shader;
|
SpriteShader *m_shader;
|
||||||
RenderState *m_renderState;
|
RenderState *m_renderState;
|
||||||
BlendState *m_blendState;
|
BlendState *m_blendState;
|
||||||
BOOL m_isRenderStateOverridden;
|
bool m_isRenderStateOverridden;
|
||||||
RenderState m_overrideRenderState;
|
RenderState m_overrideRenderState;
|
||||||
BOOL m_isBlendStateOverridden;
|
bool m_isBlendStateOverridden;
|
||||||
BlendState m_overrideBlendState;
|
BlendState m_overrideBlendState;
|
||||||
VertexBuffer *m_vertices;
|
VertexBuffer *m_vertices;
|
||||||
stl::vector<const Texture*> m_textures;
|
stl::vector<const Texture*> m_textures;
|
||||||
|
@ -212,7 +212,7 @@ private:
|
||||||
Vector3 m_cameraPosition;
|
Vector3 m_cameraPosition;
|
||||||
Vector3 m_cameraForward;
|
Vector3 m_cameraForward;
|
||||||
|
|
||||||
BOOL m_begunRendering;
|
bool m_begunRendering;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -12,7 +12,7 @@ BlendState::BlendState(BLEND_FACTOR sourceFactor, BLEND_FACTOR destinationFactor
|
||||||
{
|
{
|
||||||
Initialize();
|
Initialize();
|
||||||
|
|
||||||
m_blending = TRUE;
|
m_blending = true;
|
||||||
m_sourceBlendFactor = sourceFactor;
|
m_sourceBlendFactor = sourceFactor;
|
||||||
m_destBlendFactor = destinationFactor;
|
m_destBlendFactor = destinationFactor;
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ BlendState::~BlendState()
|
||||||
|
|
||||||
void BlendState::Initialize()
|
void BlendState::Initialize()
|
||||||
{
|
{
|
||||||
m_blending = FALSE;
|
m_blending = false;
|
||||||
m_sourceBlendFactor = ONE;
|
m_sourceBlendFactor = ONE;
|
||||||
m_destBlendFactor = ZERO;
|
m_destBlendFactor = ZERO;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,9 +47,9 @@ public:
|
||||||
void Apply() const;
|
void Apply() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return TRUE if blending is enabled
|
* @return true if blending is enabled
|
||||||
*/
|
*/
|
||||||
BOOL GetBlending() const { return m_blending; }
|
bool GetBlending() const { return m_blending; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the source blending factor
|
* @return the source blending factor
|
||||||
|
@ -64,7 +64,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Toggles blending on/off.
|
* Toggles blending on/off.
|
||||||
*/
|
*/
|
||||||
void SetBlending(BOOL enable) { m_blending = enable; }
|
void SetBlending(bool enable) { m_blending = enable; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the source blending factor.
|
* Sets the source blending factor.
|
||||||
|
@ -80,7 +80,7 @@ private:
|
||||||
void Initialize();
|
void Initialize();
|
||||||
int FindBlendFactorValue(BLEND_FACTOR factor) const;
|
int FindBlendFactorValue(BLEND_FACTOR factor) const;
|
||||||
|
|
||||||
BOOL m_blending;
|
bool m_blending;
|
||||||
BLEND_FACTOR m_sourceBlendFactor;
|
BLEND_FACTOR m_sourceBlendFactor;
|
||||||
BLEND_FACTOR m_destBlendFactor;
|
BLEND_FACTOR m_destBlendFactor;
|
||||||
};
|
};
|
||||||
|
|
|
@ -9,7 +9,7 @@ BufferObject::BufferObject()
|
||||||
m_type = BUFFEROBJECT_TYPE_VERTEX;
|
m_type = BUFFEROBJECT_TYPE_VERTEX;
|
||||||
m_usage = BUFFEROBJECT_USAGE_STATIC;
|
m_usage = BUFFEROBJECT_USAGE_STATIC;
|
||||||
m_bufferId = 0;
|
m_bufferId = 0;
|
||||||
m_isDirty = FALSE;
|
m_isDirty = false;
|
||||||
m_sizeInBytes = 0;
|
m_sizeInBytes = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,15 +21,15 @@ void BufferObject::Release()
|
||||||
m_type = BUFFEROBJECT_TYPE_VERTEX;
|
m_type = BUFFEROBJECT_TYPE_VERTEX;
|
||||||
m_usage = BUFFEROBJECT_USAGE_STATIC;
|
m_usage = BUFFEROBJECT_USAGE_STATIC;
|
||||||
m_bufferId = 0;
|
m_bufferId = 0;
|
||||||
m_isDirty = FALSE;
|
m_isDirty = false;
|
||||||
m_sizeInBytes = 0;
|
m_sizeInBytes = 0;
|
||||||
|
|
||||||
GraphicsContextResource::Release();
|
GraphicsContextResource::Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL BufferObject::Initialize(GraphicsDevice *graphicsDevice, BUFFEROBJECT_TYPE type, BUFFEROBJECT_USAGE usage)
|
bool BufferObject::Initialize(GraphicsDevice *graphicsDevice, BUFFEROBJECT_TYPE type, BUFFEROBJECT_USAGE usage)
|
||||||
{
|
{
|
||||||
BOOL success = TRUE;
|
bool success = true;
|
||||||
if (graphicsDevice != NULL)
|
if (graphicsDevice != NULL)
|
||||||
success = GraphicsContextResource::Initialize(graphicsDevice);
|
success = GraphicsContextResource::Initialize(graphicsDevice);
|
||||||
else
|
else
|
||||||
|
@ -43,20 +43,20 @@ BOOL BufferObject::Initialize(GraphicsDevice *graphicsDevice, BUFFEROBJECT_TYPE
|
||||||
|
|
||||||
void BufferObject::CreateOnGpu()
|
void BufferObject::CreateOnGpu()
|
||||||
{
|
{
|
||||||
ASSERT(IsClientSideBuffer() == TRUE);
|
ASSERT(IsClientSideBuffer() == true);
|
||||||
CreateBufferObject();
|
CreateBufferObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferObject::RecreateOnGpu()
|
void BufferObject::RecreateOnGpu()
|
||||||
{
|
{
|
||||||
ASSERT(IsClientSideBuffer() == FALSE);
|
ASSERT(IsClientSideBuffer() == false);
|
||||||
FreeBufferObject();
|
FreeBufferObject();
|
||||||
CreateBufferObject();
|
CreateBufferObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferObject::FreeFromGpu()
|
void BufferObject::FreeFromGpu()
|
||||||
{
|
{
|
||||||
ASSERT(IsClientSideBuffer() == FALSE);
|
ASSERT(IsClientSideBuffer() == false);
|
||||||
FreeBufferObject();
|
FreeBufferObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ void BufferObject::CreateBufferObject()
|
||||||
GL_CALL(glGenBuffers(1, &m_bufferId));
|
GL_CALL(glGenBuffers(1, &m_bufferId));
|
||||||
SizeBufferObject();
|
SizeBufferObject();
|
||||||
|
|
||||||
m_isDirty = TRUE;
|
m_isDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferObject::FreeBufferObject()
|
void BufferObject::FreeBufferObject()
|
||||||
|
@ -74,14 +74,14 @@ void BufferObject::FreeBufferObject()
|
||||||
GL_CALL(glDeleteBuffers(1, &m_bufferId));
|
GL_CALL(glDeleteBuffers(1, &m_bufferId));
|
||||||
|
|
||||||
m_bufferId = 0;
|
m_bufferId = 0;
|
||||||
m_isDirty = FALSE;
|
m_isDirty = false;
|
||||||
m_sizeInBytes = 0;
|
m_sizeInBytes = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferObject::Update()
|
void BufferObject::Update()
|
||||||
{
|
{
|
||||||
ASSERT(IsClientSideBuffer() == FALSE);
|
ASSERT(IsClientSideBuffer() == false);
|
||||||
ASSERT(IsDirty() == TRUE);
|
ASSERT(IsDirty() == true);
|
||||||
ASSERT(GetNumElements() > 0);
|
ASSERT(GetNumElements() > 0);
|
||||||
ASSERT(GetElementWidthInBytes() > 0);
|
ASSERT(GetElementWidthInBytes() > 0);
|
||||||
|
|
||||||
|
@ -128,12 +128,12 @@ void BufferObject::Update()
|
||||||
|
|
||||||
GL_CALL(glBindBuffer(target, 0));
|
GL_CALL(glBindBuffer(target, 0));
|
||||||
|
|
||||||
m_isDirty = FALSE;
|
m_isDirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferObject::SizeBufferObject()
|
void BufferObject::SizeBufferObject()
|
||||||
{
|
{
|
||||||
ASSERT(IsClientSideBuffer() == FALSE);
|
ASSERT(IsClientSideBuffer() == false);
|
||||||
ASSERT(GetNumElements() > 0);
|
ASSERT(GetNumElements() > 0);
|
||||||
ASSERT(GetElementWidthInBytes() > 0);
|
ASSERT(GetElementWidthInBytes() > 0);
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ void BufferObject::SizeBufferObject()
|
||||||
GL_CALL(glBufferData(target, m_sizeInBytes, NULL, usage));
|
GL_CALL(glBufferData(target, m_sizeInBytes, NULL, usage));
|
||||||
GL_CALL(glBindBuffer(target, 0));
|
GL_CALL(glBindBuffer(target, 0));
|
||||||
|
|
||||||
m_isDirty = TRUE;
|
m_isDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferObject::OnNewContext()
|
void BufferObject::OnNewContext()
|
||||||
|
|
|
@ -32,10 +32,10 @@ public:
|
||||||
virtual void Release();
|
virtual void Release();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return TRUE if this buffer object is holding client side data only
|
* @return true if this buffer object is holding client side data only
|
||||||
* (hasn't been created as a buffer object in video memory)
|
* (hasn't been created as a buffer object in video memory)
|
||||||
*/
|
*/
|
||||||
BOOL IsClientSideBuffer() const { return m_bufferId == 0; }
|
bool IsClientSideBuffer() const { return m_bufferId == 0; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the type of data this buffer holds
|
* @return the type of data this buffer holds
|
||||||
|
@ -63,10 +63,10 @@ public:
|
||||||
virtual size_t GetElementWidthInBytes() const = 0;
|
virtual size_t GetElementWidthInBytes() const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return TRUE if some or all of the buffer data has been changed since
|
* @return true if some or all of the buffer data has been changed since
|
||||||
* the last Update() call
|
* the last Update() call
|
||||||
*/
|
*/
|
||||||
BOOL IsDirty() const { return m_isDirty; }
|
bool IsDirty() const { return m_isDirty; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uploads the current buffer data to video memory.
|
* Uploads the current buffer data to video memory.
|
||||||
|
@ -94,7 +94,7 @@ protected:
|
||||||
* will be stored in it
|
* will be stored in it
|
||||||
* @param usage the expected usage pattern of this buffer object
|
* @param usage the expected usage pattern of this buffer object
|
||||||
*/
|
*/
|
||||||
BOOL Initialize(GraphicsDevice *graphicsDevice, BUFFEROBJECT_TYPE type, BUFFEROBJECT_USAGE usage);
|
bool Initialize(GraphicsDevice *graphicsDevice, BUFFEROBJECT_TYPE type, BUFFEROBJECT_USAGE usage);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a buffer object on the GPU but does not upload this
|
* Creates a buffer object on the GPU but does not upload this
|
||||||
|
@ -118,14 +118,14 @@ protected:
|
||||||
void CreateBufferObject();
|
void CreateBufferObject();
|
||||||
void FreeBufferObject();
|
void FreeBufferObject();
|
||||||
void SizeBufferObject();
|
void SizeBufferObject();
|
||||||
void SetDirty() { m_isDirty = TRUE; }
|
void SetDirty() { m_isDirty = true; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
BUFFEROBJECT_TYPE m_type;
|
BUFFEROBJECT_TYPE m_type;
|
||||||
BUFFEROBJECT_USAGE m_usage;
|
BUFFEROBJECT_USAGE m_usage;
|
||||||
uint m_bufferId;
|
uint m_bufferId;
|
||||||
BOOL m_isDirty;
|
bool m_isDirty;
|
||||||
size_t m_sizeInBytes;
|
size_t m_sizeInBytes;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -10,27 +10,27 @@ CustomSpriteShader::~CustomSpriteShader()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL CustomSpriteShader::Initialize(GraphicsDevice *graphicsDevice, const char *vertexShaderSource, const char *fragmentShaderSource)
|
bool CustomSpriteShader::Initialize(GraphicsDevice *graphicsDevice, const char *vertexShaderSource, const char *fragmentShaderSource)
|
||||||
{
|
{
|
||||||
if (!SpriteShader::Initialize(graphicsDevice, vertexShaderSource, fragmentShaderSource))
|
if (!SpriteShader::Initialize(graphicsDevice, vertexShaderSource, fragmentShaderSource))
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
ASSERT(HasUniform(GetModelViewMatrixUniform()) == TRUE);
|
ASSERT(HasUniform(GetModelViewMatrixUniform()) == true);
|
||||||
ASSERT(HasUniform(GetProjectionMatrixUniform()) == TRUE);
|
ASSERT(HasUniform(GetProjectionMatrixUniform()) == true);
|
||||||
ASSERT(HasUniform(GetTextureHasAlphaOnlyUniform()) == TRUE);
|
ASSERT(HasUniform(GetTextureHasAlphaOnlyUniform()) == true);
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL CustomSpriteShader::Initialize(GraphicsDevice *graphicsDevice, const Text *vertexShaderSource, const Text *fragmentShaderSource)
|
bool CustomSpriteShader::Initialize(GraphicsDevice *graphicsDevice, const Text *vertexShaderSource, const Text *fragmentShaderSource)
|
||||||
{
|
{
|
||||||
if (!SpriteShader::Initialize(graphicsDevice, vertexShaderSource, fragmentShaderSource))
|
if (!SpriteShader::Initialize(graphicsDevice, vertexShaderSource, fragmentShaderSource))
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
ASSERT(HasUniform(GetModelViewMatrixUniform()) == TRUE);
|
ASSERT(HasUniform(GetModelViewMatrixUniform()) == true);
|
||||||
ASSERT(HasUniform(GetProjectionMatrixUniform()) == TRUE);
|
ASSERT(HasUniform(GetProjectionMatrixUniform()) == true);
|
||||||
ASSERT(HasUniform(GetTextureHasAlphaOnlyUniform()) == TRUE);
|
ASSERT(HasUniform(GetTextureHasAlphaOnlyUniform()) == true);
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,9 +22,9 @@ public:
|
||||||
* @param graphicsDevice the graphics device to associate this shader with
|
* @param graphicsDevice the graphics device to associate this shader with
|
||||||
* @param vertexShaderSource GLSL source for a vertex shader
|
* @param vertexShaderSource GLSL source for a vertex shader
|
||||||
* @param fragmentShaderSource GLSL source for a vertex shader
|
* @param fragmentShaderSource GLSL source for a vertex shader
|
||||||
* @return TRUE if successful, FALSE if not
|
* @return true if successful, false if not
|
||||||
*/
|
*/
|
||||||
BOOL Initialize(GraphicsDevice *graphicsDevice, const char *vertexShaderSource, const char *fragmentShaderSource);
|
bool Initialize(GraphicsDevice *graphicsDevice, const char *vertexShaderSource, const char *fragmentShaderSource);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the shader object for rendering sprites using the given vertex
|
* Initializes the shader object for rendering sprites using the given vertex
|
||||||
|
@ -32,9 +32,9 @@ public:
|
||||||
* @param graphicsDevice the graphics device to associate this shader with
|
* @param graphicsDevice the graphics device to associate this shader with
|
||||||
* @param vertexShaderSource GLSL source for a vertex shader
|
* @param vertexShaderSource GLSL source for a vertex shader
|
||||||
* @param fragmentShaderSource GLSL source for a vertex shader
|
* @param fragmentShaderSource GLSL source for a vertex shader
|
||||||
* @return TRUE if successful, FALSE if not
|
* @return true if successful, false if not
|
||||||
*/
|
*/
|
||||||
BOOL Initialize(GraphicsDevice *graphicsDevice, const Text *vertexShaderSource, const Text *fragmentShaderSource);
|
bool Initialize(GraphicsDevice *graphicsDevice, const Text *vertexShaderSource, const Text *fragmentShaderSource);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -10,24 +10,24 @@ CustomStandardShader::~CustomStandardShader()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL CustomStandardShader::Initialize(GraphicsDevice *graphicsDevice, const char *vertexShaderSource, const char *fragmentShaderSource)
|
bool CustomStandardShader::Initialize(GraphicsDevice *graphicsDevice, const char *vertexShaderSource, const char *fragmentShaderSource)
|
||||||
{
|
{
|
||||||
if (!StandardShader::Initialize(graphicsDevice, vertexShaderSource, fragmentShaderSource))
|
if (!StandardShader::Initialize(graphicsDevice, vertexShaderSource, fragmentShaderSource))
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
ASSERT(HasUniform(GetModelViewMatrixUniform()) == TRUE);
|
ASSERT(HasUniform(GetModelViewMatrixUniform()) == true);
|
||||||
ASSERT(HasUniform(GetProjectionMatrixUniform()) == TRUE);
|
ASSERT(HasUniform(GetProjectionMatrixUniform()) == true);
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL CustomStandardShader::Initialize(GraphicsDevice *graphicsDevice, const Text *vertexShaderSource, const Text *fragmentShaderSource)
|
bool CustomStandardShader::Initialize(GraphicsDevice *graphicsDevice, const Text *vertexShaderSource, const Text *fragmentShaderSource)
|
||||||
{
|
{
|
||||||
if (!StandardShader::Initialize(graphicsDevice, vertexShaderSource, fragmentShaderSource))
|
if (!StandardShader::Initialize(graphicsDevice, vertexShaderSource, fragmentShaderSource))
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
ASSERT(HasUniform(GetModelViewMatrixUniform()) == TRUE);
|
ASSERT(HasUniform(GetModelViewMatrixUniform()) == true);
|
||||||
ASSERT(HasUniform(GetProjectionMatrixUniform()) == TRUE);
|
ASSERT(HasUniform(GetProjectionMatrixUniform()) == true);
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,9 +21,9 @@ public:
|
||||||
* @param graphicsDevice the graphics device to associate this shader with
|
* @param graphicsDevice the graphics device to associate this shader with
|
||||||
* @param vertexShaderSource GLSL source for a vertex shader
|
* @param vertexShaderSource GLSL source for a vertex shader
|
||||||
* @param fragmentShaderSource GLSL source for a vertex shader
|
* @param fragmentShaderSource GLSL source for a vertex shader
|
||||||
* @return TRUE if successful, FALSE if not
|
* @return true if successful, false if not
|
||||||
*/
|
*/
|
||||||
BOOL Initialize(GraphicsDevice *graphicsDevice, const char *vertexShaderSource, const char *fragmentShaderSource);
|
bool Initialize(GraphicsDevice *graphicsDevice, const char *vertexShaderSource, const char *fragmentShaderSource);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the shader object using the given vertex and fragment shader
|
* Initializes the shader object using the given vertex and fragment shader
|
||||||
|
@ -31,9 +31,9 @@ public:
|
||||||
* @param graphicsDevice the graphics device to associate this shader with
|
* @param graphicsDevice the graphics device to associate this shader with
|
||||||
* @param vertexShaderSource GLSL source for a vertex shader
|
* @param vertexShaderSource GLSL source for a vertex shader
|
||||||
* @param fragmentShaderSource GLSL source for a vertex shader
|
* @param fragmentShaderSource GLSL source for a vertex shader
|
||||||
* @return TRUE if successful, FALSE if not
|
* @return true if successful, false if not
|
||||||
*/
|
*/
|
||||||
BOOL Initialize(GraphicsDevice *graphicsDevice, const Text *vertexShaderSource, const Text *fragmentShaderSource);
|
bool Initialize(GraphicsDevice *graphicsDevice, const Text *vertexShaderSource, const Text *fragmentShaderSource);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -10,26 +10,26 @@ CustomVertexLerpShader::~CustomVertexLerpShader()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL CustomVertexLerpShader::Initialize(GraphicsDevice *graphicsDevice, const char *vertexShaderSource, const char *fragmentShaderSource)
|
bool CustomVertexLerpShader::Initialize(GraphicsDevice *graphicsDevice, const char *vertexShaderSource, const char *fragmentShaderSource)
|
||||||
{
|
{
|
||||||
if (!VertexLerpShader::Initialize(graphicsDevice, vertexShaderSource, fragmentShaderSource))
|
if (!VertexLerpShader::Initialize(graphicsDevice, vertexShaderSource, fragmentShaderSource))
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
ASSERT(HasUniform(GetModelViewMatrixUniform()) == TRUE);
|
ASSERT(HasUniform(GetModelViewMatrixUniform()) == true);
|
||||||
ASSERT(HasUniform(GetProjectionMatrixUniform()) == TRUE);
|
ASSERT(HasUniform(GetProjectionMatrixUniform()) == true);
|
||||||
ASSERT(HasUniform(GetLerpUniform()) == TRUE);
|
ASSERT(HasUniform(GetLerpUniform()) == true);
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL CustomVertexLerpShader::Initialize(GraphicsDevice *graphicsDevice, const Text *vertexShaderSource, const Text *fragmentShaderSource)
|
bool CustomVertexLerpShader::Initialize(GraphicsDevice *graphicsDevice, const Text *vertexShaderSource, const Text *fragmentShaderSource)
|
||||||
{
|
{
|
||||||
if (!VertexLerpShader::Initialize(graphicsDevice, vertexShaderSource, fragmentShaderSource))
|
if (!VertexLerpShader::Initialize(graphicsDevice, vertexShaderSource, fragmentShaderSource))
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
ASSERT(HasUniform(GetModelViewMatrixUniform()) == TRUE);
|
ASSERT(HasUniform(GetModelViewMatrixUniform()) == true);
|
||||||
ASSERT(HasUniform(GetProjectionMatrixUniform()) == TRUE);
|
ASSERT(HasUniform(GetProjectionMatrixUniform()) == true);
|
||||||
ASSERT(HasUniform(GetLerpUniform()) == TRUE);
|
ASSERT(HasUniform(GetLerpUniform()) == true);
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,8 @@ public:
|
||||||
CustomVertexLerpShader();
|
CustomVertexLerpShader();
|
||||||
virtual ~CustomVertexLerpShader();
|
virtual ~CustomVertexLerpShader();
|
||||||
|
|
||||||
BOOL Initialize(GraphicsDevice *graphicsDevice, const char *vertexShaderSource, const char *fragmentShaderSource);
|
bool Initialize(GraphicsDevice *graphicsDevice, const char *vertexShaderSource, const char *fragmentShaderSource);
|
||||||
BOOL Initialize(GraphicsDevice *graphicsDevice, const Text *vertexShaderSource, const Text *fragmentShaderSource);
|
bool Initialize(GraphicsDevice *graphicsDevice, const Text *vertexShaderSource, const Text *fragmentShaderSource);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -11,28 +11,28 @@ CustomVertexSkinningShader::~CustomVertexSkinningShader()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL CustomVertexSkinningShader::Initialize(GraphicsDevice *graphicsDevice, const char *vertexShaderSource, const char *fragmentShaderSource)
|
bool CustomVertexSkinningShader::Initialize(GraphicsDevice *graphicsDevice, const char *vertexShaderSource, const char *fragmentShaderSource)
|
||||||
{
|
{
|
||||||
if (!VertexSkinningShader::Initialize(graphicsDevice, vertexShaderSource, fragmentShaderSource))
|
if (!VertexSkinningShader::Initialize(graphicsDevice, vertexShaderSource, fragmentShaderSource))
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
ASSERT(HasUniform(GetModelViewMatrixUniform()) == TRUE);
|
ASSERT(HasUniform(GetModelViewMatrixUniform()) == true);
|
||||||
ASSERT(HasUniform(GetProjectionMatrixUniform()) == TRUE);
|
ASSERT(HasUniform(GetProjectionMatrixUniform()) == true);
|
||||||
ASSERT(HasUniform(GetJointPositionsUniform()) == TRUE);
|
ASSERT(HasUniform(GetJointPositionsUniform()) == true);
|
||||||
ASSERT(HasUniform(GetJointRotationsUniform()) == TRUE);
|
ASSERT(HasUniform(GetJointRotationsUniform()) == true);
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL CustomVertexSkinningShader::Initialize(GraphicsDevice *graphicsDevice, const Text *vertexShaderSource, const Text *fragmentShaderSource)
|
bool CustomVertexSkinningShader::Initialize(GraphicsDevice *graphicsDevice, const Text *vertexShaderSource, const Text *fragmentShaderSource)
|
||||||
{
|
{
|
||||||
if (!VertexSkinningShader::Initialize(graphicsDevice, vertexShaderSource, fragmentShaderSource))
|
if (!VertexSkinningShader::Initialize(graphicsDevice, vertexShaderSource, fragmentShaderSource))
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
ASSERT(HasUniform(GetModelViewMatrixUniform()) == TRUE);
|
ASSERT(HasUniform(GetModelViewMatrixUniform()) == true);
|
||||||
ASSERT(HasUniform(GetProjectionMatrixUniform()) == TRUE);
|
ASSERT(HasUniform(GetProjectionMatrixUniform()) == true);
|
||||||
ASSERT(HasUniform(GetJointPositionsUniform()) == TRUE);
|
ASSERT(HasUniform(GetJointPositionsUniform()) == true);
|
||||||
ASSERT(HasUniform(GetJointRotationsUniform()) == TRUE);
|
ASSERT(HasUniform(GetJointRotationsUniform()) == true);
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,8 @@ public:
|
||||||
CustomVertexSkinningShader();
|
CustomVertexSkinningShader();
|
||||||
virtual ~CustomVertexSkinningShader();
|
virtual ~CustomVertexSkinningShader();
|
||||||
|
|
||||||
BOOL Initialize(GraphicsDevice *graphicsDevice, const char *vertexShaderSource, const char *fragmentShaderSource);
|
bool Initialize(GraphicsDevice *graphicsDevice, const char *vertexShaderSource, const char *fragmentShaderSource);
|
||||||
BOOL Initialize(GraphicsDevice *graphicsDevice, const Text *vertexShaderSource, const Text *fragmentShaderSource);
|
bool Initialize(GraphicsDevice *graphicsDevice, const Text *vertexShaderSource, const Text *fragmentShaderSource);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -38,16 +38,16 @@ DebugShader::~DebugShader()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL DebugShader::Initialize(GraphicsDevice *graphicsDevice)
|
bool DebugShader::Initialize(GraphicsDevice *graphicsDevice)
|
||||||
{
|
{
|
||||||
if (!StandardShader::Initialize(graphicsDevice))
|
if (!StandardShader::Initialize(graphicsDevice))
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
BOOL result = LoadCompileAndLinkInlineSources(m_vertexShaderSource, m_fragmentShaderSource);
|
bool result = LoadCompileAndLinkInlineSources(m_vertexShaderSource, m_fragmentShaderSource);
|
||||||
ASSERT(result == TRUE);
|
ASSERT(result == true);
|
||||||
|
|
||||||
MapAttributeToStandardAttribType("a_position", VERTEX_STD_POS_3D);
|
MapAttributeToStandardAttribType("a_position", VERTEX_STD_POS_3D);
|
||||||
MapAttributeToStandardAttribType("a_color", VERTEX_STD_COLOR);
|
MapAttributeToStandardAttribType("a_color", VERTEX_STD_COLOR);
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ public:
|
||||||
DebugShader();
|
DebugShader();
|
||||||
virtual ~DebugShader();
|
virtual ~DebugShader();
|
||||||
|
|
||||||
BOOL Initialize(GraphicsDevice *graphicsDevice);
|
bool Initialize(GraphicsDevice *graphicsDevice);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const char *m_vertexShaderSource;
|
static const char *m_vertexShaderSource;
|
||||||
|
|
|
@ -21,14 +21,14 @@ Framebuffer::Framebuffer()
|
||||||
m_fixedHeight = 0;
|
m_fixedHeight = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL Framebuffer::Initialize(GraphicsDevice *graphicsDevice)
|
bool Framebuffer::Initialize(GraphicsDevice *graphicsDevice)
|
||||||
{
|
{
|
||||||
ASSERT(m_framebufferName == 0);
|
ASSERT(m_framebufferName == 0);
|
||||||
if (m_framebufferName != 0)
|
if (m_framebufferName != 0)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
if (!GraphicsContextResource::Initialize(graphicsDevice))
|
if (!GraphicsContextResource::Initialize(graphicsDevice))
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
CreateFramebuffer();
|
CreateFramebuffer();
|
||||||
|
|
||||||
|
@ -36,24 +36,24 @@ BOOL Framebuffer::Initialize(GraphicsDevice *graphicsDevice)
|
||||||
m_fixedWidth = 0;
|
m_fixedWidth = 0;
|
||||||
m_fixedHeight = 0;
|
m_fixedHeight = 0;
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL Framebuffer::Initialize(GraphicsDevice *graphicsDevice, uint fixedWidth, uint fixedHeight)
|
bool Framebuffer::Initialize(GraphicsDevice *graphicsDevice, uint fixedWidth, uint fixedHeight)
|
||||||
{
|
{
|
||||||
ASSERT(fixedWidth != 0);
|
ASSERT(fixedWidth != 0);
|
||||||
ASSERT(fixedHeight != 0);
|
ASSERT(fixedHeight != 0);
|
||||||
if (fixedWidth == 0 || fixedHeight == 0)
|
if (fixedWidth == 0 || fixedHeight == 0)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
BOOL createSuccess = Initialize(graphicsDevice);
|
bool createSuccess = Initialize(graphicsDevice);
|
||||||
if (!createSuccess)
|
if (!createSuccess)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
m_fixedWidth = fixedWidth;
|
m_fixedWidth = fixedWidth;
|
||||||
m_fixedHeight = fixedHeight;
|
m_fixedHeight = fixedHeight;
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Framebuffer::Release()
|
void Framebuffer::Release()
|
||||||
|
@ -98,18 +98,18 @@ void Framebuffer::CreateFramebuffer()
|
||||||
GL_CALL(glGenFramebuffers(1, &m_framebufferName));
|
GL_CALL(glGenFramebuffers(1, &m_framebufferName));
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL Framebuffer::AttachViewContext()
|
bool Framebuffer::AttachViewContext()
|
||||||
{
|
{
|
||||||
ASSERT(m_framebufferName != 0);
|
ASSERT(m_framebufferName != 0);
|
||||||
if (m_framebufferName == 0)
|
if (m_framebufferName == 0)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
ASSERT(m_viewContext == NULL);
|
ASSERT(m_viewContext == NULL);
|
||||||
if (m_viewContext != NULL)
|
if (m_viewContext != NULL)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
m_viewContext = new ViewContext();
|
m_viewContext = new ViewContext();
|
||||||
BOOL success;
|
bool success;
|
||||||
if (IsUsingFixedDimensions())
|
if (IsUsingFixedDimensions())
|
||||||
success = m_viewContext->Create(GetGraphicsDevice(), Rect(0, 0, m_fixedWidth, m_fixedHeight));
|
success = m_viewContext->Create(GetGraphicsDevice(), Rect(0, 0, m_fixedWidth, m_fixedHeight));
|
||||||
else
|
else
|
||||||
|
@ -117,36 +117,36 @@ BOOL Framebuffer::AttachViewContext()
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
SAFE_DELETE(m_viewContext);
|
SAFE_DELETE(m_viewContext);
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL Framebuffer::AttachTexture(FRAMEBUFFER_DATA_TYPE type)
|
bool Framebuffer::AttachTexture(FRAMEBUFFER_DATA_TYPE type)
|
||||||
{
|
{
|
||||||
ASSERT(m_framebufferName != 0);
|
ASSERT(m_framebufferName != 0);
|
||||||
if (m_framebufferName == 0)
|
if (m_framebufferName == 0)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
Texture *existing = GetTexture(type);
|
Texture *existing = GetTexture(type);
|
||||||
ASSERT(existing == NULL);
|
ASSERT(existing == NULL);
|
||||||
if (existing != NULL)
|
if (existing != NULL)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
// also need to make sure a renderbuffer isn't already attached to this type!
|
// also need to make sure a renderbuffer isn't already attached to this type!
|
||||||
Renderbuffer *existingRenderbuffer = GetRenderbuffer(type);
|
Renderbuffer *existingRenderbuffer = GetRenderbuffer(type);
|
||||||
ASSERT(existingRenderbuffer == NULL);
|
ASSERT(existingRenderbuffer == NULL);
|
||||||
if (existingRenderbuffer != NULL)
|
if (existingRenderbuffer != NULL)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
// don't allow unsupported types!
|
// don't allow unsupported types!
|
||||||
if (type == FRAMEBUFFER_DATA_NONE)
|
if (type == FRAMEBUFFER_DATA_NONE)
|
||||||
return FALSE;
|
return false;
|
||||||
if (type == FRAMEBUFFER_DATA_DEPTH && !GetGraphicsDevice()->IsDepthTextureSupported())
|
if (type == FRAMEBUFFER_DATA_DEPTH && !GetGraphicsDevice()->IsDepthTextureSupported())
|
||||||
return FALSE;
|
return false;
|
||||||
if (type == FRAMEBUFFER_DATA_STENCIL)
|
if (type == FRAMEBUFFER_DATA_STENCIL)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
// determine texture format and framebuffer attachment type
|
// determine texture format and framebuffer attachment type
|
||||||
TEXTURE_FORMAT textureFormat;
|
TEXTURE_FORMAT textureFormat;
|
||||||
|
@ -171,19 +171,19 @@ BOOL Framebuffer::AttachTexture(FRAMEBUFFER_DATA_TYPE type)
|
||||||
}
|
}
|
||||||
ASSERT(attachmentType != 0);
|
ASSERT(attachmentType != 0);
|
||||||
if (attachmentType == 0)
|
if (attachmentType == 0)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
uint width = 0;
|
uint width = 0;
|
||||||
uint height = 0;
|
uint height = 0;
|
||||||
GetDimensionsForAttachment(width, height);
|
GetDimensionsForAttachment(width, height);
|
||||||
|
|
||||||
Texture *attach = new Texture();
|
Texture *attach = new Texture();
|
||||||
BOOL textureSuccess = attach->Create(GetGraphicsDevice(), width, height, textureFormat);
|
bool textureSuccess = attach->Create(GetGraphicsDevice(), width, height, textureFormat);
|
||||||
ASSERT(textureSuccess == TRUE);
|
ASSERT(textureSuccess == true);
|
||||||
if (!textureSuccess)
|
if (!textureSuccess)
|
||||||
{
|
{
|
||||||
SAFE_DELETE(attach);
|
SAFE_DELETE(attach);
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GetGraphicsDevice()->BindFramebuffer(this);
|
GetGraphicsDevice()->BindFramebuffer(this);
|
||||||
|
@ -192,10 +192,10 @@ BOOL Framebuffer::AttachTexture(FRAMEBUFFER_DATA_TYPE type)
|
||||||
|
|
||||||
m_textures[type] = attach;
|
m_textures[type] = attach;
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL Framebuffer::ReCreateAndAttach(FramebufferTextureMap::iterator &itor, BOOL releaseFirst)
|
bool Framebuffer::ReCreateAndAttach(FramebufferTextureMap::iterator &itor, bool releaseFirst)
|
||||||
{
|
{
|
||||||
Texture *existing = itor->second;
|
Texture *existing = itor->second;
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ BOOL Framebuffer::ReCreateAndAttach(FramebufferTextureMap::iterator &itor, BOOL
|
||||||
}
|
}
|
||||||
ASSERT(attachmentType != 0);
|
ASSERT(attachmentType != 0);
|
||||||
if (attachmentType == 0)
|
if (attachmentType == 0)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
uint width = 0;
|
uint width = 0;
|
||||||
uint height = 0;
|
uint height = 0;
|
||||||
|
@ -221,38 +221,38 @@ BOOL Framebuffer::ReCreateAndAttach(FramebufferTextureMap::iterator &itor, BOOL
|
||||||
if (releaseFirst)
|
if (releaseFirst)
|
||||||
existing->Release();
|
existing->Release();
|
||||||
|
|
||||||
BOOL textureSuccess = existing->Create(GetGraphicsDevice(), width, height, existingFormat);
|
bool textureSuccess = existing->Create(GetGraphicsDevice(), width, height, existingFormat);
|
||||||
ASSERT(textureSuccess == TRUE);
|
ASSERT(textureSuccess == true);
|
||||||
if (!textureSuccess)
|
if (!textureSuccess)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
GetGraphicsDevice()->BindFramebuffer(this);
|
GetGraphicsDevice()->BindFramebuffer(this);
|
||||||
GL_CALL(glFramebufferTexture2D(GL_FRAMEBUFFER, attachmentType, GL_TEXTURE_2D, existing->GetTextureName(), 0));
|
GL_CALL(glFramebufferTexture2D(GL_FRAMEBUFFER, attachmentType, GL_TEXTURE_2D, existing->GetTextureName(), 0));
|
||||||
GetGraphicsDevice()->UnbindFramebuffer(this);
|
GetGraphicsDevice()->UnbindFramebuffer(this);
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL Framebuffer::AttachRenderbuffer(FRAMEBUFFER_DATA_TYPE type)
|
bool Framebuffer::AttachRenderbuffer(FRAMEBUFFER_DATA_TYPE type)
|
||||||
{
|
{
|
||||||
ASSERT(m_framebufferName != 0);
|
ASSERT(m_framebufferName != 0);
|
||||||
if (m_framebufferName == 0)
|
if (m_framebufferName == 0)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
Renderbuffer *existing = GetRenderbuffer(type);
|
Renderbuffer *existing = GetRenderbuffer(type);
|
||||||
ASSERT(existing == NULL);
|
ASSERT(existing == NULL);
|
||||||
if (existing != NULL)
|
if (existing != NULL)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
// also need to make sure a texture isn't already attached to this type!
|
// also need to make sure a texture isn't already attached to this type!
|
||||||
Texture *existingTexture = GetTexture(type);
|
Texture *existingTexture = GetTexture(type);
|
||||||
ASSERT(existingTexture == NULL);
|
ASSERT(existingTexture == NULL);
|
||||||
if (existingTexture != NULL)
|
if (existingTexture != NULL)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
// don't allow unsupported types!
|
// don't allow unsupported types!
|
||||||
if (type == FRAMEBUFFER_DATA_NONE)
|
if (type == FRAMEBUFFER_DATA_NONE)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
// determine framebuffer attachment type
|
// determine framebuffer attachment type
|
||||||
GLenum attachmentType;
|
GLenum attachmentType;
|
||||||
|
@ -266,19 +266,19 @@ BOOL Framebuffer::AttachRenderbuffer(FRAMEBUFFER_DATA_TYPE type)
|
||||||
}
|
}
|
||||||
ASSERT(attachmentType != 0);
|
ASSERT(attachmentType != 0);
|
||||||
if (attachmentType == 0)
|
if (attachmentType == 0)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
uint width = 0;
|
uint width = 0;
|
||||||
uint height = 0;
|
uint height = 0;
|
||||||
GetDimensionsForAttachment(width, height);
|
GetDimensionsForAttachment(width, height);
|
||||||
|
|
||||||
Renderbuffer *attach = new Renderbuffer();
|
Renderbuffer *attach = new Renderbuffer();
|
||||||
BOOL renderbufferSuccess = attach->Initialize(GetGraphicsDevice(), width, height, type);
|
bool renderbufferSuccess = attach->Initialize(GetGraphicsDevice(), width, height, type);
|
||||||
ASSERT(renderbufferSuccess == TRUE);
|
ASSERT(renderbufferSuccess == true);
|
||||||
if (!renderbufferSuccess)
|
if (!renderbufferSuccess)
|
||||||
{
|
{
|
||||||
SAFE_DELETE(attach);
|
SAFE_DELETE(attach);
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GetGraphicsDevice()->BindFramebuffer(this);
|
GetGraphicsDevice()->BindFramebuffer(this);
|
||||||
|
@ -287,10 +287,10 @@ BOOL Framebuffer::AttachRenderbuffer(FRAMEBUFFER_DATA_TYPE type)
|
||||||
|
|
||||||
m_renderbuffers[type] = attach;
|
m_renderbuffers[type] = attach;
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL Framebuffer::ReCreateAndAttach(FramebufferRenderbufferMap::iterator &itor, BOOL releaseFirst)
|
bool Framebuffer::ReCreateAndAttach(FramebufferRenderbufferMap::iterator &itor, bool releaseFirst)
|
||||||
{
|
{
|
||||||
Renderbuffer *existing = itor->second;
|
Renderbuffer *existing = itor->second;
|
||||||
|
|
||||||
|
@ -306,7 +306,7 @@ BOOL Framebuffer::ReCreateAndAttach(FramebufferRenderbufferMap::iterator &itor,
|
||||||
}
|
}
|
||||||
ASSERT(attachmentType != 0);
|
ASSERT(attachmentType != 0);
|
||||||
if (attachmentType == 0)
|
if (attachmentType == 0)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
uint width = 0;
|
uint width = 0;
|
||||||
uint height = 0;
|
uint height = 0;
|
||||||
|
@ -317,46 +317,46 @@ BOOL Framebuffer::ReCreateAndAttach(FramebufferRenderbufferMap::iterator &itor,
|
||||||
if (releaseFirst)
|
if (releaseFirst)
|
||||||
existing->Release();
|
existing->Release();
|
||||||
|
|
||||||
BOOL renderbufferSuccess = existing->Initialize(GetGraphicsDevice(), width, height, existingType);
|
bool renderbufferSuccess = existing->Initialize(GetGraphicsDevice(), width, height, existingType);
|
||||||
ASSERT(renderbufferSuccess == TRUE);
|
ASSERT(renderbufferSuccess == true);
|
||||||
if (!renderbufferSuccess)
|
if (!renderbufferSuccess)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
GetGraphicsDevice()->BindFramebuffer(this);
|
GetGraphicsDevice()->BindFramebuffer(this);
|
||||||
GL_CALL(glFramebufferRenderbuffer(GL_FRAMEBUFFER, attachmentType, GL_RENDERBUFFER, existing->GetRenderbufferName()));
|
GL_CALL(glFramebufferRenderbuffer(GL_FRAMEBUFFER, attachmentType, GL_RENDERBUFFER, existing->GetRenderbufferName()));
|
||||||
GetGraphicsDevice()->UnbindFramebuffer(this);
|
GetGraphicsDevice()->UnbindFramebuffer(this);
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL Framebuffer::ReleaseViewContext()
|
bool Framebuffer::ReleaseViewContext()
|
||||||
{
|
{
|
||||||
ASSERT(m_framebufferName != 0);
|
ASSERT(m_framebufferName != 0);
|
||||||
if (m_framebufferName == 0)
|
if (m_framebufferName == 0)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
ASSERT(m_viewContext != NULL);
|
ASSERT(m_viewContext != NULL);
|
||||||
if (m_viewContext == NULL)
|
if (m_viewContext == NULL)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
if (GetGraphicsDevice()->GetViewContext() == m_viewContext)
|
if (GetGraphicsDevice()->GetViewContext() == m_viewContext)
|
||||||
GetGraphicsDevice()->SetViewContext(NULL);
|
GetGraphicsDevice()->SetViewContext(NULL);
|
||||||
|
|
||||||
SAFE_DELETE(m_viewContext);
|
SAFE_DELETE(m_viewContext);
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL Framebuffer::ReleaseTexture(FRAMEBUFFER_DATA_TYPE type)
|
bool Framebuffer::ReleaseTexture(FRAMEBUFFER_DATA_TYPE type)
|
||||||
{
|
{
|
||||||
ASSERT(m_framebufferName != 0);
|
ASSERT(m_framebufferName != 0);
|
||||||
if (m_framebufferName == 0)
|
if (m_framebufferName == 0)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
Texture *existing = GetTexture(type);
|
Texture *existing = GetTexture(type);
|
||||||
ASSERT(existing != NULL);
|
ASSERT(existing != NULL);
|
||||||
if (existing == NULL)
|
if (existing == NULL)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
// determine attachment type
|
// determine attachment type
|
||||||
GLenum attachmentType;
|
GLenum attachmentType;
|
||||||
|
@ -376,30 +376,30 @@ BOOL Framebuffer::ReleaseTexture(FRAMEBUFFER_DATA_TYPE type)
|
||||||
}
|
}
|
||||||
ASSERT(attachmentType != 0);
|
ASSERT(attachmentType != 0);
|
||||||
if (attachmentType == 0)
|
if (attachmentType == 0)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
GetGraphicsDevice()->BindFramebuffer(this);
|
GetGraphicsDevice()->BindFramebuffer(this);
|
||||||
GL_CALL(glFramebufferTexture2D(GL_FRAMEBUFFER, attachmentType, GL_TEXTURE_2D, 0, 0));
|
GL_CALL(glFramebufferTexture2D(GL_FRAMEBUFFER, attachmentType, GL_TEXTURE_2D, 0, 0));
|
||||||
GetGraphicsDevice()->UnbindFramebuffer(this);
|
GetGraphicsDevice()->UnbindFramebuffer(this);
|
||||||
|
|
||||||
BOOL removeSuccess = RemoveTexture(existing);
|
bool removeSuccess = RemoveTexture(existing);
|
||||||
ASSERT(removeSuccess == TRUE);
|
ASSERT(removeSuccess == true);
|
||||||
if (!removeSuccess)
|
if (!removeSuccess)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL Framebuffer::ReleaseRenderbuffer(FRAMEBUFFER_DATA_TYPE type)
|
bool Framebuffer::ReleaseRenderbuffer(FRAMEBUFFER_DATA_TYPE type)
|
||||||
{
|
{
|
||||||
ASSERT(m_framebufferName != 0);
|
ASSERT(m_framebufferName != 0);
|
||||||
if (m_framebufferName == 0)
|
if (m_framebufferName == 0)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
Renderbuffer *existing = GetRenderbuffer(type);
|
Renderbuffer *existing = GetRenderbuffer(type);
|
||||||
ASSERT(existing != NULL);
|
ASSERT(existing != NULL);
|
||||||
if (existing == NULL)
|
if (existing == NULL)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
// determine attachment type
|
// determine attachment type
|
||||||
GLenum attachmentType;
|
GLenum attachmentType;
|
||||||
|
@ -419,18 +419,18 @@ BOOL Framebuffer::ReleaseRenderbuffer(FRAMEBUFFER_DATA_TYPE type)
|
||||||
}
|
}
|
||||||
ASSERT(attachmentType != 0);
|
ASSERT(attachmentType != 0);
|
||||||
if (attachmentType == 0)
|
if (attachmentType == 0)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
GetGraphicsDevice()->BindFramebuffer(this);
|
GetGraphicsDevice()->BindFramebuffer(this);
|
||||||
GL_CALL(glFramebufferRenderbuffer(GL_FRAMEBUFFER, attachmentType, GL_RENDERBUFFER, 0));
|
GL_CALL(glFramebufferRenderbuffer(GL_FRAMEBUFFER, attachmentType, GL_RENDERBUFFER, 0));
|
||||||
GetGraphicsDevice()->UnbindFramebuffer(this);
|
GetGraphicsDevice()->UnbindFramebuffer(this);
|
||||||
|
|
||||||
BOOL removeSuccess = RemoveRenderbuffer(existing);
|
bool removeSuccess = RemoveRenderbuffer(existing);
|
||||||
ASSERT(removeSuccess == TRUE);
|
ASSERT(removeSuccess == true);
|
||||||
if (!removeSuccess)
|
if (!removeSuccess)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Texture* Framebuffer::GetTexture(FRAMEBUFFER_DATA_TYPE type) const
|
Texture* Framebuffer::GetTexture(FRAMEBUFFER_DATA_TYPE type) const
|
||||||
|
@ -497,8 +497,8 @@ void Framebuffer::OnNewContext()
|
||||||
|
|
||||||
for (FramebufferTextureMap::iterator i = m_textures.begin(); i != m_textures.end(); ++i)
|
for (FramebufferTextureMap::iterator i = m_textures.begin(); i != m_textures.end(); ++i)
|
||||||
{
|
{
|
||||||
BOOL success = ReCreateAndAttach(i, FALSE);
|
bool success = ReCreateAndAttach(i, false);
|
||||||
ASSERT(success == TRUE);
|
ASSERT(success == true);
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
Release();
|
Release();
|
||||||
|
@ -508,8 +508,8 @@ void Framebuffer::OnNewContext()
|
||||||
|
|
||||||
for (FramebufferRenderbufferMap::iterator i = m_renderbuffers.begin(); i != m_renderbuffers.end(); ++i)
|
for (FramebufferRenderbufferMap::iterator i = m_renderbuffers.begin(); i != m_renderbuffers.end(); ++i)
|
||||||
{
|
{
|
||||||
BOOL success = ReCreateAndAttach(i, FALSE);
|
bool success = ReCreateAndAttach(i, false);
|
||||||
ASSERT(success == TRUE);
|
ASSERT(success == true);
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
Release();
|
Release();
|
||||||
|
@ -544,8 +544,8 @@ void Framebuffer::OnResize()
|
||||||
|
|
||||||
for (FramebufferTextureMap::iterator i = m_textures.begin(); i != m_textures.end(); ++i)
|
for (FramebufferTextureMap::iterator i = m_textures.begin(); i != m_textures.end(); ++i)
|
||||||
{
|
{
|
||||||
BOOL success = ReCreateAndAttach(i, TRUE);
|
bool success = ReCreateAndAttach(i, true);
|
||||||
ASSERT(success == TRUE);
|
ASSERT(success == true);
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
Release();
|
Release();
|
||||||
|
@ -555,8 +555,8 @@ void Framebuffer::OnResize()
|
||||||
|
|
||||||
for (FramebufferRenderbufferMap::iterator i = m_renderbuffers.begin(); i != m_renderbuffers.end(); ++i)
|
for (FramebufferRenderbufferMap::iterator i = m_renderbuffers.begin(); i != m_renderbuffers.end(); ++i)
|
||||||
{
|
{
|
||||||
BOOL success = ReCreateAndAttach(i, TRUE);
|
bool success = ReCreateAndAttach(i, true);
|
||||||
ASSERT(success == TRUE);
|
ASSERT(success == true);
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
Release();
|
Release();
|
||||||
|
@ -574,7 +574,7 @@ void Framebuffer::OnUnBind()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL Framebuffer::RemoveTexture(Texture *texture)
|
bool Framebuffer::RemoveTexture(Texture *texture)
|
||||||
{
|
{
|
||||||
for (FramebufferTextureMap::iterator i = m_textures.begin(); i != m_textures.end(); ++i)
|
for (FramebufferTextureMap::iterator i = m_textures.begin(); i != m_textures.end(); ++i)
|
||||||
{
|
{
|
||||||
|
@ -582,14 +582,14 @@ BOOL Framebuffer::RemoveTexture(Texture *texture)
|
||||||
{
|
{
|
||||||
SAFE_DELETE(texture);
|
SAFE_DELETE(texture);
|
||||||
m_textures.erase(i);
|
m_textures.erase(i);
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL Framebuffer::RemoveRenderbuffer(Renderbuffer *renderbuffer)
|
bool Framebuffer::RemoveRenderbuffer(Renderbuffer *renderbuffer)
|
||||||
{
|
{
|
||||||
for (FramebufferRenderbufferMap::iterator i = m_renderbuffers.begin(); i != m_renderbuffers.end(); ++i)
|
for (FramebufferRenderbufferMap::iterator i = m_renderbuffers.begin(); i != m_renderbuffers.end(); ++i)
|
||||||
{
|
{
|
||||||
|
@ -597,11 +597,11 @@ BOOL Framebuffer::RemoveRenderbuffer(Renderbuffer *renderbuffer)
|
||||||
{
|
{
|
||||||
SAFE_DELETE(renderbuffer);
|
SAFE_DELETE(renderbuffer);
|
||||||
m_renderbuffers.erase(i);
|
m_renderbuffers.erase(i);
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Framebuffer::GetDimensionsForAttachment(uint &width, uint &height) const
|
void Framebuffer::GetDimensionsForAttachment(uint &width, uint &height) const
|
||||||
|
|
|
@ -24,19 +24,19 @@ public:
|
||||||
|
|
||||||
void Release();
|
void Release();
|
||||||
|
|
||||||
BOOL Initialize(GraphicsDevice *graphicsDevice);
|
bool Initialize(GraphicsDevice *graphicsDevice);
|
||||||
BOOL Initialize(GraphicsDevice *graphicsDevice, uint fixedWidth, uint fixedHeight);
|
bool Initialize(GraphicsDevice *graphicsDevice, uint fixedWidth, uint fixedHeight);
|
||||||
|
|
||||||
uint GetFramebufferName() const { return m_framebufferName; }
|
uint GetFramebufferName() const { return m_framebufferName; }
|
||||||
BOOL IsInvalidated() const { return m_framebufferName == 0; }
|
bool IsInvalidated() const { return m_framebufferName == 0; }
|
||||||
BOOL IsUsingFixedDimensions() const { return (m_fixedWidth != 0 && m_fixedHeight != 0); }
|
bool IsUsingFixedDimensions() const { return (m_fixedWidth != 0 && m_fixedHeight != 0); }
|
||||||
|
|
||||||
BOOL AttachViewContext();
|
bool AttachViewContext();
|
||||||
BOOL AttachTexture(FRAMEBUFFER_DATA_TYPE type);
|
bool AttachTexture(FRAMEBUFFER_DATA_TYPE type);
|
||||||
BOOL AttachRenderbuffer(FRAMEBUFFER_DATA_TYPE type);
|
bool AttachRenderbuffer(FRAMEBUFFER_DATA_TYPE type);
|
||||||
BOOL ReleaseViewContext();
|
bool ReleaseViewContext();
|
||||||
BOOL ReleaseTexture(FRAMEBUFFER_DATA_TYPE type);
|
bool ReleaseTexture(FRAMEBUFFER_DATA_TYPE type);
|
||||||
BOOL ReleaseRenderbuffer(FRAMEBUFFER_DATA_TYPE type);
|
bool ReleaseRenderbuffer(FRAMEBUFFER_DATA_TYPE type);
|
||||||
|
|
||||||
ViewContext* GetViewContext() const { return m_viewContext; }
|
ViewContext* GetViewContext() const { return m_viewContext; }
|
||||||
Texture* GetTexture(FRAMEBUFFER_DATA_TYPE type) const;
|
Texture* GetTexture(FRAMEBUFFER_DATA_TYPE type) const;
|
||||||
|
@ -52,10 +52,10 @@ private:
|
||||||
|
|
||||||
void CreateFramebuffer();
|
void CreateFramebuffer();
|
||||||
|
|
||||||
BOOL ReCreateAndAttach(FramebufferTextureMap::iterator &itor, BOOL releaseFirst);
|
bool ReCreateAndAttach(FramebufferTextureMap::iterator &itor, bool releaseFirst);
|
||||||
BOOL ReCreateAndAttach(FramebufferRenderbufferMap::iterator &itor, BOOL releaseFirst);
|
bool ReCreateAndAttach(FramebufferRenderbufferMap::iterator &itor, bool releaseFirst);
|
||||||
BOOL RemoveTexture(Texture *texture);
|
bool RemoveTexture(Texture *texture);
|
||||||
BOOL RemoveRenderbuffer(Renderbuffer *renderbuffer);
|
bool RemoveRenderbuffer(Renderbuffer *renderbuffer);
|
||||||
|
|
||||||
void GetDimensionsForAttachment(uint &width, uint &height) const;
|
void GetDimensionsForAttachment(uint &width, uint &height) const;
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#include "../math/point3.h"
|
#include "../math/point3.h"
|
||||||
#include "../math/ray.h"
|
#include "../math/ray.h"
|
||||||
|
|
||||||
GeometryDebugRenderer::GeometryDebugRenderer(GraphicsDevice *graphicsDevice, BOOL depthTesting)
|
GeometryDebugRenderer::GeometryDebugRenderer(GraphicsDevice *graphicsDevice, bool depthTesting)
|
||||||
{
|
{
|
||||||
m_graphicsDevice = graphicsDevice;
|
m_graphicsDevice = graphicsDevice;
|
||||||
m_color1 = Color(1.0f, 1.0f, 0.0f);
|
m_color1 = Color(1.0f, 1.0f, 0.0f);
|
||||||
|
@ -37,7 +37,7 @@ GeometryDebugRenderer::GeometryDebugRenderer(GraphicsDevice *graphicsDevice, BOO
|
||||||
m_vertices->Initialize(attribs, 2, 16384, BUFFEROBJECT_USAGE_STREAM);
|
m_vertices->Initialize(attribs, 2, 16384, BUFFEROBJECT_USAGE_STREAM);
|
||||||
m_currentVertex = 0;
|
m_currentVertex = 0;
|
||||||
|
|
||||||
m_begunRendering = FALSE;
|
m_begunRendering = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GeometryDebugRenderer::~GeometryDebugRenderer()
|
GeometryDebugRenderer::~GeometryDebugRenderer()
|
||||||
|
@ -49,12 +49,12 @@ GeometryDebugRenderer::~GeometryDebugRenderer()
|
||||||
void GeometryDebugRenderer::Begin()
|
void GeometryDebugRenderer::Begin()
|
||||||
{
|
{
|
||||||
m_currentVertex = 0;
|
m_currentVertex = 0;
|
||||||
m_begunRendering = TRUE;
|
m_begunRendering = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeometryDebugRenderer::Render(const BoundingBox &box, const Color &color)
|
void GeometryDebugRenderer::Render(const BoundingBox &box, const Color &color)
|
||||||
{
|
{
|
||||||
ASSERT(m_begunRendering == TRUE);
|
ASSERT(m_begunRendering == true);
|
||||||
ASSERT(m_vertices->GetNumElements() > (m_currentVertex + 24));
|
ASSERT(m_vertices->GetNumElements() > (m_currentVertex + 24));
|
||||||
|
|
||||||
uint i = m_currentVertex;
|
uint i = m_currentVertex;
|
||||||
|
@ -117,7 +117,7 @@ void GeometryDebugRenderer::Render(const Point3 &boxMin, const Point3 &boxMax, c
|
||||||
|
|
||||||
void GeometryDebugRenderer::Render(const BoundingSphere &sphere, const Color &color)
|
void GeometryDebugRenderer::Render(const BoundingSphere &sphere, const Color &color)
|
||||||
{
|
{
|
||||||
ASSERT(m_begunRendering == TRUE);
|
ASSERT(m_begunRendering == true);
|
||||||
ASSERT(m_vertices->GetNumElements() > (m_currentVertex + 615));
|
ASSERT(m_vertices->GetNumElements() > (m_currentVertex + 615));
|
||||||
|
|
||||||
uint p = m_currentVertex;
|
uint p = m_currentVertex;
|
||||||
|
@ -178,7 +178,7 @@ void GeometryDebugRenderer::Render(const BoundingSphere &sphere, const Color &co
|
||||||
|
|
||||||
void GeometryDebugRenderer::Render(const Ray &ray, float length, const Color &color1, const Color &color2)
|
void GeometryDebugRenderer::Render(const Ray &ray, float length, const Color &color1, const Color &color2)
|
||||||
{
|
{
|
||||||
ASSERT(m_begunRendering == TRUE);
|
ASSERT(m_begunRendering == true);
|
||||||
ASSERT(m_vertices->GetNumElements() > (m_currentVertex + 2));
|
ASSERT(m_vertices->GetNumElements() > (m_currentVertex + 2));
|
||||||
|
|
||||||
Vector3 temp = ray.GetPositionAt(length);
|
Vector3 temp = ray.GetPositionAt(length);
|
||||||
|
@ -193,7 +193,7 @@ void GeometryDebugRenderer::Render(const Ray &ray, float length, const Color &co
|
||||||
|
|
||||||
void GeometryDebugRenderer::Render(const LineSegment &line, const Color &color)
|
void GeometryDebugRenderer::Render(const LineSegment &line, const Color &color)
|
||||||
{
|
{
|
||||||
ASSERT(m_begunRendering == TRUE);
|
ASSERT(m_begunRendering == true);
|
||||||
ASSERT(m_vertices->GetNumElements() > (m_currentVertex + 2));
|
ASSERT(m_vertices->GetNumElements() > (m_currentVertex + 2));
|
||||||
|
|
||||||
m_vertices->SetPosition3(m_currentVertex, line.a);
|
m_vertices->SetPosition3(m_currentVertex, line.a);
|
||||||
|
@ -206,7 +206,7 @@ void GeometryDebugRenderer::Render(const LineSegment &line, const Color &color)
|
||||||
|
|
||||||
void GeometryDebugRenderer::Render(const Vector3 &a, const Vector3 &b, const Vector3 &c, const Color &color)
|
void GeometryDebugRenderer::Render(const Vector3 &a, const Vector3 &b, const Vector3 &c, const Color &color)
|
||||||
{
|
{
|
||||||
ASSERT(m_begunRendering == TRUE);
|
ASSERT(m_begunRendering == true);
|
||||||
ASSERT(m_vertices->GetNumElements() > (m_currentVertex + 6));
|
ASSERT(m_vertices->GetNumElements() > (m_currentVertex + 6));
|
||||||
|
|
||||||
m_vertices->SetPosition3(m_currentVertex, a);
|
m_vertices->SetPosition3(m_currentVertex, a);
|
||||||
|
@ -227,7 +227,7 @@ void GeometryDebugRenderer::Render(const Vector3 &a, const Vector3 &b, const Vec
|
||||||
|
|
||||||
void GeometryDebugRenderer::End()
|
void GeometryDebugRenderer::End()
|
||||||
{
|
{
|
||||||
ASSERT(m_begunRendering == TRUE);
|
ASSERT(m_begunRendering == true);
|
||||||
|
|
||||||
if (m_currentVertex > 0)
|
if (m_currentVertex > 0)
|
||||||
{
|
{
|
||||||
|
@ -247,5 +247,5 @@ void GeometryDebugRenderer::End()
|
||||||
m_graphicsDevice->UnbindShader();
|
m_graphicsDevice->UnbindShader();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_begunRendering = FALSE;
|
m_begunRendering = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,9 +25,9 @@ public:
|
||||||
/**
|
/**
|
||||||
* Creates a geometry debug renderer.
|
* Creates a geometry debug renderer.
|
||||||
* @param graphicsDevice the graphics device to use for rendering
|
* @param graphicsDevice the graphics device to use for rendering
|
||||||
* @param depthTesting TRUE to enable depth testing for all geometry rendering
|
* @param depthTesting true to enable depth testing for all geometry rendering
|
||||||
*/
|
*/
|
||||||
GeometryDebugRenderer(GraphicsDevice *graphicsDevice, BOOL depthTesting = FALSE);
|
GeometryDebugRenderer(GraphicsDevice *graphicsDevice, bool depthTesting = false);
|
||||||
|
|
||||||
virtual ~GeometryDebugRenderer();
|
virtual ~GeometryDebugRenderer();
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ private:
|
||||||
VertexBuffer *m_vertices;
|
VertexBuffer *m_vertices;
|
||||||
uint m_currentVertex;
|
uint m_currentVertex;
|
||||||
|
|
||||||
BOOL m_begunRendering;
|
bool m_begunRendering;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void GeometryDebugRenderer::Render(const BoundingBox &box)
|
inline void GeometryDebugRenderer::Render(const BoundingBox &box)
|
||||||
|
|
|
@ -3,14 +3,14 @@
|
||||||
#include "glutils.h"
|
#include "glutils.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
BOOL IsGLExtensionPresent(const char* extension)
|
bool IsGLExtensionPresent(const char* extension)
|
||||||
{
|
{
|
||||||
ASSERT(extension != NULL);
|
ASSERT(extension != NULL);
|
||||||
ASSERT(strlen(extension) > 0);
|
ASSERT(strlen(extension) > 0);
|
||||||
|
|
||||||
const char* extensionsList = (const char*)glGetString(GL_EXTENSIONS);
|
const char* extensionsList = (const char*)glGetString(GL_EXTENSIONS);
|
||||||
|
|
||||||
return (strstr(extensionsList, extension) != NULL ? TRUE : FALSE);
|
return (strstr(extensionsList, extension) != NULL ? true : false);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* GetGLErrorString(GLenum error)
|
const char* GetGLErrorString(GLenum error)
|
||||||
|
|
|
@ -8,9 +8,9 @@
|
||||||
* Checks if an OpenGL extension is present in the current
|
* Checks if an OpenGL extension is present in the current
|
||||||
* implementation. This performs a case-sensitive string match.
|
* implementation. This performs a case-sensitive string match.
|
||||||
* @param extension the name of the extension to check for.
|
* @param extension the name of the extension to check for.
|
||||||
* @return TRUE if the extension is present, FALSE if not
|
* @return true if the extension is present, false if not
|
||||||
*/
|
*/
|
||||||
BOOL IsGLExtensionPresent(const char* extension);
|
bool IsGLExtensionPresent(const char* extension);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a OpenGL error code to a string equivalent.
|
* Converts a OpenGL error code to a string equivalent.
|
||||||
|
|
|
@ -16,27 +16,27 @@ void GraphicsContextResource::Release()
|
||||||
m_graphicsDevice = NULL;
|
m_graphicsDevice = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL GraphicsContextResource::Initialize()
|
bool GraphicsContextResource::Initialize()
|
||||||
{
|
{
|
||||||
ASSERT(m_graphicsDevice == NULL);
|
ASSERT(m_graphicsDevice == NULL);
|
||||||
if (m_graphicsDevice != NULL)
|
if (m_graphicsDevice != NULL)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL GraphicsContextResource::Initialize(GraphicsDevice *graphicsDevice)
|
bool GraphicsContextResource::Initialize(GraphicsDevice *graphicsDevice)
|
||||||
{
|
{
|
||||||
ASSERT(m_graphicsDevice == NULL);
|
ASSERT(m_graphicsDevice == NULL);
|
||||||
if (m_graphicsDevice != NULL)
|
if (m_graphicsDevice != NULL)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
ASSERT(graphicsDevice != NULL);
|
ASSERT(graphicsDevice != NULL);
|
||||||
if (graphicsDevice == NULL)
|
if (graphicsDevice == NULL)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
m_graphicsDevice = graphicsDevice;
|
m_graphicsDevice = graphicsDevice;
|
||||||
m_graphicsDevice->RegisterManagedResource(this);
|
m_graphicsDevice->RegisterManagedResource(this);
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,8 +31,8 @@ public:
|
||||||
GraphicsDevice* GetGraphicsDevice() const { return m_graphicsDevice; }
|
GraphicsDevice* GetGraphicsDevice() const { return m_graphicsDevice; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BOOL Initialize();
|
bool Initialize();
|
||||||
BOOL Initialize(GraphicsDevice *graphicsDevice);
|
bool Initialize(GraphicsDevice *graphicsDevice);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GraphicsDevice *m_graphicsDevice;
|
GraphicsDevice *m_graphicsDevice;
|
||||||
|
|
|
@ -44,11 +44,11 @@ const unsigned int MAX_GPU_ATTRIB_SLOTS = 8;
|
||||||
|
|
||||||
GraphicsDevice::GraphicsDevice()
|
GraphicsDevice::GraphicsDevice()
|
||||||
{
|
{
|
||||||
m_hasNewContextRunYet = FALSE;
|
m_hasNewContextRunYet = false;
|
||||||
m_boundVertexBuffer = NULL;
|
m_boundVertexBuffer = NULL;
|
||||||
m_boundIndexBuffer = NULL;
|
m_boundIndexBuffer = NULL;
|
||||||
m_boundShader = NULL;
|
m_boundShader = NULL;
|
||||||
m_shaderVertexAttribsSet = FALSE;
|
m_shaderVertexAttribsSet = false;
|
||||||
m_boundTextures = NULL;
|
m_boundTextures = NULL;
|
||||||
m_boundFramebuffer = NULL;
|
m_boundFramebuffer = NULL;
|
||||||
m_boundRenderbuffer = NULL;
|
m_boundRenderbuffer = NULL;
|
||||||
|
@ -64,22 +64,22 @@ GraphicsDevice::GraphicsDevice()
|
||||||
m_sprite2dShader = NULL;
|
m_sprite2dShader = NULL;
|
||||||
m_sprite3dShader = NULL;
|
m_sprite3dShader = NULL;
|
||||||
m_debugShader = NULL;
|
m_debugShader = NULL;
|
||||||
m_isDepthTextureSupported = FALSE;
|
m_isDepthTextureSupported = false;
|
||||||
m_isNonPowerOfTwoTextureSupported = FALSE;
|
m_isNonPowerOfTwoTextureSupported = false;
|
||||||
m_window = NULL;
|
m_window = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL GraphicsDevice::Initialize(GameWindow *window)
|
bool GraphicsDevice::Initialize(GameWindow *window)
|
||||||
{
|
{
|
||||||
ASSERT(m_window == NULL);
|
ASSERT(m_window == NULL);
|
||||||
if (m_window != NULL)
|
if (m_window != NULL)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
ASSERT(window != NULL);
|
ASSERT(window != NULL);
|
||||||
if (window == NULL)
|
if (window == NULL)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
m_hasNewContextRunYet = FALSE;
|
m_hasNewContextRunYet = false;
|
||||||
m_boundTextures = new const Texture*[MAX_BOUND_TEXTURES];
|
m_boundTextures = new const Texture*[MAX_BOUND_TEXTURES];
|
||||||
m_enabledVertexAttribIndices.reserve(MAX_GPU_ATTRIB_SLOTS);
|
m_enabledVertexAttribIndices.reserve(MAX_GPU_ATTRIB_SLOTS);
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ BOOL GraphicsDevice::Initialize(GameWindow *window)
|
||||||
|
|
||||||
m_solidColorTextures = new SolidColorTextureCache(this);
|
m_solidColorTextures = new SolidColorTextureCache(this);
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsDevice::Release()
|
void GraphicsDevice::Release()
|
||||||
|
@ -126,16 +126,16 @@ void GraphicsDevice::Release()
|
||||||
m_enabledVertexAttribIndices.clear();
|
m_enabledVertexAttribIndices.clear();
|
||||||
m_managedResources.clear();
|
m_managedResources.clear();
|
||||||
|
|
||||||
m_hasNewContextRunYet = FALSE;
|
m_hasNewContextRunYet = false;
|
||||||
m_boundVertexBuffer = NULL;
|
m_boundVertexBuffer = NULL;
|
||||||
m_boundIndexBuffer = NULL;
|
m_boundIndexBuffer = NULL;
|
||||||
m_boundShader = NULL;
|
m_boundShader = NULL;
|
||||||
m_shaderVertexAttribsSet = FALSE;
|
m_shaderVertexAttribsSet = false;
|
||||||
m_boundFramebuffer = NULL;
|
m_boundFramebuffer = NULL;
|
||||||
m_boundRenderbuffer = NULL;
|
m_boundRenderbuffer = NULL;
|
||||||
m_activeViewContext = NULL;
|
m_activeViewContext = NULL;
|
||||||
m_isDepthTextureSupported = FALSE;
|
m_isDepthTextureSupported = false;
|
||||||
m_isNonPowerOfTwoTextureSupported = FALSE;
|
m_isNonPowerOfTwoTextureSupported = false;
|
||||||
m_window = NULL;
|
m_window = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,7 +256,7 @@ void GraphicsDevice::OnNewContext()
|
||||||
(*i)->OnNewContext();
|
(*i)->OnNewContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_hasNewContextRunYet = TRUE;
|
m_hasNewContextRunYet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsDevice::OnLostContext()
|
void GraphicsDevice::OnLostContext()
|
||||||
|
@ -317,7 +317,7 @@ void GraphicsDevice::BindTexture(const Texture *texture, uint unit)
|
||||||
{
|
{
|
||||||
ASSERT(unit < MAX_BOUND_TEXTURES);
|
ASSERT(unit < MAX_BOUND_TEXTURES);
|
||||||
ASSERT(texture != NULL);
|
ASSERT(texture != NULL);
|
||||||
ASSERT(texture->IsInvalidated() == FALSE);
|
ASSERT(texture->IsInvalidated() == false);
|
||||||
if (texture != m_boundTextures[unit])
|
if (texture != m_boundTextures[unit])
|
||||||
{
|
{
|
||||||
GL_CALL(glActiveTexture(GL_TEXTURE0 + unit));
|
GL_CALL(glActiveTexture(GL_TEXTURE0 + unit));
|
||||||
|
@ -356,7 +356,7 @@ void GraphicsDevice::UnbindTexture(const Texture *texture)
|
||||||
void GraphicsDevice::BindRenderbuffer(Renderbuffer *renderbuffer)
|
void GraphicsDevice::BindRenderbuffer(Renderbuffer *renderbuffer)
|
||||||
{
|
{
|
||||||
ASSERT(renderbuffer != NULL);
|
ASSERT(renderbuffer != NULL);
|
||||||
ASSERT(renderbuffer->IsInvalidated() == FALSE);
|
ASSERT(renderbuffer->IsInvalidated() == false);
|
||||||
if (m_boundRenderbuffer != renderbuffer)
|
if (m_boundRenderbuffer != renderbuffer)
|
||||||
{
|
{
|
||||||
GL_CALL(glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer->GetRenderbufferName()));
|
GL_CALL(glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer->GetRenderbufferName()));
|
||||||
|
@ -383,7 +383,7 @@ void GraphicsDevice::UnbindRenderBuffer(Renderbuffer *renderBuffer)
|
||||||
void GraphicsDevice::BindFramebuffer(Framebuffer *framebuffer)
|
void GraphicsDevice::BindFramebuffer(Framebuffer *framebuffer)
|
||||||
{
|
{
|
||||||
ASSERT(framebuffer != NULL);
|
ASSERT(framebuffer != NULL);
|
||||||
ASSERT(framebuffer->IsInvalidated() == FALSE);
|
ASSERT(framebuffer->IsInvalidated() == false);
|
||||||
if (m_boundFramebuffer != framebuffer)
|
if (m_boundFramebuffer != framebuffer)
|
||||||
{
|
{
|
||||||
GL_CALL(glBindFramebuffer(GL_FRAMEBUFFER, framebuffer->GetFramebufferName()));
|
GL_CALL(glBindFramebuffer(GL_FRAMEBUFFER, framebuffer->GetFramebufferName()));
|
||||||
|
@ -505,7 +505,7 @@ void GraphicsDevice::UnbindIndexBuffer()
|
||||||
void GraphicsDevice::BindShader(Shader *shader)
|
void GraphicsDevice::BindShader(Shader *shader)
|
||||||
{
|
{
|
||||||
ASSERT(shader != NULL);
|
ASSERT(shader != NULL);
|
||||||
ASSERT(shader->IsReadyForUse() == TRUE);
|
ASSERT(shader->IsReadyForUse() == true);
|
||||||
GL_CALL(glUseProgram(shader->GetProgramId()));
|
GL_CALL(glUseProgram(shader->GetProgramId()));
|
||||||
|
|
||||||
m_boundShader = shader;
|
m_boundShader = shader;
|
||||||
|
@ -557,7 +557,7 @@ void GraphicsDevice::SetShaderVertexAttributes()
|
||||||
{
|
{
|
||||||
ASSERT(m_boundVertexBuffer != NULL);
|
ASSERT(m_boundVertexBuffer != NULL);
|
||||||
ASSERT(m_boundShader != NULL);
|
ASSERT(m_boundShader != NULL);
|
||||||
ASSERT(m_enabledVertexAttribIndices.empty() == TRUE);
|
ASSERT(m_enabledVertexAttribIndices.empty() == true);
|
||||||
ASSERT(m_boundVertexBuffer->GetNumAttributes() >= m_boundShader->GetNumAttributes());
|
ASSERT(m_boundVertexBuffer->GetNumAttributes() >= m_boundShader->GetNumAttributes());
|
||||||
|
|
||||||
uint numAttributes = m_boundShader->GetNumAttributes();
|
uint numAttributes = m_boundShader->GetNumAttributes();
|
||||||
|
@ -593,12 +593,12 @@ void GraphicsDevice::SetShaderVertexAttributes()
|
||||||
buffer = (int8_t*)NULL + (offset * sizeof(float));
|
buffer = (int8_t*)NULL + (offset * sizeof(float));
|
||||||
|
|
||||||
GL_CALL(glEnableVertexAttribArray(i));
|
GL_CALL(glEnableVertexAttribArray(i));
|
||||||
GL_CALL(glVertexAttribPointer(i, size, GL_FLOAT, FALSE, m_boundVertexBuffer->GetElementWidthInBytes(), buffer));
|
GL_CALL(glVertexAttribPointer(i, size, GL_FLOAT, false, m_boundVertexBuffer->GetElementWidthInBytes(), buffer));
|
||||||
|
|
||||||
m_enabledVertexAttribIndices.push_back(i);
|
m_enabledVertexAttribIndices.push_back(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_shaderVertexAttribsSet = TRUE;
|
m_shaderVertexAttribsSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsDevice::ClearSetShaderVertexAttributes()
|
void GraphicsDevice::ClearSetShaderVertexAttributes()
|
||||||
|
@ -610,13 +610,13 @@ void GraphicsDevice::ClearSetShaderVertexAttributes()
|
||||||
GL_CALL(glDisableVertexAttribArray(index));
|
GL_CALL(glDisableVertexAttribArray(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
m_shaderVertexAttribsSet = FALSE;
|
m_shaderVertexAttribsSet = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsDevice::RenderTriangles(const IndexBuffer *buffer)
|
void GraphicsDevice::RenderTriangles(const IndexBuffer *buffer)
|
||||||
{
|
{
|
||||||
ASSERT(buffer != NULL);
|
ASSERT(buffer != NULL);
|
||||||
ASSERT(buffer->IsClientSideBuffer() == TRUE);
|
ASSERT(buffer->IsClientSideBuffer() == true);
|
||||||
ASSERT(m_boundVertexBuffer != NULL);
|
ASSERT(m_boundVertexBuffer != NULL);
|
||||||
ASSERT(m_boundIndexBuffer == NULL);
|
ASSERT(m_boundIndexBuffer == NULL);
|
||||||
if (!m_shaderVertexAttribsSet)
|
if (!m_shaderVertexAttribsSet)
|
||||||
|
@ -692,7 +692,7 @@ void GraphicsDevice::RenderTriangles(uint startVertex, uint numTriangles)
|
||||||
void GraphicsDevice::RenderLines(const IndexBuffer *buffer)
|
void GraphicsDevice::RenderLines(const IndexBuffer *buffer)
|
||||||
{
|
{
|
||||||
ASSERT(buffer != NULL);
|
ASSERT(buffer != NULL);
|
||||||
ASSERT(buffer->IsClientSideBuffer() == TRUE);
|
ASSERT(buffer->IsClientSideBuffer() == true);
|
||||||
ASSERT(m_boundVertexBuffer != NULL);
|
ASSERT(m_boundVertexBuffer != NULL);
|
||||||
ASSERT(m_boundIndexBuffer == NULL);
|
ASSERT(m_boundIndexBuffer == NULL);
|
||||||
if (!m_shaderVertexAttribsSet)
|
if (!m_shaderVertexAttribsSet)
|
||||||
|
@ -768,7 +768,7 @@ void GraphicsDevice::RenderLines(uint startVertex, uint numLines)
|
||||||
void GraphicsDevice::RenderPoints(const IndexBuffer *buffer)
|
void GraphicsDevice::RenderPoints(const IndexBuffer *buffer)
|
||||||
{
|
{
|
||||||
ASSERT(buffer != NULL);
|
ASSERT(buffer != NULL);
|
||||||
ASSERT(buffer->IsClientSideBuffer() == TRUE);
|
ASSERT(buffer->IsClientSideBuffer() == true);
|
||||||
ASSERT(m_boundVertexBuffer != NULL);
|
ASSERT(m_boundVertexBuffer != NULL);
|
||||||
ASSERT(m_boundIndexBuffer == NULL);
|
ASSERT(m_boundIndexBuffer == NULL);
|
||||||
if (!m_shaderVertexAttribsSet)
|
if (!m_shaderVertexAttribsSet)
|
||||||
|
|
|
@ -55,9 +55,9 @@ public:
|
||||||
* Initializes the graphics device object based on a parent window that is
|
* Initializes the graphics device object based on a parent window that is
|
||||||
* hosting the OpenGL context.
|
* hosting the OpenGL context.
|
||||||
* @param window a window with an active OpenGL context associated with it
|
* @param window a window with an active OpenGL context associated with it
|
||||||
* @return TRUE if successful, FALSE if not
|
* @return true if successful, false if not
|
||||||
*/
|
*/
|
||||||
BOOL Initialize(GameWindow *window);
|
bool Initialize(GameWindow *window);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* New OpenGL graphics context creation callback.
|
* New OpenGL graphics context creation callback.
|
||||||
|
@ -345,15 +345,15 @@ public:
|
||||||
DebugShader* GetDebugShader();
|
DebugShader* GetDebugShader();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return TRUE if depth textures are supported
|
* @return true if depth textures are supported
|
||||||
*/
|
*/
|
||||||
BOOL IsDepthTextureSupported() const { return m_isDepthTextureSupported; }
|
bool IsDepthTextureSupported() const { return m_isDepthTextureSupported; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return TRUE if textures with dimensions that are not a power of two
|
* @return true if textures with dimensions that are not a power of two
|
||||||
* are supported
|
* are supported
|
||||||
*/
|
*/
|
||||||
BOOL IsNonPowerOfTwoTextureSupported() const { return m_isNonPowerOfTwoTextureSupported; }
|
bool IsNonPowerOfTwoTextureSupported() const { return m_isNonPowerOfTwoTextureSupported; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the parent window object that this graphics device is for
|
* @return the parent window object that this graphics device is for
|
||||||
|
@ -366,7 +366,7 @@ private:
|
||||||
void BindIBO(IndexBuffer *buffer);
|
void BindIBO(IndexBuffer *buffer);
|
||||||
void BindClientBuffer(IndexBuffer *buffer);
|
void BindClientBuffer(IndexBuffer *buffer);
|
||||||
|
|
||||||
BOOL IsReadyToRender() const;
|
bool IsReadyToRender() const;
|
||||||
|
|
||||||
void SetShaderVertexAttributes();
|
void SetShaderVertexAttributes();
|
||||||
void ClearSetShaderVertexAttributes();
|
void ClearSetShaderVertexAttributes();
|
||||||
|
@ -379,10 +379,10 @@ private:
|
||||||
const IndexBuffer *m_boundIndexBuffer;
|
const IndexBuffer *m_boundIndexBuffer;
|
||||||
const Texture **m_boundTextures;
|
const Texture **m_boundTextures;
|
||||||
Shader *m_boundShader;
|
Shader *m_boundShader;
|
||||||
BOOL m_shaderVertexAttribsSet;
|
bool m_shaderVertexAttribsSet;
|
||||||
EnabledVertexAttribList m_enabledVertexAttribIndices;
|
EnabledVertexAttribList m_enabledVertexAttribIndices;
|
||||||
BOOL m_isDepthTextureSupported;
|
bool m_isDepthTextureSupported;
|
||||||
BOOL m_isNonPowerOfTwoTextureSupported;
|
bool m_isNonPowerOfTwoTextureSupported;
|
||||||
|
|
||||||
GameWindow *m_window;
|
GameWindow *m_window;
|
||||||
ViewContext *m_defaultViewContext;
|
ViewContext *m_defaultViewContext;
|
||||||
|
@ -401,7 +401,7 @@ private:
|
||||||
Sprite3DShader *m_sprite3dShader;
|
Sprite3DShader *m_sprite3dShader;
|
||||||
DebugShader *m_debugShader;
|
DebugShader *m_debugShader;
|
||||||
|
|
||||||
BOOL m_hasNewContextRunYet;
|
bool m_hasNewContextRunYet;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void GraphicsDevice::SetTextureParameters(const TextureParameters ¶ms)
|
inline void GraphicsDevice::SetTextureParameters(const TextureParameters ¶ms)
|
||||||
|
@ -409,12 +409,12 @@ inline void GraphicsDevice::SetTextureParameters(const TextureParameters ¶ms
|
||||||
m_currentTextureParams = params;
|
m_currentTextureParams = params;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline BOOL GraphicsDevice::IsReadyToRender() const
|
inline bool GraphicsDevice::IsReadyToRender() const
|
||||||
{
|
{
|
||||||
if (m_boundShader != NULL && m_boundVertexBuffer != NULL && m_shaderVertexAttribsSet)
|
if (m_boundShader != NULL && m_boundVertexBuffer != NULL && m_shaderVertexAttribsSet)
|
||||||
return TRUE;
|
return true;
|
||||||
else
|
else
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -32,16 +32,16 @@ void Image::Release()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BOOL Image::Create(uint width, uint height, IMAGE_FORMAT format)
|
bool Image::Create(uint width, uint height, IMAGE_FORMAT format)
|
||||||
{
|
{
|
||||||
ASSERT(m_pixels == NULL);
|
ASSERT(m_pixels == NULL);
|
||||||
if (m_pixels != NULL)
|
if (m_pixels != NULL)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
ASSERT(width != 0);
|
ASSERT(width != 0);
|
||||||
ASSERT(height != 0);
|
ASSERT(height != 0);
|
||||||
if (width == 0 || height == 0)
|
if (width == 0 || height == 0)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
int bpp = 0;
|
int bpp = 0;
|
||||||
if (format == IMAGE_FORMAT_RGB)
|
if (format == IMAGE_FORMAT_RGB)
|
||||||
|
@ -53,7 +53,7 @@ BOOL Image::Create(uint width, uint height, IMAGE_FORMAT format)
|
||||||
|
|
||||||
ASSERT(bpp != 0);
|
ASSERT(bpp != 0);
|
||||||
if (bpp == 0)
|
if (bpp == 0)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
uint pixelsLength = (width * height) * (bpp / 8);
|
uint pixelsLength = (width * height) * (bpp / 8);
|
||||||
m_pixels = new uint8_t[pixelsLength];
|
m_pixels = new uint8_t[pixelsLength];
|
||||||
|
@ -65,59 +65,59 @@ BOOL Image::Create(uint width, uint height, IMAGE_FORMAT format)
|
||||||
m_format = format;
|
m_format = format;
|
||||||
m_pitch = width * (bpp / 8);
|
m_pitch = width * (bpp / 8);
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL Image::Create(const Image *source)
|
bool Image::Create(const Image *source)
|
||||||
{
|
{
|
||||||
ASSERT(source != NULL);
|
ASSERT(source != NULL);
|
||||||
if (source == NULL)
|
if (source == NULL)
|
||||||
return FALSE;
|
return false;
|
||||||
else
|
else
|
||||||
return Create(source, 0, 0, source->GetWidth(), source->GetHeight());
|
return Create(source, 0, 0, source->GetWidth(), source->GetHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL Image::Create(const Image *source, uint x, uint y, uint width, uint height)
|
bool Image::Create(const Image *source, uint x, uint y, uint width, uint height)
|
||||||
{
|
{
|
||||||
ASSERT(m_pixels == NULL);
|
ASSERT(m_pixels == NULL);
|
||||||
if (m_pixels != NULL)
|
if (m_pixels != NULL)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
ASSERT(source != NULL);
|
ASSERT(source != NULL);
|
||||||
if (source == NULL)
|
if (source == NULL)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
ASSERT(source->GetPixels() != NULL);
|
ASSERT(source->GetPixels() != NULL);
|
||||||
if (source->GetPixels() == NULL)
|
if (source->GetPixels() == NULL)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
ASSERT(x < source->GetWidth());
|
ASSERT(x < source->GetWidth());
|
||||||
ASSERT(y < source->GetHeight());
|
ASSERT(y < source->GetHeight());
|
||||||
ASSERT((x + width) <= source->GetWidth());
|
ASSERT((x + width) <= source->GetWidth());
|
||||||
ASSERT((y + height) <= source->GetHeight());
|
ASSERT((y + height) <= source->GetHeight());
|
||||||
|
|
||||||
BOOL baseCreateSuccess = Create(width, height, source->GetFormat());
|
bool baseCreateSuccess = Create(width, height, source->GetFormat());
|
||||||
if (!baseCreateSuccess)
|
if (!baseCreateSuccess)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
Copy(source, x, y, width, height, 0, 0);
|
Copy(source, x, y, width, height, 0, 0);
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL Image::Create(File *file)
|
bool Image::Create(File *file)
|
||||||
{
|
{
|
||||||
ASSERT(m_pixels == NULL);
|
ASSERT(m_pixels == NULL);
|
||||||
if (m_pixels != NULL)
|
if (m_pixels != NULL)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
ASSERT(file != NULL);
|
ASSERT(file != NULL);
|
||||||
if (file == NULL)
|
if (file == NULL)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
ASSERT(file->IsOpen());
|
ASSERT(file->IsOpen());
|
||||||
if (!file->IsOpen())
|
if (!file->IsOpen())
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
uint8_t *imageFileBytes = NULL;
|
uint8_t *imageFileBytes = NULL;
|
||||||
size_t imageFileSize = file->GetFileSize();
|
size_t imageFileSize = file->GetFileSize();
|
||||||
|
@ -147,7 +147,7 @@ BOOL Image::Create(File *file)
|
||||||
if (file->GetFileType() != FILETYPE_MEMORY)
|
if (file->GetFileType() != FILETYPE_MEMORY)
|
||||||
SAFE_DELETE_ARRAY(imageFileBytes);
|
SAFE_DELETE_ARRAY(imageFileBytes);
|
||||||
|
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -166,7 +166,7 @@ BOOL Image::Create(File *file)
|
||||||
{
|
{
|
||||||
ASSERT(!"Unrecognized componentsPerPixel value.");
|
ASSERT(!"Unrecognized componentsPerPixel value.");
|
||||||
stbi_image_free(pixels);
|
stbi_image_free(pixels);
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy from STB "owned" memory to our own, then free up the STB stuff
|
// copy from STB "owned" memory to our own, then free up the STB stuff
|
||||||
|
@ -183,7 +183,7 @@ BOOL Image::Create(File *file)
|
||||||
m_format = format;
|
m_format = format;
|
||||||
m_pitch = width * componentsPerPixel;
|
m_pitch = width * componentsPerPixel;
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,16 +26,16 @@ public:
|
||||||
* @param width the width of the image
|
* @param width the width of the image
|
||||||
* @param height the height of the image
|
* @param height the height of the image
|
||||||
* @param format the pixel format of the image
|
* @param format the pixel format of the image
|
||||||
* @return TRUE if successful
|
* @return true if successful
|
||||||
*/
|
*/
|
||||||
BOOL Create(uint width, uint height, IMAGE_FORMAT format);
|
bool Create(uint width, uint height, IMAGE_FORMAT format);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a copy of an image from another image object.
|
* Creates a copy of an image from another image object.
|
||||||
* @param source the source image object to copy
|
* @param source the source image object to copy
|
||||||
* @return TRUE if successful
|
* @return true if successful
|
||||||
*/
|
*/
|
||||||
BOOL Create(const Image *source);
|
bool Create(const Image *source);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a copy of a subsection of an image.
|
* Creates a copy of a subsection of an image.
|
||||||
|
@ -44,16 +44,16 @@ public:
|
||||||
* @param y top Y coordinate of the source region to copy
|
* @param y top Y coordinate of the source region to copy
|
||||||
* @param width the width of the source region to copy
|
* @param width the width of the source region to copy
|
||||||
* @param height the height of the source region to copy
|
* @param height the height of the source region to copy
|
||||||
* @return TRUE if successful
|
* @return true if successful
|
||||||
*/
|
*/
|
||||||
BOOL Create(const Image *source, uint x, uint y, uint width, uint height);
|
bool Create(const Image *source, uint x, uint y, uint width, uint height);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an image from an image file.
|
* Creates an image from an image file.
|
||||||
* @param file the file to load as an image
|
* @param file the file to load as an image
|
||||||
* @return TRUE if successful
|
* @return true if successful
|
||||||
*/
|
*/
|
||||||
BOOL Create(File *file);
|
bool Create(File *file);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Frees all image resources.
|
* Frees all image resources.
|
||||||
|
|
|
@ -18,53 +18,53 @@ void IndexBuffer::Release()
|
||||||
BufferObject::Release();
|
BufferObject::Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL IndexBuffer::Initialize(uint numIndices, BUFFEROBJECT_USAGE usage)
|
bool IndexBuffer::Initialize(uint numIndices, BUFFEROBJECT_USAGE usage)
|
||||||
{
|
{
|
||||||
return Initialize(NULL, numIndices, usage);
|
return Initialize(NULL, numIndices, usage);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL IndexBuffer::Initialize(GraphicsDevice *graphicsDevice, uint numIndices, BUFFEROBJECT_USAGE usage)
|
bool IndexBuffer::Initialize(GraphicsDevice *graphicsDevice, uint numIndices, BUFFEROBJECT_USAGE usage)
|
||||||
{
|
{
|
||||||
ASSERT(m_buffer.size() == 0);
|
ASSERT(m_buffer.size() == 0);
|
||||||
if (m_buffer.size() > 0)
|
if (m_buffer.size() > 0)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
ASSERT(numIndices > 0);
|
ASSERT(numIndices > 0);
|
||||||
if (numIndices == 0)
|
if (numIndices == 0)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
if (!BufferObject::Initialize(graphicsDevice, BUFFEROBJECT_TYPE_INDEX, usage))
|
if (!BufferObject::Initialize(graphicsDevice, BUFFEROBJECT_TYPE_INDEX, usage))
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
Resize(numIndices);
|
Resize(numIndices);
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL IndexBuffer::Initialize(const IndexBuffer *source)
|
bool IndexBuffer::Initialize(const IndexBuffer *source)
|
||||||
{
|
{
|
||||||
return Initialize(NULL, source);
|
return Initialize(NULL, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL IndexBuffer::Initialize(GraphicsDevice *graphicsDevice, const IndexBuffer *source)
|
bool IndexBuffer::Initialize(GraphicsDevice *graphicsDevice, const IndexBuffer *source)
|
||||||
{
|
{
|
||||||
ASSERT(m_buffer.size() == 0);
|
ASSERT(m_buffer.size() == 0);
|
||||||
if (m_buffer.size() > 0)
|
if (m_buffer.size() > 0)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
ASSERT(source != NULL);
|
ASSERT(source != NULL);
|
||||||
if (source == NULL)
|
if (source == NULL)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
ASSERT(source->GetNumElements() > 0);
|
ASSERT(source->GetNumElements() > 0);
|
||||||
if (source->GetNumElements() == 0)
|
if (source->GetNumElements() == 0)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
Resize(source->GetNumElements());
|
Resize(source->GetNumElements());
|
||||||
|
|
||||||
memcpy(&m_buffer[0], source->GetBuffer(), GetNumElements() * GetElementWidthInBytes());
|
memcpy(&m_buffer[0], source->GetBuffer(), GetNumElements() * GetElementWidthInBytes());
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IndexBuffer::Set(const uint16_t *indices, uint numIndices)
|
void IndexBuffer::Set(const uint16_t *indices, uint numIndices)
|
||||||
|
|
|
@ -28,9 +28,9 @@ public:
|
||||||
* Initializes the index buffer.
|
* Initializes the index buffer.
|
||||||
* @param numIndices the initial number of indices the buffer should hold
|
* @param numIndices the initial number of indices the buffer should hold
|
||||||
* @param usage the expected usage pattern of this index buffer
|
* @param usage the expected usage pattern of this index buffer
|
||||||
* @return TRUE if successful, FALSE if not
|
* @return true if successful, false if not
|
||||||
*/
|
*/
|
||||||
BOOL Initialize(uint numIndices, BUFFEROBJECT_USAGE usage);
|
bool Initialize(uint numIndices, BUFFEROBJECT_USAGE usage);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the index buffer.
|
* Initializes the index buffer.
|
||||||
|
@ -38,25 +38,25 @@ public:
|
||||||
* on the GPU
|
* on the GPU
|
||||||
* @param numIndices the initial number of indices the buffer should hold
|
* @param numIndices the initial number of indices the buffer should hold
|
||||||
* @param usage the expected usage pattern of this index buffer
|
* @param usage the expected usage pattern of this index buffer
|
||||||
* @return TRUE if successful, FALSE if not
|
* @return true if successful, false if not
|
||||||
*/
|
*/
|
||||||
BOOL Initialize(GraphicsDevice *graphicsDevice, uint numIndices, BUFFEROBJECT_USAGE usage);
|
bool Initialize(GraphicsDevice *graphicsDevice, uint numIndices, BUFFEROBJECT_USAGE usage);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the index buffer.
|
* Initializes the index buffer.
|
||||||
* @param source the source buffer to copy during creation of this buffer
|
* @param source the source buffer to copy during creation of this buffer
|
||||||
* @return TRUE if successful, FALSE if not
|
* @return true if successful, false if not
|
||||||
*/
|
*/
|
||||||
BOOL Initialize(const IndexBuffer *source);
|
bool Initialize(const IndexBuffer *source);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the index buffer.
|
* Initializes the index buffer.
|
||||||
* @param graphicsDevice the graphics device to use to create this buffer
|
* @param graphicsDevice the graphics device to use to create this buffer
|
||||||
* on the GPU
|
* on the GPU
|
||||||
* @param source the source buffer to copy during creation of this buffer
|
* @param source the source buffer to copy during creation of this buffer
|
||||||
* @return TRUE if successful, FALSE if not
|
* @return true if successful, false if not
|
||||||
*/
|
*/
|
||||||
BOOL Initialize(GraphicsDevice *graphicsDevice, const IndexBuffer *source);
|
bool Initialize(GraphicsDevice *graphicsDevice, const IndexBuffer *source);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copies the source indices over top of this buffer's existing indices.
|
* Copies the source indices over top of this buffer's existing indices.
|
||||||
|
@ -74,17 +74,17 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Moves the current index position to the next position.
|
* Moves the current index position to the next position.
|
||||||
* @return TRUE if the move succeeded, FALSE if there is no more indices
|
* @return true if the move succeeded, false if there is no more indices
|
||||||
* to move to after this one
|
* to move to after this one
|
||||||
*/
|
*/
|
||||||
BOOL MoveNext();
|
bool MoveNext();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Moves the current index position to the previous position.
|
* Moves the current index position to the previous position.
|
||||||
* @return TRUE if the move succeeded, FALSE if there is no more indices
|
* @return true if the move succeeded, false if there is no more indices
|
||||||
* to move to before the current one
|
* to move to before the current one
|
||||||
*/
|
*/
|
||||||
BOOL MovePrevious();
|
bool MovePrevious();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Moves the current index position by the specified amount relative
|
* Moves the current index position by the specified amount relative
|
||||||
|
@ -168,26 +168,26 @@ inline void IndexBuffer::SetIndex(uint index, uint16_t value)
|
||||||
m_buffer[index] = value;
|
m_buffer[index] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline BOOL IndexBuffer::MoveNext()
|
inline bool IndexBuffer::MoveNext()
|
||||||
{
|
{
|
||||||
++m_currentIndex;
|
++m_currentIndex;
|
||||||
if (m_currentIndex >= GetNumElements())
|
if (m_currentIndex >= GetNumElements())
|
||||||
{
|
{
|
||||||
--m_currentIndex;
|
--m_currentIndex;
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline BOOL IndexBuffer::MovePrevious()
|
inline bool IndexBuffer::MovePrevious()
|
||||||
{
|
{
|
||||||
if (m_currentIndex == 0)
|
if (m_currentIndex == 0)
|
||||||
return FALSE;
|
return false;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
--m_currentIndex;
|
--m_currentIndex;
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,20 +15,20 @@ Renderbuffer::Renderbuffer()
|
||||||
m_type = FRAMEBUFFER_DATA_NONE;
|
m_type = FRAMEBUFFER_DATA_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL Renderbuffer::Initialize(GraphicsDevice *graphicsDevice, uint width, uint height, FRAMEBUFFER_DATA_TYPE type)
|
bool Renderbuffer::Initialize(GraphicsDevice *graphicsDevice, uint width, uint height, FRAMEBUFFER_DATA_TYPE type)
|
||||||
{
|
{
|
||||||
ASSERT(m_renderbufferName == 0);
|
ASSERT(m_renderbufferName == 0);
|
||||||
if (m_renderbufferName != 0)
|
if (m_renderbufferName != 0)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
if (!GraphicsContextResource::Initialize(graphicsDevice))
|
if (!GraphicsContextResource::Initialize(graphicsDevice))
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
m_width = width;
|
m_width = width;
|
||||||
m_height = height;
|
m_height = height;
|
||||||
m_type = type;
|
m_type = type;
|
||||||
|
|
||||||
BOOL success = CreateRenderbuffer();
|
bool success = CreateRenderbuffer();
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
m_width = 0;
|
m_width = 0;
|
||||||
|
@ -54,7 +54,7 @@ void Renderbuffer::Release()
|
||||||
GraphicsContextResource::Release();
|
GraphicsContextResource::Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL Renderbuffer::CreateRenderbuffer()
|
bool Renderbuffer::CreateRenderbuffer()
|
||||||
{
|
{
|
||||||
ASSERT(m_renderbufferName == 0);
|
ASSERT(m_renderbufferName == 0);
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ BOOL Renderbuffer::CreateRenderbuffer()
|
||||||
#endif
|
#endif
|
||||||
ASSERT(format != 0);
|
ASSERT(format != 0);
|
||||||
if (format == 0)
|
if (format == 0)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
GL_CALL(glGenRenderbuffers(1, &m_renderbufferName));
|
GL_CALL(glGenRenderbuffers(1, &m_renderbufferName));
|
||||||
|
|
||||||
|
@ -108,15 +108,15 @@ BOOL Renderbuffer::CreateRenderbuffer()
|
||||||
// object that this will get attached to manage that for itself...
|
// object that this will get attached to manage that for itself...
|
||||||
GetGraphicsDevice()->UnbindRenderbuffer();
|
GetGraphicsDevice()->UnbindRenderbuffer();
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderbuffer::OnNewContext()
|
void Renderbuffer::OnNewContext()
|
||||||
{
|
{
|
||||||
if (m_renderbufferName == 0 && GetGraphicsDevice() != NULL)
|
if (m_renderbufferName == 0 && GetGraphicsDevice() != NULL)
|
||||||
{
|
{
|
||||||
BOOL success = CreateRenderbuffer();
|
bool success = CreateRenderbuffer();
|
||||||
ASSERT(success == TRUE);
|
ASSERT(success == true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,9 +29,9 @@ public:
|
||||||
* @param width the width of the renderbuffer in pixels
|
* @param width the width of the renderbuffer in pixels
|
||||||
* @param height the height of the renderbuffer in pixels
|
* @param height the height of the renderbuffer in pixels
|
||||||
* @param format the type of data this renderbuffer contains
|
* @param format the type of data this renderbuffer contains
|
||||||
* @return TRUE if the renderbuffer was created successfully
|
* @return true if the renderbuffer was created successfully
|
||||||
*/
|
*/
|
||||||
BOOL Initialize(GraphicsDevice *graphicsDevice, uint width, uint height, FRAMEBUFFER_DATA_TYPE type);
|
bool Initialize(GraphicsDevice *graphicsDevice, uint width, uint height, FRAMEBUFFER_DATA_TYPE type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the name or ID assigned to this renderbuffer by OpenGL
|
* @return the name or ID assigned to this renderbuffer by OpenGL
|
||||||
|
@ -54,9 +54,9 @@ public:
|
||||||
FRAMEBUFFER_DATA_TYPE GetType() const { return m_type; }
|
FRAMEBUFFER_DATA_TYPE GetType() const { return m_type; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return TRUE if the renderbuffer has been marked as invalid and needs to be recreated
|
* @return true if the renderbuffer has been marked as invalid and needs to be recreated
|
||||||
*/
|
*/
|
||||||
BOOL IsInvalidated() const { return m_renderbufferName == 0; }
|
bool IsInvalidated() const { return m_renderbufferName == 0; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* New OpenGL graphics context creation callback.
|
* New OpenGL graphics context creation callback.
|
||||||
|
@ -69,7 +69,7 @@ public:
|
||||||
void OnLostContext();
|
void OnLostContext();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BOOL CreateRenderbuffer();
|
bool CreateRenderbuffer();
|
||||||
|
|
||||||
uint m_renderbufferName;
|
uint m_renderbufferName;
|
||||||
uint m_width;
|
uint m_width;
|
||||||
|
|
|
@ -14,9 +14,9 @@ RenderState::~RenderState()
|
||||||
|
|
||||||
void RenderState::Initialize()
|
void RenderState::Initialize()
|
||||||
{
|
{
|
||||||
m_depthTesting = TRUE;
|
m_depthTesting = true;
|
||||||
m_depthFunction = DEPTH_LESS;
|
m_depthFunction = DEPTH_LESS;
|
||||||
m_faceCulling = TRUE;
|
m_faceCulling = true;
|
||||||
m_faceCullingMode = BACK;
|
m_faceCullingMode = BACK;
|
||||||
m_lineWidth = 1.0f;
|
m_lineWidth = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,9 +43,9 @@ public:
|
||||||
void Apply() const;
|
void Apply() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return TRUE if depth testing is enabled
|
* @return true if depth testing is enabled
|
||||||
*/
|
*/
|
||||||
BOOL GetDepthTesting() const { return m_depthTesting; }
|
bool GetDepthTesting() const { return m_depthTesting; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the depth testing function
|
* @return the depth testing function
|
||||||
|
@ -53,9 +53,9 @@ public:
|
||||||
DEPTH_FUNCTION GetDepthFunction() const { return m_depthFunction; }
|
DEPTH_FUNCTION GetDepthFunction() const { return m_depthFunction; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return TRUE if polygons are being culled based on their vertices winding
|
* @return true if polygons are being culled based on their vertices winding
|
||||||
*/
|
*/
|
||||||
BOOL GetFaceCulling() const { return m_faceCulling; }
|
bool GetFaceCulling() const { return m_faceCulling; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the polygon cull mode
|
* @return the polygon cull mode
|
||||||
|
@ -70,7 +70,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Toggles depth testing on/off.
|
* Toggles depth testing on/off.
|
||||||
*/
|
*/
|
||||||
void SetDepthTesting(BOOL enable) { m_depthTesting = enable; }
|
void SetDepthTesting(bool enable) { m_depthTesting = enable; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the depth testing function.
|
* Sets the depth testing function.
|
||||||
|
@ -80,7 +80,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Toggles polygon culling based on their vertices winding on/off.
|
* Toggles polygon culling based on their vertices winding on/off.
|
||||||
*/
|
*/
|
||||||
void SetFaceCulling(BOOL enable) { m_faceCulling = enable; }
|
void SetFaceCulling(bool enable) { m_faceCulling = enable; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the polygon culling mode.
|
* Sets the polygon culling mode.
|
||||||
|
@ -97,9 +97,9 @@ private:
|
||||||
void SetFaceCulling() const;
|
void SetFaceCulling() const;
|
||||||
int FindDepthFunctionValue(DEPTH_FUNCTION function) const;
|
int FindDepthFunctionValue(DEPTH_FUNCTION function) const;
|
||||||
|
|
||||||
BOOL m_depthTesting;
|
bool m_depthTesting;
|
||||||
DEPTH_FUNCTION m_depthFunction;
|
DEPTH_FUNCTION m_depthFunction;
|
||||||
BOOL m_faceCulling;
|
bool m_faceCulling;
|
||||||
CULL_MODE m_faceCullingMode;
|
CULL_MODE m_faceCullingMode;
|
||||||
float m_lineWidth;
|
float m_lineWidth;
|
||||||
};
|
};
|
||||||
|
|
|
@ -32,12 +32,12 @@ STATIC_ASSERT(sizeof(Point3) == 3 * sizeof(int));
|
||||||
|
|
||||||
Shader::Shader()
|
Shader::Shader()
|
||||||
{
|
{
|
||||||
m_isBound = FALSE;
|
m_isBound = false;
|
||||||
m_cachedVertexShaderSource = NULL;
|
m_cachedVertexShaderSource = NULL;
|
||||||
m_cachedFragmentShaderSource = NULL;
|
m_cachedFragmentShaderSource = NULL;
|
||||||
m_vertexShaderCompileStatus = FALSE;
|
m_vertexShaderCompileStatus = 0;
|
||||||
m_fragmentShaderCompileStatus = FALSE;
|
m_fragmentShaderCompileStatus = 0;
|
||||||
m_linkStatus = FALSE;
|
m_linkStatus = 0;
|
||||||
m_vertexShaderId = 0;
|
m_vertexShaderId = 0;
|
||||||
m_fragmentShaderId = 0;
|
m_fragmentShaderId = 0;
|
||||||
m_programId = 0;
|
m_programId = 0;
|
||||||
|
@ -45,44 +45,44 @@ Shader::Shader()
|
||||||
m_numAttributes = 0;
|
m_numAttributes = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL Shader::Initialize(GraphicsDevice *graphicsDevice)
|
bool Shader::Initialize(GraphicsDevice *graphicsDevice)
|
||||||
{
|
{
|
||||||
if (!GraphicsContextResource::Initialize(graphicsDevice))
|
if (!GraphicsContextResource::Initialize(graphicsDevice))
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL Shader::Initialize(GraphicsDevice *graphicsDevice, const char *vertexShaderSource, const char *fragmentShaderSource)
|
bool Shader::Initialize(GraphicsDevice *graphicsDevice, const char *vertexShaderSource, const char *fragmentShaderSource)
|
||||||
{
|
{
|
||||||
if (!GraphicsContextResource::Initialize(graphicsDevice))
|
if (!GraphicsContextResource::Initialize(graphicsDevice))
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
ASSERT(vertexShaderSource != NULL);
|
ASSERT(vertexShaderSource != NULL);
|
||||||
if (vertexShaderSource == NULL)
|
if (vertexShaderSource == NULL)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
ASSERT(fragmentShaderSource != NULL);
|
ASSERT(fragmentShaderSource != NULL);
|
||||||
if (fragmentShaderSource == NULL)
|
if (fragmentShaderSource == NULL)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
if (!LoadCompileAndLink(vertexShaderSource, fragmentShaderSource))
|
if (!LoadCompileAndLink(vertexShaderSource, fragmentShaderSource))
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
CacheShaderSources(vertexShaderSource, fragmentShaderSource);
|
CacheShaderSources(vertexShaderSource, fragmentShaderSource);
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL Shader::Initialize(GraphicsDevice *graphicsDevice, const Text *vertexShaderSource, const Text *fragmentShaderSource)
|
bool Shader::Initialize(GraphicsDevice *graphicsDevice, const Text *vertexShaderSource, const Text *fragmentShaderSource)
|
||||||
{
|
{
|
||||||
ASSERT(vertexShaderSource != NULL && vertexShaderSource->GetLength() > 0);
|
ASSERT(vertexShaderSource != NULL && vertexShaderSource->GetLength() > 0);
|
||||||
if (vertexShaderSource == NULL || vertexShaderSource->GetLength() == 0)
|
if (vertexShaderSource == NULL || vertexShaderSource->GetLength() == 0)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
ASSERT(fragmentShaderSource != NULL && fragmentShaderSource->GetLength() > 0);
|
ASSERT(fragmentShaderSource != NULL && fragmentShaderSource->GetLength() > 0);
|
||||||
if (fragmentShaderSource == NULL && fragmentShaderSource->GetLength() == 0)
|
if (fragmentShaderSource == NULL && fragmentShaderSource->GetLength() == 0)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
return Initialize(graphicsDevice, vertexShaderSource->GetText(), fragmentShaderSource->GetText());
|
return Initialize(graphicsDevice, vertexShaderSource->GetText(), fragmentShaderSource->GetText());
|
||||||
}
|
}
|
||||||
|
@ -117,12 +117,12 @@ void Shader::Release()
|
||||||
SAFE_DELETE_ARRAY(m_cachedFragmentShaderSource);
|
SAFE_DELETE_ARRAY(m_cachedFragmentShaderSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_isBound = FALSE;
|
m_isBound = false;
|
||||||
m_cachedVertexShaderSource = NULL;
|
m_cachedVertexShaderSource = NULL;
|
||||||
m_cachedFragmentShaderSource = NULL;
|
m_cachedFragmentShaderSource = NULL;
|
||||||
m_vertexShaderCompileStatus = FALSE;
|
m_vertexShaderCompileStatus = 0;
|
||||||
m_fragmentShaderCompileStatus = FALSE;
|
m_fragmentShaderCompileStatus = 0;
|
||||||
m_linkStatus = FALSE;
|
m_linkStatus = 0;
|
||||||
m_vertexShaderId = 0;
|
m_vertexShaderId = 0;
|
||||||
m_fragmentShaderId = 0;
|
m_fragmentShaderId = 0;
|
||||||
m_programId = 0;
|
m_programId = 0;
|
||||||
|
@ -136,7 +136,7 @@ void Shader::Release()
|
||||||
GraphicsContextResource::Release();
|
GraphicsContextResource::Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL Shader::LoadCompileAndLink(const char *vertexShaderSource, const char *fragmentShaderSource)
|
bool Shader::LoadCompileAndLink(const char *vertexShaderSource, const char *fragmentShaderSource)
|
||||||
{
|
{
|
||||||
const char *vertexShaderToLoad = vertexShaderSource;
|
const char *vertexShaderToLoad = vertexShaderSource;
|
||||||
const char *fragmentShaderToLoad = fragmentShaderSource;
|
const char *fragmentShaderToLoad = fragmentShaderSource;
|
||||||
|
@ -152,24 +152,24 @@ BOOL Shader::LoadCompileAndLink(const char *vertexShaderSource, const char *frag
|
||||||
ASSERT(fragmentShaderToLoad != NULL);
|
ASSERT(fragmentShaderToLoad != NULL);
|
||||||
|
|
||||||
if (!Compile(vertexShaderToLoad, fragmentShaderToLoad))
|
if (!Compile(vertexShaderToLoad, fragmentShaderToLoad))
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
if (!Link())
|
if (!Link())
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
LoadUniformInfo();
|
LoadUniformInfo();
|
||||||
LoadAttributeInfo();
|
LoadAttributeInfo();
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL Shader::ReloadCompileAndLink(const char *vertexShaderSource, const char *fragmentShaderSource)
|
bool Shader::ReloadCompileAndLink(const char *vertexShaderSource, const char *fragmentShaderSource)
|
||||||
{
|
{
|
||||||
// clear out data that will be reset during the reload first
|
// clear out data that will be reset during the reload first
|
||||||
m_isBound = FALSE;
|
m_isBound = false;
|
||||||
m_vertexShaderCompileStatus = FALSE;
|
m_vertexShaderCompileStatus = 0;
|
||||||
m_fragmentShaderCompileStatus = FALSE;
|
m_fragmentShaderCompileStatus = 0;
|
||||||
m_linkStatus = FALSE;
|
m_linkStatus = 0;
|
||||||
m_vertexShaderId = 0;
|
m_vertexShaderId = 0;
|
||||||
m_fragmentShaderId = 0;
|
m_fragmentShaderId = 0;
|
||||||
m_programId = 0;
|
m_programId = 0;
|
||||||
|
@ -216,7 +216,7 @@ void Shader::CacheShaderSources(const char *vertexShaderSource, const char *frag
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL Shader::Compile(const char *vertexShaderSource, const char *fragmentShaderSource)
|
bool Shader::Compile(const char *vertexShaderSource, const char *fragmentShaderSource)
|
||||||
{
|
{
|
||||||
ASSERT(m_vertexShaderId == 0);
|
ASSERT(m_vertexShaderId == 0);
|
||||||
ASSERT(m_fragmentShaderId == 0);
|
ASSERT(m_fragmentShaderId == 0);
|
||||||
|
@ -292,12 +292,12 @@ BOOL Shader::Compile(const char *vertexShaderSource, const char *fragmentShaderS
|
||||||
|
|
||||||
// only return success if both compiled successfully
|
// only return success if both compiled successfully
|
||||||
if (m_fragmentShaderCompileStatus && m_vertexShaderCompileStatus)
|
if (m_fragmentShaderCompileStatus && m_vertexShaderCompileStatus)
|
||||||
return TRUE;
|
return true;
|
||||||
else
|
else
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL Shader::Link()
|
bool Shader::Link()
|
||||||
{
|
{
|
||||||
ASSERT(m_vertexShaderId != 0);
|
ASSERT(m_vertexShaderId != 0);
|
||||||
ASSERT(m_fragmentShaderId != 0);
|
ASSERT(m_fragmentShaderId != 0);
|
||||||
|
@ -434,7 +434,7 @@ void Shader::LoadAttributeInfo()
|
||||||
attribute.location = (uint)location;
|
attribute.location = (uint)location;
|
||||||
attribute.type = (uint)type;
|
attribute.type = (uint)type;
|
||||||
attribute.size = (uint)size;
|
attribute.size = (uint)size;
|
||||||
attribute.isTypeBound = FALSE;
|
attribute.isTypeBound = false;
|
||||||
stl::string name = attributeName;
|
stl::string name = attributeName;
|
||||||
|
|
||||||
m_attributes[name] = attribute;
|
m_attributes[name] = attribute;
|
||||||
|
@ -443,13 +443,13 @@ void Shader::LoadAttributeInfo()
|
||||||
SAFE_DELETE_ARRAY(attributeName);
|
SAFE_DELETE_ARRAY(attributeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL Shader::HasUniform(const stl::string &name) const
|
bool Shader::HasUniform(const stl::string &name) const
|
||||||
{
|
{
|
||||||
ShaderUniformMap::const_iterator i = m_uniforms.find(name);
|
ShaderUniformMap::const_iterator i = m_uniforms.find(name);
|
||||||
if (i == m_uniforms.end())
|
if (i == m_uniforms.end())
|
||||||
return FALSE;
|
return false;
|
||||||
else
|
else
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ShaderUniform* Shader::GetUniform(const stl::string &name) const
|
const ShaderUniform* Shader::GetUniform(const stl::string &name) const
|
||||||
|
@ -470,13 +470,13 @@ ShaderUniform* Shader::GetUniform(const stl::string &name)
|
||||||
return &i->second;
|
return &i->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL Shader::HasAttribute(const stl::string &name) const
|
bool Shader::HasAttribute(const stl::string &name) const
|
||||||
{
|
{
|
||||||
ShaderAttributeMap::const_iterator i = m_attributes.find(name);
|
ShaderAttributeMap::const_iterator i = m_attributes.find(name);
|
||||||
if (i == m_attributes.end())
|
if (i == m_attributes.end())
|
||||||
return FALSE;
|
return false;
|
||||||
else
|
else
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ShaderAttribute* Shader::GetAttribute(const stl::string &name) const
|
const ShaderAttribute* Shader::GetAttribute(const stl::string &name) const
|
||||||
|
@ -516,7 +516,7 @@ CachedShaderUniform* Shader::GetCachedUniform(const stl::string &name)
|
||||||
|
|
||||||
void Shader::FlushCachedUniforms()
|
void Shader::FlushCachedUniforms()
|
||||||
{
|
{
|
||||||
ASSERT(m_isBound == TRUE);
|
ASSERT(m_isBound == true);
|
||||||
if (m_cachedUniforms.empty())
|
if (m_cachedUniforms.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -851,7 +851,7 @@ void Shader::SetUniform(const stl::string &name, const Matrix3x3 &m)
|
||||||
const ShaderUniform *uniform = GetUniform(name);
|
const ShaderUniform *uniform = GetUniform(name);
|
||||||
ASSERT(uniform != NULL);
|
ASSERT(uniform != NULL);
|
||||||
ASSERT(uniform->size == 1);
|
ASSERT(uniform->size == 1);
|
||||||
GL_CALL(glUniformMatrix3fv(uniform->location, 1, FALSE, m.m));
|
GL_CALL(glUniformMatrix3fv(uniform->location, 1, false, m.m));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -869,7 +869,7 @@ void Shader::SetUniform(const stl::string &name, const Matrix4x4 &m)
|
||||||
const ShaderUniform *uniform = GetUniform(name);
|
const ShaderUniform *uniform = GetUniform(name);
|
||||||
ASSERT(uniform != NULL);
|
ASSERT(uniform != NULL);
|
||||||
ASSERT(uniform->size == 1);
|
ASSERT(uniform->size == 1);
|
||||||
GL_CALL(glUniformMatrix4fv(uniform->location, 1, FALSE, m.m));
|
GL_CALL(glUniformMatrix4fv(uniform->location, 1, false, m.m));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -998,7 +998,7 @@ void Shader::SetUniform(const stl::string &name, const Matrix3x3 *m, uint count)
|
||||||
ASSERT(uniform != NULL);
|
ASSERT(uniform != NULL);
|
||||||
ASSERT(uniform->size >= count);
|
ASSERT(uniform->size >= count);
|
||||||
|
|
||||||
GL_CALL(glUniformMatrix3fv(uniform->location, count, FALSE, values));
|
GL_CALL(glUniformMatrix3fv(uniform->location, count, false, values));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1017,7 +1017,7 @@ void Shader::SetUniform(const stl::string &name, const Matrix4x4 *m, uint count)
|
||||||
ASSERT(uniform != NULL);
|
ASSERT(uniform != NULL);
|
||||||
ASSERT(uniform->size >= count);
|
ASSERT(uniform->size >= count);
|
||||||
|
|
||||||
GL_CALL(glUniformMatrix4fv(uniform->location, count, FALSE, values));
|
GL_CALL(glUniformMatrix4fv(uniform->location, count, false, values));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1032,10 +1032,10 @@ void Shader::MapAttributeToVboAttribIndex(const stl::string &name, uint vboAttri
|
||||||
ASSERT(attribute->location < m_numAttributes);
|
ASSERT(attribute->location < m_numAttributes);
|
||||||
|
|
||||||
ShaderAttributeMapInfo *mappingInfo = &m_attributeMapping[attribute->location];
|
ShaderAttributeMapInfo *mappingInfo = &m_attributeMapping[attribute->location];
|
||||||
mappingInfo->usesStandardType = FALSE;
|
mappingInfo->usesStandardType = false;
|
||||||
mappingInfo->attribIndex = vboAttribIndex;
|
mappingInfo->attribIndex = vboAttribIndex;
|
||||||
|
|
||||||
attribute->isTypeBound = TRUE;
|
attribute->isTypeBound = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Shader::MapAttributeToStandardAttribType(const stl::string &name, VERTEX_STANDARD_ATTRIBS standardAttribType)
|
void Shader::MapAttributeToStandardAttribType(const stl::string &name, VERTEX_STANDARD_ATTRIBS standardAttribType)
|
||||||
|
@ -1045,10 +1045,10 @@ void Shader::MapAttributeToStandardAttribType(const stl::string &name, VERTEX_ST
|
||||||
ASSERT(attribute->location < m_numAttributes);
|
ASSERT(attribute->location < m_numAttributes);
|
||||||
|
|
||||||
ShaderAttributeMapInfo *mappingInfo = &m_attributeMapping[attribute->location];
|
ShaderAttributeMapInfo *mappingInfo = &m_attributeMapping[attribute->location];
|
||||||
mappingInfo->usesStandardType = TRUE;
|
mappingInfo->usesStandardType = true;
|
||||||
mappingInfo->standardType = standardAttribType;
|
mappingInfo->standardType = standardAttribType;
|
||||||
|
|
||||||
attribute->isTypeBound = TRUE;
|
attribute->isTypeBound = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Shader::OnNewContext()
|
void Shader::OnNewContext()
|
||||||
|
@ -1062,14 +1062,14 @@ void Shader::OnLostContext()
|
||||||
|
|
||||||
void Shader::OnBind()
|
void Shader::OnBind()
|
||||||
{
|
{
|
||||||
ASSERT(m_isBound == FALSE);
|
ASSERT(m_isBound == false);
|
||||||
m_isBound = TRUE;
|
m_isBound = true;
|
||||||
FlushCachedUniforms();
|
FlushCachedUniforms();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Shader::OnUnbind()
|
void Shader::OnUnbind()
|
||||||
{
|
{
|
||||||
ASSERT(m_isBound == TRUE);
|
ASSERT(m_isBound == true);
|
||||||
m_isBound = FALSE;
|
m_isBound = false;
|
||||||
m_cachedUniforms.clear();
|
m_cachedUniforms.clear();
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,9 +41,9 @@ public:
|
||||||
* @param graphicsDevice the graphics device to associate this shader with
|
* @param graphicsDevice the graphics device to associate this shader with
|
||||||
* @param vertexShaderSource GLSL source for a vertex shader
|
* @param vertexShaderSource GLSL source for a vertex shader
|
||||||
* @param fragmentShaderSource GLSL source for a vertex shader
|
* @param fragmentShaderSource GLSL source for a vertex shader
|
||||||
* @return TRUE if successful, FALSE if not
|
* @return true if successful, false if not
|
||||||
*/
|
*/
|
||||||
virtual BOOL Initialize(GraphicsDevice *graphicsDevice, const char *vertexShaderSource, const char *fragmentShaderSource);
|
virtual bool Initialize(GraphicsDevice *graphicsDevice, const char *vertexShaderSource, const char *fragmentShaderSource);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the shader object using the given vertex and fragment shader
|
* Initializes the shader object using the given vertex and fragment shader
|
||||||
|
@ -51,36 +51,36 @@ public:
|
||||||
* @param graphicsDevice the graphics device to associate this shader with
|
* @param graphicsDevice the graphics device to associate this shader with
|
||||||
* @param vertexShaderSource GLSL source for a vertex shader
|
* @param vertexShaderSource GLSL source for a vertex shader
|
||||||
* @param fragmentShaderSource GLSL source for a vertex shader
|
* @param fragmentShaderSource GLSL source for a vertex shader
|
||||||
* @return TRUE if successful, FALSE if not
|
* @return true if successful, false if not
|
||||||
*/
|
*/
|
||||||
virtual BOOL Initialize(GraphicsDevice *graphicsDevice, const Text *vertexShaderSource, const Text *fragmentShaderSource);
|
virtual bool Initialize(GraphicsDevice *graphicsDevice, const Text *vertexShaderSource, const Text *fragmentShaderSource);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return TRUE if this shader has been compiled and linked into a program
|
* @return true if this shader has been compiled and linked into a program
|
||||||
* that can be bound and rendered with
|
* that can be bound and rendered with
|
||||||
*/
|
*/
|
||||||
BOOL IsReadyForUse() const;
|
bool IsReadyForUse() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return TRUE if this shader is currently bound to the graphics device
|
* @return true if this shader is currently bound to the graphics device
|
||||||
*/
|
*/
|
||||||
BOOL IsBound() const { return m_isBound; }
|
bool IsBound() const { return m_isBound; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return TRUE if the vertex shader was compiled without errors
|
* @return true if the vertex shader was compiled without errors
|
||||||
*/
|
*/
|
||||||
BOOL GetVertexShaderCompileStatus() const { return m_vertexShaderCompileStatus; }
|
bool GetVertexShaderCompileStatus() const { return m_vertexShaderCompileStatus; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return TRUE if the fragment shader was compiled without errors
|
* @return true if the fragment shader was compiled without errors
|
||||||
*/
|
*/
|
||||||
BOOL GetFragmentShaderCompileStatus() const { return m_fragmentShaderCompileStatus; }
|
bool GetFragmentShaderCompileStatus() const { return m_fragmentShaderCompileStatus; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return TRUE if the compiled vertex and fragment shaders were linked
|
* @return true if the compiled vertex and fragment shaders were linked
|
||||||
* without errors
|
* without errors
|
||||||
*/
|
*/
|
||||||
BOOL GetLinkStatus() const { return m_linkStatus; }
|
bool GetLinkStatus() const { return m_linkStatus; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the OpenGL program ID that can be bound
|
* @return the OpenGL program ID that can be bound
|
||||||
|
@ -91,18 +91,18 @@ public:
|
||||||
* Checks if this shader contains a uniform. Note that the GLSL compiler
|
* Checks if this shader contains a uniform. Note that the GLSL compiler
|
||||||
* could optimize out uniforms if they aren't used in the GLSL code.
|
* could optimize out uniforms if they aren't used in the GLSL code.
|
||||||
* @param name the name of the uniform to check for
|
* @param name the name of the uniform to check for
|
||||||
* @return TRUE if the uniform is present
|
* @return true if the uniform is present
|
||||||
*/
|
*/
|
||||||
BOOL HasUniform(const stl::string &name) const;
|
bool HasUniform(const stl::string &name) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if this shader contains an attribute. Note that the GLSL
|
* Checks if this shader contains an attribute. Note that the GLSL
|
||||||
* compiler could optimize out attributes if they aren't used in the
|
* compiler could optimize out attributes if they aren't used in the
|
||||||
* GLSL code.
|
* GLSL code.
|
||||||
* @param name the name of the attribute to check for
|
* @param name the name of the attribute to check for
|
||||||
* @return TRUE if the attribute is present
|
* @return true if the attribute is present
|
||||||
*/
|
*/
|
||||||
BOOL HasAttribute(const stl::string &name) const;
|
bool HasAttribute(const stl::string &name) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the value of a uniform.
|
* Sets the value of a uniform.
|
||||||
|
@ -225,10 +225,10 @@ public:
|
||||||
* attribute type or not.
|
* attribute type or not.
|
||||||
* @param attribIndex the index of the shader attribute to check the
|
* @param attribIndex the index of the shader attribute to check the
|
||||||
* mapping of
|
* mapping of
|
||||||
* @return TRUE if this shader attribute was mapped to a standard attribute
|
* @return true if this shader attribute was mapped to a standard attribute
|
||||||
* type or FALSE if it wasn't
|
* type or false if it wasn't
|
||||||
*/
|
*/
|
||||||
BOOL IsAttributeMappedToStandardType(uint attribIndex) const;
|
bool IsAttributeMappedToStandardType(uint attribIndex) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a vertex buffer object attribute index that corresponds to the
|
* Gets a vertex buffer object attribute index that corresponds to the
|
||||||
|
@ -289,19 +289,19 @@ protected:
|
||||||
* for shader subclasses to begin initializing their own custom state
|
* for shader subclasses to begin initializing their own custom state
|
||||||
* immediately afterward.
|
* immediately afterward.
|
||||||
* @param graphicsDevice the graphics device to associate this shader with
|
* @param graphicsDevice the graphics device to associate this shader with
|
||||||
* @return TRUE if successful, FALSE if not
|
* @return true if successful, false if not
|
||||||
*/
|
*/
|
||||||
BOOL Initialize(GraphicsDevice *graphicsDevice);
|
bool Initialize(GraphicsDevice *graphicsDevice);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the provided shader sources, compiles and links them and
|
* Loads the provided shader sources, compiles and links them and
|
||||||
* caches information about attributes and uniforms.
|
* caches information about attributes and uniforms.
|
||||||
* @param vertexShaderSource vertex shader source
|
* @param vertexShaderSource vertex shader source
|
||||||
* @param fragmentShaderSource fragment shader source
|
* @param fragmentShaderSource fragment shader source
|
||||||
* @return TRUE if compilation and linking succeeded and the shader
|
* @return true if compilation and linking succeeded and the shader
|
||||||
* is now ready for use
|
* is now ready for use
|
||||||
*/
|
*/
|
||||||
BOOL LoadCompileAndLink(const char *vertexShaderSource, const char *fragmentShaderSource);
|
bool LoadCompileAndLink(const char *vertexShaderSource, const char *fragmentShaderSource);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reloads shader sources either from those provided or from the
|
* Reloads shader sources either from those provided or from the
|
||||||
|
@ -311,10 +311,10 @@ protected:
|
||||||
* the source from the cache
|
* the source from the cache
|
||||||
* @param fragmentShaderSource fragment shader source, or NULL to load
|
* @param fragmentShaderSource fragment shader source, or NULL to load
|
||||||
* the source from the cache
|
* the source from the cache
|
||||||
* @return TRUE if compilation and linking succeeded and the shader
|
* @return true if compilation and linking succeeded and the shader
|
||||||
* is now ready for use
|
* is now ready for use
|
||||||
*/
|
*/
|
||||||
BOOL ReloadCompileAndLink(const char *vertexShaderSource, const char *fragmentShaderSource);
|
bool ReloadCompileAndLink(const char *vertexShaderSource, const char *fragmentShaderSource);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Caches the provided shader sources. ReloadCompileAndLink() can
|
* Caches the provided shader sources. ReloadCompileAndLink() can
|
||||||
|
@ -353,8 +353,8 @@ protected:
|
||||||
ShaderAttribute* GetAttribute(const stl::string &name);
|
ShaderAttribute* GetAttribute(const stl::string &name);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BOOL Compile(const char *vertexShaderSource, const char *fragmentShaderSource);
|
bool Compile(const char *vertexShaderSource, const char *fragmentShaderSource);
|
||||||
BOOL Link();
|
bool Link();
|
||||||
void LoadUniformInfo();
|
void LoadUniformInfo();
|
||||||
void LoadAttributeInfo();
|
void LoadAttributeInfo();
|
||||||
|
|
||||||
|
@ -367,13 +367,13 @@ private:
|
||||||
|
|
||||||
char *m_cachedVertexShaderSource;
|
char *m_cachedVertexShaderSource;
|
||||||
char *m_cachedFragmentShaderSource;
|
char *m_cachedFragmentShaderSource;
|
||||||
BOOL m_vertexShaderCompileStatus;
|
int m_vertexShaderCompileStatus;
|
||||||
BOOL m_fragmentShaderCompileStatus;
|
int m_fragmentShaderCompileStatus;
|
||||||
BOOL m_linkStatus;
|
int m_linkStatus;
|
||||||
uint m_vertexShaderId;
|
uint m_vertexShaderId;
|
||||||
uint m_fragmentShaderId;
|
uint m_fragmentShaderId;
|
||||||
uint m_programId;
|
uint m_programId;
|
||||||
BOOL m_isBound;
|
bool m_isBound;
|
||||||
|
|
||||||
ShaderUniformMap m_uniforms;
|
ShaderUniformMap m_uniforms;
|
||||||
ShaderAttributeMap m_attributes;
|
ShaderAttributeMap m_attributes;
|
||||||
|
@ -383,15 +383,15 @@ private:
|
||||||
CachedShaderUniformMap m_cachedUniforms;
|
CachedShaderUniformMap m_cachedUniforms;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline BOOL Shader::IsReadyForUse() const
|
inline bool Shader::IsReadyForUse() const
|
||||||
{
|
{
|
||||||
if (GetVertexShaderCompileStatus() && GetFragmentShaderCompileStatus() && GetLinkStatus())
|
if (GetVertexShaderCompileStatus() && GetFragmentShaderCompileStatus() && GetLinkStatus())
|
||||||
return TRUE;
|
return true;
|
||||||
else
|
else
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline BOOL Shader::IsAttributeMappedToStandardType(uint attribIndex) const
|
inline bool Shader::IsAttributeMappedToStandardType(uint attribIndex) const
|
||||||
{
|
{
|
||||||
return m_attributeMapping[attribIndex].usesStandardType;
|
return m_attributeMapping[attribIndex].usesStandardType;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ struct ShaderAttribute
|
||||||
uint location;
|
uint location;
|
||||||
uint type;
|
uint type;
|
||||||
uint size;
|
uint size;
|
||||||
BOOL isTypeBound;
|
bool isTypeBound;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -33,7 +33,7 @@ struct ShaderAttribute
|
||||||
*/
|
*/
|
||||||
struct ShaderAttributeMapInfo
|
struct ShaderAttributeMapInfo
|
||||||
{
|
{
|
||||||
BOOL usesStandardType;
|
bool usesStandardType;
|
||||||
VERTEX_STANDARD_ATTRIBS standardType;
|
VERTEX_STANDARD_ATTRIBS standardType;
|
||||||
uint attribIndex;
|
uint attribIndex;
|
||||||
};
|
};
|
||||||
|
|
|
@ -37,16 +37,16 @@ SimpleColorShader::~SimpleColorShader()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL SimpleColorShader::Initialize(GraphicsDevice *graphicsDevice)
|
bool SimpleColorShader::Initialize(GraphicsDevice *graphicsDevice)
|
||||||
{
|
{
|
||||||
if (!StandardShader::Initialize(graphicsDevice))
|
if (!StandardShader::Initialize(graphicsDevice))
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
BOOL result = LoadCompileAndLinkInlineSources(m_vertexShaderSource, m_fragmentShaderSource);
|
bool result = LoadCompileAndLinkInlineSources(m_vertexShaderSource, m_fragmentShaderSource);
|
||||||
ASSERT(result == TRUE);
|
ASSERT(result == true);
|
||||||
|
|
||||||
MapAttributeToStandardAttribType("a_position", VERTEX_STD_POS_3D);
|
MapAttributeToStandardAttribType("a_position", VERTEX_STD_POS_3D);
|
||||||
MapAttributeToStandardAttribType("a_color", VERTEX_STD_COLOR);
|
MapAttributeToStandardAttribType("a_color", VERTEX_STD_COLOR);
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ public:
|
||||||
SimpleColorShader();
|
SimpleColorShader();
|
||||||
virtual ~SimpleColorShader();
|
virtual ~SimpleColorShader();
|
||||||
|
|
||||||
BOOL Initialize(GraphicsDevice *graphicsDevice);
|
bool Initialize(GraphicsDevice *graphicsDevice);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const char *m_vertexShaderSource;
|
static const char *m_vertexShaderSource;
|
||||||
|
|
|
@ -42,17 +42,17 @@ SimpleColorTextureShader::~SimpleColorTextureShader()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL SimpleColorTextureShader::Initialize(GraphicsDevice *graphicsDevice)
|
bool SimpleColorTextureShader::Initialize(GraphicsDevice *graphicsDevice)
|
||||||
{
|
{
|
||||||
if (!StandardShader::Initialize(graphicsDevice))
|
if (!StandardShader::Initialize(graphicsDevice))
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
BOOL result = LoadCompileAndLinkInlineSources(m_vertexShaderSource, m_fragmentShaderSource);
|
bool result = LoadCompileAndLinkInlineSources(m_vertexShaderSource, m_fragmentShaderSource);
|
||||||
ASSERT(result == TRUE);
|
ASSERT(result == true);
|
||||||
|
|
||||||
MapAttributeToStandardAttribType("a_position", VERTEX_STD_POS_3D);
|
MapAttributeToStandardAttribType("a_position", VERTEX_STD_POS_3D);
|
||||||
MapAttributeToStandardAttribType("a_color", VERTEX_STD_COLOR);
|
MapAttributeToStandardAttribType("a_color", VERTEX_STD_COLOR);
|
||||||
MapAttributeToStandardAttribType("a_texcoord0", VERTEX_STD_TEXCOORD);
|
MapAttributeToStandardAttribType("a_texcoord0", VERTEX_STD_TEXCOORD);
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ public:
|
||||||
SimpleColorTextureShader();
|
SimpleColorTextureShader();
|
||||||
virtual ~SimpleColorTextureShader();
|
virtual ~SimpleColorTextureShader();
|
||||||
|
|
||||||
BOOL Initialize(GraphicsDevice *graphicsDevice);
|
bool Initialize(GraphicsDevice *graphicsDevice);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const char *m_vertexShaderSource;
|
static const char *m_vertexShaderSource;
|
||||||
|
|
|
@ -37,16 +37,16 @@ SimpleTextureShader::~SimpleTextureShader()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL SimpleTextureShader::Initialize(GraphicsDevice *graphicsDevice)
|
bool SimpleTextureShader::Initialize(GraphicsDevice *graphicsDevice)
|
||||||
{
|
{
|
||||||
if (!StandardShader::Initialize(graphicsDevice))
|
if (!StandardShader::Initialize(graphicsDevice))
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
BOOL result = LoadCompileAndLinkInlineSources(m_vertexShaderSource, m_fragmentShaderSource);
|
bool result = LoadCompileAndLinkInlineSources(m_vertexShaderSource, m_fragmentShaderSource);
|
||||||
ASSERT(result == TRUE);
|
ASSERT(result == true);
|
||||||
|
|
||||||
MapAttributeToStandardAttribType("a_position", VERTEX_STD_POS_3D);
|
MapAttributeToStandardAttribType("a_position", VERTEX_STD_POS_3D);
|
||||||
MapAttributeToStandardAttribType("a_texcoord0", VERTEX_STD_TEXCOORD);
|
MapAttributeToStandardAttribType("a_texcoord0", VERTEX_STD_TEXCOORD);
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ public:
|
||||||
SimpleTextureShader();
|
SimpleTextureShader();
|
||||||
virtual ~SimpleTextureShader();
|
virtual ~SimpleTextureShader();
|
||||||
|
|
||||||
BOOL Initialize(GraphicsDevice *graphicsDevice);
|
bool Initialize(GraphicsDevice *graphicsDevice);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const char *m_vertexShaderSource;
|
static const char *m_vertexShaderSource;
|
||||||
|
|
|
@ -38,17 +38,17 @@ SimpleTextureVertexLerpShader::~SimpleTextureVertexLerpShader()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL SimpleTextureVertexLerpShader::Initialize(GraphicsDevice *graphicsDevice)
|
bool SimpleTextureVertexLerpShader::Initialize(GraphicsDevice *graphicsDevice)
|
||||||
{
|
{
|
||||||
if (!VertexLerpShader::Initialize(graphicsDevice))
|
if (!VertexLerpShader::Initialize(graphicsDevice))
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
BOOL result = LoadCompileAndLinkInlineSources(m_vertexShaderSource, m_fragmentShaderSource);
|
bool result = LoadCompileAndLinkInlineSources(m_vertexShaderSource, m_fragmentShaderSource);
|
||||||
ASSERT(result == TRUE);
|
ASSERT(result == true);
|
||||||
|
|
||||||
MapAttributeToVboAttribIndex("a_position1", 0);
|
MapAttributeToVboAttribIndex("a_position1", 0);
|
||||||
MapAttributeToVboAttribIndex("a_position2", 1);
|
MapAttributeToVboAttribIndex("a_position2", 1);
|
||||||
MapAttributeToStandardAttribType("a_texcoord0", VERTEX_STD_TEXCOORD);
|
MapAttributeToStandardAttribType("a_texcoord0", VERTEX_STD_TEXCOORD);
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ public:
|
||||||
SimpleTextureVertexLerpShader();
|
SimpleTextureVertexLerpShader();
|
||||||
virtual ~SimpleTextureVertexLerpShader();
|
virtual ~SimpleTextureVertexLerpShader();
|
||||||
|
|
||||||
BOOL Initialize(GraphicsDevice *graphicsDevice);
|
bool Initialize(GraphicsDevice *graphicsDevice);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const char *m_vertexShaderSource;
|
static const char *m_vertexShaderSource;
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Reference in a new issue