First blood
This commit is contained in:
1 parent
04f270f322
commit
5720f8322b
250 files changed
+33215
No files matched your search
@@ -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
|
||||
Reference in new issue
Block a user