TDME2  1.9.200
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BRDFLUTShader.cpp
Go to the documentation of this file.
2 
3 #include <tdme/tdme.h>
6 #include <tdme/engine/Engine.h>
7 
9 
13 
14 BRDFLUTShader::BRDFLUTShader(Renderer* renderer)
15 {
16  this->renderer = renderer;
17 }
18 
20 {
21 }
22 
24 {
25  return initialized;
26 }
27 
29 {
30  auto shaderVersion = renderer->getShaderVersion();
33  "shader/" + shaderVersion + "/framebuffer",
34  "render_vertexshader.vert"
35  );
36  if (vertexShaderId == 0) return;
37 
40  "shader/" + shaderVersion + "/framebuffer/brdflut",
41  "render_brdflut_fragmentshader.frag"
42  );
43  if (fragmentShaderId == 0) return;
44 
51  }
52  if (renderer->linkProgram(programId) == false) return;
53 
54  //
57 
58  //
59  initialized = true;
60 }
61 
63  // use default context
64  auto contextIdx = renderer->CONTEXTINDEX_DEFAULT;
65 
66  //
70 
71  //
72  renderer->useProgram(contextIdx, programId);
74 
75  //
78  renderer->disableCulling(contextIdx);
79 
80  // clear
81  renderer->setClearColor(0.0f, 0.0f, 0.0f, 1.0f);
83 
84  // use frame buffer render shader
85  auto frameBufferRenderShader = Engine::getFrameBufferRenderShader();
86 
87  //
88  renderer->bindVerticesBufferObject(contextIdx, frameBufferRenderShader->getVBOVertices());
89  renderer->bindTextureCoordinatesBufferObject(contextIdx, frameBufferRenderShader->getVBOTextureCoordinates());
90 
91  // draw
92  renderer->drawTrianglesFromBufferObjects(contextIdx, 2, 0);
93 
94  // unbind buffers
95  renderer->unbindBufferObjects(contextIdx);
96 
97  // unset
98  renderer->enableCulling(contextIdx);
101 
102  //
103  renderer->bindFrameBuffer(Engine::getRenderer()->FRAMEBUFFER_DEFAULT);
106 }
Engine main class.
Definition: Engine.h:131
static FrameBufferRenderShader * getFrameBufferRenderShader()
Definition: Engine.h:490
static Renderer * getRenderer()
Definition: Engine.h:434
static STATIC_DLL_IMPEXT Engine * instance
Definition: Engine.h:204
virtual int32_t loadShader(int32_t type, const string &pathName, const string &fileName, const string &definitions=string(), const string &functions=string())=0
Loads a shader.
virtual void setViewPort(int32_t width, int32_t height)=0
Set up viewport parameter.
virtual void enableCulling(int contextIdx)=0
Enable culling.
virtual void enableDepthBufferTest()=0
Enable depth buffer test.
virtual void enableDepthBufferWriting()=0
Enable depth buffer writing.
virtual void unbindBufferObjects(int contextIdx)=0
Unbind buffer objects.
virtual void setClearColor(float red, float green, float blue, float alpha)=0
Set up clear color.
virtual int32_t createProgram(int type)=0
Creates a shader program.
virtual void updateViewPort()=0
Update viewport.
virtual void setProgramAttributeLocation(int32_t programId, int32_t location, const string &name)=0
Bind attribute to a input location.
virtual int32_t createFramebufferObject(int32_t depthBufferTextureId, int32_t colorBufferTextureId, int32_t cubeMapTextureId=0, int32_t cubeMapTextureIndex=0)=0
Creates a frame buffer object with depth texture attached.
virtual bool linkProgram(int32_t programId)=0
Links attached shaders to a program.
virtual void disableDepthBufferWriting()=0
Disable depth buffer writing.
void setLighting(int contextIdx, int32_t lighting)
Set current lighting model.
Definition: Renderer.h:504
virtual void attachShaderToProgram(int32_t programId, int32_t shaderId)=0
Attaches a shader to a program.
virtual int32_t createGBufferGeometryTexture(int32_t width, int32_t height)=0
Creates a geometry buffer geometry texture.
virtual void drawTrianglesFromBufferObjects(int contextIdx, int32_t triangles, int32_t trianglesOffset)=0
Draw triangles from buffer objects.
virtual void bindFrameBuffer(int32_t frameBufferId)=0
Enables a framebuffer to be rendered.
virtual void clear(int32_t mask)=0
Clear render buffer with given mask.
virtual void disableCulling(int contextIdx)=0
Disable culling.
virtual void bindTextureCoordinatesBufferObject(int contextIdx, int32_t bufferObjectId)=0
Bind texture coordinates buffer object.
virtual void useProgram(int contextIdx, int32_t programId)=0
Use shader program.
virtual void bindVerticesBufferObject(int contextIdx, int32_t bufferObjectId)=0
Bind vertices buffer object.
virtual void disableDepthBufferTest()=0
Disable depth buffer test.