5#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__linux__) || defined(_WIN32) || defined(__HAIKU__)
58GL2Renderer::GL2Renderer()
88 auto vendor = glGetString(GL_VENDOR);
89 return string((
char*)vendor);
93 auto renderer = glGetString(GL_RENDERER);
94 return string((
char*)renderer) +
" [GL2/3]";
110 auto extensionOK =
true;
112 auto functionsOK =
true;
113 return extensionOK ==
true && functionsOK ==
true;
129 glShadeModel(GL_SMOOTH);
130 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
132 glEnable(GL_DEPTH_TEST);
133 glEnable(GL_CULL_FACE);
134 glDepthFunc(GL_LEQUAL);
135 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
136 glBlendEquation(GL_FUNC_ADD);
138 glEnable(GL_POINT_SPRITE);
139 glEnable(GL_PROGRAM_POINT_SIZE_EXT);
144 for (
auto i = 0; i < rendererContext.lights.size(); i++) {
145 rendererContext.lights[i].spotCosCutoff =
static_cast<float>(Math::cos(Math::PI / 180.0f * 180.0f));
147 rendererContext.textureMatrix.identity();
213int32_t
GL2Renderer::loadShader(int32_t type,
const string& pathName,
const string& fileName,
const string& definitions,
const string& functions)
216 int32_t handle = glCreateShader(type);
218 if (handle == 0)
return 0;
220 auto shaderSource = StringTools::replace(
221 StringTools::replace(
222 FileSystem::getInstance()->getContentAsString(pathName, fileName),
230 shaderSource = StringTools::replace(shaderSource,
"#version 100",
"#version 120");
231 shaderSource = StringTools::replace(shaderSource,
"\r",
"");
235 shaderSource.clear();
238 if (StringTools::startsWith(line,
"precision") ==
true)
continue;
239 shaderSource+= line +
"\n";
243 string sourceString = (shaderSource);
244 char* sourceHeap =
new char[sourceString.length() + 1];
245 strcpy(sourceHeap, sourceString.c_str());
247 glShaderSource(handle, 1, &sourceHeap,
nullptr);
249 glCompileShader(handle);
251 delete [] sourceHeap;
253 int32_t compileStatus;
254 glGetShaderiv(handle, GL_COMPILE_STATUS, &compileStatus);
256 if (compileStatus == 0) {
257 int32_t infoLogLengthBuffer;
258 glGetShaderiv(handle, GL_INFO_LOG_LENGTH, &infoLogLengthBuffer);
259 char* infoLogBuffer =
new char[infoLogLengthBuffer];
260 glGetShaderInfoLog(handle, infoLogLengthBuffer, &infoLogLengthBuffer, infoLogBuffer);
261 auto infoLogString = (string(infoLogBuffer, infoLogLengthBuffer));
265 string(
"GL2Renderer::loadShader") +
272 string(
": failed: ") +
276 Console::println(shaderSource);
278 delete [] infoLogBuffer;
280 glDeleteShader(handle);
291 glUseProgram(programId);
296 auto programId = glCreateProgram();
302 glAttachShader(programId, shaderId);
307 glLinkProgram(programId);
310 glGetProgramiv(programId, GL_LINK_STATUS, &linkStatus);
311 if (linkStatus == 0) {
313 int32_t infoLogLength = 0;
314 glGetProgramiv(programId, GL_INFO_LOG_LENGTH, &infoLogLength);
315 char* infoLog =
new char[infoLogLength];
316 glGetProgramInfoLog(programId, infoLogLength, &infoLogLength, infoLog);
317 auto infoLogString = (string(infoLog, infoLogLength));
322 to_string(programId) +
335 auto uniformLocation = glGetUniformLocation(programId, (name).c_str());
336 return uniformLocation;
341 glUniform1i(uniformId, value);
346 glUniform1f(uniformId, value);
351 glUniformMatrix4fv(uniformId, count,
false, (
float*)data->
getBuffer());
356 glUniformMatrix3fv(uniformId, 1,
false, data.data());
361 glUniformMatrix4fv(uniformId, 1,
false, data.data());
366 glUniform4fv(uniformId, 1, data.data());
371 glUniform3fv(uniformId, 1, data.data());
376 glUniform2fv(uniformId, 1, data.data());
381 glBindAttribLocation(programId, location, (name).c_str());
397 glClearColor(red, green, blue, alpha);
402 glEnable(GL_CULL_FACE);
407 glDisable(GL_CULL_FACE);
412 glFrontFace(frontFace);
417 glCullFace(cullFace);
422 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
427 glBlendFunc(GL_ONE, GL_ONE);
448 glDisable(GL_DEPTH_TEST);
453 glEnable(GL_DEPTH_TEST);
458 glDepthFunc(depthFunction);
463 glColorMask(red, green, blue, alpha);
475 glGenTextures(1, &textureId);
481 uint32_t depthTextureId;
483 glGenTextures(1, &depthTextureId);
484 glBindTexture(GL_TEXTURE_2D, depthTextureId);
486 glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, width, height, 0, GL_DEPTH_COMPONENT, GL_FLOAT,
nullptr);
488 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
489 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
490 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
491 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
493 glBindTexture(GL_TEXTURE_2D,
ID_NONE);
494 return depthTextureId;
499 uint32_t colorBufferTextureId;
501 glGenTextures(1, &colorBufferTextureId);
502 glBindTexture(GL_TEXTURE_2D, colorBufferTextureId);
504 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE,
static_cast< Buffer*
>(
nullptr));
506 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
507 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
508 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
509 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
511 glBindTexture(GL_TEXTURE_2D,
ID_NONE);
512 return colorBufferTextureId;
516 Console::println(
"GL2Renderer::createGBufferGeometryTexture(): Not implemented");
521 Console::println(
"GL2Renderer::createGBufferColorTexture(): Not implemented");
530 texture->
getDepth() == 32?GL_RGBA:GL_RGB,
534 texture->
getDepth() == 32?GL_RGBA:GL_RGB,
541 glGetFloatv(GL_MAX_TEXTURE_LOD_BIAS, &maxLodBias);
542 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_LOD_BIAS, -Math::clamp(
static_cast<float>(texture->
getAtlasSize()) * 0.125f, 0.0f, maxLodBias));
543 auto borderSize = 32;
545 while (borderSize > 4) {
549 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
550 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, maxLevel - 1);
551 glGenerateMipmap(GL_TEXTURE_2D);
553 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
554 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
556 if (texture->
isUseMipMap() ==
true) glGenerateMipmap(GL_TEXTURE_2D);
558 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
559 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
561 float color[4] = {0.0f, 0.0f, 0.0f, 0.0f};
562 if (texture->
getClampMode() == Texture::CLAMPMODE_TRANSPARENTPIXEL) glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, color);
563 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, texture->
getClampMode() == Texture::CLAMPMODE_EDGE?GL_CLAMP_TO_EDGE:GL_CLAMP_TO_BORDER);
564 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, texture->
getClampMode() == Texture::CLAMPMODE_EDGE?GL_CLAMP_TO_EDGE:GL_CLAMP_TO_BORDER);
567 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, texture->
isUseMipMap() ==
true?GL_LINEAR_MIPMAP_LINEAR:GL_LINEAR);
568 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
574 GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
576 textureLeft->
getDepth() == 32?GL_RGBA:GL_RGB,
580 textureLeft->
getDepth() == 32?GL_RGBA:GL_RGB,
585 GL_TEXTURE_CUBE_MAP_POSITIVE_X,
587 textureRight->
getDepth() == 32?GL_RGBA:GL_RGB,
591 textureRight->
getDepth() == 32?GL_RGBA:GL_RGB,
596 GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
598 textureTop->
getDepth() == 32?GL_RGBA:GL_RGB,
602 textureTop->
getDepth() == 32?GL_RGBA:GL_RGB,
607 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
609 textureBottom->
getDepth() == 32?GL_RGBA:GL_RGB,
613 textureBottom->
getDepth() == 32?GL_RGBA:GL_RGB,
618 GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
620 textureFront->
getDepth() == 32?GL_RGBA:GL_RGB,
624 textureFront->
getDepth() == 32?GL_RGBA:GL_RGB,
629 GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,
631 textureBack->
getDepth() == 32?GL_RGBA:GL_RGB,
635 textureBack->
getDepth() == 32?GL_RGBA:GL_RGB,
639 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
640 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
641 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
642 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
643 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
650 glGenTextures(1, &textureId);
651 glBindTexture(GL_TEXTURE_CUBE_MAP, textureId);
652 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
653 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
654 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
655 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
656 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
658 GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
669 GL_TEXTURE_CUBE_MAP_POSITIVE_X,
680 GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
691 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
702 GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
713 GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,
723 glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
729 glBindTexture(GL_TEXTURE_2D, textureId);
730 glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, width, height, 0, GL_DEPTH_COMPONENT, GL_FLOAT,
nullptr);
731 glBindTexture(GL_TEXTURE_2D, 0);
736 glBindTexture(GL_TEXTURE_2D, textureId);
737 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE,
nullptr);
738 glBindTexture(GL_TEXTURE_2D, 0);
742 Console::println(
"GL2Renderer::resizeGBufferGeometryTexture(): Not implemented");
746 Console::println(
"GL2Renderer::resizeGBufferColorTexture(): Not implemented");
751 glBindTexture(GL_TEXTURE_2D, textureId);
756 glBindTexture(GL_TEXTURE_CUBE_MAP, textureId);
762 glDeleteTextures(1, (
const uint32_t*)&textureId);
769 uint32_t frameBufferId;
770 glGenFramebuffers(1, &frameBufferId);
771 glBindFramebuffer(GL_FRAMEBUFFER, frameBufferId);
773 if (depthBufferTextureId !=
ID_NONE) {
775 glFramebufferTextureEXT(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, depthBufferTextureId, 0);
777 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthBufferTextureId, 0);
781 if (colorBufferTextureId !=
ID_NONE) {
783 glFramebufferTextureEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, colorBufferTextureId, 0);
785 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorBufferTextureId, 0);
787 glDrawBuffer(GL_COLOR_ATTACHMENT0);
788 glReadBuffer(GL_COLOR_ATTACHMENT0);
790 if (cubeMapTextureId !=
ID_NONE) {
791 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, cubeMapTextureIndex, cubeMapTextureId, 0);
793 glDrawBuffer(GL_NONE);
794 glReadBuffer(GL_NONE);
797 int32_t fboStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER);
798 if (fboStatus != GL_FRAMEBUFFER_COMPLETE) {
799 Console::println(
string(
"GL_FRAMEBUFFER_COMPLETE_EXT failed, CANNOT use FBO: ") + to_string(fboStatus));
802 glBindFramebuffer(GL_FRAMEBUFFER, 0);
803 return frameBufferId;
807 int32_t depthBufferTextureId,
808 int32_t geometryBufferTextureId1,
809 int32_t geometryBufferTextureId2,
810 int32_t geometryBufferTextureId3,
811 int32_t colorBufferTextureId1,
812 int32_t colorBufferTextureId2,
813 int32_t colorBufferTextureId3,
814 int32_t colorBufferTextureId4,
815 int32_t colorBufferTextureId5
817 Console::println(
string(
"GL2Renderer::createGeometryBufferObject()::not implemented yet"));
823 glBindFramebuffer(GL_FRAMEBUFFER, frameBufferId);
828 glDeleteFramebuffers(1, (uint32_t*)&frameBufferId);
833 vector<int32_t> bufferObjectIds;
834 bufferObjectIds.resize(buffers);
835 glGenBuffers(buffers, (uint32_t*)bufferObjectIds.data());
836 for (
auto bufferObjectId: bufferObjectIds)
vbosUsage[bufferObjectId] = useGPUMemory ==
true?GL_STATIC_DRAW:GL_STREAM_DRAW;
837 return bufferObjectIds;
842 glBindBuffer(GL_ARRAY_BUFFER, bufferObjectId);
844 glBindBuffer(GL_ARRAY_BUFFER,
ID_NONE);
850 glBindBuffer(GL_ARRAY_BUFFER, bufferObjectId);
852 glBindBuffer(GL_ARRAY_BUFFER,
ID_NONE);
858 glBindBuffer(GL_ARRAY_BUFFER, bufferObjectId);
860 glBindBuffer(GL_ARRAY_BUFFER,
ID_NONE);
866 Console::println(
string(
"GL2Renderer::uploadIndicesBufferObject()::not implemented yet"));
871 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferObjectId);
872 glBufferData(GL_ELEMENT_ARRAY_BUFFER, size, data->
getBuffer(),
vbosUsage[bufferObjectId]);
873 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,
ID_NONE);
879 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferObjectId);
884 glBindBuffer(GL_ARRAY_BUFFER, bufferObjectId);
885 glEnableVertexAttribArray(2);
886 glVertexAttribPointer(2, 2, GL_FLOAT,
false, 0, 0LL);
891 glBindBuffer(GL_ARRAY_BUFFER, bufferObjectId);
892 glEnableVertexAttribArray(0);
893 glVertexAttribPointer(0, 3, GL_FLOAT,
false, 0, 0LL);
898 glBindBuffer(GL_ARRAY_BUFFER, bufferObjectId);
899 glEnableVertexAttribArray(1);
900 glVertexAttribPointer(1, 3, GL_FLOAT,
false, 0, 0LL);
905 glBindBuffer(GL_ARRAY_BUFFER, bufferObjectId);
906 glEnableVertexAttribArray(3);
907 glVertexAttribPointer(3, 4, GL_FLOAT,
false, 0, 0LL);
912 Console::println(
string(
"GL2Renderer::bindTangentsBufferObject()::not implemented yet"));
917 Console::println(
string(
"GL2Renderer::bindBitangentsBufferObject()::not implemented yet"));
921 Console::println(
string(
"GL2Renderer::bindModelViewMatricesBufferObject()::not implemented yet"));
925 glBindBuffer(GL_ARRAY_BUFFER, bufferObjectId);
926 glEnableVertexAttribArray(10);
927 glVertexAttribPointer(10, 4, GL_FLOAT,
false, 0, 0LL);
931 glBindBuffer(GL_ARRAY_BUFFER, bufferObjectId);
932 glEnableVertexAttribArray(11);
933 glVertexAttribPointer(11, 4, GL_FLOAT,
false, 0, 0LL);
937 glBindBuffer(GL_ARRAY_BUFFER, bufferObjectId);
938 glEnableVertexAttribArray(4);
939 glVertexAttribPointer(4, 3, GL_FLOAT,
false, 0, 0LL);
943 glBindBuffer(GL_ARRAY_BUFFER, bufferObjectId);
944 glEnableVertexAttribArray(1);
945 glVertexAttribPointer(1, 2, GL_FLOAT,
false, 0, 0LL);
949 glBindBuffer(GL_ARRAY_BUFFER, bufferObjectId);
950 glEnableVertexAttribArray(5);
951 glVertexAttribPointer(5, 1, GL_FLOAT,
false, 0, 0LL);
955 glBindBuffer(GL_ARRAY_BUFFER, bufferObjectId);
956 glEnableVertexAttribArray(6);
957 glVertexAttribPointer(6, 2, GL_FLOAT,
false, 0, 0LL);
962 Console::println(
string(
"GL2Renderer::drawInstancedIndexedTrianglesFromBufferObjects()::not implemented yet"));
967 #define BUFFER_OFFSET(i) ((void*)(i))
968 glDrawElements(GL_TRIANGLES, triangles * 3, GL_UNSIGNED_INT,
BUFFER_OFFSET(
static_cast< int64_t
>(trianglesOffset) * 3LL * 4LL));
975 Console::println(
string(
"GL2Renderer::drawInstancedTrianglesFromBufferObjects()::not implemented yet"));
980 glDrawArrays(GL_TRIANGLES, trianglesOffset * 3, triangles * 3);
988 glDrawArrays(GL_POINTS, pointsOffset, points);
995 glLineWidth(lineWidth);
1000 glDrawArrays(GL_LINES, pointsOffset, points);
1007 glDisableVertexAttribArray(0);
1008 glDisableVertexAttribArray(1);
1009 glDisableVertexAttribArray(2);
1010 glDisableVertexAttribArray(3);
1011 glBindBuffer(GL_ARRAY_BUFFER, 0);
1012 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
1017 for (
auto& bufferObjectId: bufferObjectIds)
vbosUsage.erase(bufferObjectId);
1018 glDeleteBuffers(bufferObjectIds.size(), (
const uint32_t*)bufferObjectIds.data());
1030 glActiveTexture(GL_TEXTURE0 + textureUnit);
1036 glReadPixels(x, y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth);
1042 auto pixelBuffer = ByteBuffer::allocate(width * height * 4);
1043 glPixelStorei(GL_PACK_ALIGNMENT, 1);
1044 glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixelBuffer->getBuffer());
1051 glBindTexture(GL_TEXTURE_2D,
ID_NONE);
1052 glBlendEquationSeparate(GL_FUNC_ADD, GL_FUNC_ADD);
1053 glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
1055 glDisable(GL_DEPTH_TEST);
1056 glDisable(GL_CULL_FACE);
1063 glBindTexture(GL_TEXTURE_2D,
ID_NONE);
1064 glDisable(GL_BLEND);
1065 glEnable(GL_DEPTH_TEST);
1066 glEnable(GL_CULL_FACE);
1070 Console::println(
"GL2Renderer::dispatchCompute(): Not implemented");
1074 Console::println(
"GL2Renderer::memoryBarrier(): Not implemented");
1078 Console::println(
"GL2Renderer::uploadSkinningBufferObject(): Not implemented");
1082 Console::println(
"GL2Renderer::uploadSkinningBufferObject(): Not implemented");
1086 Console::println(
"GL2Renderer::bindSkinningVerticesBufferObject(): Not implemented");
1090 Console::println(
"GL2Renderer::bindSkinningNormalsBufferObject(): Not implemented");
1094 Console::println(
"GL2Renderer::bindSkinningVertexJointsBufferObject(): Not implemented");
1098 Console::println(
"GL2Renderer::bindSkinningVertexJointIdxsBufferObject(): Not implemented");
1102 Console::println(
"GL2Renderer::bindSkinningVertexJointWeightsBufferObject(): Not implemented");
1106 Console::println(
"GL2Renderer::bindSkinningVerticesResultBufferObject(): Not implemented");
1110 Console::println(
"GL2Renderer::bindSkinningNormalsResultBufferObject(): Not implemented");
1114 Console::println(
"GL2Renderer::bindSkinningMatricesBufferObject(): Not implemented");
ByteBuffer * getTextureData()
int32_t getAtlasSize() const
int32_t getTextureHeight() const
ClampMode getClampMode() 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.
bool bufferObjectsAvailable
void bindOriginsBufferObject(int contextIdx, int32_t bufferObjectId) override
Bind origins buffer object.
int32_t createProgram(int type) override
Creates a shader program.
bool checkBufferObjectsAvailable()
Checks if VBO is available.
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 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.
const string & nextToken()
void tokenize(const string &str, const string &delimiters)
Tokenize.
Bean holding light properties.
uint32_t disposedTextures
int64_t memoryUsageShared