engine/include/Render/RenderMisc.h

175 lines
5.0 KiB
C
Raw Normal View History

2013-01-19 20:02:34 +00:00
#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;
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
{
2013-02-05 20:17:58 +00:00
protected:
virtual void InnerRefreshBuffer();
2013-01-19 20:02:34 +00:00
bool NeedPrepareBufferObjects;
2013-02-05 20:17:58 +00:00
bool NeedRefreshBuffer; //Dummy for Android, but you need this for PC
public:
mutable std::map<std::string, std::shared_ptr<VBOObject>> VertBufferArr;
2013-01-19 20:02:34 +00:00
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
2013-02-10 19:08:19 +00:00
2013-01-19 20:02:34 +00:00
void FillVertexCoordVec(std::vector<vec3>& coordVec, int pos, vec2 posFrom, vec2 posTo);
2013-02-10 19:08:19 +00:00
//Adds rect points (6 vertices) into coordVec
2013-01-19 20:02:34 +00:00
2013-02-10 19:08:19 +00:00
void FillTexCoordVec(std::vector<vec2>& coordVec, int pos, vec2 texCoordFrom = vec2(0,0), vec2 texCoordTo = vec2(1,1));
//Adds rect points (6 tex coords) into coordVec
2013-01-19 20:02:34 +00:00
2013-12-01 22:42:47 +00:00
void FillVertexCoordVec_4Points(std::vector<vec3>& coordVec, int pos, vec2 pos1, vec2 pos2, vec2 pos3, vec2 pos4);
//Adds rect points (6 vertices) into coordVec
void FillTexCoordVec_4Points(std::vector<vec2>& coordVec, int pos, vec2 texCoord1 = vec2(0,0), vec2 texCoord2 = vec2(1,0), vec2 texCoord3 = vec2(1,1), vec2 texCoord4 = vec2(0,1));
//Adds rect points (6 tex coords) into coordVec
2013-01-19 20:02:34 +00:00
std::vector<vec3> MakeVertexCoordVec(vec2 posFrom, vec2 posTo);
2013-02-10 19:08:19 +00:00
//Creates array of rect (6 vertices)
2013-01-19 20:02:34 +00:00
std::vector<vec2> MakeTexCoordVec(vec2 texCoordFrom = vec2(0,0), vec2 texCoordTo = vec2(1,1));
2013-02-10 19:08:19 +00:00
//Creates array of rect (6 tex coords)
2013-01-19 20:02:34 +00:00
TDataTriangleList MakeDataTriangleList(vec2 posFrom, vec2 posTo, vec2 texCoordFrom = vec2(0,0), vec2 texCoordTo = vec2(1,1));
2013-02-10 19:08:19 +00:00
//Creates a DataTriangleList just containing rect
2013-01-19 20:02:34 +00:00
void MoveDataTriangleList(TDataTriangleList& triangleList, vec3 shift);
2013-02-10 19:08:19 +00:00
//Translates all points in DataTriangleList with shift vector
2013-01-19 20:02:34 +00:00
void RotateDataTriangleList(TDataTriangleList& triangleList, const mat3& m);
2013-02-10 19:08:19 +00:00
//Rotates all points in triangleList with rotation matrix
2013-01-19 20:02:34 +00:00
void ScaleDataTriangleList(TDataTriangleList& triangleList, float scale);
2013-02-10 19:08:19 +00:00
//Scales all points in triangleList by scale value
2013-01-19 20:02:34 +00:00
void ScaleDataTriangleList(TDataTriangleList& triangleList, vec3 scaleVec);
2013-02-10 19:08:19 +00:00
//Scales all points in triangleList by scaleVec vector
2013-01-19 20:02:34 +00:00
TDataTriangleList& ClearDataTriangleList(TDataTriangleList& triangleList);
2013-02-10 19:08:19 +00:00
//Clears triangle list, returning itself
2013-01-19 20:02:34 +00:00
TDataTriangleList& InsertIntoDataTriangleList(TDataTriangleList& triangleList, const std::vector<vec3>& vertexArr, const std::vector<vec2>& texCoordArr);
2013-02-10 19:08:19 +00:00
//Inserts additional points and their tex coords into triangle list
2013-01-19 20:02:34 +00:00
void Replace6PointsInTriangleList(TDataTriangleList& triangleList, int pos, vec2 posFrom, vec2 posTo, vec2 texCoordFrom = vec2(0,0), vec2 texCoordTo = vec2(1,1));
2013-02-10 19:08:19 +00:00
//Replaces one rect in triangleList at position pos by new rect. pos is position in array for first vertex of a rectangle
2013-01-19 20:02:34 +00:00
2013-12-01 22:42:47 +00:00
void Replace6PointsInTriangleList_4Points(TDataTriangleList& triangleList, int pos, vec2 pos1, vec2 pos2, vec2 pos3, vec2 pos4, vec2 texCoord1 = vec2(0,0), vec2 texCoord2 = vec2(1,0), vec2 texCoord3 = vec2(1,1), vec2 texCoord4 = vec2(0,1));
//Replaces one rect in triangleList at position pos by new rect. pos is position in array for first vertex of a rectangle
2013-01-19 20:02:34 +00:00
TTriangleList MakeTriangleList(vec2 posFrom, vec2 posTo, vec2 texCoordFrom = vec2(0,0), vec2 texCoordTo = vec2(1,1));
2013-02-10 19:08:19 +00:00
//Creates triangle list containing rect
2013-01-19 20:02:34 +00:00
void CheckGlError(const std::string& msg = "");
} //namespace SE
#endif