3#define GL_GLEXT_PROTOTYPES
52GLES2Renderer::GLES2Renderer()
80 auto vendor = (
char*)glGetString(GL_VENDOR);
81 return string(vendor);
85 auto renderer = (
char*)glGetString(GL_RENDERER);
86 return string(renderer) +
" [GLES2]";
105 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
107 glEnable(GL_DEPTH_TEST);
108 glEnable(GL_CULL_FACE);
109 glDepthFunc(GL_LEQUAL);
110 glBlendEquation(GL_FUNC_ADD);
115 for (
auto i = 0; i < rendererContext.lights.size(); i++) {
116 rendererContext.lights[i].spotCosCutoff =
static_cast<float>(Math::cos(Math::PI / 180.0f * 180.0f));
118 rendererContext.textureMatrix.identity();
191int32_t
GLES2Renderer::loadShader(int32_t type,
const string& pathName,
const string& fileName,
const string& definitions,
const string& functions)
194 int32_t handle = glCreateShader(type);
196 if (handle == 0)
return 0;
198 auto shaderSource = StringTools::replace(
199 StringTools::replace(
200 FileSystem::getInstance()->getContentAsString(pathName, fileName),
207 string sourceString = (shaderSource);
208 char *sourceHeap =
new char[sourceString.length() + 1];
209 strcpy(sourceHeap, sourceString.c_str());
211 glShaderSource(handle, 1, &sourceHeap,
nullptr);
213 glCompileShader(handle);
215 int32_t compileStatus;
216 glGetShaderiv(handle, GL_COMPILE_STATUS, &compileStatus);
217 if (compileStatus == 0) {
219 int32_t infoLogLengthBuffer;
220 glGetShaderiv(handle, GL_INFO_LOG_LENGTH, &infoLogLengthBuffer);
221 char infoLogBuffer[infoLogLengthBuffer];
222 glGetShaderInfoLog(handle, infoLogLengthBuffer, &infoLogLengthBuffer, infoLogBuffer);
223 auto infoLogString = (string(infoLogBuffer, infoLogLengthBuffer));
227 string(
"GLES2Renderer::loadShader") +
234 string(
": failed: ") +
239 glDeleteShader(handle);
248 glUseProgram(programId);
253 auto program = glCreateProgram();
259 glAttachShader(programId, shaderId);
264 glLinkProgram(programId);
267 glGetProgramiv(programId, GL_LINK_STATUS, &linkStatus);
268 if (linkStatus == 0) {
270 int32_t infoLogLength = 0;
271 glGetProgramiv(programId, GL_INFO_LOG_LENGTH, &infoLogLength);
272 char infoLog[infoLogLength];
273 glGetProgramInfoLog(programId, infoLogLength, &infoLogLength, infoLog);
274 auto infoLogString = (string(infoLog, infoLogLength));
279 to_string(programId) +
291 auto uniformLocation = glGetUniformLocation(programId, name.c_str());
293 return uniformLocation;
298 glUniform1i(uniformId, value);
303 glUniform1f(uniformId, value);
308 glUniformMatrix3fv(uniformId, 1,
false, data.data());
313 glUniformMatrix4fv(uniformId, 1,
false, data.data());
318 glUniformMatrix4fv(uniformId, count,
false, (
float*)data->
getBuffer());
323 glUniform4fv(uniformId, 1, data.data());
328 glUniform3fv(uniformId, 1, data.data());
333 glUniform2fv(uniformId, 1, data.data());
338 glBindAttribLocation(programId, location, (name).c_str());
354 glClearColor(red, green, blue, alpha);
359 glEnable(GL_CULL_FACE);
364 glDisable(GL_CULL_FACE);
369 glFrontFace(frontFace);
374 glCullFace(cullFace);
379 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
384 glBlendFunc(GL_ONE, GL_ONE);
405 glDisable(GL_DEPTH_TEST);
410 glEnable(GL_DEPTH_TEST);
416 glDepthFunc(depthFunction);
421 glColorMask(red, green, blue, alpha);
433 glGenTextures(1, &textureId);
439 uint32_t depthTextureId;
441 glGenTextures(1, &depthTextureId);
442 glBindTexture(GL_TEXTURE_2D, depthTextureId);
444 glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, width, height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT,
nullptr);
446 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
447 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
448 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
449 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
451 glBindTexture(GL_TEXTURE_2D,
ID_NONE);
452 return depthTextureId;
457 uint32_t colorBufferTextureId;
459 glGenTextures(1, &colorBufferTextureId);
460 glBindTexture(GL_TEXTURE_2D, colorBufferTextureId);
462 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE,
nullptr);
464 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
465 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
466 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
467 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
469 glBindTexture(GL_TEXTURE_2D,
ID_NONE);
470 return colorBufferTextureId;
474 Console::println(
"GLES2Renderer::createGBufferGeometryTexture(): Not implemented");
479 Console::println(
"GLES2Renderer::createGBufferColorTexture(): Not implemented");
488 texture->
getDepth() == 32?GL_RGBA:GL_RGB,
492 texture->
getDepth() == 32?GL_RGBA:GL_RGB,
498 glGenerateMipmap(GL_TEXTURE_2D);
500 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
501 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
503 if (texture->
isUseMipMap() ==
true) glGenerateMipmap(GL_TEXTURE_2D);
505 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
506 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
517 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, texture->
isUseMipMap() ==
true?GL_LINEAR_MIPMAP_LINEAR:GL_LINEAR);
518 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
524 GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
526 textureLeft->
getDepth() == 32?GL_RGBA:GL_RGB,
530 textureLeft->
getDepth() == 32?GL_RGBA:GL_RGB,
535 GL_TEXTURE_CUBE_MAP_POSITIVE_X,
537 textureRight->
getDepth() == 32?GL_RGBA:GL_RGB,
541 textureRight->
getDepth() == 32?GL_RGBA:GL_RGB,
546 GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
548 textureTop->
getDepth() == 32?GL_RGBA:GL_RGB,
552 textureTop->
getDepth() == 32?GL_RGBA:GL_RGB,
557 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
559 textureBottom->
getDepth() == 32?GL_RGBA:GL_RGB,
563 textureBottom->
getDepth() == 32?GL_RGBA:GL_RGB,
568 GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
570 textureFront->
getDepth() == 32?GL_RGBA:GL_RGB,
574 textureFront->
getDepth() == 32?GL_RGBA:GL_RGB,
579 GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,
581 textureBack->
getDepth() == 32?GL_RGBA:GL_RGB,
585 textureBack->
getDepth() == 32?GL_RGBA:GL_RGB,
589 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
590 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
591 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
592 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
599 glGenTextures(1, &textureId);
600 glBindTexture(GL_TEXTURE_CUBE_MAP, textureId);
601 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
602 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
603 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
604 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
606 GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
617 GL_TEXTURE_CUBE_MAP_POSITIVE_X,
628 GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
639 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
650 GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
661 GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,
671 glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
677 glBindTexture(GL_TEXTURE_2D, textureId);
678 glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, width, height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT,
nullptr);
679 glBindTexture(GL_TEXTURE_2D, 0);
684 glBindTexture(GL_TEXTURE_2D, textureId);
685 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE,
nullptr);
686 glBindTexture(GL_TEXTURE_2D, 0);
690 Console::println(
"GLES2Renderer::resizeGBufferGeometryTexture(): Not implemented");
694 Console::println(
"GLES2Renderer::resizeGBufferColorTexture(): Not implemented");
699 glBindTexture(GL_TEXTURE_2D, textureId);
704 glBindTexture(GL_TEXTURE_CUBE_MAP, textureId);
710 glDeleteTextures(1, (
const uint32_t*)&textureId);
716 uint32_t frameBufferId;
718 glGenFramebuffers(1, &frameBufferId);
719 glBindFramebuffer(GL_FRAMEBUFFER, frameBufferId);
721 if (depthBufferTextureId !=
ID_NONE) {
722 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthBufferTextureId, 0);
725 if (colorBufferTextureId !=
ID_NONE) {
726 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorBufferTextureId, 0);
730 if (cubeMapTextureId !=
ID_NONE) {
731 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, cubeMapTextureIndex, cubeMapTextureId, 0);
737 auto fboStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER);
738 if (fboStatus != GL_FRAMEBUFFER_COMPLETE) {
739 Console::println(
string(
"GL_FRAMEBUFFER_COMPLETE_EXT failed, CANNOT use FBO: "+ to_string(fboStatus)));
742 glBindFramebuffer(GL_FRAMEBUFFER, 0);
743 return frameBufferId;
747 int32_t depthBufferTextureId,
748 int32_t geometryBufferTextureId1,
749 int32_t geometryBufferTextureId2,
750 int32_t geometryBufferTextureId3,
751 int32_t colorBufferTextureId1,
752 int32_t colorBufferTextureId2,
753 int32_t colorBufferTextureId3,
754 int32_t colorBufferTextureId4,
755 int32_t colorBufferTextureId5
757 Console::println(
string(
"GLES2Renderer::createGeometryBufferObject()::not implemented yet"));
763 glBindFramebuffer(GL_FRAMEBUFFER, frameBufferId);
768 glDeleteFramebuffers(1, (
const uint32_t*)&frameBufferId);
773 vector<int32_t> bufferObjectIds;
774 bufferObjectIds.resize(buffers);
775 glGenBuffers(buffers, (uint32_t*)bufferObjectIds.data());
776 for (
auto bufferObjectId: bufferObjectIds)
vbosUsage[bufferObjectId] = useGPUMemory ==
true?GL_STATIC_DRAW:GL_STREAM_DRAW;
777 return bufferObjectIds;
782 glBindBuffer(GL_ARRAY_BUFFER, bufferObjectId);
784 glBindBuffer(GL_ARRAY_BUFFER,
ID_NONE);
790 glBindBuffer(GL_ARRAY_BUFFER, bufferObjectId);
792 glBindBuffer(GL_ARRAY_BUFFER,
ID_NONE);
798 glBindBuffer(GL_ARRAY_BUFFER, bufferObjectId);
800 glBindBuffer(GL_ARRAY_BUFFER,
ID_NONE);
806 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferObjectId);
807 glBufferData(GL_ELEMENT_ARRAY_BUFFER, size, data->
getBuffer(),
vbosUsage[bufferObjectId]);
808 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,
ID_NONE);
814 Console::println(
"GLES2Renderer::uploadIndicesBufferObject()::not implemented");
819 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferObjectId);
824 glBindBuffer(GL_ARRAY_BUFFER, bufferObjectId);
825 glEnableVertexAttribArray(2);
826 glVertexAttribPointer(2, 2, GL_FLOAT,
false, 0, 0LL);
831 glBindBuffer(GL_ARRAY_BUFFER, bufferObjectId);
832 glEnableVertexAttribArray(0);
833 glVertexAttribPointer(0, 3, GL_FLOAT,
false, 0, 0LL);
838 glBindBuffer(GL_ARRAY_BUFFER, bufferObjectId);
839 glEnableVertexAttribArray(1);
840 glVertexAttribPointer(1, 3, GL_FLOAT,
false, 0, 0LL);
845 glBindBuffer(GL_ARRAY_BUFFER, bufferObjectId);
846 glEnableVertexAttribArray(3);
847 glVertexAttribPointer(3, 4, GL_FLOAT,
false, 0, 0LL);
852 Console::println(
"GLES2Renderer::bindTangentsBufferObject()::not implemented");
857 Console::println(
"GLES2Renderer::bindBitangentsBufferObject()::not implemented");
861 Console::println(
string(
"GLES2Renderer::bindModelViewMatricesBufferObject()::not implemented yet"));
865 glBindBuffer(GL_ARRAY_BUFFER, bufferObjectId);
866 glEnableVertexAttribArray(10);
867 glVertexAttribPointer(10, 4, GL_FLOAT,
false, 0, 0LL);
871 glBindBuffer(GL_ARRAY_BUFFER, bufferObjectId);
872 glEnableVertexAttribArray(11);
873 glVertexAttribPointer(11, 4, GL_FLOAT,
false, 0, 0LL);
877 glBindBuffer(GL_ARRAY_BUFFER, bufferObjectId);
878 glEnableVertexAttribArray(4);
879 glVertexAttribPointer(4, 3, GL_FLOAT,
false, 0, 0LL);
883 glBindBuffer(GL_ARRAY_BUFFER, bufferObjectId);
884 glEnableVertexAttribArray(1);
885 glVertexAttribPointer(1, 2, GL_FLOAT,
false, 0, 0LL);
889 glBindBuffer(GL_ARRAY_BUFFER, bufferObjectId);
890 glEnableVertexAttribArray(5);
891 glVertexAttribPointer(5, 1, GL_FLOAT,
false, 0, 0LL);
895 glBindBuffer(GL_ARRAY_BUFFER, bufferObjectId);
896 glEnableVertexAttribArray(6);
897 glVertexAttribPointer(6, 2, GL_FLOAT,
false, 0, 0LL);
902 Console::println(
string(
"GLES2Renderer::drawInstancedIndexedTrianglesFromBufferObjects()::not implemented yet"));
907 #define BUFFER_OFFSET(i) ((void*)(i))
908 glDrawElements(GL_TRIANGLES, triangles * 3, GL_UNSIGNED_SHORT,
BUFFER_OFFSET(
static_cast< int64_t
>(trianglesOffset) * 3LL * 2LL));
915 Console::println(
string(
"GL2Renderer::drawInstancedTrianglesFromBufferObjects()::not implemented yet"));
920 glDrawArrays(GL_TRIANGLES, trianglesOffset * 3, triangles * 3);
928 glDrawArrays(GL_POINTS, pointsOffset, points);
935 glLineWidth(lineWidth);
940 glDrawArrays(GL_LINES, pointsOffset, points);
947 glDisableVertexAttribArray(0);
948 glDisableVertexAttribArray(1);
949 glDisableVertexAttribArray(2);
950 glDisableVertexAttribArray(3);
951 glDisableVertexAttribArray(4);
952 glBindBuffer(GL_ARRAY_BUFFER, 0);
953 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
958 for (
auto& bufferObjectId: bufferObjectIds)
vbosUsage.erase(bufferObjectId);
959 glDeleteBuffers(bufferObjectIds.size(), (
const uint32_t*)bufferObjectIds.data());
971 glActiveTexture(GL_TEXTURE0 + textureUnit);
987 glBindTexture(GL_TEXTURE_2D,
ID_NONE);
988 glBlendEquationSeparate(GL_FUNC_ADD, GL_FUNC_ADD);
989 glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
991 glDisable(GL_DEPTH_TEST);
992 glDisable(GL_CULL_FACE);
997 glBindTexture(GL_TEXTURE_2D,
ID_NONE);
999 glEnable(GL_DEPTH_TEST);
1000 glEnable(GL_CULL_FACE);
1004 Console::println(
"GLES2Renderer::dispatchCompute(): Not implemented");
1008 Console::println(
"GLES2Renderer::memoryBarrier(): Not implemented");
1012 Console::println(
"GLES2Renderer::uploadSkinningBufferObject(): Not implemented");
1016 Console::println(
"GLES2Renderer::uploadSkinningBufferObject(): Not implemented");
1020 Console::println(
"GLES2Renderer::bindSkinningVerticesBufferObject(): Not implemented");
1024 Console::println(
"GLES2Renderer::bindSkinningNormalsBufferObject(): Not implemented");
1028 Console::println(
"GLES2Renderer::bindSkinningVertexJointsBufferObject(): Not implemented");
1032 Console::println(
"GLES2Renderer::bindSkinningVertexJointIdxsBufferObject(): Not implemented");
1036 Console::println(
"GLES2Renderer::bindSkinningVertexJointWeightsBufferObject(): Not implemented");
1040 Console::println(
"GLES2Renderer::bindSkinningVerticesResultBufferObject(): Not implemented");
1044 Console::println(
"GLES2Renderer::bindSkinningNormalsResultBufferObject(): Not implemented");
1048 Console::println(
"GLES2Renderer::bindSkinningMatricesBufferObject(): Not implemented");
1079 auto error = glGetError();
1080 if (error != GL_NO_ERROR) {
1081 Console::println(
string(
"OpenGL Error: (" + to_string(error) +
") @:"));
ByteBuffer * getTextureData()
int32_t getAtlasSize() const
int32_t getTextureHeight() const
int32_t getTextureWidth() const
void setClearColor(float red, float green, float blue, float alpha) override
Set up clear color.
void enableDepthBufferWriting() override
Enable depth buffer writing.
const string getShaderVersion() override
void bindSpriteSheetDimensionBufferObject(int contextIdx, int32_t bufferObjectId) override
Bind sprite sheet dimension buffer object.
void bindTexture(int contextIdx, int32_t textureId) override
Binds a texture with given id or unbinds when using ID_NONE.
void clear(int32_t mask) override
Clear render buffer with given mask.
void bindTangentsBufferObject(int contextIdx, int32_t bufferObjectId) override
Bind tangents buffer object.
void disposeBufferObjects(vector< int32_t > &bufferObjectIds) override
Disposes a frame buffer object.
int32_t getTextureUnit(int contextIdx) override
Get texture unit.
void setProgramUniformFloatMatrix3x3(int contextIdx, int32_t uniformId, const array< float, 9 > &data) override
Set up a float matrix 3x3 uniform value.
map< uint32_t, int32_t > vbosUsage
void doneGuiMode() override
Set up renderer for 3d rendering.
void setColorMask(bool red, bool green, bool blue, bool alpha) override
Set up GL rendering colormask.
void bindTextureCoordinatesBufferObject(int contextIdx, int32_t bufferObjectId) override
Bind texture coordinates buffer object.
void bindSkinningVertexJointWeightsBufferObject(int contextIdx, int32_t bufferObjectId) override
Bind skinning vertex joint weights buffer object.
void dispatchCompute(int contextIdx, int32_t numGroupsX, int32_t numGroupsY, int32_t numGroupsZ) override
Dispatch compute.
bool isGLCLAvailable() override
void attachShaderToProgram(int32_t programId, int32_t shaderId) override
Attaches a shader to a program.
void setFrontFace(int contextIdx, int32_t frontFace) override
Set up clock wise or counter clock wise faces as front face.
void setTextureUnit(int contextIdx, int32_t textureUnit) override
Sets up texture unit.
void drawLinesFromBufferObjects(int contextIdx, int32_t points, int32_t pointsOffset) override
Draw lines from buffer objects.
void disableBlending() override
Disables blending.
void setProgramAttributeLocation(int32_t programId, int32_t location, const string &name) override
Bind attribute to a input location.
void setViewPort(int32_t width, int32_t height) override
Set up viewport parameter.
bool isSupportingMultithreadedRendering() override
int32_t getTextureUnits() override
void bindSkinningVerticesResultBufferObject(int contextIdx, int32_t bufferObjectId) override
Bind skinning vertices result buffer object.
void setProgramUniformFloat(int contextIdx, int32_t uniformId, float value) override
Set up a float uniform value.
const string getRenderer() override
const Renderer_Statistics getStatistics() override
void initialize() override
Initialize renderer.
void setVSync(bool vSync) override
Enable/Disable v-sync.
int32_t createGBufferColorTexture(int32_t width, int32_t height) override
Creates a geometry buffer color RGBA texture.
void setProgramUniformFloatVec3(int contextIdx, int32_t uniformId, const array< float, 3 > &data) override
Set up a float vec3 uniform value.
bool isSupportingIntegerProgramAttributes() override
void bindEffectColorAddsBufferObject(int contextIdx, int32_t bufferObjectId, int32_t divisor) override
Bind effect color adds buffer object.
bool isBufferObjectsAvailable() override
Checks if buffer objects is available.
void disposeFrameBufferObject(int32_t frameBufferId) override
Disposes a frame buffer object.
const string getVendor() override
void uploadBufferObject(int contextIdx, int32_t bufferObjectId, int32_t size, FloatBuffer *data) override
Uploads buffer data to buffer object.
void memoryBarrier() override
Memory barrier.
void setProgramUniformInteger(int contextIdx, int32_t uniformId, int32_t value) override
Set up a integer uniform value.
int32_t getProgramUniformLocation(int32_t programId, const string &name) override
Returns location of given uniform variable.
void disableDepthBufferWriting() override
Disable depth buffer writing.
void bindSkinningVertexJointIdxsBufferObject(int contextIdx, int32_t bufferObjectId) override
Bind skinning vertex joint indices buffer object.
void bindNormalsBufferObject(int contextIdx, int32_t bufferObjectId) override
Bind normals buffer object.
void drawPointsFromBufferObjects(int contextIdx, int32_t points, int32_t pointsOffset) override
Draw points from buffer objects.
void drawInstancedTrianglesFromBufferObjects(int contextIdx, int32_t triangles, int32_t trianglesOffset, int32_t instances) override
Draw instanced triangles from buffer objects.
void disposeTexture(int32_t textureId) override
Dispose a texture.
int32_t createColorBufferTexture(int32_t width, int32_t height, int32_t cubeMapTextureId, int32_t cubeMapTextureIndex) override
Creates a color buffer texture.
void disableCulling(int contextIdx) override
Disable culling.
void bindEffectColorMulsBufferObject(int contextIdx, int32_t bufferObjectId, int32_t divisor) override
Bind effect color muls buffer object.
int32_t createCubeMapTexture(int contextIdx, int32_t width, int32_t height) override
Create cube map texture from frame buffers.
int32_t createFramebufferObject(int32_t depthBufferTextureId, int32_t colorBufferTextureId, int32_t cubeMapTextureId=0, int32_t cubeMapTextureIndex=0) override
Creates a frame buffer object with depth texture attached.
int32_t createDepthBufferTexture(int32_t width, int32_t height, int32_t cubeMapTextureId, int32_t cubeMapTextureIndex) override
Creates a depth buffer texture.
void bindCubeMapTexture(int contextIdx, int32_t textureId) override
Binds a cube map texture with given id or unbinds when using ID_NONE.
bool isPBRAvailable() override
void setProgramUniformFloatVec4(int contextIdx, int32_t uniformId, const array< float, 4 > &data) override
Set up a float vec4 uniform value.
void setDepthFunction(int32_t depthFunction) override
Set up depth function.
void uploadCubeMapTexture(int contextIdx, Texture *textureLeft, Texture *textureRight, Texture *textureTop, Texture *textureBottom, Texture *textureFront, Texture *textureBack) override
Uploads cube map texture data to current bound texture.
void bindFrameBuffer(int32_t frameBufferId) override
Enables a framebuffer to be rendered.
int32_t loadShader(int32_t type, const string &pathName, const string &fileName, const string &definitions=string(), const string &functions=string()) override
Loads a shader.
bool isNormalMappingAvailable() override
bool isDepthTextureAvailable() override
Checks if depth texture is available.
void resizeDepthBufferTexture(int32_t textureId, int32_t width, int32_t height) override
Resizes a depth texture.
void resizeGBufferGeometryTexture(int32_t textureId, int32_t width, int32_t height) override
Resizes a geometry buffer geometry texture.
void finishFrame() override
Finish frame.
bool isInstancedRenderingAvailable() override
Checks if instanced rendering is available.
void drawTrianglesFromBufferObjects(int contextIdx, int32_t triangles, int32_t trianglesOffset) override
Draw triangles from buffer objects.
bool isSpecularMappingAvailable() override
void initGuiMode() override
Set up renderer for GUI rendering.
void bindSkinningVertexJointsBufferObject(int contextIdx, int32_t bufferObjectId) override
Bind skinning vertex joints buffer object.
void setCullFace(int32_t cullFace) override
Sets up which face will be culled.
void enableBlending() override
Enables blending.
void uploadIndicesBufferObject(int contextIdx, int32_t bufferObjectId, int32_t size, ShortBuffer *data) override
Uploads buffer data to buffer object.
bool linkProgram(int32_t programId) override
Links attached shaders to a program.
void setProgramUniformFloatMatrix4x4(int contextIdx, int32_t uniformId, const array< float, 16 > &data) override
Set up a float matrix 4x4 uniform value.
void enableCulling(int contextIdx) override
Enable culling.
void bindOriginsBufferObject(int contextIdx, int32_t bufferObjectId) override
Bind origins buffer object.
int32_t createProgram(int type) override
Creates a shader program.
void bindIndicesBufferObject(int contextIdx, int32_t bufferObjectId) override
Bind indices buffer object.
bool isComputeShaderAvailable() override
void initializeFrame() override
Pre Frame Initialization.
int32_t createGBufferGeometryTexture(int32_t width, int32_t height) override
Creates a geometry buffer geometry texture.
void uploadSkinningBufferObject(int contextIdx, int32_t bufferObjectId, int32_t size, FloatBuffer *data) override
Upload skinning buffer object.
void enableAdditionBlending() override
Enable blending with c = a + b.
void bindVerticesBufferObject(int contextIdx, int32_t bufferObjectId) override
Bind vertices buffer object.
void drawInstancedIndexedTrianglesFromBufferObjects(int contextIdx, int32_t triangles, int32_t trianglesOffset, int32_t instances) override
Draw instanced indexed triangles from buffer objects.
void useProgram(int contextIdx, int32_t programId) override
Use shader program.
void bindColorsBufferObject(int contextIdx, int32_t bufferObjectId) override
Bind colors buffer object.
void bindPointSizesBufferObject(int contextIdx, int32_t bufferObjectId) override
Bind point sizes buffer object.
void bindSkinningVerticesBufferObject(int contextIdx, int32_t bufferObjectId) override
Bind skinning vertices buffer object.
void bindBitangentsBufferObject(int contextIdx, int32_t bufferObjectId) override
Bind bitangents buffer object.
void bindSkinningNormalsResultBufferObject(int contextIdx, int32_t bufferObjectId) override
Bind skinning normals result buffer object.
void setProgramUniformFloatMatrices4x4(int contextIdx, int32_t uniformId, int32_t count, FloatBuffer *data) override
Set up a float matrices 4x4 uniform values.
void resizeGBufferColorTexture(int32_t textureId, int32_t width, int32_t height) override
Resizes a geometry buffer color RGBA texture.
void bindSkinningMatricesBufferObject(int contextIdx, int32_t bufferObjectId) override
Bind skinning matrices result buffer object.
int32_t createGeometryBufferObject(int32_t depthBufferTextureId, int32_t geometryBufferTextureId1, int32_t geometryBufferTextureId2, int32_t geometryBufferTextureId3, int32_t colorBufferTextureId1, int32_t colorBufferTextureId2, int32_t colorBufferTextureId3, int32_t colorBufferTextureId4, int32_t colorBufferTextureId5) override
Creates a geometry frame buffer object.
vector< int32_t > createBufferObjects(int32_t buffers, bool useGPUMemory, bool shared) override
Generate buffer objects for vertex data and such.
void updateViewPort() override
Update viewport.
void bindModelMatricesBufferObject(int contextIdx, int32_t bufferObjectId) override
Bind model matrices buffer object.
void drawIndexedTrianglesFromBufferObjects(int contextIdx, int32_t triangles, int32_t trianglesOffset) override
Draw indexed triangles from buffer objects.
void disableDepthBufferTest() override
Disable depth buffer test.
void bindSkinningNormalsBufferObject(int contextIdx, int32_t bufferObjectId) override
Bind skinning normal buffer object.
void unbindBufferObjects(int contextIdx) override
Unbind buffer objects.
int32_t createTexture() override
Creates a texture.
float readPixelDepth(int32_t x, int32_t y) override
Reads a pixel depth.
void uploadTexture(int contextIdx, Texture *texture) override
Uploads texture data to current bound texture.
bool isUsingShortIndices() override
void checkGLError()
Checks if GL error did occour.
void setLineWidth(float lineWidth) override
Set line width.
ByteBuffer * readPixels(int32_t x, int32_t y, int32_t width, int32_t height) override
Read pixels.
void enableDepthBufferTest() override
Enable depth buffer test.
void resizeColorBufferTexture(int32_t textureId, int32_t width, int32_t height) override
Resize color buffer texture.
void bindTextureSpriteIndicesBufferObject(int contextIdx, int32_t bufferObjectId) override
Bind texture and sprite indices buffer object.
void setProgramUniformFloatVec2(int contextIdx, int32_t uniformId, const array< float, 2 > &data) override
Set up a float vec2 uniform value.
bool isDeferredShadingAvailable() override
bool isUsingProgramAttributeLocation() override
int32_t CUBEMAPTEXTUREINDEX_NEGATIVE_Z
int32_t SHADER_FRAGMENT_SHADER
Renderer_Statistics statistics
int32_t SHADER_COMPUTE_SHADER
int32_t SHADER_VERTEX_SHADER
int32_t CLEAR_COLOR_BUFFER_BIT
int32_t CUBEMAPTEXTUREINDEX_NEGATIVE_X
int32_t CUBEMAPTEXTUREINDEX_POSITIVE_Y
vector< Renderer_Context > rendererContexts
int32_t CUBEMAPTEXTUREINDEX_NEGATIVE_Y
virtual void onBindTexture(int contextIdx, int32_t textureId)=0
On bind texture event.
RendererType rendererType
int32_t DEPTHFUNCTION_ALWAYS
int32_t DEPTHFUNCTION_LESSEQUAL
int32_t DEPTHFUNCTION_GREATEREQUAL
int32_t CUBEMAPTEXTUREINDEX_POSITIVE_Z
int32_t CONTEXTINDEX_DEFAULT
int32_t DEPTHFUNCTION_EQUAL
int32_t FRAMEBUFFER_DEFAULT
int32_t CUBEMAPTEXTUREINDEX_POSITIVE_X
int32_t CLEAR_DEPTH_BUFFER_BIT
File system singleton class.
Bean holding light properties.
uint32_t disposedTextures
int64_t memoryUsageShared