First blood
This commit is contained in:
1 parent
04f270f322
commit
5720f8322b
250 files changed
+33215
No files matched your search
@@ -0,0 +1,178 @@
|
||||
#ifndef SALMON_ANIMATION_H_INCLUDED
|
||||
#define SALMON_ANIMATION_H_INCLUDED
|
||||
/*
|
||||
This code contains Model Animation Manager and code to operate Animation
|
||||
*/
|
||||
|
||||
#include "include/ModelManager/ModelManager.h"
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
//We have to declare it in advance
|
||||
class TAnimModel;
|
||||
|
||||
//This struct contains bone information
|
||||
struct TBoneStruct
|
||||
{
|
||||
vec3 Pos;
|
||||
vec4 Quat;
|
||||
float Len;
|
||||
int Ancient;
|
||||
};
|
||||
|
||||
struct TBoneWeightStruct
|
||||
{
|
||||
int BoneNum;
|
||||
float BoneWeight;
|
||||
};
|
||||
|
||||
//This struct contains additional info for every model vertex - weight of 3 bones per vertex
|
||||
struct TVertexWeightStruct
|
||||
{
|
||||
int WeightCount;
|
||||
std::vector<TBoneWeightStruct> VertexBoneInfo;
|
||||
};
|
||||
|
||||
//One animation sequence (i.e. one move for one model)
|
||||
class TAnimSequence
|
||||
{
|
||||
protected:
|
||||
std::vector<std::vector<TBoneStruct> > BoneInfoMatrix;
|
||||
int BoneCount;
|
||||
int FrameCount;
|
||||
public:
|
||||
TAnimSequence() : BoneCount(0), FrameCount(0) { }
|
||||
|
||||
//copy constructor
|
||||
TAnimSequence(const TAnimSequence& animSeq);
|
||||
|
||||
~TAnimSequence();
|
||||
|
||||
TAnimSequence& operator=(const TAnimSequence& animSeq);
|
||||
|
||||
bool LoadFromFileAn1(const std::string& fileName); //not safe
|
||||
|
||||
void Clear();
|
||||
|
||||
|
||||
void ScaleAnimSequence(float s);
|
||||
void MoveAnimSequence(const vec3& v);
|
||||
void RotateAnimSequence(const mat3& m);
|
||||
|
||||
friend class TAnimModel;
|
||||
};
|
||||
|
||||
typedef std::vector<TBoneStruct> TBoneList;
|
||||
typedef std::vector<TVertexWeightStruct> TVertexWeightList;
|
||||
typedef std::map<std::string, TAnimSequence, std::less<std::string> > TAnimSequenceMap;
|
||||
|
||||
/* Class for list of animations
|
||||
List of animations contains bone system + vertex weight table + a list of avaiable animations
|
||||
*/
|
||||
class TAnimList
|
||||
{
|
||||
protected:
|
||||
TBoneList BoneList;
|
||||
TBoneList PrevBoneList;
|
||||
TVertexWeightList VertexWeightList;
|
||||
TAnimSequenceMap AnimSequenceMap;
|
||||
|
||||
//Means bonelist and vertex weight list are loaded (AnimSequence may remain empty)
|
||||
bool Ready;
|
||||
public:
|
||||
TAnimList() : Ready(false) { }
|
||||
~TAnimList() { Clear(); }
|
||||
|
||||
//Load bone system + vertex weight from file
|
||||
bool LoadBoneSystemFromFileBn1(const std::string& fileName);
|
||||
bool LoadBoneSystemFromFileBn2(const std::string& fileName);
|
||||
|
||||
//Add one more anim sequence to sequence map
|
||||
bool LoadAnimSequenceFromFileAn1(const std::string& fileName);
|
||||
|
||||
//Process animations. Must be processed after you process model
|
||||
void ScaleAnimList(float s);
|
||||
void MoveAnimList(const vec3& v);
|
||||
void RotateAnimList(const mat3& m);
|
||||
|
||||
void Clear();
|
||||
|
||||
void DrawBoneSystem();
|
||||
|
||||
//this method copies bone system to reserved memory
|
||||
void SaveBoneSystemToBuf();
|
||||
|
||||
//this method reloads bone system form reserved memory
|
||||
void LoadBoneSystemFromBuf();
|
||||
|
||||
friend class TAnimModel;
|
||||
};
|
||||
|
||||
typedef std::map<std::string, TAnimList, std::less<std::string> > TAnimListMap;
|
||||
|
||||
//Class that contains list of animations for each model
|
||||
class TModelAnimManager
|
||||
{
|
||||
protected:
|
||||
TAnimListMap AnimListMap;
|
||||
|
||||
public:
|
||||
TModelAnimManager() { };
|
||||
~TModelAnimManager() { Clear(); };
|
||||
|
||||
TAnimList* operator [] (const std::string& s);
|
||||
|
||||
//NOT SAFE!!!
|
||||
bool AddAnimationToModel(const std::string& modelName, const std::string& boneListFileName);
|
||||
|
||||
void Clear();
|
||||
|
||||
};
|
||||
|
||||
|
||||
class TAnimModel
|
||||
{
|
||||
protected:
|
||||
TLiteModel LiteModel;
|
||||
|
||||
std::vector<vec3> CopyVertexArr;
|
||||
|
||||
TAnimList* AnimList;
|
||||
|
||||
bool Ready;
|
||||
|
||||
void RecalcVertexPos();
|
||||
|
||||
//This is used for animation only - to save original t=0 position
|
||||
void SaveVertexInfoToBuf();
|
||||
void LoadVertexInfoFromBuf();
|
||||
|
||||
public:
|
||||
TAnimModel() : Ready(false), AnimList(NULL) {}
|
||||
|
||||
~TAnimModel() { Clear(); }
|
||||
|
||||
bool LoadModel(const std::string& modelName);
|
||||
|
||||
void Clear();
|
||||
|
||||
void ScaleModel(float s);
|
||||
void MoveModel(const vec3& v);
|
||||
void RotateModel(const mat3& r);
|
||||
|
||||
inline void SetShaderTranslateVector(const vec3& v) { LiteModel.SetShaderTranslateVector(v); }
|
||||
inline void SetShaderRotateMatrix(const mat3& m) { LiteModel.SetShaderRotateMatrix(m); }
|
||||
|
||||
void DrawImmediate();
|
||||
void DrawVBO() { LiteModel.DrawVBO(); }
|
||||
void UpdateVBO() { LiteModel.UpdateVBO(); }
|
||||
|
||||
//n must be in 0..99; ???
|
||||
void ApplySequence(const std::string& seq, int n);
|
||||
|
||||
};
|
||||
|
||||
} //namespace SE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,43 @@
|
||||
#ifndef APPLICATION_INTERFACE_H_INCLUDED
|
||||
#define APPLICATION_INTERFACE_H_INCLUDED
|
||||
|
||||
#include "include/Utils/Utils.h"
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
class TApplicationInterface
|
||||
{
|
||||
protected:
|
||||
bool IsConsoleOut;
|
||||
public:
|
||||
|
||||
|
||||
TApplicationInterface();
|
||||
|
||||
virtual ~TApplicationInterface() { }
|
||||
|
||||
virtual void OuterInit(int screenWidth, int screenHeight, float matrixWidth, float matrixHeight);
|
||||
|
||||
virtual void InnerInit() { }
|
||||
//To do on init
|
||||
|
||||
virtual void OuterDeinit();
|
||||
|
||||
virtual void InnerDeinit() { }
|
||||
//To do on deinit
|
||||
|
||||
virtual void OuterDraw() { }
|
||||
|
||||
virtual void InnerDraw() { }
|
||||
//What to draw
|
||||
|
||||
virtual void OuterUpdate(cardinal timer) { }
|
||||
|
||||
virtual void InnerUpdate(cardinal timer) { }
|
||||
};
|
||||
|
||||
} //namespace SE
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,57 @@
|
||||
#ifndef ENGINE_H_INCLUDED
|
||||
#define ENGINE_H_INCLUDED
|
||||
|
||||
|
||||
|
||||
#ifdef TARGET_HALIBUT
|
||||
#ifdef TARGET_WIN32
|
||||
#define HALIBUT_WIN32
|
||||
#endif
|
||||
|
||||
#ifdef TARGET_ANDROID
|
||||
#define HALIBUT_ANDROID
|
||||
#endif
|
||||
#ifdef TARGET_IOS
|
||||
#define HALIBUT_IOS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef TARGET_SALMON
|
||||
#ifdef TARGET_WIN32
|
||||
#define SALMON_WIN32
|
||||
#endif
|
||||
|
||||
#ifdef TARGET_ANDROID
|
||||
#define SALMON_ANDROID
|
||||
#endif
|
||||
#ifdef TARGET_IOS
|
||||
#define SALMON_IOS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef SALMON_WIN32
|
||||
#include "SalmonEngineWindows.h"
|
||||
#endif
|
||||
|
||||
#ifdef HALIBUT_WIN32
|
||||
#include "HalibutEngineWindows.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef SALMON_ANDROID
|
||||
#include "SalmonEngineAndroid.h"
|
||||
#endif
|
||||
#ifdef HALIBUT_ANDROID
|
||||
#include "HalibutEngineAndroid.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef SALMON_IOS
|
||||
#include "include/SalmonEngineIos.h"
|
||||
#endif
|
||||
#ifdef HALIBUT_IOS
|
||||
#include "include/HalibutEngineIos.h"
|
||||
#endif
|
||||
|
||||
#endif //ENGINE_H_INCLUDED
|
||||
@@ -0,0 +1,186 @@
|
||||
#ifndef FONT_MANAGER_H_INCLUDED
|
||||
#define FONT_MANAGER_H_INCLUDED
|
||||
|
||||
|
||||
#include "include/Utils/Utils.h"
|
||||
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
enum TTextHorizontalAlignment
|
||||
{
|
||||
THA_LEFT,
|
||||
THA_CENTER,
|
||||
THA_RIGHT
|
||||
};
|
||||
|
||||
enum TTextVerticalAlignment
|
||||
{
|
||||
TVA_BOTTOM,
|
||||
TVA_CENTER,
|
||||
TVA_TOP
|
||||
};
|
||||
|
||||
struct TTextBasicAreaParams : public TSerializeInterface
|
||||
{
|
||||
int Height;
|
||||
float HorizontalPadding;
|
||||
float VerticalPadding;
|
||||
TTextHorizontalAlignment TextHorizontalAlignment;
|
||||
TTextVerticalAlignment TextVerticalAlignment;
|
||||
|
||||
TTextBasicAreaParams(int height = 12, float horizontalPadding = 2, float verticalPadding = 2, TTextHorizontalAlignment textHorizontalAlignment = THA_LEFT, TTextVerticalAlignment textVerticalAlignment = TVA_BOTTOM)
|
||||
: Height(height)
|
||||
, HorizontalPadding(horizontalPadding)
|
||||
, VerticalPadding(verticalPadding)
|
||||
, TextHorizontalAlignment(textHorizontalAlignment)
|
||||
, TextVerticalAlignment(textVerticalAlignment)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void Serialize(boost::property_tree::ptree& propertyTree)
|
||||
{
|
||||
Height = propertyTree.get<int>("<xmlattr>.height");
|
||||
HorizontalPadding = propertyTree.get<float>("<xmlattr>.horizontalPadding");
|
||||
VerticalPadding = propertyTree.get<float>("<xmlattr>.verticalPadding");
|
||||
|
||||
std::string textHorizontalAlignment = propertyTree.get<std::string>("<xmlattr>.textHorizontalAlignment");
|
||||
|
||||
if (textHorizontalAlignment == "THA_RIGHT")
|
||||
{
|
||||
TextHorizontalAlignment = THA_RIGHT;
|
||||
}
|
||||
else if (textHorizontalAlignment == "THA_CENTER")
|
||||
{
|
||||
TextHorizontalAlignment = THA_CENTER;
|
||||
}
|
||||
else
|
||||
{
|
||||
TextHorizontalAlignment = THA_LEFT;
|
||||
}
|
||||
|
||||
std::string textVerticalAlignment = propertyTree.get<std::string>("<xmlattr>.textVerticalAlignment");
|
||||
|
||||
|
||||
if (textVerticalAlignment == "TVA_TOP")
|
||||
{
|
||||
TextVerticalAlignment = TVA_TOP;
|
||||
}
|
||||
else if (textVerticalAlignment == "TVA_CENTER")
|
||||
{
|
||||
TextVerticalAlignment = TVA_CENTER;
|
||||
}
|
||||
else
|
||||
{
|
||||
TextVerticalAlignment = TVA_BOTTOM;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct TFontParams
|
||||
{
|
||||
float ShiftX;
|
||||
float ShiftY;
|
||||
float InternalShiftX;
|
||||
float InternalShiftY;
|
||||
float BitmapHeight;
|
||||
float BitmapWidth;
|
||||
float Advance;
|
||||
};
|
||||
|
||||
struct TFont
|
||||
{
|
||||
std::string TexName;
|
||||
cardinal SheetWidth;
|
||||
cardinal SheetHeight;
|
||||
std::map<cardinal, TFontParams> CharMap;
|
||||
};
|
||||
|
||||
class TTriangleList; //HalibutRender.h
|
||||
|
||||
class TFontManager : public TSerializeInterface
|
||||
{
|
||||
protected:
|
||||
std::map<std::string, TFont> FontMap;
|
||||
|
||||
std::stack<std::string> FontStack;
|
||||
|
||||
float DrawChar(vec2 pos, cardinal character);
|
||||
float DrawCharToVBO(vec2 pos, cardinal character, TTriangleList& triangleList);
|
||||
|
||||
vec2 FitStringToBox(vec2 posFrom, vec2 posTo, TTextBasicAreaParams params, std::string& str);
|
||||
vec2 FitStringToBoxWithWordWrap(vec2 posFrom, vec2 posTo, TTextBasicAreaParams params, std::string& str);
|
||||
public:
|
||||
TFontManager() { }
|
||||
~TFontManager();
|
||||
|
||||
virtual void Serialize(boost::property_tree::ptree& propertyTree);
|
||||
|
||||
void AddFont(const std::string& fontName, const std::string& bitmapFile, const std::string& charmapFile);
|
||||
|
||||
void PushFont(const std::string& fontName);
|
||||
void PopFont();
|
||||
|
||||
void DrawString(vec2 pos, TTextBasicAreaParams params, const std::string& str);
|
||||
|
||||
TTriangleList DrawStringToVBO(vec2 pos, TTextBasicAreaParams params, const std::string& str);
|
||||
|
||||
void DrawTextInBox(vec2 posFrom, vec2 posTo, TTextBasicAreaParams params, std::string str, bool wordWrap = true);
|
||||
|
||||
std::string GetCurrentFontName();
|
||||
std::string GetCurrentFontTextureName();
|
||||
|
||||
TTriangleList DrawTextInBoxToVBO(vec2 posFrom, vec2 posTo, TTextBasicAreaParams params, std::string str, bool wordWrap = true);
|
||||
|
||||
|
||||
template<typename CHARTYPE>
|
||||
float GetCharAdvance(CHARTYPE character)
|
||||
{
|
||||
std::string fontName = GetCurrentFontName();
|
||||
|
||||
if (FontMap.count(fontName) == 0)
|
||||
{
|
||||
throw ErrorToLog("Trying to use unknown font! " + fontName);
|
||||
}
|
||||
|
||||
TFont& currentFont = FontMap[fontName];
|
||||
|
||||
static_assert(sizeof(CHARTYPE) <= 4, "LOL, we have to implement more than 4-byte character!"); // LOL, we have to implement more than 4-byte character!
|
||||
|
||||
TFontParams& fontParams = currentFont.CharMap[static_cast<cardinal>(character)];
|
||||
|
||||
|
||||
int scale_x = currentFont.SheetWidth;
|
||||
|
||||
return fontParams.Advance*scale_x;
|
||||
|
||||
}
|
||||
|
||||
template<typename STRINGTYPE>
|
||||
float GetTextAdvance(STRINGTYPE text)
|
||||
{
|
||||
|
||||
boost::erase_all(text, "\n"); //that is easier
|
||||
|
||||
float advance = 0;
|
||||
|
||||
for (size_t i=0; i<text.size(); i++)
|
||||
{
|
||||
advance += GetCharAdvance(text[i]);
|
||||
}
|
||||
|
||||
return advance;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
} //namespace SE
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,92 @@
|
||||
#ifndef FRAME_MANAGER_H_INCLUDED
|
||||
#define FRAME_MANAGER_H_INCLUDED
|
||||
|
||||
/*
|
||||
This code contains frame manager to do posteffects
|
||||
|
||||
Use global variable ResourceManager to get access to light manager
|
||||
|
||||
*/
|
||||
|
||||
#ifdef TARGET_ANDROID
|
||||
#include <GLES2/gl2.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
#endif
|
||||
#ifdef TARGET_WIN32
|
||||
#include "include/OpenGlExt/OpenGlExt.h"
|
||||
#endif
|
||||
|
||||
#include "include/Utils/Utils.h"
|
||||
#include "include/TextureManager/SalmonTexture.h"
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
struct TFrame
|
||||
{
|
||||
cardinal FrameBuffer;
|
||||
cardinal DepthRenderBuffer;
|
||||
cardinal TexID;
|
||||
cardinal Width;
|
||||
cardinal Height;
|
||||
std::string TexName;
|
||||
};
|
||||
|
||||
typedef std::map<std::string, TFrame> TFrameMap;
|
||||
|
||||
class TRendererInterface;
|
||||
class THalibutRendererInterface;
|
||||
class THalibutRenderer;
|
||||
class THalibutRendererAndroid;
|
||||
class THalibutRendererIos;
|
||||
class TSalmonRendererInterface;
|
||||
class TSalmonRenderer;
|
||||
class TSalmonRendererAndroid;
|
||||
class TSalmonRendererIos;
|
||||
|
||||
class TFrameManager
|
||||
{
|
||||
protected:
|
||||
TFrameMap FrameMap;
|
||||
public:
|
||||
TFrameManager() {}
|
||||
|
||||
~TFrameManager();
|
||||
|
||||
void FreeFrameManager();
|
||||
//Clean up frame map
|
||||
|
||||
cardinal AddFrameRenderBuffer(const std::string& frameName, cardinal width, cardinal height);
|
||||
//Add a new render buffer with name frameName. Width and height must be power of two (512, 1024 etc)
|
||||
|
||||
void DeleteFrameRenderBuffer(const std::string& frameName);
|
||||
//Delete render / depth buffer with name frameName
|
||||
|
||||
cardinal AddDepthBuffer(const std::string& frameName, cardinal width, cardinal height);
|
||||
//Add depth buffer with name frameName Width and height must be power of two (512, 1024 etc)
|
||||
|
||||
cardinal AddCubemapBuffer(const std::string& frameName, cardinal width, cardinal height);
|
||||
//Add cubemap render buffer with name frameName Width and height must be power of two (512, 1024 etc)
|
||||
|
||||
cardinal GetFrameTexture(const std::string& frameName);
|
||||
//Get texture ID from frame with name frameName
|
||||
|
||||
ivec2 GetFrameWidthHeight(const std::string& frameName);
|
||||
|
||||
TTextureData ReadFromBufferToTexData(const std::string& frameName);
|
||||
|
||||
friend class TRendererInterface;
|
||||
friend class THalibutRendererInterface;
|
||||
friend class THalibutRenderer;
|
||||
friend class THalibutRendererAndroid;
|
||||
friend class THalibutRendererIos;
|
||||
friend class TSalmonRendererInterface;
|
||||
friend class TSalmonRenderer;
|
||||
friend class TSalmonRendererAndroid;
|
||||
friend class TSalmonRendererIos;
|
||||
|
||||
};
|
||||
|
||||
} //namespace SE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,344 @@
|
||||
#ifndef BUTTON_WIDGET_H_INCLUDED
|
||||
#define BUTTON_WIDGET_H_INCLUDED
|
||||
|
||||
|
||||
#include "include/Render/RenderMisc.h"
|
||||
#include "include/Render/RenderParams.h"
|
||||
#include "include/Utils/Utils.h"
|
||||
#include "include/FontManager/FontManager.h"
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
class TInstancingWidgetAncestor
|
||||
{
|
||||
protected:
|
||||
|
||||
public:
|
||||
TRenderPairList TriangleListVector;
|
||||
vec2 LeftBottomPos;
|
||||
|
||||
virtual void Update(cardinal dt);
|
||||
|
||||
virtual bool CheckClick(vec2 mousePos);
|
||||
|
||||
virtual void OnTapDown(vec2 pos) { }
|
||||
virtual void OnTapUp(vec2 pos) { }
|
||||
virtual void OnMove(vec2 shift) { }
|
||||
virtual void OnMoveOut() { }
|
||||
virtual void OnKeyPress(int key) { }
|
||||
|
||||
virtual bool IsTransparentForInput() { return false; }
|
||||
|
||||
virtual ~TInstancingWidgetAncestor();
|
||||
};
|
||||
|
||||
|
||||
struct TTextParams : public TSerializeInterface
|
||||
{
|
||||
std::string Text;
|
||||
std::string FontName;
|
||||
TTextBasicAreaParams BasicTextAreaParams;
|
||||
TRenderParams RenderParams;
|
||||
|
||||
TTextParams()
|
||||
{
|
||||
}
|
||||
|
||||
TTextParams(const std::string& text)
|
||||
: Text(text)
|
||||
{
|
||||
}
|
||||
|
||||
TTextParams(const std::string& text, const std::string& fontName, int height, float horizontalPadding, float verticalPadding, TTextHorizontalAlignment textHorizontalAlignment, TTextVerticalAlignment textVerticalAlignment)
|
||||
: Text(text)
|
||||
, FontName(fontName)
|
||||
, BasicTextAreaParams(height, horizontalPadding, verticalPadding, textHorizontalAlignment, textVerticalAlignment)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void Serialize(boost::property_tree::ptree& propertyTree)
|
||||
{
|
||||
Text = propertyTree.get<std::string>("Text");
|
||||
|
||||
FontName = propertyTree.get<std::string>("Font");
|
||||
|
||||
BasicTextAreaParams.Serialize(propertyTree.find("TextAreaParams")->second);
|
||||
|
||||
if (propertyTree.count("RenderParams") != 0)
|
||||
{
|
||||
RenderParams.Serialize(propertyTree.find("RenderParams")->second);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct TSquareStatic : public TInstancingWidgetAncestor
|
||||
{
|
||||
float Width;
|
||||
|
||||
float Height;
|
||||
|
||||
TSquareStatic()
|
||||
: Width(0)
|
||||
, Height(0)
|
||||
{
|
||||
}
|
||||
|
||||
virtual bool CheckClick(vec2 mousePos);
|
||||
|
||||
static TSquareStatic* CreateStatic(vec2 posFrom, vec2 posTo);
|
||||
static TSquareStatic* CreateStaticWithFiller(vec2 posFrom, vec2 posTo, boost::function<void(TSquareStatic*)> staticFillerFunc);
|
||||
static TSquareStatic* CreateStaticWithFillers(vec2 posFrom, vec2 posTo, std::vector<boost::function<void(TSquareStatic*)>> staticFillerFuncArr);
|
||||
|
||||
static void StaticTextureFiller(vec2 posFrom, vec2 posTo, const std::string& texName, TSquareStatic* staticToFill);
|
||||
static void StaticTextFiller(vec2 posFrom, vec2 posTo, TTextParams buttonTextParams, TSquareStatic* staticToFill);
|
||||
|
||||
static TSquareStatic* CreateStaticTexture(vec2 posFrom, vec2 posTo, const std::string& texName);
|
||||
static TSquareStatic* CreateStaticText(vec2 posFrom, vec2 posTo, TTextParams buttonTextParams);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct TDynamicText : public TInstancingWidgetAncestor
|
||||
{
|
||||
protected:
|
||||
boost::signals::connection SmartValueConnection;
|
||||
|
||||
TTextParams LastTextParams;
|
||||
|
||||
TRenderPairList::iterator TextRenderPairItr;
|
||||
|
||||
public:
|
||||
float Width;
|
||||
|
||||
float Height;
|
||||
|
||||
TDynamicText();
|
||||
~TDynamicText();
|
||||
|
||||
virtual bool CheckClick(vec2 mousePos);
|
||||
|
||||
void UpdateText(std::string text);
|
||||
|
||||
static TDynamicText* CreateDynamicText(vec2 posFrom, vec2 posTo);
|
||||
static TDynamicText* CreateDynamicTextWithFiller(vec2 posFrom, vec2 posTo, boost::function<void(TDynamicText*)> dynamicTextFillerFunc);
|
||||
static TDynamicText* CreateDynamicTextWithFillers(vec2 posFrom, vec2 posTo, std::vector<boost::function<void(TDynamicText*)>> dynamicTextFillerFuncArr);
|
||||
|
||||
static void TextParamsFiller(vec2 posFrom, vec2 posTo, TTextParams textParams, TDynamicText* dynamicTextToFill);
|
||||
static void SmartValueTextFiller(const std::string& dictionaryName, const std::string& smartValueName, TDynamicText* dynamicTextToFill);
|
||||
|
||||
};
|
||||
|
||||
|
||||
TTriangleList CreateTriangleListForText(vec2 posFrom, vec2 posTo, TTextParams buttonTextParams);
|
||||
|
||||
class TUniversalButton : public TInstancingWidgetAncestor
|
||||
{
|
||||
protected:
|
||||
|
||||
enum
|
||||
{
|
||||
BS_NORMAL,
|
||||
BS_GO_PRESSED,
|
||||
BS_PRESSED,
|
||||
BS_GO_NORMAL
|
||||
} ButtonState;
|
||||
|
||||
float ButtonStateTimer;
|
||||
|
||||
public:
|
||||
std::vector<TRenderPairList::iterator> NormalTextureIteratorArr;
|
||||
std::vector<TRenderPairList::iterator> PressedTextureIteratorArr;
|
||||
|
||||
float Width;
|
||||
|
||||
float Height;
|
||||
|
||||
TUniversalButton();
|
||||
|
||||
virtual void Update(cardinal dt);
|
||||
|
||||
virtual bool CheckClick(vec2 mousePos);
|
||||
|
||||
virtual void OnTapDown(vec2 pos);
|
||||
virtual void OnTapUp(vec2 pos);
|
||||
virtual void OnMoveOut();
|
||||
|
||||
static TUniversalButton* CreateButton(vec2 posFrom, vec2 posTo);
|
||||
static TUniversalButton* CreateButtonWithFiller(vec2 posFrom, vec2 posTo, boost::function<void(TUniversalButton*)> buttonFillerFunc);
|
||||
static TUniversalButton* CreateButtonWithFillers(vec2 posFrom, vec2 posTo, std::vector<boost::function<void(TUniversalButton*)> > buttonFillerFuncArr);
|
||||
|
||||
static void SquareButtonFiller(vec2 posFrom, vec2 posTo, const std::string& texName, const std::string& texNamePressed, TUniversalButton* buttonToFill);
|
||||
static void TextButtonFiller(vec2 posFrom, vec2 posTo, TTextParams buttonTextParamsNormal, TTextParams buttonTextParamsPressed, TUniversalButton* buttonToFill);
|
||||
|
||||
static TUniversalButton* CreateSquareButton(vec2 posFrom, vec2 posTo, const std::string& texName, const std::string& texNamePressed);
|
||||
static TUniversalButton* CreateTextOnlyButton(vec2 posFrom, vec2 posTo, TTextParams buttonTextParamsNormal, TTextParams buttonTextParamsPressed);
|
||||
static TUniversalButton* CreateSquareAndTextButton(vec2 posFrom, vec2 posTo, const std::string& texName, const std::string& texNamePressed, TTextParams buttonTextParamsNormal, TTextParams buttonTextParamsPressed);
|
||||
};
|
||||
|
||||
|
||||
class TEdit : public TInstancingWidgetAncestor
|
||||
{
|
||||
protected:
|
||||
|
||||
float Width;
|
||||
|
||||
float Height;
|
||||
|
||||
TTextParams TextParams;
|
||||
|
||||
void RefreshTextTriangleList();
|
||||
|
||||
boost::signals::connection InputConnection;
|
||||
|
||||
boost::signals::connection SetTextSlotConnection;
|
||||
|
||||
public:
|
||||
~TEdit();
|
||||
TRenderPairList::iterator TextIterator;
|
||||
|
||||
|
||||
boost::signal<void(std::string)> OnTextChanged;
|
||||
|
||||
virtual bool CheckClick(vec2 mousePos);
|
||||
|
||||
virtual void OnKeyPress(int key);
|
||||
virtual void OnTapDown(vec2 pos);
|
||||
|
||||
void SetText(const std::string& newText);
|
||||
|
||||
static TEdit* CreateEdit(vec2 posFrom, vec2 posTo);
|
||||
static TEdit* CreateEditWithFiller(vec2 posFrom, vec2 posTo, boost::function<void(TEdit*)> fillerFunc);
|
||||
static TEdit* CreateEditWithFillers(vec2 posFrom, vec2 posTo, std::vector<boost::function<void(TEdit*)> > fillerFuncArr);
|
||||
|
||||
static void EditFiller(vec2 posFrom, vec2 posTo, const std::string& texName, TTextParams textParams, TEdit* edit);
|
||||
static void SmartValueTextFiller(const std::string& dictionaryName, const std::string& smartValueName, TEdit* edit);
|
||||
|
||||
//static TEdit* CreateEdit(vec2 posFrom, vec2 posTo, const std::string& texName, TTextParams textParams);
|
||||
};
|
||||
|
||||
|
||||
class TCheckBox : public TInstancingWidgetAncestor
|
||||
{
|
||||
protected:
|
||||
bool IsChecked; //To be set immediately on tap up
|
||||
|
||||
boost::signals::connection SetCheckedSlotConnection;
|
||||
void RefreshVisibility();
|
||||
public:
|
||||
std::vector<TRenderPairList::iterator> StaticTextureIteratorArr;
|
||||
std::vector<TRenderPairList::iterator> CheckedTextureIteratorArr;
|
||||
|
||||
float Width;
|
||||
|
||||
float Height;
|
||||
|
||||
TCheckBox();
|
||||
~TCheckBox();
|
||||
|
||||
virtual bool CheckClick(vec2 mousePos);
|
||||
virtual void Update(cardinal dt);
|
||||
|
||||
virtual void OnTapDown(vec2 pos);
|
||||
virtual void OnTapUp(vec2 pos);
|
||||
virtual void OnMoveOut();
|
||||
|
||||
//Logic:
|
||||
void SetChecked(bool isChecked);
|
||||
boost::signal<void(bool)> OnSetChecked;
|
||||
|
||||
static TCheckBox* CreateCheckBox(vec2 posFrom, vec2 posTo);
|
||||
static TCheckBox* CreateCheckBoxWithFiller(vec2 posFrom, vec2 posTo, boost::function<void(TCheckBox*)> checkBoxFillerFunc);
|
||||
static TCheckBox* CreateCheckBoxWithFillers(vec2 posFrom, vec2 posTo, std::vector<boost::function<void(TCheckBox*)> > checkBoxFillerFuncArr);
|
||||
|
||||
static void TextureFiller(vec2 posFrom, vec2 posTo, const std::string& texName, const std::string& texNameChecked, TCheckBox* checkBoxToFill);
|
||||
static void TextFiller(vec2 posFrom, vec2 posTo, TTextParams textParams, TCheckBox* checkBoxToFill);
|
||||
static void CheckedFiller(bool isChecked, TCheckBox* checkBoxToFill);
|
||||
static void SmartValueFiller(const std::string& dictionaryName, const std::string& smartValueName, TCheckBox* checkBoxToFill);
|
||||
|
||||
static TCheckBox* CreateSimpleCheckBox(vec2 posFrom, vec2 posTo, const std::string& texName, const std::string& texNameChecked);
|
||||
static TCheckBox* CreateCheckBoxWithText(vec2 posFrom, vec2 posTo, const std::string& texName, const std::string& texNameChecked, vec2 textPosFrom, vec2 textPosTo, TTextParams textParams);
|
||||
};
|
||||
|
||||
|
||||
|
||||
class TRadioButton : public TInstancingWidgetAncestor
|
||||
{
|
||||
protected:
|
||||
bool IsChecked; //To be set immediately on tap up
|
||||
|
||||
boost::signals::connection SetCheckedSlotConnection;
|
||||
void RefreshVisibility();
|
||||
public:
|
||||
std::vector<TRenderPairList::iterator> StaticTextureIteratorArr;
|
||||
std::vector<TRenderPairList::iterator> CheckedTextureIteratorArr;
|
||||
|
||||
float Width;
|
||||
|
||||
float Height;
|
||||
|
||||
TRadioButton();
|
||||
~TRadioButton();
|
||||
|
||||
virtual bool CheckClick(vec2 mousePos);
|
||||
virtual void Update(cardinal dt);
|
||||
|
||||
virtual void OnTapDown(vec2 pos);
|
||||
virtual void OnTapUp(vec2 pos);
|
||||
virtual void OnMoveOut();
|
||||
|
||||
//Logic:
|
||||
void SetChecked(bool isChecked);
|
||||
boost::signal<void(bool)> OnSetChecked;
|
||||
|
||||
static TRadioButton* CreateRadioButton(vec2 posFrom, vec2 posTo);
|
||||
static TRadioButton* CreateRadioButtonWithFiller(vec2 posFrom, vec2 posTo, boost::function<void(TRadioButton*)> radioButtonFillerFunc);
|
||||
static TRadioButton* CreateRadioButtonWithFillers(vec2 posFrom, vec2 posTo, std::vector<boost::function<void(TRadioButton*)> > radioButtonFillerFuncArr);
|
||||
|
||||
static void TextureFiller(vec2 posFrom, vec2 posTo, const std::string& texName, const std::string& texNameChecked, TRadioButton* radioButtonToFill);
|
||||
static void TextFiller(vec2 posFrom, vec2 posTo, TTextParams textParams, TRadioButton* radioButtonToFill);
|
||||
static void CheckedFiller(bool isChecked, TRadioButton* radioButtonToFill);
|
||||
|
||||
template <typename TYPENAME>
|
||||
static void SmartValueFiller(const std::string& dictionaryName, const std::string& smartValueName, TYPENAME value, TRadioButton* radioButtonToFill);
|
||||
|
||||
static TRadioButton* CreateSimpleRadioButton(vec2 posFrom, vec2 posTo, const std::string& texName, const std::string& texNameChecked);
|
||||
static TRadioButton* CreateRadioButtonWithText(vec2 posFrom, vec2 posTo, const std::string& texName, const std::string& texNameChecked, vec2 textPosFrom, vec2 textPosTo, TTextParams textParams);
|
||||
};
|
||||
|
||||
|
||||
class TMover : public TInstancingWidgetAncestor
|
||||
{
|
||||
protected:
|
||||
|
||||
float PosCursor;
|
||||
public:
|
||||
float Width;
|
||||
float Height;
|
||||
float MaxHeight;
|
||||
|
||||
std::string GroupName;
|
||||
std::string SelfName; //For exclusion
|
||||
|
||||
TMover();
|
||||
~TMover();
|
||||
|
||||
virtual void Update(cardinal dt);
|
||||
|
||||
virtual bool CheckClick(vec2 mousePos);
|
||||
|
||||
virtual void OnTapDown(vec2 pos);
|
||||
virtual void OnTapUp(vec2 pos);
|
||||
virtual void OnMove(vec2 shift);
|
||||
virtual void OnMoveOut();
|
||||
|
||||
virtual bool IsTransparentForInput() { return true; }
|
||||
|
||||
static TMover* CreateMover(vec2 posFrom, vec2 posTo, std::string groupName, std::string selfName, float maxHeight);
|
||||
};
|
||||
|
||||
} //namespace SE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,184 @@
|
||||
#ifndef GUIMANAGER_H_INCLUDED
|
||||
#define GUIMANAGER_H_INCLUDED
|
||||
|
||||
#include "include/Render/RenderMisc.h"
|
||||
#include "include/GUIManager/ButtonWidget.h"
|
||||
#include "include/GUIManager/WidgetXmlParsers.h"
|
||||
#include "include/Utils/Utils.h"
|
||||
#include "include/ScriptManager/ScriptManager.h"
|
||||
|
||||
#include "boost/variant.hpp"
|
||||
#include "boost/thread.hpp"
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
extern const std::string CONST_HOLD_SIGNAL_NAME;
|
||||
extern const std::string CONST_CLICK_SIGNAL_NAME;
|
||||
extern const std::string CONST_DRAG_SIGNAL_NAME;
|
||||
|
||||
|
||||
typedef boost::variant<cardinal, vec2> TSignalParam;
|
||||
|
||||
struct TWidgetStruct
|
||||
{
|
||||
std::string Name;
|
||||
std::string GroupName;
|
||||
int Order;
|
||||
|
||||
bool IsMouseDown;
|
||||
|
||||
std::shared_ptr<TInstancingWidgetAncestor> Widget;
|
||||
|
||||
std::map<std::string, std::shared_ptr<boost::signal<void (TSignalParam)>>> SignalMap;
|
||||
|
||||
TWidgetStruct(const std::string& name, const std::string& groupName, std::shared_ptr<TInstancingWidgetAncestor> widget, int order = 0)
|
||||
: Name(name)
|
||||
, GroupName(groupName)
|
||||
, Order(order)
|
||||
, IsMouseDown(false)
|
||||
, Widget(widget)
|
||||
{
|
||||
SignalMap[CONST_HOLD_SIGNAL_NAME] = std::shared_ptr<boost::signal<void (TSignalParam)>>(new boost::signal<void (TSignalParam)>());
|
||||
SignalMap[CONST_CLICK_SIGNAL_NAME] = std::shared_ptr<boost::signal<void (TSignalParam)>>(new boost::signal<void (TSignalParam)>());
|
||||
SignalMap[CONST_DRAG_SIGNAL_NAME] = std::shared_ptr<boost::signal<void (TSignalParam)>>(new boost::signal<void (TSignalParam)>());
|
||||
}
|
||||
|
||||
TWidgetStruct(const TWidgetStruct& widgetStruct)
|
||||
{
|
||||
Name = widgetStruct.Name;
|
||||
Widget = widgetStruct.Widget;
|
||||
GroupName = widgetStruct.GroupName;
|
||||
IsMouseDown = widgetStruct.IsMouseDown;
|
||||
Order = widgetStruct.Order;
|
||||
SignalMap = widgetStruct.SignalMap;
|
||||
|
||||
}
|
||||
|
||||
TWidgetStruct& operator=(const TWidgetStruct& widgetStruct)
|
||||
{
|
||||
//Self-assignment is ok
|
||||
Name = widgetStruct.Name;
|
||||
Widget = widgetStruct.Widget;
|
||||
GroupName = widgetStruct.GroupName;
|
||||
IsMouseDown = widgetStruct.IsMouseDown;
|
||||
Order = widgetStruct.Order;
|
||||
SignalMap = widgetStruct.SignalMap;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
~TWidgetStruct()
|
||||
{
|
||||
}
|
||||
|
||||
//For sorting
|
||||
bool operator>(const TWidgetStruct& widget) const
|
||||
{
|
||||
return Order > widget.Order;
|
||||
}
|
||||
|
||||
bool operator<(const TWidgetStruct& widget) const
|
||||
{
|
||||
return Order < widget.Order;
|
||||
}
|
||||
|
||||
bool operator==(const TWidgetStruct& widget) const
|
||||
{
|
||||
return Order == widget.Order;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
struct TWidgetTransformTask
|
||||
{
|
||||
std::string GroupName;
|
||||
vec2 PosTo;
|
||||
int CurrentTime;
|
||||
int TotalTime;
|
||||
|
||||
enum TMoveStyle
|
||||
{
|
||||
MS_LINEAR,
|
||||
MS_SQR,
|
||||
MS_SQRT
|
||||
} MoveStyle;
|
||||
|
||||
TWidgetTransformTask(const std::string& groupName, vec2 posTo, int totalTime, int currentTime, TMoveStyle moveStyle)
|
||||
: GroupName(groupName)
|
||||
, PosTo(posTo)
|
||||
, TotalTime(totalTime)
|
||||
, CurrentTime(currentTime)
|
||||
, MoveStyle(moveStyle)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
typedef std::list<TWidgetTransformTask> TWidgetTrasfromTaskList;
|
||||
|
||||
typedef std::vector<TWidgetStruct> TWidgetArr;
|
||||
|
||||
class TGUIManager : public TFunctionBinderInterface
|
||||
{
|
||||
protected:
|
||||
|
||||
TWidgetArr WidgetArr;
|
||||
|
||||
TWidgetTrasfromTaskList WidgetTrasfromTaskList;
|
||||
|
||||
void MoveWidgetByIterator(TWidgetArr::iterator widget, vec2 shift);
|
||||
|
||||
TWidgetArr::iterator FindWidgetInArr(const std::string& widgetName);
|
||||
|
||||
vec2 LastTapPos;
|
||||
vec2 TotalShift;
|
||||
|
||||
boost::mutex WidgetListMutex;
|
||||
|
||||
public:
|
||||
|
||||
boost::signal<void(int)> KeyPressedSignal;
|
||||
boost::signal<void()> PostUpdateSignal;
|
||||
|
||||
~TGUIManager();
|
||||
|
||||
void AddWidget(std::shared_ptr<TInstancingWidgetAncestor> widgetAncestor, const std::string& name, const std::string& groupName, int order = 0);
|
||||
|
||||
void DeleteWidget(std::string name);
|
||||
void DeleteWidgetGroup(std::string groupName);
|
||||
|
||||
void DeleteWidgetOnUpdate(const std::string& name);
|
||||
void DeleteWidgetGroupOnUpdate(const std::string& groupName);
|
||||
|
||||
void Update(cardinal dt);
|
||||
void Draw();
|
||||
|
||||
void MoveWidget(const std::string& widgetName, vec2 shift);
|
||||
void MoveWidgetGroup(const std::string& widgetGroupName, const std::string& exceptWidget, vec2 shift);
|
||||
|
||||
void AddWidgetTransformTask(TWidgetTransformTask widgetTransformTask);
|
||||
|
||||
void OnMouseDown(vec2 pos);
|
||||
|
||||
void OnMouseUp(vec2 pos);
|
||||
|
||||
void OnMove(vec2 shift);
|
||||
|
||||
void PrintWidgetList();
|
||||
|
||||
std::shared_ptr<boost::signal<void (TSignalParam)>> GetOnClickSignal(const std::string& widgetName);
|
||||
std::shared_ptr<boost::signal<void (TSignalParam)>> GetOnHoldSignal(const std::string& widgetName);
|
||||
std::shared_ptr<boost::signal<void (TSignalParam)>> GetSignal(const std::string& signalName, const std::string& widgetName);
|
||||
|
||||
//TFunctionBinderInterface implementation:
|
||||
void SQ_MoveWidget(const SQChar *widgetName, float x, float y);
|
||||
virtual void BindFunctions();
|
||||
|
||||
};
|
||||
|
||||
} //namespace SE
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,36 @@
|
||||
|
||||
// This file contains templates for widgets
|
||||
// This file must be included somewhere in HalibutEngine.h just after ResourceManager is declared
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
template <typename TYPENAME>
|
||||
void TRadioButton::SmartValueFiller(const std::string& dictionaryName, const std::string& smartValueName, TYPENAME value, TRadioButton* radioButtonToFill)
|
||||
{
|
||||
|
||||
radioButtonToFill->SetChecked(ResourceManager->SmartValueManager.GetImmediateValue<TYPENAME>(dictionaryName, smartValueName) == value);
|
||||
radioButtonToFill->OnSetChecked.connect
|
||||
(
|
||||
[dictionaryName, smartValueName, value](bool checked)
|
||||
{
|
||||
if (checked)
|
||||
{
|
||||
if (ResourceManager->SmartValueManager.GetImmediateValue<TYPENAME>(dictionaryName, smartValueName) != value)
|
||||
{
|
||||
ResourceManager->SmartValueManager.SetImmediateValue<TYPENAME>(dictionaryName, smartValueName, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
radioButtonToFill->SetCheckedSlotConnection = ResourceManager->SmartValueManager.GetSignal<TYPENAME>(dictionaryName, smartValueName).connect
|
||||
(
|
||||
[radioButtonToFill, value](const TYPENAME& newValue)
|
||||
{
|
||||
radioButtonToFill->SetChecked(value == newValue);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
} //namespace SE
|
||||
@@ -0,0 +1,55 @@
|
||||
#ifndef WIDGET_XML_PARSERS_H_INCLUDED
|
||||
#define WIDGET_XML_PARSERS_H_INCLUDED
|
||||
|
||||
#include "ButtonWidget.h"
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
struct TStaticWidgetParser : public TSerializeInterface
|
||||
{
|
||||
virtual void Serialize(boost::property_tree::ptree& propertyTree);
|
||||
};
|
||||
|
||||
struct TDynamicTextWidgetParser : public TSerializeInterface
|
||||
{
|
||||
virtual void Serialize(boost::property_tree::ptree& propertyTree);
|
||||
};
|
||||
|
||||
|
||||
struct TButtonWidgetParser : public TSerializeInterface
|
||||
{
|
||||
virtual void Serialize(boost::property_tree::ptree& propertyTree);
|
||||
};
|
||||
|
||||
|
||||
struct TEditWidgetParser : public TSerializeInterface
|
||||
{
|
||||
virtual void Serialize(boost::property_tree::ptree& propertyTree);
|
||||
};
|
||||
|
||||
struct TCheckBoxWidgetParser : public TSerializeInterface
|
||||
{
|
||||
virtual void Serialize(boost::property_tree::ptree& propertyTree);
|
||||
};
|
||||
|
||||
struct TRadioButtonWidgetParser : public TSerializeInterface
|
||||
{
|
||||
virtual void Serialize(boost::property_tree::ptree& propertyTree);
|
||||
};
|
||||
|
||||
|
||||
struct TWidgetParser : public TSerializeInterface
|
||||
{
|
||||
virtual void Serialize(boost::property_tree::ptree& propertyTree);
|
||||
};
|
||||
|
||||
|
||||
struct TWidgetListParser : public TSerializeInterface
|
||||
{
|
||||
virtual void Serialize(boost::property_tree::ptree& propertyTree);
|
||||
};
|
||||
|
||||
} //namespace SE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,46 @@
|
||||
#ifndef GLOBAL_CONST_H_INCLUDED
|
||||
#define GLOBAL_CONST_H_INCLUDED
|
||||
|
||||
#include "include/Utils/DataTypes/DataTypes.h"
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
/*
|
||||
This code contains global constant values for engine
|
||||
*/
|
||||
|
||||
const float CONST_MAX_CAM_DIST = 20.0f;
|
||||
//How far camera could be from game field
|
||||
|
||||
//const float CONST_MIN_CAM_DIST = 4.0f;
|
||||
const float CONST_MIN_CAM_DIST = 0.0f;
|
||||
//How near camera could be from game field
|
||||
|
||||
const float CONST_MIN_CAM_PHI = pi/48;
|
||||
|
||||
const float CONST_MAX_CAM_PHI = pi/2;
|
||||
|
||||
const int CONST_MAX_SHADER_LIGHTS = 8;
|
||||
//Max light sources count (for shader)
|
||||
|
||||
//const cardinal CONST_TIMER_INTERVAL = 5;
|
||||
//Time interval to call Application::Update()
|
||||
|
||||
const float CONST_DEFAULT_FOG_BEGIN_DISTANCE = 14.0f;
|
||||
|
||||
const float CONST_DEFAULT_FOG_END_DISTANCE = 19.0f;
|
||||
|
||||
const vec4 CONST_DEFAULT_FOG_COLOR(0.2f, 0.5f, 1.0f, 1.0f);
|
||||
|
||||
const float CONST_DEFAULT_GLOBAL_SHADOW_AREA_HALFSIZE = 20.0f;
|
||||
|
||||
const int CONST_MAX_STACK_SIZE = 100;
|
||||
|
||||
const float CONST_CAMERA_VERTICAL_SHIFT = 1.5f;
|
||||
|
||||
const float CONST_CAMERA_PHI_ELEVATION_STEP = pi/48;
|
||||
|
||||
} //namespace SE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,171 @@
|
||||
#ifndef HALIBUT_ANIMATION_H_INCLUDED
|
||||
#define HALIBUT_ANIMATION_H_INCLUDED
|
||||
|
||||
#include "include/Render/RenderMisc.h"
|
||||
#include "include/Render/RenderParams.h"
|
||||
#include "include/ScriptManager/ScriptManager.h"
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
struct TAnimShot
|
||||
{
|
||||
vec2 TexCoordFrom;
|
||||
vec2 TexCoordTo;
|
||||
cardinal TimePassedFromStart;
|
||||
TAnimShot(vec2 texCoordFrom, vec2 texCoordTo, cardinal timePassedFromStart)
|
||||
: TexCoordFrom(texCoordFrom)
|
||||
, TexCoordTo(texCoordTo)
|
||||
, TimePassedFromStart(timePassedFromStart)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class THalibutAnimObject : public TSerializeInterface
|
||||
{
|
||||
protected:
|
||||
std::string TexName;
|
||||
std::vector<TAnimShot> AnimShotArr;
|
||||
|
||||
cardinal CurrentAnimTime;
|
||||
cardinal TotalAnimTime;
|
||||
|
||||
cardinal CurrentAnimFrame;
|
||||
|
||||
void RefreshTriangleListVector();
|
||||
|
||||
public:
|
||||
|
||||
TRenderPairList TriangleListVector;
|
||||
|
||||
vec2 LeftBottomPos;
|
||||
|
||||
THalibutAnimObject(const std::string& texName, vec2 posFrom, vec2 posTo);
|
||||
|
||||
void AddAnimShot(vec2 texCoordFrom, vec2 texCoordTo, cardinal timePassedFromStart);
|
||||
|
||||
void CalcTotalAnimTime();
|
||||
|
||||
void Update(cardinal dt);
|
||||
|
||||
void Reset();
|
||||
|
||||
void Clear();
|
||||
|
||||
virtual void Serialize(boost::property_tree::ptree& propertyTree);
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
class THalibutExternalAnimObject : public TSerializeInterface
|
||||
{
|
||||
protected:
|
||||
|
||||
cardinal CurrentAnimTime;
|
||||
cardinal TotalAnimTime;
|
||||
|
||||
cardinal CurrentAnimFrame;
|
||||
|
||||
std::vector<TAnimShot> AnimShotArr;
|
||||
|
||||
TRenderPairList::iterator RenderPairIter;
|
||||
|
||||
cardinal RectCount;
|
||||
cardinal RectFrom;
|
||||
|
||||
void RefreshTriangleListVector();
|
||||
|
||||
public:
|
||||
|
||||
THalibutExternalAnimObject()
|
||||
: RectCount(1)
|
||||
{
|
||||
}
|
||||
|
||||
THalibutExternalAnimObject(TRenderPairList::iterator renderPairIter, cardinal rectFrom, cardinal rectCount);
|
||||
|
||||
THalibutExternalAnimObject(const THalibutExternalAnimObject& copyFrom);
|
||||
|
||||
THalibutExternalAnimObject& operator=(const THalibutExternalAnimObject& copyFrom);
|
||||
|
||||
~THalibutExternalAnimObject();
|
||||
|
||||
void ReplaceAnimObject(TRenderPairList::iterator renderPairIter, cardinal rectFrom);
|
||||
|
||||
void AddAnimShot(vec2 texCoordFrom, vec2 texCoordTo, cardinal timePassedFromStart);
|
||||
|
||||
void CalcTotalAnimTime();
|
||||
|
||||
void Update(cardinal dt);
|
||||
|
||||
void Reset();
|
||||
|
||||
void Clear();
|
||||
|
||||
virtual void Serialize(boost::property_tree::ptree& propertyTree);
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct THalibutAnimObjectRecord
|
||||
{
|
||||
std::string Name;
|
||||
|
||||
THalibutExternalAnimObject HalibutAnimObject;
|
||||
|
||||
enum TAnimState
|
||||
{
|
||||
AS_PLAY,
|
||||
AS_STOP
|
||||
} AnimState;
|
||||
|
||||
bool Visible;
|
||||
|
||||
THalibutAnimObjectRecord(const std::string& name, THalibutExternalAnimObject halibutAnimObject, TAnimState animState)
|
||||
: Name(name)
|
||||
, HalibutAnimObject(halibutAnimObject)
|
||||
, AnimState(animState)
|
||||
, Visible(true)
|
||||
{
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
class THalibutAnimationManager : public TFunctionBinderInterface
|
||||
{
|
||||
protected:
|
||||
std::vector<THalibutAnimObjectRecord> HalibutAnimObjectArr;
|
||||
std::vector<THalibutAnimObjectRecord>::iterator FindAnimObjectByName(const std::string& name);
|
||||
|
||||
public:
|
||||
|
||||
~THalibutAnimationManager();
|
||||
|
||||
void AddAnimationObject(const std::string& animName, THalibutExternalAnimObject halibutExternalAnimObject);
|
||||
void DeleteAnimationObject(const std::string& animName);
|
||||
|
||||
bool AnimationExists(const std::string& animName);
|
||||
void ReplaceAnimationObject(const std::string& animName, TRenderPairList::iterator renderPairIter, cardinal rectFrom);
|
||||
|
||||
void Update(cardinal dt);
|
||||
|
||||
void StartAnimation(const std::string& animName);
|
||||
void StopAnimation(const std::string& animName);
|
||||
void PauseAnimation(const std::string& animName);
|
||||
//void HideAnimation(const std::string& animName);
|
||||
//void ShowAnimation(const std::string& animName);
|
||||
|
||||
void PrintAnimationList();
|
||||
virtual void BindFunctions();
|
||||
|
||||
};
|
||||
|
||||
} //namespace SE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,48 @@
|
||||
#ifndef HALIBUT_ENGINE_ANDROID_H_INCLUDED
|
||||
#define HALIBUT_ENGINE_ANDROID_H_INCLUDED
|
||||
|
||||
|
||||
#include "include/Utils/Utils.h"
|
||||
#include "include/Utils/Console/console.h"
|
||||
|
||||
#include "include/Render/HalibutRender/HalibutRenderAndroid.h"
|
||||
|
||||
#include "include/HalibutEngineInterface.h"
|
||||
//Android code only
|
||||
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
extern TJavaConsole* Console;
|
||||
|
||||
extern THalibutResourceManager* ResourceManager;
|
||||
|
||||
extern THalibutRendererAndroid* Renderer;
|
||||
|
||||
class TApplication : public TApplicationAncestor
|
||||
{
|
||||
protected:
|
||||
public:
|
||||
TApplication();
|
||||
|
||||
virtual ~TApplication();
|
||||
|
||||
virtual void OuterInit(int screenWidth, int screenHeight, float matrixWidth, float matrixHeight);
|
||||
|
||||
virtual void OuterDeinit();
|
||||
|
||||
virtual void OnKeyPress(cardinal key);
|
||||
|
||||
};
|
||||
|
||||
|
||||
} //namespace SE
|
||||
|
||||
//This file includes templates that call any of three singletones: Console, ResourceManager or Renderer
|
||||
|
||||
#include "include/GUIManager/WidgetTemplatesImpl.h"
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,104 @@
|
||||
#ifndef HALIBUT_ENGINE_INTERFACE_H_INCLUDED
|
||||
#define HALIBUT_ENGINE_INTERFACE_H_INCLUDED
|
||||
|
||||
#include "include/ApplicationInterface.h"
|
||||
|
||||
#include "include/TextureManager/SalmonTexture.h"
|
||||
#include "include/ShaderManager/ShaderManager.h"
|
||||
#include "include/ScriptManager/ScriptManager.h"
|
||||
#include "include/GUIManager/GUIManager.h"
|
||||
#include "include/FrameManager/FrameManager.h"
|
||||
#include "include/FontManager/FontManager.h"
|
||||
#include "include/HalibutAnimation/HalibutAnimation.h"
|
||||
#include "include/SmartValueManager/SmartValueManager.h"
|
||||
|
||||
|
||||
|
||||
#ifdef TARGET_WIN32
|
||||
#include "include/SoundManager/SoundManagerWindows.h"
|
||||
#endif
|
||||
#ifdef TARGET_ANDROID
|
||||
#include "include/SoundManager/SoundManagerAndroid.h"
|
||||
#endif
|
||||
#ifdef TARGET_IOS
|
||||
#include "include/SoundManager/SoundManagerIos.h"
|
||||
#endif
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
//Windows only
|
||||
struct TMouseState
|
||||
{
|
||||
int X;
|
||||
int Y;
|
||||
bool LeftButtonPressed;
|
||||
bool MiddleButtonPressed;
|
||||
bool RightButtonPressed;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class THalibutResourceManager
|
||||
{
|
||||
public:
|
||||
std::string PathToResources;
|
||||
|
||||
TTextureListClass TexList;
|
||||
TShaderManager ShaderManager;
|
||||
TScriptManager ScriptManager;
|
||||
TGUIManager GUIManager;
|
||||
TFrameManager FrameManager;
|
||||
TFontManager FontManager;
|
||||
THalibutAnimationManager HalibutAnimationManager;
|
||||
TSmartValueManager SmartValueManager;
|
||||
|
||||
#ifdef TARGET_WIN32
|
||||
TSoundManagerWindows SoundManager;
|
||||
#endif
|
||||
#ifdef TARGET_ANDROID
|
||||
TSoundManagerAndroid SoundManager;
|
||||
#endif
|
||||
#ifdef TARGET_IOS
|
||||
TSoundManagerIos SoundManager;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
class TApplicationAncestor : public TApplicationInterface
|
||||
{
|
||||
protected:
|
||||
|
||||
public:
|
||||
|
||||
TApplicationAncestor();
|
||||
|
||||
//If you override them, call ancestor:
|
||||
virtual void OuterDraw();
|
||||
virtual void OuterUpdate(cardinal dt);
|
||||
|
||||
|
||||
virtual void OuterOnTapDown(vec2 p);
|
||||
virtual void OuterOnTapUp(vec2 p);
|
||||
virtual void OuterOnMove(vec2 shift);
|
||||
|
||||
virtual void InnerOnTapDown(vec2 p) { }
|
||||
|
||||
virtual void InnerOnTapUp(vec2 p) { }
|
||||
|
||||
virtual void InnerOnMove(vec2 shift) { }
|
||||
|
||||
virtual void OnFling(vec2 v) { } //Android only
|
||||
|
||||
virtual void OnMouseMove(TMouseState& mouseState) { } //Windows only
|
||||
|
||||
virtual void OnMouseWheel(short int delta) { } //Windows only
|
||||
|
||||
virtual void OnKeyPress(cardinal key) { } //Try not to override this. But if you need to override, call ancestor!
|
||||
|
||||
};
|
||||
|
||||
} //namespace SE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// HalibutEngineIos.h
|
||||
// Halibut Engine
|
||||
//
|
||||
// Created by vvv ооо on 13.07.12.
|
||||
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef HALIBUT_ENGINE_IOS_H_INCLUDED
|
||||
#define HALIBUT_ENGINE_IOS_H_INCLUDED
|
||||
|
||||
#include "include/HalibutEngineInterface.h"
|
||||
|
||||
#include "include/Render/HalibutRender/HalibutRenderIos.h"
|
||||
|
||||
#include "include/Utils/Utils.h"
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
extern TIosConsole* Console;
|
||||
|
||||
extern THalibutResourceManager* ResourceManager;
|
||||
|
||||
extern THalibutRenderIos* Renderer;
|
||||
|
||||
class TApplication : public TApplicationAncestor
|
||||
{
|
||||
public:
|
||||
TApplication();
|
||||
|
||||
virtual ~TApplication();
|
||||
|
||||
virtual void OuterInit(int screenWidth, int screenHeight, float matrixWidth, float matrixHeight);
|
||||
|
||||
virtual void OuterDeinit();
|
||||
|
||||
virtual void OnKeyPress(cardinal key);
|
||||
};
|
||||
|
||||
|
||||
|
||||
} //namespace SE
|
||||
|
||||
|
||||
//This file includes templates that call any of three singletones: Console, ResourceManager or Renderer
|
||||
|
||||
#include "include/GUIManager/WidgetTemplatesImpl.h"
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,63 @@
|
||||
#pragma once //Windows ok
|
||||
|
||||
|
||||
#include "include/Render/HalibutRender/HalibutRenderWindows.h"
|
||||
|
||||
#include "include/HalibutEngineInterface.h"
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
//==============================================================
|
||||
//========= GLOBAL VARIABLES - REMEMBER THIS LIST!!! ===========
|
||||
//==============================================================
|
||||
|
||||
extern HGLRC hRC; //Render context
|
||||
extern HWND Hwnd; //Main window handle
|
||||
extern HDC hDC; //Device context
|
||||
|
||||
extern TFileConsole* Console;
|
||||
//Console and log for output
|
||||
|
||||
extern THalibutRenderer* Renderer;
|
||||
//OpenGL renderer
|
||||
|
||||
extern THalibutResourceManager* ResourceManager;
|
||||
//Resource Manager
|
||||
|
||||
|
||||
|
||||
class TApplication : public TApplicationAncestor
|
||||
{
|
||||
protected:
|
||||
std::string LogFilename; //Log file name
|
||||
unsigned char KeyboardBuffer[256];
|
||||
public:
|
||||
int X, Y, Width, Height; //Window position and size
|
||||
float MatrixWidth, MatrixHeight;
|
||||
|
||||
std::string WindowName; //Window name
|
||||
|
||||
TApplication();
|
||||
virtual ~TApplication();
|
||||
|
||||
const std::string& GetLogFilename();
|
||||
|
||||
char GetKeyState(cardinal keyNum);
|
||||
|
||||
void SetKeyboardBuffer(const unsigned char* source);
|
||||
|
||||
virtual void OnKeyPress(cardinal key); // If you override this, call ancestor!
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
int MainLoop(TApplication& application);
|
||||
|
||||
} //namespace SE
|
||||
|
||||
//This file includes templates that call any of three singletones: Console, ResourceManager or Renderer
|
||||
|
||||
#include "include/GUIManager/WidgetTemplatesImpl.h"
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
#ifndef LIGHT_MANAGER_H_INCLUDED
|
||||
#define LIGHT_MANAGER_H_INCLUDED
|
||||
|
||||
|
||||
/*
|
||||
This code contains manager to operate OpenGL lighting
|
||||
|
||||
Use global variable ResourceManager to get access to light manager
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "include/Utils/Utils.h"
|
||||
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
class TLightManager
|
||||
{
|
||||
protected:
|
||||
bool LightingEnabled;
|
||||
|
||||
vec3 LightPos;
|
||||
vec3 LightDirection;
|
||||
|
||||
vec4 LightColor;
|
||||
|
||||
public:
|
||||
TLightManager();
|
||||
|
||||
void SetLightPos(vec3 pos);
|
||||
void SetLightDirection(vec3 dir);
|
||||
void SetLightColor(vec4 color);
|
||||
|
||||
void SetLightOn();
|
||||
void SetLightOff();
|
||||
|
||||
//To be called from SetUniforms
|
||||
void SetLightUniforms();
|
||||
};
|
||||
|
||||
|
||||
} //namespace SE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,130 @@
|
||||
#ifndef MODEL_MANAGER_H_INCLUDED
|
||||
#define MODEL_MANAGER_H_INCLUDED
|
||||
|
||||
/*
|
||||
This code contains manager to operate static Lite Models
|
||||
|
||||
Use global variable ResourceManager to get access to model manager
|
||||
*/
|
||||
|
||||
|
||||
#include "include/Utils/Utils.h"
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
class TLiteModel;
|
||||
|
||||
class TAnimModel;
|
||||
|
||||
/* Class to work with Lite Model Resource from model file.
|
||||
Lite Model Resource can be applied to a number of in-game Lite Models */
|
||||
class TLiteModelResource
|
||||
{
|
||||
protected:
|
||||
|
||||
std::vector<vec3> VertexArr;
|
||||
std::vector<vec3> NormalArr;
|
||||
std::vector<vec3> TangentArr;
|
||||
std::vector<vec3> BinormalArr;
|
||||
std::vector<vec2> TexCoordArr;
|
||||
|
||||
int TriangleCount;
|
||||
std::string Texname;
|
||||
std::string Normtexname;
|
||||
std::string PathToResource;
|
||||
public:
|
||||
TLiteModelResource() : TriangleCount(0), PathToResource("") { }
|
||||
~TLiteModelResource();
|
||||
|
||||
bool LoadModel(boost::shared_array<byte> filePointer, cardinal fileSize);
|
||||
|
||||
void FreeModel();
|
||||
|
||||
void SetPathToResource(const std::string& pathToResource);
|
||||
|
||||
friend class TLiteModel;
|
||||
};
|
||||
|
||||
typedef std::map<std::string, TLiteModelResource> TLiteModelResourceMap;
|
||||
|
||||
/* Class to work with Lite Model in game.
|
||||
Lite Model could be translated/scaled/rotated, also Lite Model have its own model matrix */
|
||||
class TLiteModel
|
||||
{
|
||||
protected:
|
||||
std::string Modelname;
|
||||
|
||||
cardinal TriangleCount;
|
||||
cardinal TexID;
|
||||
cardinal NormTexID;
|
||||
|
||||
TTriangleList TriangleList;
|
||||
|
||||
mat3 ShaderRotateMatrix;
|
||||
vec3 ShaderTranslateVector;
|
||||
bool Loaded;
|
||||
|
||||
public:
|
||||
TLiteModel() : Modelname(""), TriangleCount(0), TexID(0), NormTexID(0),
|
||||
Loaded(false), ShaderRotateMatrix(IdentityMatrix), ShaderTranslateVector(ZeroVec3) {}
|
||||
|
||||
~TLiteModel();
|
||||
|
||||
bool LoadModel(const std::string& s);
|
||||
//Load model from Resource Manager with name s
|
||||
//Model must already be loaded as a Lite Model Resource
|
||||
|
||||
void FreeModel();
|
||||
//Clear all data from model
|
||||
|
||||
//Long-term model processing methods
|
||||
//To rotate/translate model quickly use SetShaderRotateMatrix/SetShaderTranslateVector
|
||||
//If you use VBO to draw model, you must call UpdateVBO() after you finished model translation/rotation/scaling
|
||||
void MoveModel(const vec3& v);
|
||||
void RotateModel(const mat3& r);
|
||||
void ScaleModel(float s);
|
||||
void ScaleModel(const vec3& s);
|
||||
|
||||
//Sets translate vector to do fast model translation. No need to call UpdateVBO after
|
||||
void SetShaderTranslateVector(const vec3& v);
|
||||
|
||||
//Sets rotate matrix to do fast model rotation. No need to call UpdateVBO after
|
||||
void SetShaderRotateMatrix(const mat3& m);
|
||||
|
||||
//Method to update VBO after translation / rotation / scaling
|
||||
void UpdateVBO();
|
||||
|
||||
//Method to draw model in immediate mode. Slow method
|
||||
void DrawImmediate();
|
||||
|
||||
//Method to draw model using VBO. Faster than previous but must be called between SalmonRender->BeginDrawVBO() and SalmonRender->EndDrawVBO()
|
||||
void DrawVBO();
|
||||
|
||||
friend class TAnimModel; //For animation;
|
||||
};
|
||||
|
||||
class TModelManager
|
||||
{
|
||||
protected:
|
||||
TLiteModelResourceMap LiteModelMap;
|
||||
public:
|
||||
TModelManager() {}
|
||||
~TModelManager();
|
||||
|
||||
//Clean up
|
||||
void Clear();
|
||||
|
||||
//Get access to Lite Model resource
|
||||
TLiteModelResource& operator[](const std::string& s);
|
||||
|
||||
//Add lite model resource from file
|
||||
bool AddLiteModel(const std::string& filename, const std::string& pathToResources = "");
|
||||
|
||||
//Delete lite model resource
|
||||
void DeleteLiteModel(const std::string& modelname);
|
||||
};
|
||||
|
||||
} //namespace SE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,78 @@
|
||||
#ifndef NEW_MODEL_MANAGER_H_INCLUDED
|
||||
#define NEW_MODEL_MANAGER_H_INCLUDED
|
||||
|
||||
#include "include/Utils/Utils.h"
|
||||
#include "include/Render/RenderMisc.h"
|
||||
#include "include/Render/RenderParams.h"
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
|
||||
class TFlexModelManager;
|
||||
|
||||
class TFlexModelResource : public TSerializeInterface
|
||||
{
|
||||
protected:
|
||||
TDataTriangleList DataTriangleList;
|
||||
|
||||
std::map<std::string, std::string> SamplerMap;
|
||||
|
||||
int TriangleCount;
|
||||
public:
|
||||
|
||||
TFlexModelResource()
|
||||
: TriangleCount(0)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void Serialize(boost::property_tree::ptree& propertyTree);
|
||||
|
||||
friend class TFlexModelManager;
|
||||
};
|
||||
|
||||
|
||||
class TFlexModel
|
||||
{
|
||||
protected:
|
||||
TRenderPair RenderPair;
|
||||
|
||||
std::stack<TDataTriangleList> DataTriangleListStack;
|
||||
|
||||
bool Loaded;
|
||||
|
||||
public:
|
||||
|
||||
void PushModelDataTriangleList();
|
||||
void PopModelDataTriangleList();
|
||||
|
||||
void MoveModel(const vec3& v);
|
||||
void RotateModel(const mat3& r);
|
||||
void ScaleModel(float s);
|
||||
void ScaleModel(const vec3& s);
|
||||
|
||||
void RefreshBuffer();
|
||||
|
||||
void Draw();
|
||||
|
||||
friend class TFlexModelManager;
|
||||
};
|
||||
|
||||
|
||||
class TFlexModelManager
|
||||
{
|
||||
protected:
|
||||
|
||||
std::map<std::string, TFlexModelResource> FlexModelResourceMap;
|
||||
|
||||
public:
|
||||
|
||||
void LoadModelFromXml(std::string xmlFileName);
|
||||
|
||||
TFlexModel InstanciateModel(const std::string& modelName);
|
||||
|
||||
};
|
||||
|
||||
} //namespace SE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,120 @@
|
||||
#pragma once
|
||||
|
||||
/*
|
||||
This code contains openGL extensions (for them to be called from everywhere)
|
||||
|
||||
Windows only!
|
||||
*/
|
||||
|
||||
#include "include/Utils/WinApi/WinApi.h"
|
||||
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
//====================================================
|
||||
//===================== GLSL Shaders =================
|
||||
//====================================================
|
||||
|
||||
//Requires GL_VERSION_2_0
|
||||
extern PFNGLCREATEPROGRAMPROC glCreateProgram;
|
||||
extern PFNGLDELETEPROGRAMPROC glDeleteProgram;
|
||||
extern PFNGLLINKPROGRAMPROC glLinkProgram;
|
||||
extern PFNGLVALIDATEPROGRAMPROC glValidateProgram;
|
||||
extern PFNGLUSEPROGRAMPROC glUseProgram;
|
||||
extern PFNGLGETPROGRAMIVPROC glGetProgramiv;
|
||||
extern PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog;
|
||||
extern PFNGLCREATESHADERPROC glCreateShader;
|
||||
extern PFNGLDELETESHADERPROC glDeleteShader;
|
||||
extern PFNGLSHADERSOURCEPROC glShaderSource;
|
||||
extern PFNGLCOMPILESHADERPROC glCompileShader;
|
||||
extern PFNGLATTACHSHADERPROC glAttachShader;
|
||||
extern PFNGLDETACHSHADERPROC glDetachShader;
|
||||
extern PFNGLGETSHADERIVPROC glGetShaderiv;
|
||||
extern PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog;
|
||||
extern PFNGLGETATTRIBLOCATIONPROC glGetAttribLocation;
|
||||
extern PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer;
|
||||
extern PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray;
|
||||
extern PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray;
|
||||
extern PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation;
|
||||
extern PFNGLUNIFORMMATRIX3FVPROC glUniformMatrix3fv;
|
||||
extern PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv;
|
||||
extern PFNGLUNIFORM1IPROC glUniform1i;
|
||||
extern PFNGLUNIFORM1FVPROC glUniform1fv;
|
||||
extern PFNGLUNIFORM3FVPROC glUniform2fv;
|
||||
extern PFNGLUNIFORM3FVPROC glUniform3fv;
|
||||
extern PFNGLUNIFORM4FVPROC glUniform4fv;
|
||||
extern PFNGLVERTEXATTRIB1FPROC glVertexAttrib1f;
|
||||
extern PFNGLVERTEXATTRIB2FPROC glVertexAttrib2f;
|
||||
extern PFNGLVERTEXATTRIB3FPROC glVertexAttrib3f;
|
||||
extern PFNGLVERTEXATTRIB4FPROC glVertexAttrib4f;
|
||||
extern PFNGLVERTEXATTRIB2FVPROC glVertexAttrib2fv;
|
||||
extern PFNGLVERTEXATTRIB3FVPROC glVertexAttrib3fv;
|
||||
extern PFNGLVERTEXATTRIB4FVPROC glVertexAttrib4fv;
|
||||
extern PFNGLGETACTIVEATTRIBPROC glGetActiveAttrib;
|
||||
extern PFNGLGETACTIVEUNIFORMPROC glGetActiveUniform;
|
||||
|
||||
|
||||
//=======================================
|
||||
//=========== Multitexture ==============
|
||||
//=======================================
|
||||
|
||||
//Requires GL version 1.3
|
||||
extern PFNGLACTIVETEXTUREPROC glActiveTexture;
|
||||
|
||||
//=======================================
|
||||
//========== Vertex buffer ==============
|
||||
//=======================================
|
||||
|
||||
//Requires GL_VERSION_1_5
|
||||
extern PFNGLGENBUFFERSPROC glGenBuffers;
|
||||
extern PFNGLDELETEBUFFERSPROC glDeleteBuffers;
|
||||
extern PFNGLBINDBUFFERPROC glBindBuffer;
|
||||
extern PFNGLBUFFERDATAPROC glBufferData;
|
||||
extern PFNGLBUFFERSUBDATAPROC glBufferSubData;
|
||||
extern PFNGLMAPBUFFERPROC glMapBuffer;
|
||||
extern PFNGLUNMAPBUFFERPROC glUnmapBuffer;
|
||||
|
||||
//=========================================
|
||||
//============ Frame buffer ===============
|
||||
//=========================================
|
||||
|
||||
//Requires GL_ARB_framebuffer_object
|
||||
extern PFNGLISRENDERBUFFERPROC glIsRenderbuffer;
|
||||
extern PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer;
|
||||
extern PFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers;
|
||||
extern PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers;
|
||||
extern PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage;
|
||||
extern PFNGLGETRENDERBUFFERPARAMETERIVPROC glGetRenderbufferParameteriv;
|
||||
extern PFNGLISFRAMEBUFFERPROC glIsFramebuffer;
|
||||
extern PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer;
|
||||
extern PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers;
|
||||
extern PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers;
|
||||
extern PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus;
|
||||
extern PFNGLFRAMEBUFFERTEXTURE1DPROC glFramebufferTexture1D;
|
||||
extern PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D;
|
||||
extern PFNGLFRAMEBUFFERTEXTURE3DPROC glFramebufferTexture3D;
|
||||
extern PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer;
|
||||
extern PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glGetFramebufferAttachmentParameteriv;
|
||||
extern PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer;
|
||||
extern PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glRenderbufferStorageMultisample;
|
||||
extern PFNGLGENERATEMIPMAPPROC glGenerateMipmap;
|
||||
extern PFNGLFRAMEBUFFERTEXTURELAYERPROC glFramebufferTextureLayer;
|
||||
|
||||
|
||||
|
||||
//===========================================
|
||||
//============ Uniform buffer ===============
|
||||
//===========================================
|
||||
|
||||
//Requires GL_ARB_uniform_buffer_object
|
||||
extern PFNGLGETUNIFORMINDICESPROC glGetUniformIndices;
|
||||
extern PFNGLGETACTIVEUNIFORMSIVPROC glGetActiveUniformsiv;
|
||||
extern PFNGLGETACTIVEUNIFORMNAMEPROC glGetActiveUniformName;
|
||||
extern PFNGLGETUNIFORMBLOCKINDEXPROC glGetUniformBlockIndex;
|
||||
extern PFNGLGETACTIVEUNIFORMBLOCKIVPROC glGetActiveUniformBlockiv;
|
||||
extern PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC glGetActiveUniformBlockName;
|
||||
extern PFNGLUNIFORMBLOCKBINDINGPROC glUniformBlockBinding;
|
||||
extern PFNGLBINDBUFFERBASEPROC glBindBufferBase;
|
||||
|
||||
} //namespace SE
|
||||
@@ -0,0 +1,18 @@
|
||||
#ifndef HALIBUT_RENDER_ANDROID_H_INCLUDED
|
||||
#define HALIBUT_RENDER_ANDROID_H_INCLUDED
|
||||
|
||||
|
||||
#include "include/Utils/Utils.h"
|
||||
|
||||
#include "include/Render/HalibutRender/HalibutRenderGLES20.h"
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
class THalibutRendererAndroid : public THalibutRendererGLES20
|
||||
{
|
||||
};
|
||||
|
||||
} //namespace SE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,28 @@
|
||||
#ifndef HALIBUT_RENDER_GLES20_H_INCLUDED
|
||||
#define HALIBUT_RENDER_GLES20_H_INCLUDED
|
||||
|
||||
#include "include/Utils/Utils.h"
|
||||
|
||||
#include "include/Render/HalibutRender/HalibutRenderInterface.h"
|
||||
#include "include/Render/RenderMisc.h"
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
class THalibutRendererGLES20 : public THalibutRendererInterface
|
||||
{
|
||||
protected:
|
||||
|
||||
void DrawQuad(const T2DQuad& quad);
|
||||
|
||||
public:
|
||||
THalibutRendererGLES20();
|
||||
~THalibutRendererGLES20();
|
||||
|
||||
virtual void DrawTriangleList(const TTriangleList& triangleList);
|
||||
|
||||
};
|
||||
|
||||
} //namespace SE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,32 @@
|
||||
#ifndef HALIBUT_RENDER_INTERFACE_H_INCLUDED
|
||||
#define HALIBUT_RENDER_INTERFACE_H_INCLUDED
|
||||
|
||||
#include "include/Utils/Utils.h"
|
||||
#include "include/Render/RenderInterface.h"
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
class THalibutRendererInterface : public TRendererInterface
|
||||
{
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
public:
|
||||
|
||||
virtual void SetUniforms();
|
||||
|
||||
virtual void InitOpenGL(int screenWidth, int screenHeight, float matrixWidth, float matrixHeight);
|
||||
|
||||
virtual void SwitchToScreen();
|
||||
virtual void SwitchToFrameBuffer(const std::string& frameName);
|
||||
|
||||
virtual void PrintMatrices();
|
||||
|
||||
|
||||
};
|
||||
|
||||
} //namespace SE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,18 @@
|
||||
#ifndef HALIBUT_RENDER_IOS_H_INCLUDED
|
||||
#define HALIBUT_RENDER_IOS_H_INCLUDED
|
||||
|
||||
|
||||
#include "include/Utils/Utils.h"
|
||||
|
||||
#include "include/Render/HalibutRender/HalibutRenderGLES20.h"
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
class THalibutRenderIos : public THalibutRendererGLES20
|
||||
{
|
||||
};
|
||||
|
||||
} //namespace SE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include "include/Utils/Utils.h"
|
||||
#include "include/Render/HalibutRender/HalibutRenderInterface.h"
|
||||
#include "include/Render/RenderMisc.h"
|
||||
|
||||
#include "boost/shared_ptr.hpp"
|
||||
#include "include/OpenGLExt/OpenGlExt.h"
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
class THalibutRenderer : public THalibutRendererInterface
|
||||
{
|
||||
protected:
|
||||
|
||||
|
||||
void DrawTriangleStripImmediate(const TTriangleList& triangleList);
|
||||
void DrawQuad(const T2DQuad& quad);
|
||||
public:
|
||||
THalibutRenderer();
|
||||
~THalibutRenderer();
|
||||
|
||||
bool BindOpenGLFunctions(); //Must be called once
|
||||
|
||||
virtual void DrawTriangleList(const TTriangleList& triangleList);
|
||||
|
||||
};
|
||||
|
||||
} //namespace SE
|
||||
@@ -0,0 +1,78 @@
|
||||
#ifndef RENDER_INTERFACE_H_INCLUDED
|
||||
#define RENDER_INTERFACE_H_INCLUDED
|
||||
|
||||
|
||||
#include "include/Utils/Utils.h"
|
||||
#include "include/Render/RenderMisc.h"
|
||||
#include "include/Render/RenderParams.h"
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
class TRendererInterface
|
||||
{
|
||||
protected:
|
||||
int ScreenWidth;
|
||||
int ScreenHeight;
|
||||
|
||||
float MatrixWidth;
|
||||
float MatrixHeight;
|
||||
|
||||
mat4 ProjectionModelviewMatrix;
|
||||
|
||||
std::stack<mat4> ProjectionMatrixStack;
|
||||
std::stack<mat4> ModelviewMatrixStack;
|
||||
|
||||
virtual void TryEnableVertexAttribArrays();
|
||||
virtual void TryDisableVertexAttribArrays();
|
||||
virtual void DrawQuad(const T2DQuad& quad) = 0;
|
||||
public:
|
||||
TRendererInterface();
|
||||
virtual ~TRendererInterface() { }
|
||||
|
||||
virtual void InitOpenGL(int screenWidth, int screenHeight, float matrixWidth, float matrixHeight) = 0;
|
||||
|
||||
virtual int GetScreenWidth();
|
||||
virtual int GetScreenHeight();
|
||||
|
||||
virtual float GetMatrixWidth();
|
||||
virtual float GetMatrixHeight();
|
||||
|
||||
virtual void SetScreenWidthHeight(int screenWidth, int screenHeight);
|
||||
|
||||
virtual void SetUniforms() = 0;
|
||||
|
||||
virtual void PushMatrix();
|
||||
virtual void LoadIdentity();
|
||||
virtual void TranslateMatrix(const vec3& p);
|
||||
virtual void ScaleMatrix(float scale);
|
||||
virtual void ScaleMatrix(const vec3& scale);
|
||||
virtual void RotateMatrix(const vec4& q);
|
||||
virtual void PushSpecialMatrix(const mat4& m);
|
||||
virtual void PopMatrix();
|
||||
|
||||
virtual void SetProjectionMatrix(float width, float height);
|
||||
virtual void PushProjectionMatrix(float width, float height);
|
||||
virtual void PopProjectionMatrix();
|
||||
|
||||
virtual void SetFrameViewport(const std::string& frameName);
|
||||
virtual void SetFullScreenViewport();
|
||||
|
||||
virtual void PushShader(const std::string& shaderName);
|
||||
virtual void PopShader();
|
||||
|
||||
virtual void DrawRect(const vec2& p1, const vec2& p2);
|
||||
virtual void DrawRect(const vec2& p1, const vec2& p2, const vec2& t1, const vec2& t2);
|
||||
virtual void DrawTriangleList(const TTriangleList& triangleList) = 0;
|
||||
|
||||
virtual void SwitchToScreen() = 0;
|
||||
virtual void SwitchToFrameBuffer(const std::string& frameName) = 0;
|
||||
|
||||
void DrawFrameFullScreen(const std::string& frameName);
|
||||
void DrawFramePartScreen(const std::string& frameName, vec2 posFrom, vec2 posTo); //To draw water. posFrom and posTo goes from 0 to 1
|
||||
|
||||
};
|
||||
|
||||
} //namespace SE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,145 @@
|
||||
#ifndef RENDER_MISC_H_INCLUDED
|
||||
#define RENDER_MISC_H_INCLUDED
|
||||
|
||||
|
||||
#include "include/Utils/DataTypes/DataTypes.h"
|
||||
//#include "include/Utils/SerializeInterface/SerializeInterface.h"
|
||||
#include "boost/shared_ptr.hpp"
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <map>
|
||||
|
||||
|
||||
|
||||
#ifdef TARGET_WIN32
|
||||
|
||||
#include "include/OpenGLExt/OpenGlExt.h"
|
||||
|
||||
#endif
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
struct T2DQuad
|
||||
{
|
||||
vec3 VertexCoord[4];
|
||||
vec2 TextureCoord[4];
|
||||
};
|
||||
|
||||
struct TDataTriangleList
|
||||
{
|
||||
mutable std::map<std::string, std::vector<vec3>> Vec3CoordArr; //mutable because when you call [] on map, it may create a new vector =)
|
||||
mutable std::map<std::string, std::vector<vec2>> Vec2CoordArr; //mutable because when you call [] on map, it may create a new vector =)
|
||||
|
||||
TDataTriangleList& operator+=(const TDataTriangleList& dataTriangleList);
|
||||
};
|
||||
|
||||
class TTriangleListAncestor
|
||||
{
|
||||
public:
|
||||
|
||||
TDataTriangleList Data;
|
||||
|
||||
bool NeedRefreshBuffer;//Dummy for Android, but you need this for PC
|
||||
|
||||
virtual void RefreshBuffer() { } //Dummy for Android, but you need this for PC
|
||||
|
||||
TTriangleListAncestor();
|
||||
|
||||
TTriangleListAncestor(const TTriangleListAncestor& c);
|
||||
|
||||
TTriangleListAncestor& operator=(const TTriangleListAncestor& c);
|
||||
|
||||
TTriangleListAncestor(const TDataTriangleList& dataTriangleList);
|
||||
|
||||
TTriangleListAncestor& operator=(const TDataTriangleList& dataTriangleList);
|
||||
|
||||
virtual ~TTriangleListAncestor();
|
||||
};
|
||||
|
||||
|
||||
#ifdef TARGET_WIN32
|
||||
|
||||
class VBOObject //Must stay in shared ptr only!
|
||||
{
|
||||
public:
|
||||
cardinal Buffer;
|
||||
|
||||
VBOObject();
|
||||
|
||||
VBOObject(const VBOObject& c);
|
||||
|
||||
VBOObject& operator=(const VBOObject& c);
|
||||
|
||||
~VBOObject();
|
||||
};
|
||||
|
||||
|
||||
|
||||
class TTriangleList : public TTriangleListAncestor //Implementation differs for Windows and Android
|
||||
{
|
||||
public:
|
||||
|
||||
mutable std::map<std::string, std::shared_ptr<VBOObject> > VertBufferArr;
|
||||
|
||||
bool NeedPrepareBufferObjects;
|
||||
|
||||
TTriangleList();
|
||||
|
||||
~TTriangleList();
|
||||
|
||||
virtual void RefreshBuffer();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef TARGET_ANDROID
|
||||
|
||||
class TTriangleList : public TTriangleListAncestor
|
||||
{
|
||||
//No difference
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef TARGET_IOS
|
||||
|
||||
class TTriangleList : public TTriangleListAncestor
|
||||
{
|
||||
//No difference
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
void FillVertexCoordVec(std::vector<vec3>& coordVec, int pos, vec2 posFrom, vec2 posTo);
|
||||
|
||||
void FillTexCoordVec(std::vector<vec2>& coordVec, int pos, vec2 texCoordFrom = vec2(0,0), vec2 texCoordTo = vec2(1,1));
|
||||
|
||||
|
||||
std::vector<vec3> MakeVertexCoordVec(vec2 posFrom, vec2 posTo);
|
||||
|
||||
std::vector<vec2> MakeTexCoordVec(vec2 texCoordFrom = vec2(0,0), vec2 texCoordTo = vec2(1,1));
|
||||
|
||||
|
||||
TDataTriangleList MakeDataTriangleList(vec2 posFrom, vec2 posTo, vec2 texCoordFrom = vec2(0,0), vec2 texCoordTo = vec2(1,1));
|
||||
void MoveDataTriangleList(TDataTriangleList& triangleList, vec3 shift);
|
||||
void RotateDataTriangleList(TDataTriangleList& triangleList, const mat3& m);
|
||||
void ScaleDataTriangleList(TDataTriangleList& triangleList, float scale);
|
||||
void ScaleDataTriangleList(TDataTriangleList& triangleList, vec3 scaleVec);
|
||||
TDataTriangleList& ClearDataTriangleList(TDataTriangleList& triangleList);
|
||||
TDataTriangleList& InsertIntoDataTriangleList(TDataTriangleList& triangleList, const std::vector<vec3>& vertexArr, const std::vector<vec2>& texCoordArr);
|
||||
|
||||
void Replace6PointsInTriangleList(TDataTriangleList& triangleList, int pos, vec2 posFrom, vec2 posTo, vec2 texCoordFrom = vec2(0,0), vec2 texCoordTo = vec2(1,1));
|
||||
|
||||
|
||||
TTriangleList MakeTriangleList(vec2 posFrom, vec2 posTo, vec2 texCoordFrom = vec2(0,0), vec2 texCoordTo = vec2(1,1));
|
||||
|
||||
void CheckGlError(const std::string& msg = "");
|
||||
|
||||
|
||||
} //namespace SE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,51 @@
|
||||
#ifndef RENDER_PARAMS_H_INCLUDED
|
||||
#define RENDER_PARAMS_H_INCLUDED
|
||||
|
||||
|
||||
#include "include/Utils/DataTypes/DataTypes.h"
|
||||
#include "include/Utils/SerializeInterface/SerializeInterface.h"
|
||||
#include "boost/shared_ptr.hpp"
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <map>
|
||||
|
||||
|
||||
|
||||
#ifdef TARGET_WIN32
|
||||
|
||||
#include "include/OpenGLExt/OpenGlExt.h"
|
||||
|
||||
#endif
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
struct TRenderParams : public TSerializeInterface
|
||||
{
|
||||
std::string ShaderName;
|
||||
|
||||
mutable std::map<std::string, std::string> SamplerMap;
|
||||
mutable std::map<std::string, float> FloatMap;
|
||||
mutable std::map<std::string, vec4> Vec4Map;
|
||||
|
||||
virtual void Serialize(boost::property_tree::ptree& propertyTree);
|
||||
|
||||
};
|
||||
|
||||
typedef std::pair<TRenderParams, TTriangleList> TRenderPair;
|
||||
|
||||
typedef std::list<TRenderPair> TRenderPairList;
|
||||
|
||||
|
||||
struct TRenderParamsSetter
|
||||
{
|
||||
protected:
|
||||
const TRenderParams& RenderParams;
|
||||
public:
|
||||
TRenderParamsSetter(const TRenderParams& renderParams);
|
||||
~TRenderParamsSetter();
|
||||
};
|
||||
|
||||
} //namespace SE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,27 @@
|
||||
#ifndef BACKGROUND_CUBEMAP_H_INCLUDED
|
||||
#define BACKGROUND_CUBEMAP_H_INCLUDED
|
||||
|
||||
#include "include/Render/RenderMisc.h"
|
||||
#include "include/Utils/Utils.h"
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
class TBackgroundCubemapClass
|
||||
{
|
||||
protected:
|
||||
TTriangleList TriangleList;
|
||||
|
||||
|
||||
public:
|
||||
cardinal BkgTexId;
|
||||
|
||||
TBackgroundCubemapClass();
|
||||
|
||||
void Draw();
|
||||
};
|
||||
|
||||
} //namespace SE
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,17 @@
|
||||
#ifndef SALMON_RENDER_ANDROID_H_INCLUDED
|
||||
#define SALMON_RENDER_ANDROID_H_INCLUDED
|
||||
|
||||
#include "include/Render/SalmonRender/SalmonRenderGLES20.h"
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
class TSalmonRendererAndroid : public TSalmonRendererGLES20
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
} //namespace SE
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,29 @@
|
||||
#ifndef SALMON_RENDER_GLES20_H_INCLUDED
|
||||
#define SALMON_RENDER_GLES20_H_INCLUDED
|
||||
|
||||
#include "include/Render/SalmonRender/SalmonRenderInterface.h"
|
||||
|
||||
#ifdef TARGET_ANDROID
|
||||
#include <GLES/gl.h>
|
||||
#include <GLES2/gl2.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
#endif
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
class TSalmonRendererGLES20 : public TSalmonRendererInterface
|
||||
{
|
||||
protected:
|
||||
|
||||
virtual void DrawQuad(const T2DQuad& quad);
|
||||
public:
|
||||
|
||||
void DrawTriangleList(const TTriangleList& triangleList);
|
||||
|
||||
|
||||
};
|
||||
|
||||
} //namespace SE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,86 @@
|
||||
#ifndef SALMON_RENDER_INTERFACE_H_INCLUDED
|
||||
#define SALMON_RENDER_INTERFACE_H_INCLUDED
|
||||
|
||||
#include "include/Utils/Utils.h"
|
||||
|
||||
#include "include/SimpleLand/SimpleLand.h"
|
||||
|
||||
#include "include/Render/RenderMisc.h"
|
||||
|
||||
#include "include/Render/SalmonRender/BackgroundCubemap.h"
|
||||
|
||||
#include "include/Render/RenderInterface.h"
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
class TSalmonRendererInterface : public TRendererInterface
|
||||
{
|
||||
protected:
|
||||
|
||||
float CamAlpha;
|
||||
float CamPhi;
|
||||
float CamDist;
|
||||
vec3 CamShift;
|
||||
vec3 CamPos; //Do not change - call CalcCamPosVec instead
|
||||
vec3 CamVec; //Do not change - call CalcCamPosVec instead
|
||||
|
||||
mat4 CamModelViewMatrix;
|
||||
mat4 CamInversedModelViewMatrix;
|
||||
|
||||
float GlobalShadowAreaHalfSize;
|
||||
|
||||
void CalcCamPosVec();
|
||||
|
||||
virtual void DrawQuad(const T2DQuad& quad) = 0;
|
||||
public:
|
||||
|
||||
TSalmonRendererInterface();
|
||||
|
||||
virtual void InitOpenGL(int screenWidth, int screenHeight, float matrixWidth, float matrixHeight);
|
||||
|
||||
virtual void SetUniforms();
|
||||
|
||||
void SetPerspectiveFullScreenViewport();
|
||||
void SetOrthoFullScreenViewport();
|
||||
|
||||
mat4 GetModelviewMatrix();
|
||||
|
||||
void SetPerspectiveProjectionMatrix(float angle, float aspect, float zNear, float zFar);
|
||||
void PushPerspectiveProjectionMatrix(float angle, float aspect, float zNear, float zFar);
|
||||
|
||||
void SetGLCamView();
|
||||
void SetGlIdentityView();
|
||||
void SetGlPosXView();
|
||||
void SetGlNegXView();
|
||||
void SetGlPosYView();
|
||||
void SetGlNegYView();
|
||||
void SetGlPosZView();
|
||||
void SetGlNegZView();
|
||||
|
||||
|
||||
void MoveAlpha(float dAlpha);
|
||||
void MovePhi(float dPhi);
|
||||
void MoveDist(float dDist);
|
||||
|
||||
void SetAlpha(float alpha);
|
||||
vec3 GetCamPos();
|
||||
|
||||
void MoveForward();
|
||||
void MoveBackward();
|
||||
void MoveLeft();
|
||||
void MoveRight();
|
||||
|
||||
virtual void SwitchToScreen();
|
||||
virtual void SwitchToFrameBuffer(const std::string& frameName);
|
||||
void SwitchToCubemapBuffer(const std::string& frameName,cardinal cubeSide);
|
||||
|
||||
void BeginDrawToDepthBufferGlobal(std::string& globalBufferName);
|
||||
void BeginDrawToDepthBufferLocal(std::string& localBufferName);
|
||||
void EndDrawToDepthBuffer();
|
||||
|
||||
};
|
||||
|
||||
} //namespace SE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef SALMON_RENDER_IOS_H_INCLUDED
|
||||
#define SALMON_RENDER_IOS_H_INCLUDED
|
||||
|
||||
#include "include/Render/SalmonRender/SalmonRenderGLES20.h"
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
class TSalmonRendererIos : public TSalmonRendererGLES20
|
||||
{
|
||||
protected:
|
||||
|
||||
public:
|
||||
|
||||
|
||||
};
|
||||
|
||||
} //namespace SE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,57 @@
|
||||
#pragma once
|
||||
|
||||
/*
|
||||
This code is the heart of engine. Here is the render and resource manager
|
||||
*/
|
||||
|
||||
|
||||
#include "include/Utils/Utils.h"
|
||||
|
||||
#include "include/SimpleLand/SimpleLand.h"
|
||||
|
||||
#include "include/Render/SalmonRender/SalmonRenderInterface.h"
|
||||
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
class TSalmonRenderer : public TSalmonRendererInterface
|
||||
{
|
||||
protected:
|
||||
|
||||
bool IsCameraTransparentToLand; //To make it work you must setup LandToCalcCollision
|
||||
TSimpleLandClass* LandToCalcCollision;
|
||||
|
||||
float FogBeginDistance;
|
||||
float FogEndDistance;
|
||||
vec4 FogColor;
|
||||
|
||||
|
||||
//Other data:
|
||||
|
||||
float ShadowClampValue;
|
||||
|
||||
virtual void DrawQuad(const T2DQuad& quad);
|
||||
|
||||
public:
|
||||
TSalmonRenderer();
|
||||
|
||||
~TSalmonRenderer();
|
||||
|
||||
bool BindOpenGLFunctions();
|
||||
|
||||
void SetLandToCalcCollision(TSimpleLandClass* landToCalcCollision);
|
||||
|
||||
float GetShadowClampValue();
|
||||
void SetShadowClampValue(float shadowClampValue);
|
||||
|
||||
float GetFogBeginDistance();
|
||||
float GetFogEndDistance();
|
||||
vec4 GetFogColor();
|
||||
|
||||
void DrawTriangleList(const TTriangleList& triangleList);
|
||||
|
||||
|
||||
};
|
||||
|
||||
} //namespace SE
|
||||
@@ -0,0 +1,63 @@
|
||||
#ifndef SALMON_ENGINE_ANDROID_H_INCLUDED
|
||||
#define SALMON_ENGINE_ANDROID_H_INCLUDED
|
||||
/*
|
||||
This code combines all headers for Salmon engine into one header file
|
||||
*/
|
||||
|
||||
#include "include/SalmonEngineInterface.h"
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
extern TJavaConsole* Console;
|
||||
extern TSalmonRendererAndroid* Renderer;
|
||||
extern TResourceManager* ResourceManager;
|
||||
|
||||
class TApplication : public TApplicationAncestor
|
||||
{
|
||||
protected:
|
||||
public:
|
||||
int X, Y, Width, Height; //Window position and size
|
||||
|
||||
TApplication() : X(0), Y(0), Width(4), Height(4) { }
|
||||
|
||||
virtual void OuterInit(int screenWidth, int screenHeight, float matrixWidth, float matrixHeight);
|
||||
|
||||
virtual void InnerInit() = 0;
|
||||
//To do on init
|
||||
|
||||
virtual void OuterDeinit();
|
||||
|
||||
virtual void InnerDeinit() = 0;
|
||||
//To do on deinit
|
||||
|
||||
virtual void OuterDraw();
|
||||
|
||||
virtual void InnerDraw() = 0;
|
||||
//What to draw
|
||||
|
||||
virtual void OuterUpdate(cardinal timer);
|
||||
|
||||
virtual void InnerUpdate(cardinal timer) = 0;
|
||||
//To do on update
|
||||
|
||||
virtual void UpdateQuick() { };
|
||||
//To process input - this method is called more frequently than Update()
|
||||
|
||||
virtual void OnMouseMove(TMouseState& mouseState) { }
|
||||
//To do on mouse move (with or without pressed buttons)
|
||||
|
||||
virtual void OnMouseDown(TMouseState& mouseState) { }
|
||||
//To do on mouse up (with or without pressed buttons)
|
||||
|
||||
virtual void OnMouseUp(TMouseState& mouseState) { }
|
||||
//To do on mouse down (with or without pressed buttons)
|
||||
//Be careful - even when user "upped" button, in mouseState this button appears as pressed
|
||||
|
||||
virtual void OnMouseWheel(short int delta) { }
|
||||
//To do on mouse wheel move
|
||||
};
|
||||
|
||||
} //namespace SE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,135 @@
|
||||
#ifndef SALMON_ENGINE_INTERFACE_H_INCLUDED
|
||||
#define SALMON_ENGINE_INTERFACE_H_INCLUDED
|
||||
|
||||
/*
|
||||
This code combines all headers for Salmon engine into one header file
|
||||
*/
|
||||
|
||||
|
||||
#include "include/ApplicationInterface.h"
|
||||
|
||||
#include "include/Render/SalmonRender/SalmonRenderInterface.h"
|
||||
|
||||
#ifdef TARGET_ANDROID
|
||||
#include "include/Render/SalmonRender/SalmonRenderAndroid.h"
|
||||
#endif
|
||||
#ifdef TARGET_WIN32
|
||||
#include "include/Render/SalmonRender/SalmonRenderWindows.h"
|
||||
#endif
|
||||
#ifdef TARGET_IOS
|
||||
#include "include/Render/SalmonRender/SalmonRenderIos.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include "include/Render/RenderMisc.h"
|
||||
|
||||
#include "include/Animation/SalmonAnimation.h"
|
||||
#include "include/TextureManager/SalmonTexture.h"
|
||||
#include "include/ShaderManager/ShaderManager.h"
|
||||
#include "include/FrameManager/FrameManager.h"
|
||||
#include "include/LightManager/LightManager.h"
|
||||
#include "include/ScriptManager/ScriptManager.h"
|
||||
#ifdef TARGET_ANDROID
|
||||
#include "include/SoundManager/SoundManagerAndroid.h"
|
||||
#endif
|
||||
#ifdef TARGET_WIN32
|
||||
#include "include/SoundManager/SoundManagerWindows.h"
|
||||
#endif
|
||||
#ifdef TARGET_IOS
|
||||
#include "include/SoundManager/SoundManagerIos.h"
|
||||
#endif
|
||||
#include "include/FontManager/FontManager.h"
|
||||
#include "include/SimpleLand/SimpleLand.h"
|
||||
#include "include/SmartValueManager/SmartValueManager.h"
|
||||
|
||||
#include "include/ModelManager/NewModelManager.h"
|
||||
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
class TResourceManager
|
||||
{
|
||||
protected:
|
||||
public:
|
||||
std::string PathToResources;
|
||||
|
||||
TTextureListClass TexList;
|
||||
TModelManager ModelManager;
|
||||
TFlexModelManager FlexModelManager;
|
||||
TShaderManager ShaderManager;
|
||||
TFrameManager FrameManager;
|
||||
TLightManager LightManager;
|
||||
TModelAnimManager ModelAnimManager;
|
||||
TScriptManager ScriptManager;
|
||||
TFontManager FontManager;
|
||||
TSmartValueManager SmartValueManager;
|
||||
|
||||
#ifdef TARGET_ANDROID
|
||||
TSoundManagerAndroid SoundManager;
|
||||
#endif
|
||||
#ifdef TARGET_WIN32
|
||||
TSoundManagerWindows SoundManager;
|
||||
#endif
|
||||
#ifdef TARGET_IOS
|
||||
TSoundManagerIos SoundManager;
|
||||
#endif
|
||||
|
||||
~TResourceManager() { }
|
||||
};
|
||||
|
||||
|
||||
struct TMouseState
|
||||
{
|
||||
int X;
|
||||
int Y;
|
||||
bool LeftButtonPressed;
|
||||
bool MiddleButtonPressed;
|
||||
bool RightButtonPressed;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class TApplicationAncestor : public TApplicationInterface
|
||||
{
|
||||
protected:
|
||||
|
||||
public:
|
||||
|
||||
TApplicationAncestor();
|
||||
|
||||
|
||||
virtual void OuterDeinit();
|
||||
//To do on deinit
|
||||
|
||||
virtual void OuterDraw();
|
||||
//What to draw
|
||||
|
||||
virtual void OuterUpdate(cardinal timer);
|
||||
//To do on update
|
||||
|
||||
virtual void UpdateQuick() { }
|
||||
//To process input - this method is called more frequently than Update()
|
||||
|
||||
virtual void OuterOnMove(vec2 shift);
|
||||
virtual void InnerOnMove(vec2 shift) { }
|
||||
//To do on mouse move (with or without pressed buttons)
|
||||
|
||||
virtual void OnMouseDown(TMouseState& mouseState) { }
|
||||
//To do on mouse up (with or without pressed buttons)
|
||||
|
||||
virtual void OnMouseUp(TMouseState& mouseState) { }
|
||||
//To do on mouse down (with or without pressed buttons)
|
||||
//Be careful - even when user "upped" button, in mouseState this button appears as pressed
|
||||
|
||||
virtual void OnMouseWheel(short int delta) { }
|
||||
//To do on mouse wheel move
|
||||
|
||||
virtual void OnKeyPress(cardinal key) { } //Try not to override this. But if you need to override, call ancestor!
|
||||
};
|
||||
|
||||
|
||||
} //namespace SE
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
#ifndef SALMON_ENGINE_ANDROID_H_INCLUDED
|
||||
#define SALMON_ENGINE_ANDROID_H_INCLUDED
|
||||
/*
|
||||
This code combines all headers for Salmon engine into one header file
|
||||
*/
|
||||
|
||||
#include "include/SalmonEngineInterface.h"
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
extern TIosConsole* Console;
|
||||
extern TSalmonRendererIos* Renderer;
|
||||
extern TResourceManager* ResourceManager;
|
||||
|
||||
class TApplication : public TApplicationAncestor
|
||||
{
|
||||
protected:
|
||||
public:
|
||||
int X, Y, Width, Height; //Window position and size
|
||||
|
||||
TApplication() : X(0), Y(0), Width(4), Height(4) { }
|
||||
|
||||
virtual void OuterInit(int screenWidth, int screenHeight, float matrixWidth, float matrixHeight);
|
||||
|
||||
virtual void InnerInit() = 0;
|
||||
//To do on init
|
||||
|
||||
virtual void OuterDeinit();
|
||||
|
||||
virtual void InnerDeinit() = 0;
|
||||
//To do on deinit
|
||||
|
||||
virtual void OuterDraw();
|
||||
|
||||
virtual void InnerDraw() = 0;
|
||||
//What to draw
|
||||
|
||||
virtual void OuterUpdate(cardinal timer);
|
||||
|
||||
virtual void InnerUpdate(cardinal timer) = 0;
|
||||
//To do on update
|
||||
|
||||
virtual void UpdateQuick() { };
|
||||
//To process input - this method is called more frequently than Update()
|
||||
|
||||
virtual void OnMouseMove(TMouseState& mouseState) { }
|
||||
//To do on mouse move (with or without pressed buttons)
|
||||
|
||||
virtual void OnMouseDown(TMouseState& mouseState) { }
|
||||
//To do on mouse up (with or without pressed buttons)
|
||||
|
||||
virtual void OnMouseUp(TMouseState& mouseState) { }
|
||||
//To do on mouse down (with or without pressed buttons)
|
||||
//Be careful - even when user "upped" button, in mouseState this button appears as pressed
|
||||
|
||||
virtual void OnMouseWheel(short int delta) { }
|
||||
//To do on mouse wheel move
|
||||
};
|
||||
|
||||
} //namespace SE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,72 @@
|
||||
#pragma once
|
||||
|
||||
/*
|
||||
This code combines all headers for Salmon engine into one header file
|
||||
*/
|
||||
|
||||
#include "include/SalmonEngineInterface.h"
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
//==============================================================
|
||||
//========= GLOBAL VARIABLES - REMEMBER THIS LIST!!! ===========
|
||||
//==============================================================
|
||||
|
||||
extern TFileConsole* Console;
|
||||
extern TSalmonRenderer* Renderer;
|
||||
extern TResourceManager* ResourceManager;
|
||||
|
||||
|
||||
extern HGLRC hRC; //Render context
|
||||
extern HWND Hwnd; //Main window handle
|
||||
extern HDC hDC; //Device context
|
||||
|
||||
|
||||
class TApplication : public TApplicationAncestor
|
||||
{
|
||||
protected:
|
||||
std::string LogFilename; //Log file name
|
||||
public:
|
||||
int X, Y, Width, Height; //Window position and size
|
||||
|
||||
std::string WindowName; //Window name
|
||||
|
||||
TApplication() : X(0), Y(0), Width(800), Height(600), WindowName("Salmon Engine"), LogFilename("log.txt") { }
|
||||
|
||||
const std::string& GetLogFilename() { return LogFilename; }
|
||||
|
||||
virtual void InnerInit() = 0;
|
||||
//To do on init
|
||||
|
||||
virtual void InnerDeinit() = 0;
|
||||
//To do on deinit
|
||||
|
||||
virtual void InnerDraw() = 0;
|
||||
//What to draw
|
||||
|
||||
virtual void InnerUpdate(cardinal timer) = 0;
|
||||
//To do on update
|
||||
|
||||
virtual void UpdateQuick() { };
|
||||
//To process input - this method is called more frequently than Update()
|
||||
|
||||
virtual void OnMouseMove(TMouseState& mouseState) { }
|
||||
//To do on mouse move (with or without pressed buttons)
|
||||
|
||||
virtual void OnMouseDown(TMouseState& mouseState) { }
|
||||
//To do on mouse up (with or without pressed buttons)
|
||||
|
||||
virtual void OnMouseUp(TMouseState& mouseState) { }
|
||||
//To do on mouse down (with or without pressed buttons)
|
||||
//Be careful - even when user "upped" button, in mouseState this button appears as pressed
|
||||
|
||||
virtual void OnMouseWheel(short int delta) { }
|
||||
//To do on mouse wheel move
|
||||
|
||||
virtual void OnKeyPress(cardinal key); //Try not to override this. But if you need to override, call ancestor!
|
||||
};
|
||||
|
||||
int MainLoop(TApplication& application);
|
||||
|
||||
} //namespace SE
|
||||
@@ -0,0 +1,117 @@
|
||||
#ifndef SCRIPT_MANAGER_H_INCLUDED
|
||||
#define SCRIPT_MANAGER_H_INCLUDED
|
||||
|
||||
#include "sqplus.h"
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
struct TScriptInfo
|
||||
{
|
||||
std::string LongName;
|
||||
std::string ShortDescription;
|
||||
std::string Description;
|
||||
bool Registered;
|
||||
|
||||
TScriptInfo()
|
||||
: Registered(false)
|
||||
{
|
||||
}
|
||||
|
||||
TScriptInfo(const std::string& longName, const std::string& shortDescription = "", const std::string& description = "")
|
||||
: LongName(longName)
|
||||
, ShortDescription(shortDescription)
|
||||
, Description(description)
|
||||
, Registered(false)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class TFunctionBinderInterface
|
||||
{
|
||||
public:
|
||||
static std::vector<TFunctionBinderInterface*> BinderList;
|
||||
|
||||
TFunctionBinderInterface()
|
||||
{
|
||||
BinderList.push_back(this);
|
||||
}
|
||||
|
||||
virtual void BindFunctions() = 0;
|
||||
};
|
||||
|
||||
|
||||
class TScriptManager : public TSerializeInterface
|
||||
{
|
||||
protected:
|
||||
HSQUIRRELVM virtualMachine;
|
||||
std::map<std::string, TScriptInfo> FuncInfoMap;
|
||||
|
||||
template<typename T1,typename T2>
|
||||
void RegisterFunc(T1& object, T2 method, const std::string& funcName)
|
||||
{
|
||||
SqPlus::RegisterGlobal(virtualMachine, object, method, _SC(funcName.c_str()));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void RegisterFunc(T globalFunc, const std::string& funcName)
|
||||
{
|
||||
SqPlus::RegisterGlobal(virtualMachine, globalFunc, _SC(funcName.c_str()));
|
||||
}
|
||||
|
||||
public:
|
||||
TScriptManager();
|
||||
~TScriptManager();
|
||||
|
||||
void AddFuncDescription(const std::string& shortName, TScriptInfo scriptInfo);
|
||||
|
||||
void RunScript(const std::string& scriptCode);
|
||||
|
||||
void BindBasicFunctions();
|
||||
|
||||
template<typename T1, typename T2>
|
||||
void AddFunction(const std::string& shortName, TScriptInfo scriptInfo, T1& object, T2 method)
|
||||
{
|
||||
AddFuncDescription(shortName, scriptInfo);
|
||||
RegisterFunc(object, method, shortName);
|
||||
RegisterFunc(object, method, scriptInfo.LongName);
|
||||
FuncInfoMap[shortName].Registered = true;
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
void AddFunction(const std::string& shortName, TScriptInfo scriptInfo, T globalFunc)
|
||||
{
|
||||
AddFuncDescription(shortName, scriptInfo);
|
||||
RegisterFunc(globalFunc, shortName);
|
||||
RegisterFunc(globalFunc, scriptInfo.LongName);
|
||||
FuncInfoMap[shortName].Registered = true;
|
||||
}
|
||||
|
||||
void BindFunctionsFromObject(TFunctionBinderInterface* binderObject);
|
||||
|
||||
void PrintRegisteredFunctionList();
|
||||
|
||||
void PrintFunctionInfo(const std::string& funcName);
|
||||
|
||||
virtual void Serialize(boost::property_tree::ptree& propertyTree);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
void SQ_Print(const SQChar *inString);
|
||||
void SQ_PrintWidgetList();
|
||||
void SQ_MoveWidget(const SQChar *widgetName, float x, float y);
|
||||
//void SQ_PrintTextureList();
|
||||
//void SQ_PrintAnimationList();
|
||||
|
||||
//void SQ_MoveWidgetTransformTaskTest(const SQChar *groupName, float x, float y, cardinal totalTime);
|
||||
|
||||
|
||||
} //namespace SE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,160 @@
|
||||
#ifndef SHADER_MANAGER_H_INCLUDED
|
||||
#define SHADER_MANAGER_H_INCLUDED
|
||||
|
||||
/*
|
||||
This code contains shader manager
|
||||
*/
|
||||
|
||||
#include <stack>
|
||||
|
||||
#ifdef TARGET_WIN32
|
||||
#include "../OpenGlExt/OpenGlExt.h"
|
||||
#endif
|
||||
|
||||
#include "include/Utils/Utils.h"
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
//==============================================
|
||||
//=============== CONST AREA ===================
|
||||
//==============================================
|
||||
|
||||
|
||||
//Global uniforms (must remain same from shader to shader)
|
||||
//If you add a new one - put it to SetCurrentShader() too
|
||||
const std::string CONST_STRING_TEXTURE_UNIFORM = "Texture";
|
||||
const std::string CONST_STRING_NORMALMAP_UNIFORM = "NormalMap";
|
||||
const std::string CONST_STRING_SHADOWMAPGLOBAL_UNIFORM = "ShadowMapGlobal";
|
||||
const std::string CONST_STRING_SHADOWMAPLOCAL_UNIFORM = "ShadowMapLocal";
|
||||
const std::string CONST_STRING_ENV_UNIFORM = "Env";
|
||||
const std::string CONST_STRING_NORMALMAPEXISTS_UNIFORM = "NormalMapExists";
|
||||
|
||||
const std::string CONST_STRING_LIGHT_POS_UNIFORM = "LightPos";
|
||||
const std::string CONST_STRING_LIGHT_DIRECTION_UNIFORM = "LightDirection";
|
||||
const std::string CONST_STRING_LIGHT_COLOR_UNIFORM = "LightColor";
|
||||
|
||||
const std::string CONST_STRING_CAMPOS_UNIFORM = "CamPos";
|
||||
const std::string CONST_STRING_SHADOWCLAMPVALUE_UNIFORM = "ShadowClampValue";
|
||||
|
||||
const std::string CONST_STRING_FOG_BEGIN_DISTANCE_UNIFORM = "FogBeginDistance";
|
||||
const std::string CONST_STRING_FOG_END_DISTANCE_UNIFORM = "FogEndDistance";
|
||||
const std::string CONST_STRING_FOG_COLOR_UNIFORM = "FogColor";
|
||||
|
||||
const std::string CONST_STRING_MATERIAL_COLOR_UNIFORM = "MaterialColor";
|
||||
const std::string CONST_STRING_TRANSPARENCY_UNIFORM = "Transparency";
|
||||
|
||||
//For Halibut Render
|
||||
const std::string CONST_STRING_HALIBUT_PROJECTION_MATRIX_UNIFORM = "ProjectionMatrix";
|
||||
|
||||
//Local uniforms (need to be setup before each draw)
|
||||
const std::string CONST_STRING_MODELROTATEMATRIX_UNIFORM = "ModelRotateMatrix";
|
||||
const std::string CONST_STRING_MODELTRANSLATEVECTOR_UNIFORM = "ModelTranslateVector";
|
||||
|
||||
|
||||
//Attributes
|
||||
const std::string CONST_STRING_POSITION_ATTRIB = "vPosition";
|
||||
const std::string CONST_STRING_TEXCOORD_ATTRIB = "vTexCoord";
|
||||
|
||||
const std::string CONST_STRING_NORMAL_ATTRIB = "Normal";
|
||||
const std::string CONST_STRING_TANGENT_ATTRIB = "Tangent";
|
||||
const std::string CONST_STRING_BINORMAL_ATTRIB = "Binormal";
|
||||
|
||||
//======================================
|
||||
|
||||
class TShaderManager; //see below
|
||||
|
||||
|
||||
|
||||
class TShaderResource
|
||||
{
|
||||
protected:
|
||||
cardinal ShaderProgram;
|
||||
|
||||
std::map<std::string,cardinal,std::less<std::string> > UniformList;
|
||||
std::map<std::string,cardinal,std::less<std::string> > AttribList;
|
||||
|
||||
public:
|
||||
TShaderResource();
|
||||
~TShaderResource();
|
||||
|
||||
bool CompileShader(boost::shared_array<char> vertexCode, boost::shared_array<char> fragmentCode);
|
||||
void FreeShader();
|
||||
|
||||
int GetAttribIndex(const std::string& attribName);
|
||||
int GetUniformIndex(const std::string& uniformName);
|
||||
|
||||
friend void RenderUniform1f(const std::string& uniformName, const float value);
|
||||
friend void RenderUniform3fv(const std::string& uniformName, const float* value);
|
||||
friend void RenderUniform4fv(const std::string& uniformName, const float* value);
|
||||
friend void RenderUniformMatrix3fv(const std::string& uniformName, bool transpose, const float* value);
|
||||
friend void RenderUniformMatrix4fv(const std::string& uniformName, bool transpose, const float* value);
|
||||
friend void RenderUniform1i(const std::string& uniformName, const int value);
|
||||
|
||||
friend void VertexAttrib2fv(const std::string& attribName, const float* value);
|
||||
friend void VertexAttrib3fv(const std::string& attribName, const float* value);
|
||||
friend void VertexAttribPointer2fv(const std::string& attribName,int stride, const char* pointer);
|
||||
friend void VertexAttribPointer3fv(const std::string& attribName,int stride, const char* pointer);
|
||||
|
||||
friend void EnableVertexAttribArray(const std::string& attribName);
|
||||
friend void DisableVertexAttribArray(const std::string& attribName);
|
||||
|
||||
|
||||
#ifdef TARGET_WIN32
|
||||
friend void RefreshAttribBuffer2fv(const std::string& attribName, std::map<std::string, std::vector<vec2> >& vec2CoordArr);
|
||||
friend void RefreshAttribBuffer3fv(const std::string& attribName, std::map<std::string, std::vector<vec3> >& vec3CoordArr);
|
||||
#endif
|
||||
|
||||
friend class TShaderManager;
|
||||
|
||||
};
|
||||
|
||||
class TShaderManager : public TSerializeInterface
|
||||
{
|
||||
protected:
|
||||
std::map<std::string, std::shared_ptr<TShaderResource>, std::less<std::string> > ShaderList;
|
||||
|
||||
std::stack<std::string> ShaderNameStack;
|
||||
|
||||
//To be called only by SalmonRander/HalibutRender!!!
|
||||
void PushShader(const std::string& shaderName);
|
||||
void PopShader();
|
||||
public:
|
||||
TShaderManager() {}
|
||||
~TShaderManager();
|
||||
std::shared_ptr<TShaderResource> GetCurrentShader();
|
||||
|
||||
virtual void Serialize(boost::property_tree::ptree& propertyTree);
|
||||
|
||||
bool AddShader(const std::string& shaderName, const std::string& vertexFileName, const std::string& fragmentFileName);
|
||||
|
||||
void Clear();
|
||||
|
||||
friend class TRendererInterface;
|
||||
|
||||
};
|
||||
|
||||
//Dont forget to make them friend to TShaderResource
|
||||
void RenderUniform1f(const std::string& uniformName, const float value);
|
||||
void RenderUniform3fv(const std::string& uniformName, const float* value);
|
||||
void RenderUniform4fv(const std::string& uniformName, const float* value);
|
||||
void RenderUniformMatrix3fv(const std::string& uniformName, bool transpose, const float* value);
|
||||
void RenderUniformMatrix4fv(const std::string& uniformName, bool transpose, const float* value);
|
||||
void RenderUniform1i(const std::string& uniformName, const int value);
|
||||
|
||||
void VertexAttrib2fv(const std::string& attribName, const float* value);
|
||||
void VertexAttrib3fv(const std::string& attribName, const float* value);
|
||||
void VertexAttribPointer2fv(const std::string& attribName, int stride, const char* pointer);
|
||||
void VertexAttribPointer3fv(const std::string& attribName, int stride, const char* pointer);
|
||||
|
||||
void EnableVertexAttribArray(const std::string& attribName);
|
||||
void DisableVertexAttribArray(const std::string& attribName);
|
||||
|
||||
#ifdef TARGET_WIN32
|
||||
void RefreshAttribBuffer2fv(const std::string& attribName, std::map<std::string, std::vector<vec2> >& vec2CoordArr);
|
||||
void RefreshAttribBuffer3fv(const std::string& attribName, std::map<std::string, std::vector<vec3> >& vec3CoordArr);
|
||||
#endif
|
||||
|
||||
} //namespace SE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,142 @@
|
||||
#ifndef SIMPLE_LAND_H_INCLUDED
|
||||
#define SIMPLE_LAND_H_INCLUDED
|
||||
|
||||
#include "include/Utils/Utils.h"
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
const int CONST_DEFAULT_LAND_WIDTH = 16;
|
||||
const int CONST_DEFAULT_LAND_HEIGHT = 16;
|
||||
const float CONST_DEFAULT_LAND_CELL_INVERVAL = 2.0f;
|
||||
|
||||
const float CONST_LAND_MOVE_STEP = 0.3f;
|
||||
|
||||
|
||||
//Struct for one land vertex
|
||||
struct TSimpleLandVertex
|
||||
{
|
||||
vec3 pos; //Vertex position (x,y,z)
|
||||
vec3 norm; //Vertex normal vector
|
||||
vec3 tangent; //Vertex tangent vector
|
||||
vec3 binorm; //Vertex binormal vector
|
||||
int landtype; //Vertex type - not in use right now
|
||||
};
|
||||
|
||||
struct TVBOLandVertex
|
||||
{
|
||||
std::vector<vec3> pos; //Vertex position (x,y,z)
|
||||
std::vector<vec3> norm; //Vertex normal vector
|
||||
std::vector<vec3> tangent; //Vertex tangent vector
|
||||
std::vector<vec3> binorm; //Vertex binormal vector
|
||||
std::vector<vec2> texCoord; //Vertex texture coords
|
||||
};
|
||||
|
||||
//Land triangle
|
||||
struct TLandSimpleTriangle
|
||||
{
|
||||
vec3 PointList[3]; //3 vertices
|
||||
vec3 NormVec; //Normal vector (not for draw, but for physics/collision)
|
||||
};
|
||||
|
||||
//Land class
|
||||
class TSimpleLandClass
|
||||
{
|
||||
private:
|
||||
|
||||
int Width; //Number of vertices along X
|
||||
int Height; //Number of vertices along -Z
|
||||
float CellInterval; //Distance between vertices
|
||||
|
||||
std::vector<TSimpleLandVertex> VertexMatrix;
|
||||
std::vector<TLandSimpleTriangle> TriangleMatrix;
|
||||
|
||||
//Textures:
|
||||
cardinal TexID;
|
||||
cardinal NormTexID;
|
||||
|
||||
//For VBO:
|
||||
std::vector<word> IndexArr;
|
||||
TVBOLandVertex VBOLandVertexArr;
|
||||
|
||||
cardinal IndexBuffer;
|
||||
cardinal VertexBuffer;
|
||||
cardinal NormBuffer;
|
||||
cardinal TangentBuffer;
|
||||
cardinal BinormBuffer;
|
||||
cardinal TexcoordBuffer;
|
||||
|
||||
void CreateVBO();
|
||||
void FreeVBO();
|
||||
|
||||
void UpdateVBO();
|
||||
void UpdateTriangleMatrix();
|
||||
|
||||
|
||||
vec3 CalcCrossingForPoint(const vec3& lineFrom, const vec3& lineTo, int i, int j);
|
||||
vec3 CalcCrossingForPoint(const vec3& pos, int i, int j);
|
||||
public:
|
||||
|
||||
TSimpleLandClass();
|
||||
|
||||
~TSimpleLandClass();
|
||||
|
||||
bool LoadFromFile(const std::string& filename);
|
||||
//Load land struct from ls1 file
|
||||
|
||||
void SaveToFile(char* filename); //Xperimental. Not in use right now
|
||||
|
||||
void SetTexture(const std::string& texFilename);
|
||||
//Set land texture name
|
||||
|
||||
void SetNormTexture(const std::string& normTexFilename);
|
||||
//Set land texture name
|
||||
|
||||
void DrawImmediate(); //Very sloooow. Need to speed up!
|
||||
//Draw land immediate
|
||||
|
||||
void DrawVBO();
|
||||
|
||||
vec3 CalcCrossing(vec3 LineFrom, vec3 LineTo);
|
||||
//Calculate intersection (segment LiteFrom -> LineTo and the land)
|
||||
|
||||
vec3 CalcVerticalCrossing(const vec3& pos);
|
||||
//Calculate land height on (pos.x, pos.y)
|
||||
|
||||
float CalcVerticalCrossingFast(const vec3& pos);
|
||||
//Calculate approximate land height on (pos.x, pos.y)
|
||||
|
||||
bool IsOnTheLand(const vec3& pos);
|
||||
|
||||
void RecalcNormalVectors();
|
||||
//Recalc normal vectors - must be called after land is modified
|
||||
|
||||
void MoveLandUp(vec3 CursorPos, float R);//NIU
|
||||
//Move land up under cursor
|
||||
|
||||
void MoveLandDown(vec3 CursorPos, float R);//NIU
|
||||
//Move land down under cursor
|
||||
|
||||
void SmoothLand(vec3 CursorPos, float R);//NIU
|
||||
//Smooth land up under cursor
|
||||
|
||||
void TextureLand(vec3 CursorPos, float R, int ltype);//NIU
|
||||
//Set land type under cursor
|
||||
|
||||
void Scale(float s);
|
||||
|
||||
void Scale(vec3 s);
|
||||
|
||||
void Move(const vec3& v);
|
||||
|
||||
int GetWidth();
|
||||
|
||||
int GetHeight();
|
||||
|
||||
float* GetTriangleMatrix();
|
||||
//Use it for physics only!
|
||||
};
|
||||
|
||||
} //namespace SE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,56 @@
|
||||
#ifndef SMART_VALUE_MANAGER_H_INCLUDED
|
||||
#define SMART_VALUE_MANAGER_H_INCLUDED
|
||||
|
||||
#include "include/Utils/Utils.h"
|
||||
|
||||
#pragma warning(disable: 4503) //ololo, DisctionariesMap expands into looong boolshit
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
typedef boost::variant<
|
||||
std::shared_ptr<TBindableVar<int>>,
|
||||
std::shared_ptr<TBindableVar<float>>,
|
||||
std::shared_ptr<TBindableVar<bool>>,
|
||||
std::shared_ptr<TBindableVar<std::string>>,
|
||||
std::shared_ptr<TBindableVar<vec2>>,
|
||||
std::shared_ptr<TBindableVar<vec3>>,
|
||||
std::shared_ptr<TBindableVar<vec4>>> TSmartValue;
|
||||
|
||||
|
||||
class TSmartValueManager : public TSerializeInterface
|
||||
{
|
||||
protected:
|
||||
|
||||
std::map<std::string, std::map<std::string, TSmartValue>> DisctionariesMap;
|
||||
|
||||
public:
|
||||
|
||||
TSmartValue& GetSmartValue(const std::string& dictName, const std::string& valueName);
|
||||
|
||||
template<typename TYPENAME>
|
||||
TYPENAME GetImmediateValue(const std::string& dictName, const std::string& valueName)
|
||||
{
|
||||
return (*boost::get<std::shared_ptr<TBindableVar<TYPENAME>>>(GetSmartValue(dictName, valueName)))();
|
||||
}
|
||||
|
||||
template<typename TYPENAME>
|
||||
void SetImmediateValue(const std::string& dictName, const std::string& valueName, TYPENAME value)
|
||||
{
|
||||
*boost::get<std::shared_ptr<TBindableVar<TYPENAME>>>(GetSmartValue(dictName, valueName)) = value;
|
||||
}
|
||||
|
||||
template<typename TYPENAME>
|
||||
boost::signal<void(const TYPENAME&)>& GetSignal(const std::string& dictName, const std::string& valueName)
|
||||
{
|
||||
return boost::get<std::shared_ptr<TBindableVar<TYPENAME>>>(GetSmartValue(dictName, valueName))->OnVarChanged;
|
||||
}
|
||||
|
||||
virtual void Serialize(boost::property_tree::ptree& propertyTree);
|
||||
|
||||
};
|
||||
|
||||
|
||||
} //namespace SE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,33 @@
|
||||
#ifndef SOUND_MANAGER_ANDROID_INCLUDED
|
||||
#define SOUND_MANAGER_ANDROID_INCLUDED
|
||||
|
||||
#include "include/Utils/DataTypes/DataTypes.h"
|
||||
#include "include/SoundManager/SoundManagerInterface.h"
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
class TSoundManagerAndroid : public TSoundManagerInterface
|
||||
{
|
||||
public:
|
||||
TSoundManagerAndroid();
|
||||
~TSoundManagerAndroid();
|
||||
|
||||
|
||||
virtual void LoadSound(const std::string& soundFileName);
|
||||
virtual void PlaySound(const std::string& soundName);
|
||||
|
||||
virtual void LoadMusic(const std::string& musicFileName);
|
||||
virtual void PlayMusic(const std::string& musicName);
|
||||
virtual void PlayMusicLooped(const std::string& musicName);
|
||||
virtual void StopMusic(const std::string& musicName);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
} //namespace SE
|
||||
@@ -0,0 +1,105 @@
|
||||
#ifndef SOUND_MANAGER_DATA_TYPES_H_INCLUDED
|
||||
#define SOUND_MANAGER_DATA_TYPES_H_INCLUDED
|
||||
|
||||
#ifndef NOSOUND
|
||||
|
||||
|
||||
#ifdef TARGET_ANDROID
|
||||
#include <asm/page.h>
|
||||
#include <limits.h>
|
||||
#endif
|
||||
|
||||
#include "boost/thread.hpp"
|
||||
#include "boost/smart_ptr.hpp"
|
||||
#include "boost/bind.hpp"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <queue>
|
||||
|
||||
|
||||
#include "vorbis/codec.h"
|
||||
#include "vorbis/vorbisfile.h"
|
||||
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
typedef boost::shared_array<char> TByteArrPtr;
|
||||
|
||||
|
||||
|
||||
struct TBasicWAVEHeader
|
||||
{
|
||||
char Riff[4];//'RIFF'
|
||||
unsigned int RiffSize;
|
||||
char Wave[4];//'WAVE'
|
||||
char Fmt[4];//'fmt '
|
||||
unsigned int FmtSize;
|
||||
unsigned short Format;
|
||||
unsigned short Channels;
|
||||
unsigned int SamplesPerSec;
|
||||
unsigned int BytesPerSec;
|
||||
unsigned short BlockAlign;
|
||||
unsigned short BitsPerSample;
|
||||
char Data[4];//'data'
|
||||
unsigned int DataSize;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
struct TOggCallbackFileBuffer
|
||||
{
|
||||
size_t FileSize;
|
||||
size_t FilePos;
|
||||
TByteArrPtr FileData;
|
||||
|
||||
TOggCallbackFileBuffer(const TByteArrPtr& fileData, size_t fileSize)
|
||||
: FileData(fileData)
|
||||
, FileSize(fileSize)
|
||||
, FilePos(0)
|
||||
{
|
||||
}
|
||||
|
||||
TOggCallbackFileBuffer()
|
||||
: FileData(NULL) //dummy
|
||||
, FileSize(0)
|
||||
, FilePos(0)
|
||||
{
|
||||
}
|
||||
|
||||
TOggCallbackFileBuffer(const TOggCallbackFileBuffer& copyFrom)
|
||||
{
|
||||
FileSize = copyFrom.FileSize;
|
||||
FilePos = copyFrom.FilePos;
|
||||
FileData = copyFrom.FileData;
|
||||
}
|
||||
|
||||
TOggCallbackFileBuffer& operator=(const TOggCallbackFileBuffer& copyFrom)
|
||||
{
|
||||
if (©From == this)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
FileSize = copyFrom.FileSize;
|
||||
FilePos = copyFrom.FilePos;
|
||||
FileData = copyFrom.FileData;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
extern ov_callbacks OggCallbacks;
|
||||
|
||||
} //namespace SE
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,34 @@
|
||||
#ifndef SOUND_MANAGER_INTERFACE_H_INCLUDED
|
||||
#define SOUND_MANAGER_INTERFACE_H_INCLUDED
|
||||
#include "include/Utils/DataTypes/DataTypes.h"
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
class TSoundManagerInterface
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void LoadSound(const std::string& soundFileName) = 0;
|
||||
virtual void PlaySound(const std::string& soundName) = 0;
|
||||
|
||||
virtual void LoadMusic(const std::string& musicFileName) = 0;
|
||||
virtual void PlayMusic(const std::string& musicName) = 0;
|
||||
virtual void PlayMusicLooped(const std::string& musicName) = 0;
|
||||
virtual void StopMusic(const std::string& musicName) = 0;
|
||||
|
||||
virtual void StopAllMusic() { }
|
||||
|
||||
virtual void TryStopAndPlayMusicLooped(const std::string& musicName) { }
|
||||
|
||||
virtual void Update(cardinal dt) { };
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
};
|
||||
|
||||
} //namespace SE
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// SoundManagerIos.h
|
||||
// Halibut Engine
|
||||
//
|
||||
// Created by vvv ооо on 21.07.12.
|
||||
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef SOUND_MANAGER_IOS_H_INCLUDED
|
||||
#define SOUND_MANAGER_IOS_H_INCLUDED
|
||||
|
||||
#include "include/SoundManager/SoundManagerInterface.h"
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
class TSoundManagerIos : public TSoundManagerInterface
|
||||
{
|
||||
public:
|
||||
|
||||
TSoundManagerIos();
|
||||
~TSoundManagerIos();
|
||||
|
||||
virtual void LoadSound(const std::string& soundFileName);
|
||||
virtual void PlaySound(const std::string& soundName);
|
||||
|
||||
void LoadMusicLooped(const std::string& musicFileName);
|
||||
virtual void LoadMusic(const std::string& musicFileName);
|
||||
virtual void PlayMusic(const std::string& musicName);
|
||||
virtual void PlayMusicLooped(const std::string& musicName);
|
||||
virtual void StopMusic(const std::string& musicName);
|
||||
|
||||
};
|
||||
|
||||
|
||||
} //namespace SE
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,248 @@
|
||||
#ifndef SOUND_MANAGER_WINDOWS_H_INCLUDED
|
||||
#define SOUND_MANAGER_WINDOWS_H_INCLUDED
|
||||
|
||||
#include "include/SoundManager/SoundManagerDataTypes.h"
|
||||
#include "include/SoundManager/SoundManagerInterface.h"
|
||||
#include "include/Utils/Utils.h"
|
||||
|
||||
|
||||
#ifndef NOSOUND
|
||||
#include "audiodefs.h"
|
||||
#include "dsound.h"
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
|
||||
const cardinal CONST_DIRECTSOUND_BUFFER_SIZE = 4096*16;
|
||||
|
||||
const cardinal CONST_BPS = 2;
|
||||
|
||||
struct TDirectSoundStruct
|
||||
{
|
||||
IDirectSoundBuffer8* soundBuffer;
|
||||
|
||||
TDirectSoundStruct() : soundBuffer(NULL) { }
|
||||
|
||||
~TDirectSoundStruct()
|
||||
{
|
||||
if (soundBuffer != NULL)
|
||||
{
|
||||
soundBuffer->Release();
|
||||
soundBuffer = NULL;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct TWaveFile
|
||||
{
|
||||
TBasicWAVEHeader WaveHeader;
|
||||
TByteArrPtr WaveData;
|
||||
cardinal WaveDataCursor;
|
||||
};
|
||||
|
||||
|
||||
TWaveFile OggSoundFromFile(const std::string& fileName);
|
||||
TWaveFile LoadWaveFile(const std::string& fileName);
|
||||
|
||||
DSBUFFERDESC FillPrimaryWaveBufferDescription();
|
||||
|
||||
WAVEFORMATEX FillPrimaryWaveFormat(cardinal samplesPerSec);
|
||||
|
||||
DSBUFFERDESC FillSecondaryWaveBufferDescription(cardinal bufferSize, WAVEFORMATEX* pWaveFormat);
|
||||
|
||||
WAVEFORMATEX FillSecondaryWaveFormat(cardinal bufferSize);
|
||||
|
||||
|
||||
class TMusicDataAccessInterface
|
||||
{
|
||||
public:
|
||||
|
||||
TMusicDataAccessInterface() : goneOverEnd(false) { }
|
||||
|
||||
protected:
|
||||
|
||||
bool goneOverEnd;
|
||||
|
||||
void ResetDataCursor();
|
||||
|
||||
virtual int InnerReadDataToBuffer(char* buffer, int size, int& bytesRead) = 0;
|
||||
|
||||
virtual void InnerResetDataCursor() = 0;
|
||||
|
||||
virtual void LoadSoundData(const std::string& fileName) = 0;
|
||||
|
||||
virtual void ClearSoundData() = 0;
|
||||
|
||||
virtual bool CheckIfSoundIsOver() = 0;
|
||||
|
||||
virtual cardinal GetSamplesPerSec() = 0;
|
||||
|
||||
void ReadDataToBuffer_Looped(char* buffer, int size);
|
||||
|
||||
int ReadDataToBuffer(char* buffer, int size);
|
||||
|
||||
};
|
||||
|
||||
|
||||
class TMusicStreamAncestor : public TMusicDataAccessInterface
|
||||
{
|
||||
public:
|
||||
|
||||
TMusicStreamAncestor();
|
||||
~TMusicStreamAncestor();
|
||||
|
||||
void Load(const std::string& musicFileName);
|
||||
void Clear();
|
||||
|
||||
void Update();
|
||||
|
||||
void Play();
|
||||
void PlayLooped();
|
||||
|
||||
void Stop();
|
||||
|
||||
protected:
|
||||
void InnerPlay();
|
||||
void InitialFillBuffer();
|
||||
|
||||
|
||||
bool IsPlaying;
|
||||
bool Looped;
|
||||
bool IsLoaded;
|
||||
|
||||
TDirectSoundStruct DirectSoundBuffer;
|
||||
|
||||
cardinal BufferCursorPos;
|
||||
cardinal PlayCursorPos;
|
||||
|
||||
cardinal TotalPlayCursorPos;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
class TWaveStream : public TMusicStreamAncestor
|
||||
{
|
||||
public:
|
||||
|
||||
TWaveStream();
|
||||
~TWaveStream();
|
||||
|
||||
protected:
|
||||
|
||||
virtual int InnerReadDataToBuffer(char* buffer, int size, int& bytesRead);
|
||||
virtual void InnerResetDataCursor();
|
||||
virtual void ClearSoundData();
|
||||
virtual void LoadSoundData(const std::string& fileName);
|
||||
virtual bool CheckIfSoundIsOver();
|
||||
|
||||
virtual cardinal GetSamplesPerSec();
|
||||
|
||||
TWaveFile MusicFile;
|
||||
|
||||
};
|
||||
|
||||
|
||||
class TOggMusicStream : public TMusicStreamAncestor
|
||||
{
|
||||
public:
|
||||
|
||||
TOggMusicStream();
|
||||
~TOggMusicStream();
|
||||
|
||||
protected:
|
||||
|
||||
bool IsInited;
|
||||
|
||||
virtual int InnerReadDataToBuffer(char* buffer, int size, int& bytesRead);
|
||||
virtual void InnerResetDataCursor();
|
||||
virtual void ClearSoundData();
|
||||
virtual void LoadSoundData(const std::string& fileName);
|
||||
virtual bool CheckIfSoundIsOver();
|
||||
virtual cardinal GetSamplesPerSec();
|
||||
|
||||
TOggCallbackFileBuffer FileBuffer;
|
||||
OggVorbis_File OggFileData;
|
||||
vorbis_info* VorbisInfo;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
DWORD GetMaxWriteSize(cardinal m_cbBufOffset, cardinal m_cbBufSize, TDirectSoundStruct& soundStruct);
|
||||
|
||||
void FillMemoryWithZero(char* bufferPtr, cardinal bufferSize);
|
||||
|
||||
|
||||
class TSoundManagerWindows : public TSoundManagerInterface
|
||||
{
|
||||
private:
|
||||
|
||||
std::map<std::string, TDirectSoundStruct> SoundMap;
|
||||
std::map<std::string, boost::shared_ptr<TMusicStreamAncestor> > StreamMap;
|
||||
|
||||
void InitDirectSound();
|
||||
void ShutdownDirectSound();
|
||||
|
||||
|
||||
|
||||
public:
|
||||
TSoundManagerWindows();
|
||||
~TSoundManagerWindows();
|
||||
|
||||
virtual void LoadSound(const std::string& soundFileName);
|
||||
virtual void PlaySound(const std::string& soundName);
|
||||
|
||||
virtual void LoadMusic(const std::string& musicFileName);
|
||||
virtual void PlayMusic(const std::string& musicName);
|
||||
virtual void PlayMusicLooped(const std::string& musicName);
|
||||
virtual void StopMusic(const std::string& musicName);
|
||||
|
||||
virtual void StopAllMusic();
|
||||
virtual void TryStopAndPlayMusicLooped(const std::string& musicName);
|
||||
|
||||
virtual void Update(cardinal dt);
|
||||
|
||||
IDirectSoundBuffer8* CreateDirectSound8InterfaceBuffer(cardinal dataSize, cardinal samplesPerSec);
|
||||
|
||||
IDirectSound8* DirectSound;
|
||||
IDirectSoundBuffer* PrimaryBuffer;
|
||||
|
||||
};
|
||||
|
||||
} //namespace SE
|
||||
|
||||
#else
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
|
||||
//NOSOUND version - just dummy
|
||||
class TSoundManagerWindows : public TSoundManagerInterface
|
||||
{
|
||||
private:
|
||||
|
||||
public:
|
||||
|
||||
virtual void LoadSound(const std::string& soundFileName) { }
|
||||
virtual void PlaySound(const std::string& soundName) { }
|
||||
|
||||
virtual void LoadMusic(const std::string& musicFileName) { }
|
||||
virtual void PlayMusic(const std::string& musicName) { }
|
||||
virtual void PlayMusicLooped(const std::string& musicName) { }
|
||||
virtual void StopMusic(const std::string& musicName) { }
|
||||
|
||||
};
|
||||
|
||||
|
||||
} //namespace SE
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,106 @@
|
||||
#pragma once
|
||||
|
||||
/*
|
||||
This code contains texture manager
|
||||
*/
|
||||
|
||||
#ifdef TARGET_WIN32
|
||||
#include "include/OpenGlExt/OpenGlExt.h"
|
||||
#endif
|
||||
|
||||
#ifdef TARGET_ANDROID
|
||||
#include <GLES2/gl2.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include "include/Utils/Utils.h"
|
||||
#include "include/Utils/PngHelper.h"
|
||||
#include "include/ScriptManager/ScriptManager.h"
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
|
||||
struct TTextureInfo
|
||||
{
|
||||
cardinal Width;
|
||||
cardinal Height;
|
||||
cardinal TexID;
|
||||
cardinal RefCount;
|
||||
};
|
||||
|
||||
|
||||
struct TTextureData
|
||||
{
|
||||
cardinal Width;
|
||||
cardinal Height;
|
||||
char Format[8];
|
||||
cardinal DataSize;
|
||||
boost::shared_array<char> Data;
|
||||
};
|
||||
|
||||
typedef std::map<std::string, TTextureInfo, std::less<std::string> > TTextureMap;
|
||||
|
||||
|
||||
class TTextureListClass : public TSerializeInterface, public TFunctionBinderInterface
|
||||
{
|
||||
protected:
|
||||
|
||||
TTextureMap TexMap;
|
||||
|
||||
std::map<std::string, boost::function<bool(const std::string&, TTextureData&)>> CreateFunctionMap;
|
||||
std::map<std::string, boost::function<cardinal(TTextureData&)>> AddFunctionMap;
|
||||
|
||||
void NormalizeTexData(TTextureData& texData);
|
||||
|
||||
bool CreateTexDataFromBmp24(const std::string& filename, TTextureData& texData);
|
||||
bool CreateTexDataFromBmp32(const std::string& filename, TTextureData& texData);
|
||||
bool CreateTexDataFromTga(const std::string& filename, TTextureData& texData);
|
||||
bool CreateTexDataFromPng(const std::string& filename, TTextureData& texData);
|
||||
cardinal AddTextureBmp24Data(const TTextureData& texData);
|
||||
cardinal AddTextureBmp32Data(const TTextureData& texData);
|
||||
|
||||
cardinal AddCubemapTextureBmp24Data(TTextureData* texData);
|
||||
//cardinal AddCubemapTextureBmp32Data(TTextureData* texData); Not implemented yet
|
||||
|
||||
public:
|
||||
TTextureListClass();
|
||||
~TTextureListClass();
|
||||
|
||||
void Clear();
|
||||
|
||||
virtual void Serialize(boost::property_tree::ptree& propertyTree);
|
||||
|
||||
cardinal operator[](const std::string& s)
|
||||
{
|
||||
if (TexMap.count(s) != 0)
|
||||
return TexMap[s].TexID;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
cardinal GetTextureHeight(const std::string& texName);
|
||||
cardinal GetTextureWidth(const std::string& texName);
|
||||
|
||||
cardinal AddTextureDirectly(const std::string& filename, std::string texName = ""); //Loads texture directly from this file or fails
|
||||
cardinal AddTexture(const std::string& fileName, std::string texName = ""); //Adds path to resources to the filename then call previous one
|
||||
cardinal AddTextureFromUserdata(const std::string& fileName, std::string texName = ""); //Same as above but checks if file is created in user data
|
||||
|
||||
cardinal AddCubemapTexture(std::string filename[6]); // "posx.bmp","negx.bmp","posy.bmp","negy.bmp","posz.bmp","negz.bmp"
|
||||
|
||||
|
||||
cardinal AddEmptyTexture(const std::string& texName, cardinal width, cardinal height);
|
||||
cardinal AddEmptyCubemapTexture(const std::string& texName, cardinal width, cardinal height);
|
||||
cardinal AddDepthTexture(const std::string& texName, cardinal width, cardinal height);
|
||||
void DeleteTexture(const std::string& texName);
|
||||
void DeleteTexture(cardinal texID);
|
||||
|
||||
void PrintTextureList();
|
||||
|
||||
virtual void BindFunctions();
|
||||
|
||||
void SaveTexDataToPlainBmpToUserData(const std::string& fileName, TTextureData texData);
|
||||
};
|
||||
|
||||
} //namespace SE
|
||||
@@ -0,0 +1,53 @@
|
||||
#ifndef BINDABLE_VAR_H_INCLUDED
|
||||
#define BINDABLE_VAR_H_INCLUDED
|
||||
|
||||
#include "boost/signal.hpp"
|
||||
#include "boost/variant.hpp"
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
//Must be stored in shared_ptr:
|
||||
|
||||
template<typename TYPENAME>
|
||||
class TBindableVar
|
||||
{
|
||||
protected:
|
||||
TYPENAME Variable;
|
||||
|
||||
public:
|
||||
|
||||
boost::signal<void(const TYPENAME&)> OnVarChanged;
|
||||
|
||||
TBindableVar()
|
||||
{
|
||||
}
|
||||
|
||||
TBindableVar(const TYPENAME&& var)
|
||||
: Variable(var)
|
||||
{
|
||||
}
|
||||
|
||||
operator TYPENAME()
|
||||
{
|
||||
return Variable;
|
||||
}
|
||||
|
||||
TYPENAME operator()()
|
||||
{
|
||||
return Variable;
|
||||
}
|
||||
|
||||
TBindableVar<TYPENAME>& operator=(const TYPENAME& var)
|
||||
{
|
||||
Variable = var;
|
||||
OnVarChanged(Variable);
|
||||
return *this;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
} //namespace SE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,132 @@
|
||||
#ifndef CONSOLE_H_INCLUDED
|
||||
#define CONSOLE_H_INCLUDED
|
||||
|
||||
/*
|
||||
This code contains console/log to work with
|
||||
|
||||
Use global variable Console like that:
|
||||
|
||||
*Console<<"something"<<endl;
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#ifdef TARGET_WIN32
|
||||
#include <fstream>
|
||||
#endif
|
||||
#ifdef TARGET_ANDROID
|
||||
#include <asm/page.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "boost/thread.hpp"
|
||||
#endif
|
||||
|
||||
|
||||
#include "include/Render/RenderMisc.h"
|
||||
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
extern const std::string CONST_CONSOLE_TEX_NAME;
|
||||
|
||||
|
||||
|
||||
class TSimpleConsole
|
||||
{
|
||||
protected:
|
||||
std::string History;
|
||||
|
||||
std::string TextSavedInTriangleList;
|
||||
|
||||
std::shared_ptr<TTriangleList> HistoryTriangeList;
|
||||
|
||||
|
||||
|
||||
public:
|
||||
std::string ConsoleInput;
|
||||
cardinal ConsoleCursor;
|
||||
std::vector<std::string> InputHistory;
|
||||
cardinal InputHistoryCursor;
|
||||
|
||||
TSimpleConsole() : History(""), TextSavedInTriangleList(""), ConsoleCursor(0), InputHistoryCursor(0) { }
|
||||
|
||||
virtual ~TSimpleConsole() { }
|
||||
|
||||
void Clear() { History = ""; }
|
||||
|
||||
void CutHistory();
|
||||
|
||||
virtual std::string GetHistory();
|
||||
|
||||
virtual void Draw();
|
||||
};
|
||||
|
||||
|
||||
#ifdef TARGET_WIN32
|
||||
|
||||
class TFileConsole : public TSimpleConsole
|
||||
{
|
||||
protected:
|
||||
std::string filename;
|
||||
std::ofstream f;
|
||||
public:
|
||||
TFileConsole();
|
||||
|
||||
TFileConsole(const std::string& Afilename);
|
||||
|
||||
~TFileConsole();
|
||||
|
||||
TFileConsole& operator<<(const std::string& s);
|
||||
|
||||
void PrintImmediate(const std::string& s);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef TARGET_ANDROID
|
||||
|
||||
class TJavaConsole : public TSimpleConsole
|
||||
{
|
||||
protected:
|
||||
boost::mutex ConsoleMutex;
|
||||
std::string AppDir;
|
||||
std::string LogFilename;
|
||||
public:
|
||||
|
||||
TJavaConsole();
|
||||
|
||||
TJavaConsole& operator<<(const std::string& s);
|
||||
|
||||
void PrintImmediate(const std::string& s);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef TARGET_IOS
|
||||
|
||||
class TIosConsole : public TSimpleConsole
|
||||
{
|
||||
protected:
|
||||
public:
|
||||
TIosConsole();
|
||||
|
||||
//TFileConsole(const std::string& Afilename);
|
||||
|
||||
~TIosConsole();
|
||||
|
||||
TIosConsole& operator<<(const std::string& s);
|
||||
|
||||
void PrintImmediate(const std::string& s);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
} //namespace SE
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,201 @@
|
||||
#ifndef DATA_TYPES_H_INCLUDED
|
||||
#define DATA_TYPES_H_INCLUDED
|
||||
|
||||
/*
|
||||
This code contains additional data types and some const values to use
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <stdlib.h>
|
||||
#include "boost/lexical_cast.hpp"
|
||||
|
||||
#include "NewDataTypes.h"
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
typedef unsigned int cardinal;
|
||||
typedef unsigned short int word;
|
||||
typedef unsigned char byte;
|
||||
|
||||
typedef cardinal* pcardinal;
|
||||
|
||||
//Use mat4 to store projection/modelview matrices (i.e. for shadow mapping)
|
||||
struct mat4
|
||||
{
|
||||
float m[16];
|
||||
};
|
||||
|
||||
struct TSmpTriangle
|
||||
{
|
||||
vec3 p[3];
|
||||
vec3 v;
|
||||
vec3 w;
|
||||
vec3 n;
|
||||
};
|
||||
|
||||
|
||||
const float pi = 3.14159265359f;
|
||||
|
||||
const float CONST_EPSILON = 0.00001f;
|
||||
|
||||
const float WhiteColor[4] = {1.0f, 1.0f, 1.0f, 1.0f};
|
||||
const float RedColor[4] = {1.0f, 0.0f, 0.0f, 1.0f};
|
||||
const float NoColor[4] = {0.0f, 0.0f, 0.0f, 1.0f};
|
||||
|
||||
const mat3 IdentityMatrix(vec3(1.0f, 0.0f, 0.0f), vec3(0.0f, 1.0f, 0.0f), vec3(0.0f, 0.0f, 1.0f));
|
||||
|
||||
const mat4 IdentityMatrix4 =
|
||||
{ 1.f, 0.f, 0.f, 0.f,
|
||||
0.f, 1.f, 0.f, 0.f,
|
||||
0.f, 0.f, 1.f, 0.f,
|
||||
0.f, 0.f, 0.f, 1.f };
|
||||
|
||||
|
||||
const vec3 ZeroVec3(0.0f, 0.0f, 0.0f);
|
||||
|
||||
const vec4 ZeroQuat(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
const std::string fendl="\x0D\x0A"; //Windows-style, for files
|
||||
const std::string endl="\n";
|
||||
|
||||
vec4 InverseQuat(const vec4& q);
|
||||
|
||||
//For shadow mapping or for OpenGL ES 2.0
|
||||
mat4 InverseModelViewMatrix(const mat4& m);
|
||||
mat4 SetToNormalMatrix(const mat4& m);
|
||||
mat4 MakeOrthoMatrix(float width, float height);
|
||||
mat4 MakeFrustumMatrix(float left, float right, float bottom, float top, float nearVal, float farVal);
|
||||
mat4 MakePerspectiveMatrix(float angle, float aspect, float zNear, float zFar);
|
||||
|
||||
mat4 MultMatrixMatrix(const mat4& m1, const mat4& m2);
|
||||
|
||||
bool IsFloatEqual(float a, float b);
|
||||
|
||||
int LineCrossTriangle(const vec3& a, const vec3& b, const TSmpTriangle& tr);
|
||||
|
||||
int LineCrossTriangle(const vec3& a, const vec3& b, const TSmpTriangle& tr, vec3& CrossPoint);
|
||||
|
||||
int PointInTriangle(const vec3& q, const TSmpTriangle& tr);
|
||||
|
||||
|
||||
template<typename T>
|
||||
inline std::string tostr(T i)
|
||||
{
|
||||
return boost::lexical_cast<std::string>(i);
|
||||
}
|
||||
|
||||
inline int toint(const char* str)
|
||||
{
|
||||
return boost::lexical_cast<int>(str);
|
||||
}
|
||||
|
||||
inline int toint(const std::string& str)
|
||||
{
|
||||
return boost::lexical_cast<int>(str);
|
||||
}
|
||||
//#ifndef TARGET_WIN32 //Already defined in windows.h
|
||||
|
||||
template<typename T>
|
||||
inline T min(T a, T b)
|
||||
{
|
||||
return a < b ? a : b;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline T max(T a, T b)
|
||||
{
|
||||
return a > b ? a : b;
|
||||
}
|
||||
|
||||
//#endif
|
||||
|
||||
template<typename T>
|
||||
inline T clamp(T a, T c_from, T c_to)
|
||||
{
|
||||
if (a < c_from)
|
||||
{
|
||||
return c_from;
|
||||
}
|
||||
|
||||
if (a > c_to)
|
||||
{
|
||||
return c_to;
|
||||
}
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline T sign(T a)
|
||||
{
|
||||
if (a == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (a < 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
float roundf(float r);
|
||||
|
||||
template<typename T>
|
||||
T InterpolateLinear(T a, T b, float t)
|
||||
{
|
||||
return a + (b-a)*t;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T InterpolateSqr(T a, T b, float t)
|
||||
{
|
||||
return a + (b-a)*t*t;
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
T InterpolateSqrt(T a, T b, float t)
|
||||
{
|
||||
return a + (b-a)*sqrtf(t);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool IsPower2(T x)
|
||||
{
|
||||
return ( (x > 0) && ((x & (x - 1)) == 0) );
|
||||
}
|
||||
|
||||
cardinal GetGreaterPower2(cardinal x);
|
||||
|
||||
vec2 StringToVec2(std::string str);
|
||||
vec3 StringToVec3(std::string str);
|
||||
vec4 StringToVec4(std::string str);
|
||||
|
||||
// ================================================
|
||||
// ========== wide strings and UTF8 strings =======
|
||||
// ================================================
|
||||
|
||||
|
||||
void utf8toWStr(std::wstring& dest, const std::string& src);
|
||||
|
||||
void wstrToUtf8(std::string& dest, const std::wstring& src);
|
||||
|
||||
std::string wstrToUtf8(const std::wstring& str);
|
||||
|
||||
std::wstring utf8toWStr(const std::string& str);
|
||||
|
||||
std::ostream& operator<<(std::ostream& f, const std::wstring& s);
|
||||
|
||||
std::istream& operator>>(std::istream& f, std::wstring& s);
|
||||
|
||||
} //namespace SE
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,93 @@
|
||||
#ifndef ERROR_TYPES_H_INCLUDED
|
||||
#define ERROR_TYPES_H_INCLUDED
|
||||
|
||||
/*
|
||||
This code contains exception types for asserting and log watch
|
||||
*/
|
||||
|
||||
#include "include/Utils/Console/Console.h"
|
||||
#include "include/Utils/DataTypes/DataTypes.h"
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
#ifdef TARGET_WIN32
|
||||
extern TFileConsole* Console;
|
||||
#endif
|
||||
|
||||
#ifdef TARGET_ANDROID
|
||||
extern TJavaConsole* Console;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef TARGET_IOS
|
||||
extern TIosConsole* Console;
|
||||
#endif
|
||||
|
||||
class ErrorCommon
|
||||
{
|
||||
public:
|
||||
ErrorCommon() {/* *Console<<"Common error!";*/ }
|
||||
virtual ~ErrorCommon() { }
|
||||
};
|
||||
|
||||
class ErrorToLog : public ErrorCommon
|
||||
{
|
||||
public:
|
||||
ErrorToLog(const std::string& message) { *Console<<message; }
|
||||
};
|
||||
|
||||
class ErrorFile : public ErrorCommon
|
||||
{
|
||||
public:
|
||||
ErrorFile(const std::string& fileName) { *Console<<"File error in file: "+fileName; }
|
||||
};
|
||||
|
||||
class ErrorFileNotFound : public ErrorFile
|
||||
{
|
||||
public:
|
||||
ErrorFileNotFound(const std::string& fileName) : ErrorFile(fileName) { *Console<<"File not found: "<<fileName; }
|
||||
};
|
||||
|
||||
class ErrorFileNotCorrect : public ErrorFile
|
||||
{
|
||||
public:
|
||||
ErrorFileNotCorrect(const std::string& fileName) : ErrorFile(fileName) { *Console<<"File not correct: "+fileName; }
|
||||
};
|
||||
|
||||
class ErrorFileNotRead : public ErrorFile
|
||||
{
|
||||
public:
|
||||
ErrorFileNotRead(const std::string& fileName) : ErrorFile(fileName) { *Console<<"File could not be read: "+fileName; }
|
||||
};
|
||||
|
||||
class ErrorFileNotLoaded : public ErrorFile
|
||||
{
|
||||
public:
|
||||
ErrorFileNotLoaded(const std::string& fileName) : ErrorFile(fileName) { *Console<<"File could not be loaded: "+fileName; }
|
||||
};
|
||||
|
||||
class ErrorFileTooShort : public ErrorFile
|
||||
{
|
||||
public:
|
||||
ErrorFileTooShort(const std::string& fileName) : ErrorFile(fileName) { *Console<<"File is too short: "+fileName; }
|
||||
};
|
||||
|
||||
|
||||
class ErrorShaderNotExists : public ErrorCommon
|
||||
{
|
||||
public:
|
||||
ErrorShaderNotExists(const std::string& shaderName) { *Console<<"Shader not exists: "+shaderName; }
|
||||
};
|
||||
|
||||
|
||||
class ErrorShaderStackOverflow : public ErrorCommon
|
||||
{
|
||||
public:
|
||||
ErrorShaderStackOverflow() { *Console<<"Shader stack overflow!"; }
|
||||
};
|
||||
|
||||
|
||||
} //namespace SE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,253 @@
|
||||
#ifndef FILE_UTILS_H_INCLUDED
|
||||
#define FILE_UTILS_H_INCLUDED
|
||||
|
||||
/*
|
||||
This code contains API to ease file access
|
||||
|
||||
WINDOWS AND ANDROID
|
||||
*/
|
||||
|
||||
#include "include/Utils/DataTypes/DataTypes.h"
|
||||
#include "include/Utils/Console/Console.h"
|
||||
#include "boost/shared_array.hpp"
|
||||
|
||||
#ifdef TARGET_WIN32
|
||||
#include "include/Utils/WinApi/WinApi.h"
|
||||
#endif
|
||||
|
||||
#ifdef TARGET_ANDROID
|
||||
#include "include/Utils/JniApi/JniApi.h"
|
||||
#endif
|
||||
|
||||
#ifdef TARGET_IOS
|
||||
#include "include/Utils/IosApi/IosApi.h"
|
||||
#endif
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
bool findString(char* in, char* list);
|
||||
//utility for opengl extensions parsing. Not safe
|
||||
|
||||
|
||||
bool IsFileExistsInUserData(const std::string& filename);
|
||||
std::string GetFilePathUserData(const std::string& filename);
|
||||
|
||||
|
||||
#ifdef TARGET_WIN32
|
||||
|
||||
template<typename TYPENAME>
|
||||
boost::shared_array<TYPENAME> CreateMemFromFile(const std::string& fileName, cardinal& intCount)
|
||||
{
|
||||
cardinal SIZEOF_TYPENAME = sizeof(TYPENAME);
|
||||
|
||||
FILE * pFile;
|
||||
|
||||
long fSize;
|
||||
|
||||
size_t result;
|
||||
|
||||
TYPENAME* fileData;
|
||||
|
||||
std::string realFileName = fileName;
|
||||
|
||||
|
||||
if (fopen_s(&pFile, realFileName.c_str(), "rb" ) != 0)
|
||||
{
|
||||
throw ErrorToLog("File not loaded: " + fileName);
|
||||
}
|
||||
|
||||
// obtain file size:
|
||||
fseek (pFile , 0 , SEEK_END);
|
||||
fSize = ftell (pFile);
|
||||
rewind (pFile);
|
||||
|
||||
fileData = new TYPENAME [fSize % SIZEOF_TYPENAME == 0 ? fSize/SIZEOF_TYPENAME : fSize/SIZEOF_TYPENAME + 1];
|
||||
|
||||
result = fread (&fileData[0], 1, fSize, pFile);
|
||||
|
||||
if (result != fSize)
|
||||
{
|
||||
throw ErrorToLog("File not loaded: " + fileName);
|
||||
}
|
||||
|
||||
// terminate
|
||||
fclose (pFile);
|
||||
|
||||
intCount = fSize;
|
||||
|
||||
return boost::shared_array<TYPENAME>(fileData);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef TARGET_ANDROID
|
||||
|
||||
template<typename TYPENAME>
|
||||
boost::shared_array<TYPENAME> CreateMemFromFile(const std::string& fileName, cardinal& intCount)
|
||||
{
|
||||
if (std::string(fileName.begin(), fileName.begin() + 5) == "/data")
|
||||
{
|
||||
*Console<<"File is in userdata - "+fileName;
|
||||
|
||||
cardinal SIZEOF_TYPENAME = sizeof(TYPENAME);
|
||||
|
||||
FILE * pFile;
|
||||
|
||||
long fSize;
|
||||
|
||||
size_t result;
|
||||
|
||||
TYPENAME* fileData;
|
||||
|
||||
std::string realFileName = fileName;
|
||||
|
||||
pFile = fopen ( realFileName.c_str(), "rb" );
|
||||
if (pFile == NULL)
|
||||
{
|
||||
throw ErrorToLog("File not loaded: " + fileName);
|
||||
}
|
||||
|
||||
// obtain file size:
|
||||
fseek (pFile , 0 , SEEK_END);
|
||||
fSize = ftell (pFile);
|
||||
rewind (pFile);
|
||||
|
||||
fileData = new TYPENAME [fSize % SIZEOF_TYPENAME == 0 ? fSize/SIZEOF_TYPENAME : fSize/SIZEOF_TYPENAME + 1];
|
||||
|
||||
result = fread (&fileData[0], 1, fSize, pFile);
|
||||
|
||||
if (result != fSize)
|
||||
{
|
||||
throw ErrorToLog("File not loaded: " + fileName);
|
||||
}
|
||||
|
||||
// terminate
|
||||
fclose (pFile);
|
||||
|
||||
intCount = fSize;
|
||||
|
||||
return boost::shared_array<TYPENAME>(fileData);
|
||||
}
|
||||
|
||||
*Console<<"File is in resources - "+fileName;
|
||||
|
||||
return JniCreateMemFromFile<TYPENAME>(fileName, intCount);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef TARGET_IOS
|
||||
|
||||
template<typename TYPENAME>
|
||||
boost::shared_array<TYPENAME> CreateMemFromFile(const std::string& fileName, cardinal& intCount)
|
||||
{
|
||||
cardinal SIZEOF_TYPENAME = sizeof(TYPENAME);
|
||||
|
||||
FILE * pFile;
|
||||
|
||||
long fSize;
|
||||
|
||||
size_t result;
|
||||
|
||||
TYPENAME* fileData;
|
||||
|
||||
std::string realFileName = IosGetFileReadPath(fileName);
|
||||
|
||||
pFile = fopen ( realFileName.c_str(), "rb" );
|
||||
if (pFile == NULL)
|
||||
{
|
||||
throw ErrorToLog("File not loaded: " + fileName);
|
||||
}
|
||||
|
||||
// obtain file size:
|
||||
fseek (pFile , 0 , SEEK_END);
|
||||
fSize = ftell (pFile);
|
||||
rewind (pFile);
|
||||
|
||||
fileData = new TYPENAME [fSize % SIZEOF_TYPENAME == 0 ? fSize/SIZEOF_TYPENAME : fSize/SIZEOF_TYPENAME + 1];
|
||||
|
||||
result = fread (&fileData[0], 1, fSize, pFile);
|
||||
|
||||
if (result != fSize)
|
||||
{
|
||||
throw ErrorToLog("File not loaded: " + fileName);
|
||||
}
|
||||
|
||||
// terminate
|
||||
fclose (pFile);
|
||||
|
||||
intCount = fSize;
|
||||
|
||||
return boost::shared_array<TYPENAME>(fileData);
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
//utitily to process texture uploading
|
||||
inline char* GetFileName(const char* filename)
|
||||
{
|
||||
char* fname = (char*)filename + strlen(filename);
|
||||
|
||||
while ((*fname != '\\')&&(*fname != '/')&&(fname >= filename ))
|
||||
--fname;
|
||||
|
||||
++fname;
|
||||
|
||||
return fname;
|
||||
}
|
||||
|
||||
inline std::string GetFileName(const std::string& filename)
|
||||
{
|
||||
std::string::const_iterator i = filename.end() - 1;
|
||||
|
||||
while ((i > filename.begin() )&&(*i != '\\')&&(*i != '/'))
|
||||
--i;
|
||||
|
||||
if (*i == '\\' || *i == '/')
|
||||
{
|
||||
i++;
|
||||
}
|
||||
|
||||
return std::string(i, filename.end());
|
||||
}
|
||||
|
||||
//utitily to process texture uploading
|
||||
inline char* GetFileExt(const char* filename)
|
||||
{
|
||||
char* fext = (char*)filename + strlen(filename);
|
||||
|
||||
while (*fext != '.')
|
||||
--fext;
|
||||
|
||||
return fext;
|
||||
}
|
||||
|
||||
inline std::string GetFileExt(const std::string& filename)
|
||||
{
|
||||
std::string::const_iterator i = filename.end() - 1;
|
||||
|
||||
while (*i != '.')
|
||||
--i;
|
||||
|
||||
return std::string(i, filename.end());
|
||||
|
||||
}
|
||||
|
||||
std::string GetFilePath(const std::string& filename);
|
||||
|
||||
#ifdef TARGET_IOS
|
||||
|
||||
//Special for IOS, because Foundation.h conflicts with sq_plus.h
|
||||
|
||||
// Obviously, this returns ResourceManager->PathToResources
|
||||
|
||||
std::string GetPathToResources();
|
||||
#endif
|
||||
|
||||
} //namespace SE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// Halibut_Engine.h
|
||||
// Halibut Engine
|
||||
//
|
||||
// Created by vvv ооо on 13.07.12.
|
||||
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <OpenGLES/ES2/gl.h>
|
||||
#include <OpenGLES/ES2/glext.h>
|
||||
|
||||
#include "include/Utils/ErrorTypes/ErrorTypes.h"
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
std::string IosGetFileReadPath(const std::string& filename);
|
||||
|
||||
std::string IosGetFilePathUserData(const std::string& filename);
|
||||
|
||||
|
||||
} //namespace SE
|
||||
@@ -0,0 +1,140 @@
|
||||
#ifndef JNI_API_H_INCLUDED
|
||||
#define JNI_API_H_INCLUDED
|
||||
|
||||
#include <jni.h>
|
||||
#include <string>
|
||||
#include "include/Utils/DataTypes/DataTypes.h"
|
||||
#include "include/Utils/ErrorTypes/ErrorTypes.h"
|
||||
#include "boost/shared_array.hpp"
|
||||
|
||||
#include "zip.h"
|
||||
#include "zipint.h"
|
||||
#include <zlib.h>
|
||||
#include <zconf.h>
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
/*
|
||||
|
||||
This code mostly hard to explain
|
||||
You may treat this like a factory-class
|
||||
|
||||
But you cannot put JNI functions inside a class, that's why it is not a real class
|
||||
|
||||
The only thing you need from here - functions JniCreateDataFromFile and JniCreateDataFromAlignedFile for FileUtils.h/cpp
|
||||
|
||||
See doc for details
|
||||
|
||||
*/
|
||||
|
||||
extern const std::string CONST_JAVA_FILESYSTEM_CLASS_NAME;
|
||||
|
||||
//All 3 deprecated
|
||||
extern cardinal* FileArr;
|
||||
extern int FileSize;
|
||||
extern std::string ApkFilePath;
|
||||
|
||||
extern "C" {
|
||||
JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_SetupEnviroment(JNIEnv* env, jobject thiz);
|
||||
JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_SetupApkFilePath(JNIEnv* env, jobject thiz, jstring s);
|
||||
JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_ConsoleOut(JNIEnv* env, jobject thiz, jstring s);
|
||||
|
||||
//All 2 deprecated
|
||||
JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_CreateFile(JNIEnv* env, jobject thiz, int fileSize);
|
||||
JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_WriteToFile(JNIEnv* env, jobject thiz, jbyteArray buffer, int bufferSize);
|
||||
|
||||
|
||||
};
|
||||
|
||||
//Deprecated
|
||||
void JniCallOpenFile(const std::string& fileName);
|
||||
|
||||
|
||||
//Deprecated
|
||||
template<typename TYPENAME>
|
||||
boost::shared_array<TYPENAME> JniCreateMemFromFileOld(const std::string& fileName, cardinal& blockCount)
|
||||
{
|
||||
|
||||
//if size is too large - need to do some work
|
||||
cardinal SIZEOF_TYPENAME = sizeof(TYPENAME);
|
||||
if (SIZEOF_TYPENAME > 4)
|
||||
{
|
||||
throw ErrorToLog("ERROR! Size of type too large - file is not properly aligned. Need work!");
|
||||
}
|
||||
|
||||
if (FileArr != NULL)
|
||||
throw ErrorToLog("ERROR: Trying to reach two files at same time!!!!");
|
||||
|
||||
JniCallOpenFile(fileName);
|
||||
|
||||
// ...
|
||||
//Wait until Java pass all file data to FileArr through WriteToFile()
|
||||
// ...
|
||||
|
||||
//Give pointer away
|
||||
boost::shared_array<TYPENAME> r(reinterpret_cast<TYPENAME*>(FileArr));
|
||||
blockCount = FileSize % SIZEOF_TYPENAME == 0 ? FileSize / SIZEOF_TYPENAME: FileSize / SIZEOF_TYPENAME + 1;
|
||||
FileArr = NULL;
|
||||
FileSize = 0;
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
std::string JniGetApplicationDir();
|
||||
|
||||
void JniLoadSound(const std::string& fileName);
|
||||
void JniPlaySound(const std::string& soundName);
|
||||
|
||||
void JniPlayMusic(const std::string& fileName);
|
||||
void JniPlayMusicLooped(const std::string& fileName);
|
||||
void JniStopMusic();
|
||||
|
||||
void JniReleaseAllSoundsAndMusic();
|
||||
void JniPauseAllSoundsAndMusic();//NIU right now
|
||||
void JniResumeAllSoundsAndMusic(); //NIU right now
|
||||
|
||||
void LoadApk(const std::string& fileName, std::vector<char>& returnData);
|
||||
|
||||
void PrintApkContent();
|
||||
|
||||
|
||||
template<typename TYPENAME>
|
||||
boost::shared_array<TYPENAME> JniCreateMemFromFile(const std::string& fileName, cardinal& blockCount)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
//if size is too large - need to do some work
|
||||
cardinal SIZEOF_TYPENAME = sizeof(TYPENAME);
|
||||
if (SIZEOF_TYPENAME > 4)
|
||||
{
|
||||
throw ErrorToLog("ERROR! Size of type too large - file is not properly aligned. Need work!");
|
||||
}
|
||||
|
||||
std::vector<char> fileData;
|
||||
|
||||
LoadApk(fileName, fileData);
|
||||
|
||||
cardinal fileSize = fileData.size();
|
||||
|
||||
blockCount = fileSize % SIZEOF_TYPENAME == 0 ? fileSize / SIZEOF_TYPENAME: fileSize / SIZEOF_TYPENAME + 1;
|
||||
|
||||
boost::shared_array<TYPENAME> result(new TYPENAME[blockCount]);
|
||||
|
||||
memcpy(&result[0], &fileData[0], fileSize);
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
catch(ErrorCommon e)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
} //namespace SE
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,37 @@
|
||||
#ifndef PNG_HELPER_H_INCLUDED
|
||||
#define PNG_HELPER_H_INCLUDED
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#define PNG_DEBUG 3
|
||||
#include "png.h"
|
||||
}
|
||||
|
||||
#include "boost/shared_array.hpp"
|
||||
#include "include/Utils/DataTypes/DataTypes.h"
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
struct TPngDataStruct
|
||||
{
|
||||
int Width;
|
||||
int Height;
|
||||
png_byte ColorType;
|
||||
png_byte BitDepth;
|
||||
|
||||
png_structp PngPtr;
|
||||
png_infop InfoPtr;
|
||||
int NumberOfPasses;
|
||||
png_bytep* RowPointers;
|
||||
};
|
||||
|
||||
|
||||
|
||||
TPngDataStruct read_png_file(const boost::shared_array<char>& fileArr, cardinal fileSize);
|
||||
|
||||
|
||||
} //namespace SE
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,62 @@
|
||||
#ifndef SERIALIZE_INTERFACE_H_INCLUDED
|
||||
#define SERIALIZE_INTERFACE_H_INCLUDED
|
||||
|
||||
#include "include/Utils/DataTypes/DataTypes.h"
|
||||
#include "include/Utils/ErrorTypes/ErrorTypes.h"
|
||||
#include "boost/property_tree/ptree.hpp"
|
||||
#include "boost/property_tree/xml_parser.hpp"
|
||||
#include "boost/shared_array.hpp"
|
||||
|
||||
#include "boost/foreach.hpp"
|
||||
#include <string>
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
std::shared_ptr<boost::property_tree::ptree> StringToPropertyTree(std::string xmlCode, std::map<std::string, std::string> replaceMap = std::map<std::string, std::string>());
|
||||
|
||||
std::shared_ptr<boost::property_tree::ptree> FileToPropertyTree(boost::shared_array<char> xmlFileArr, cardinal xmlFileSize, std::map<std::string, std::string> replaceMap = std::map<std::string, std::string>());
|
||||
|
||||
std::shared_ptr<boost::property_tree::ptree> FileToPropertyTree(const std::string& fileName, std::map<std::string, std::string> replaceMap = std::map<std::string, std::string>());
|
||||
|
||||
|
||||
class TSerializeInterface
|
||||
{
|
||||
public:
|
||||
virtual void Serialize(boost::property_tree::ptree& propertyTree)
|
||||
{
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
template <typename TKEY, typename TVALUE>
|
||||
class TMapParser : public TSerializeInterface
|
||||
{
|
||||
public:
|
||||
std::map<TKEY, TVALUE> Map;
|
||||
|
||||
virtual void Serialize(boost::property_tree::ptree& propertyTree)
|
||||
{
|
||||
|
||||
BOOST_FOREACH(boost::property_tree::ptree::value_type& subTree, propertyTree)
|
||||
{
|
||||
TKEY key = subTree.second.get<TKEY>("<xmlattr>.key");
|
||||
TVALUE value = subTree.second.get<TVALUE>("<xmlattr>.value");
|
||||
|
||||
Map[key] = value;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <typename TKEY, typename TVALUE>
|
||||
std::map<TKEY, TVALUE> SerializeToMap(boost::property_tree::ptree& propertyTree)
|
||||
{
|
||||
TMapParser<TKEY, TVALUE> mapParser;
|
||||
mapParser.Serialize(propertyTree);
|
||||
return mapParser.Map;
|
||||
}
|
||||
|
||||
} //namespace SE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,30 @@
|
||||
#ifndef SIMPLE_TIMER_H_INCLUDED
|
||||
#define SIMPLE_TIMER_H_INCLUDED
|
||||
|
||||
#include "include/Utils/DataTypes/DataTypes.h"
|
||||
|
||||
#include "boost/date_time/posix_time/posix_time.hpp"
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
class TSimpleTimer
|
||||
{
|
||||
protected:
|
||||
int Timer;
|
||||
public:
|
||||
|
||||
TSimpleTimer();
|
||||
|
||||
void SetTimer(int timer);
|
||||
void Update(cardinal dt);
|
||||
bool IsOver();
|
||||
|
||||
boost::posix_time::time_duration GetPosixTime();
|
||||
|
||||
};
|
||||
|
||||
} //namespace SE
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,42 @@
|
||||
#ifndef UTILS_H_INCLUDED
|
||||
#define UTILS_H_INCLUDED
|
||||
/*
|
||||
This code combines additional routines (such as console/log, exceptions, math utils, file utils) for engine to use
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <stack>
|
||||
#include "boost/shared_array.hpp"
|
||||
#include "boost/property_tree/ptree.hpp"
|
||||
#include "boost/foreach.hpp"
|
||||
|
||||
#include "boost/asio.hpp"
|
||||
#include "boost/date_time/posix_time/posix_time.hpp"
|
||||
#include "boost/signal.hpp"
|
||||
|
||||
|
||||
#include "include/Utils/Console/Console.h"
|
||||
#include "include/Utils/ErrorTypes/ErrorTypes.h"
|
||||
#include "../GlobalConst.h"
|
||||
#include "include/Utils/FileUtils/FileUtils.h"
|
||||
#include "include/Utils/SerializeInterface/SerializeInterface.h"
|
||||
|
||||
#include "include/Utils/BindableVar.h"
|
||||
#include "include/Utils/SimpleTimer.h"
|
||||
|
||||
#ifdef TARGET_WIN32
|
||||
#include "WinApi/WinApi.h"
|
||||
#endif
|
||||
|
||||
#ifdef TARGET_ANDROID
|
||||
#include "JniApi/JniApi.h"
|
||||
#endif
|
||||
|
||||
#ifdef TARGET_IOS
|
||||
#include "IosApi/IosApi.h"
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#define NOMINMAX 1
|
||||
#include "windows.h"
|
||||
#undef NOMINMAX
|
||||
#include "gl/gl.h"
|
||||
#include "gl/glu.h"
|
||||
#include "gl/glext.h"
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
/*
|
||||
Here goes all functions that are platform-specific
|
||||
When I make iOS/Mac/Linux port, I will make same API pair h/cpp
|
||||
*/
|
||||
|
||||
void GetWindowWidthHeight(int& width, int& height);
|
||||
|
||||
int GetWindowWidth();
|
||||
|
||||
int GetWindowHeight();
|
||||
|
||||
} //namespace SE
|
||||
Reference in new issue
Block a user