1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */
#ifndef GEOMETRYBUFFER_H
#define GEOMETRYBUFFER_H
#include "Rendering/GL/FBO.h"
#include "System/type2.h"
namespace GL {
struct GeometryBuffer {
public:
enum {
ATTACHMENT_NORMTEX = 0, // shading (not geometric) normals
ATTACHMENT_DIFFTEX = 1, // diffuse texture fragments
ATTACHMENT_SPECTEX = 2, // specular texture fragments
ATTACHMENT_EMITTEX = 3, // emissive texture fragments
ATTACHMENT_MISCTEX = 4, // custom data for Lua UnitRendering shaders
ATTACHMENT_ZVALTEX = 5, // fragment depth-values (must be last)
ATTACHMENT_COUNT = 6,
};
GeometryBuffer() : bufferName(NULL) { Init(); }
~GeometryBuffer() { Kill(); }
void Init();
void Kill();
void DetachTextures(const bool init);
void DrawDebug(unsigned int texID);
void SetName(const char* name) { bufferName = name; }
bool HasAttachments() const { return (bufferTextureIDs[0] != 0); }
bool Valid() const { return (buffer.IsValid()); }
bool Create(const int2 size);
bool Update(const bool init);
GLuint GetBufferTexture(unsigned int idx) const { return bufferTextureIDs[idx]; }
GLuint GetBufferAttachment(unsigned int idx) const { return bufferAttachments[idx]; }
const FBO& GetObject() const { return buffer; }
FBO& GetObject() { return buffer; }
void Bind() { buffer.Bind(); }
void UnBind() { buffer.Unbind(); }
int2 GetCurrSize() const { return currBufferSize; }
int2 GetPrevSize() const { return prevBufferSize; }
int2 GetWantedSize(bool allowed) const;
private:
FBO buffer;
GLuint bufferTextureIDs[ATTACHMENT_COUNT];
GLenum bufferAttachments[ATTACHMENT_COUNT];
int2 prevBufferSize;
int2 currBufferSize;
const char* bufferName;
};
}
#endif
|