4 #include <OpenGL/gl3.h>
5 #include <OpenGL/OpenGL.h>
6 #include <OpenCL/opencl.h>
7 #include <OpenCL/cl_gl.h>
8#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__linux__) || defined(_WIN32) || defined(__HAIKU__)
64GL3Renderer::GL3Renderer()
77 #if defined (__APPLE__)
101 auto vendor = (
char*)glGetString(GL_VENDOR);
102 return string(vendor);
106 auto renderer = (
char*)glGetString(GL_RENDERER);
107 return string(renderer) +
" [GL3+/CORE]";
119#if defined (__APPLE__)
120 void GL3Renderer::clErrorCallback(
const char* errorInfo,
const void* privateInfo,
size_t cb,
void* userData) {
121 Console::println(
string(
"GL3Renderer::clErrorCallback(): ") + errorInfo);
131 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
133 glEnable(GL_DEPTH_TEST);
134 glEnable(GL_CULL_FACE);
135 glDepthFunc(GL_LEQUAL);
136 glBlendEquation(GL_FUNC_ADD);
138 #if !defined (__APPLE__)
139 glEnable(GL_POINT_SPRITE);
141 glEnable(GL_PROGRAM_POINT_SIZE);
147 #if defined (__APPLE__)
150 auto skinningKernelProgramSource = FileSystem::getInstance()->getContentAsString(
"shader/gl3/skinning",
"skinning.cl");
151 auto skinningKernelProgramSourceSize = skinningKernelProgramSource.size();
152 char* skinningKernelProgramSourceHeap =
new char[skinningKernelProgramSourceSize + 1];
153 strcpy(skinningKernelProgramSourceHeap, skinningKernelProgramSource.c_str());
157 cl_device_id clDeviceId = 0;
158 auto clCurrentContext = CGLGetCurrentContext();
159 auto clShareGroup = CGLGetShareGroup(clCurrentContext);
160 gcl_gl_set_sharegroup(clShareGroup);
161 auto clDispatchQueue = gcl_create_dispatch_queue(CL_DEVICE_TYPE_GPU,
nullptr);
162 clDeviceId = gcl_get_device_id_with_dispatch_queue(clDispatchQueue);
166 cl_char clDeviceVendorName[1024] = {0};
167 cl_char clDeviceDeviceName[1024] = {0};
168 clError = clGetDeviceInfo(clDeviceId, CL_DEVICE_VENDOR,
sizeof(clDeviceVendorName) - 1, clDeviceVendorName, &clSize);
169 clError|= clGetDeviceInfo(clDeviceId, CL_DEVICE_NAME,
sizeof(clDeviceDeviceName) - 1, clDeviceDeviceName, &clSize);
170 Console::println(
string(
"GL3Renderer::initialize(): Using OpenCL CL device: ") + (
char*)clDeviceVendorName +
": " + (
char*)clDeviceDeviceName);
173 cl_context_properties properties[] = {
174 CL_CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE,
175 (cl_context_properties)clShareGroup,
178 clContext = clCreateContext(properties, 1, &clDeviceId, clErrorCallback,
nullptr, &clError);
179 clCommandQueue = clCreateCommandQueue(clContext, clDeviceId, 0, &clError);
180 clSkinningKernelProgram = clCreateProgramWithSource(clContext, 1, (
const char**)&skinningKernelProgramSourceHeap, &skinningKernelProgramSourceSize, &clError);
181 clError = clBuildProgram(clSkinningKernelProgram, 1, &clDeviceId,
nullptr,
nullptr,
nullptr);
182 auto clBuildInfo = clGetProgramBuildInfo(clSkinningKernelProgram, clDeviceId, CL_PROGRAM_BUILD_STATUS, 0,
nullptr, &clSize);
183 clSkinningKernel = clCreateKernel(clSkinningKernelProgram,
"computeSkinning", &clError);
186 int glMaxColorAttachments = 0;
187 glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &glMaxColorAttachments);
188 int glMaxDrawBuffers = 0;
189 glGetIntegerv(GL_MAX_DRAW_BUFFERS, &glMaxDrawBuffers);
194 for (
auto i = 0; i < rendererContext.lights.size(); i++) {
195 rendererContext.lights[i].spotCosCutoff =
static_cast<float>(Math::cos(Math::PI / 180.0f * 180.0f));
197 rendererContext.textureMatrix.identity();
248 #if defined(__HAIKU__)
254 glGetIntegerv(GL_MAJOR_VERSION, &glMajorVersion);
255 glGetIntegerv(GL_MINOR_VERSION, &glMinorVersion);
256 return (glMajorVersion == 4 && glMinorVersion >= 3) || glMajorVersion > 4;
261 #if defined (__APPLE__)
281int32_t
GL3Renderer::loadShader(int32_t type,
const string& pathName,
const string& fileName,
const string& definitions,
const string& functions)
284 int32_t handle = glCreateShader(type);
286 if (handle == 0)
return 0;
289 auto shaderSource = StringTools::replace(
290 StringTools::replace(
291 FileSystem::getInstance()->getContentAsString(pathName, fileName),
298 string sourceString = (shaderSource);
299 char* sourceHeap =
new char[sourceString.length() + 1];
300 strcpy(sourceHeap, sourceString.c_str());
302 glShaderSource(handle, 1, &sourceHeap,
nullptr);
304 glCompileShader(handle);
306 delete [] sourceHeap;
308 int32_t compileStatus;
309 glGetShaderiv(handle, GL_COMPILE_STATUS, &compileStatus);
310 if (compileStatus == 0) {
312 int32_t infoLogLengthBuffer;
313 glGetShaderiv(handle, GL_INFO_LOG_LENGTH, &infoLogLengthBuffer);
314 char* infoLogBuffer =
new char[infoLogLengthBuffer];
315 glGetShaderInfoLog(handle, infoLogLengthBuffer, &infoLogLengthBuffer, infoLogBuffer);
316 auto infoLogString = (string(infoLogBuffer, infoLogLengthBuffer));
320 string(
"GL3Renderer::loadShader") +
327 string(
": failed: ") +
331 Console::println(shaderSource);
333 delete [] infoLogBuffer;
335 glDeleteShader(handle);
344 glUseProgram(programId);
349 auto glProgram = glCreateProgram();
355 glAttachShader(programId, shaderId);
360 glLinkProgram(programId);
363 glGetProgramiv(programId, GL_LINK_STATUS, &linkStatus);
364 if (linkStatus == 0) {
366 int32_t infoLogLength = 0;
367 glGetProgramiv(programId, GL_INFO_LOG_LENGTH, &infoLogLength);
368 char* infoLog =
new char[infoLogLength];
369 glGetProgramInfoLog(programId, infoLogLength, &infoLogLength, infoLog);
370 auto infoLogString = (string(infoLog, infoLogLength));
375 to_string(programId) +
390 auto uniformLocation = glGetUniformLocation(programId, (name).c_str());
391 return uniformLocation;
396 #if defined (__APPLE__)
398 clSkinningParameters.vertexCount = value;
401 clSkinningParameters.matrixCount = value;
404 clSkinningParameters.instanceCount = value;
406 glUniform1i(uniformId, value);
409 glUniform1i(uniformId, value);
415 glUniform1f(uniformId, value);
420 glUniformMatrix3fv(uniformId, 1,
false, data.data());
425 glUniformMatrix4fv(uniformId, 1,
false, data.data());
430 glUniformMatrix4fv(uniformId, count,
false, (
float*)data->
getBuffer());
435 glUniform4fv(uniformId, 1, data.data());
440 glUniform3fv(uniformId, 1, data.data());
445 glUniform2fv(uniformId, 1, data.data());
450 glBindAttribLocation(programId, location, (name).c_str());
466 glClearColor(red, green, blue, alpha);
471 glEnable(GL_CULL_FACE);
476 glDisable(GL_CULL_FACE);
481 glFrontFace(frontFace);
486 glCullFace(cullFace);
491 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
496 glBlendFunc(GL_ONE, GL_ONE);
517 glDisable(GL_DEPTH_TEST);
522 glEnable(GL_DEPTH_TEST);
528 glDepthFunc(depthFunction);
533 glColorMask(red, green, blue, alpha);
546 glGenTextures(1, &textureId);
552 uint32_t depthTextureId;
554 glGenTextures(1, &depthTextureId);
555 glBindTexture(GL_TEXTURE_2D, depthTextureId);
557 glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, width, height, 0, GL_DEPTH_COMPONENT, GL_FLOAT,
nullptr);
559 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
560 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
561 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
562 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
564 glBindTexture(GL_TEXTURE_2D,
ID_NONE);
565 return depthTextureId;
570 uint32_t colorBufferTextureId;
572 glGenTextures(1, &colorBufferTextureId);
573 glBindTexture(GL_TEXTURE_2D, colorBufferTextureId);
575 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE,
nullptr);
577 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
578 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
579 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
580 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
582 glBindTexture(GL_TEXTURE_2D,
ID_NONE);
583 return colorBufferTextureId;
587 uint32_t gBufferGeometryTextureId;
588 glGenTextures(1, &gBufferGeometryTextureId);
589 glBindTexture(GL_TEXTURE_2D, gBufferGeometryTextureId);
590 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, width, height, 0, GL_RGBA, GL_FLOAT,
nullptr);
591 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
592 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
593 glBindTexture(GL_TEXTURE_2D,
ID_NONE);
594 return gBufferGeometryTextureId;
598 uint32_t gBufferColorTextureId;
599 glGenTextures(1, &gBufferColorTextureId);
600 glBindTexture(GL_TEXTURE_2D, gBufferColorTextureId);
601 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE,
nullptr);
602 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
603 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
604 glBindTexture(GL_TEXTURE_2D,
ID_NONE);
605 return gBufferColorTextureId;
613 texture->
getDepth() == 32?GL_RGBA:GL_RGB,
617 texture->
getDepth() == 32?GL_RGBA:GL_RGB,
624 glGetFloatv(GL_MAX_TEXTURE_LOD_BIAS, &maxLodBias);
625 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_LOD_BIAS, -Math::clamp(
static_cast<float>(texture->
getAtlasSize()) * 0.125f, 0.0f, maxLodBias));
626 auto borderSize = 32;
628 while (borderSize > 4) {
632 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
633 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, maxLevel - 1);
634 glGenerateMipmap(GL_TEXTURE_2D);
636 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
637 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
639 if (texture->
isUseMipMap() ==
true) glGenerateMipmap(GL_TEXTURE_2D);
641 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
642 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
644 float color[4] = {0.0f, 0.0f, 0.0f, 0.0f};
645 if (texture->
getClampMode() == Texture::CLAMPMODE_TRANSPARENTPIXEL) glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, color);
646 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, texture->
getClampMode() == Texture::CLAMPMODE_EDGE?GL_CLAMP_TO_EDGE:GL_CLAMP_TO_BORDER);
647 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, texture->
getClampMode() == Texture::CLAMPMODE_EDGE?GL_CLAMP_TO_EDGE:GL_CLAMP_TO_BORDER);
650 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, texture->
isUseMipMap() ==
true?GL_LINEAR_MIPMAP_LINEAR:GL_LINEAR);
651 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
657 GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
659 textureLeft->
getDepth() == 32?GL_RGBA:GL_RGB,
663 textureLeft->
getDepth() == 32?GL_RGBA:GL_RGB,
668 GL_TEXTURE_CUBE_MAP_POSITIVE_X,
670 textureRight->
getDepth() == 32?GL_RGBA:GL_RGB,
674 textureRight->
getDepth() == 32?GL_RGBA:GL_RGB,
679 GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
681 textureTop->
getDepth() == 32?GL_RGBA:GL_RGB,
685 textureTop->
getDepth() == 32?GL_RGBA:GL_RGB,
690 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
692 textureBottom->
getDepth() == 32?GL_RGBA:GL_RGB,
696 textureBottom->
getDepth() == 32?GL_RGBA:GL_RGB,
701 GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
703 textureFront->
getDepth() == 32?GL_RGBA:GL_RGB,
707 textureFront->
getDepth() == 32?GL_RGBA:GL_RGB,
712 GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,
714 textureBack->
getDepth() == 32?GL_RGBA:GL_RGB,
718 textureBack->
getDepth() == 32?GL_RGBA:GL_RGB,
722 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
723 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
724 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
725 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
726 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
733 glGenTextures(1, &textureId);
734 glBindTexture(GL_TEXTURE_CUBE_MAP, textureId);
735 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
736 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
737 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
738 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
739 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
741 GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
752 GL_TEXTURE_CUBE_MAP_POSITIVE_X,
763 GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
774 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
785 GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
796 GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,
806 glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
812 glBindTexture(GL_TEXTURE_2D, textureId);
813 glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, width, height, 0, GL_DEPTH_COMPONENT, GL_FLOAT,
nullptr);
814 glBindTexture(GL_TEXTURE_2D, 0);
819 glBindTexture(GL_TEXTURE_2D, textureId);
820 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE,
nullptr);
821 glBindTexture(GL_TEXTURE_2D, 0);
825 glBindTexture(GL_TEXTURE_2D, textureId);
826 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, width, height, 0, GL_RGBA, GL_FLOAT,
nullptr);
827 glBindTexture(GL_TEXTURE_2D, 0);
831 glBindTexture(GL_TEXTURE_2D, textureId);
832 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE,
nullptr);
833 glBindTexture(GL_TEXTURE_2D, 0);
838 glBindTexture(GL_TEXTURE_2D, textureId);
843 glBindTexture(GL_TEXTURE_CUBE_MAP, textureId);
849 glDeleteTextures(1, (
const uint32_t*)&textureId);
855 uint32_t frameBufferId;
857 glGenFramebuffers(1, &frameBufferId);
858 glBindFramebuffer(GL_FRAMEBUFFER, frameBufferId);
860 if (depthBufferTextureId !=
ID_NONE) {
861 glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, depthBufferTextureId, 0);
864 if (colorBufferTextureId !=
ID_NONE) {
865 glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, colorBufferTextureId, 0);
866 glDrawBuffer(GL_COLOR_ATTACHMENT0);
867 glReadBuffer(GL_COLOR_ATTACHMENT0);
869 if (cubeMapTextureId !=
ID_NONE) {
870 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, cubeMapTextureIndex, cubeMapTextureId, 0);
872 glDrawBuffer(GL_NONE);
873 glReadBuffer(GL_NONE);
876 int32_t fboStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER);
877 if (fboStatus != GL_FRAMEBUFFER_COMPLETE) {
878 Console::println(
string(
"GL_FRAMEBUFFER_COMPLETE_EXT failed, CANNOT use FBO: "+ to_string(fboStatus)));
881 glBindFramebuffer(GL_FRAMEBUFFER, 0);
882 return frameBufferId;
886 int32_t depthBufferTextureId,
887 int32_t geometryBufferTextureId1,
888 int32_t geometryBufferTextureId2,
889 int32_t geometryBufferTextureId3,
890 int32_t colorBufferTextureId1,
891 int32_t colorBufferTextureId2,
892 int32_t colorBufferTextureId3,
893 int32_t colorBufferTextureId4,
894 int32_t colorBufferTextureId5
896 uint32_t frameBufferId;
898 glGenFramebuffers(1, &frameBufferId);
899 glBindFramebuffer(GL_FRAMEBUFFER, frameBufferId);
901 if (depthBufferTextureId !=
ID_NONE) {
902 glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, depthBufferTextureId, 0);
904 vector<uint32_t> drawBuffers;
906 if (geometryBufferTextureId1 !=
ID_NONE) {
907 glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, geometryBufferTextureId1, 0);
908 drawBuffers.push_back(GL_COLOR_ATTACHMENT0);
910 if (geometryBufferTextureId2 !=
ID_NONE) {
911 glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, geometryBufferTextureId2, 0);
912 drawBuffers.push_back(GL_COLOR_ATTACHMENT1);
914 if (geometryBufferTextureId3 !=
ID_NONE) {
915 glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT2, geometryBufferTextureId3, 0);
916 drawBuffers.push_back(GL_COLOR_ATTACHMENT2);
919 if (colorBufferTextureId1 !=
ID_NONE) {
920 glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT3, colorBufferTextureId1, 0);
921 drawBuffers.push_back(GL_COLOR_ATTACHMENT3);
923 if (colorBufferTextureId2 !=
ID_NONE) {
924 glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT4, colorBufferTextureId2, 0);
925 drawBuffers.push_back(GL_COLOR_ATTACHMENT4);
927 if (colorBufferTextureId3 !=
ID_NONE) {
928 glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT5, colorBufferTextureId3, 0);
929 drawBuffers.push_back(GL_COLOR_ATTACHMENT5);
931 if (colorBufferTextureId4 !=
ID_NONE) {
932 glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT6, colorBufferTextureId4, 0);
933 drawBuffers.push_back(GL_COLOR_ATTACHMENT6);
935 if (colorBufferTextureId5 !=
ID_NONE) {
936 glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT7, colorBufferTextureId5, 0);
937 drawBuffers.push_back(GL_COLOR_ATTACHMENT7);
940 glDrawBuffers(drawBuffers.size(), drawBuffers.data());
942 int32_t fboStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER);
943 if (fboStatus != GL_FRAMEBUFFER_COMPLETE) {
944 Console::println(
string(
"GL_FRAMEBUFFER_COMPLETE_EXT failed, CANNOT use FBO: "+ to_string(fboStatus)));
947 glBindFramebuffer(GL_FRAMEBUFFER, 0);
948 return frameBufferId;
953 glBindFramebuffer(GL_FRAMEBUFFER, frameBufferId);
958 glDeleteFramebuffers(1, (uint32_t*)&frameBufferId);
963 vector<int32_t> bufferObjectIds;
964 bufferObjectIds.resize(buffers);
965 glGenBuffers(buffers, (uint32_t*)bufferObjectIds.data());
966 for (
auto bufferObjectId: bufferObjectIds)
vbosUsage[bufferObjectId] = useGPUMemory ==
true?GL_STATIC_DRAW:GL_STREAM_DRAW;
967 return bufferObjectIds;
972 glBindBuffer(GL_ARRAY_BUFFER, bufferObjectId);
974 glBindBuffer(GL_ARRAY_BUFFER,
ID_NONE);
980 glBindBuffer(GL_ARRAY_BUFFER, bufferObjectId);
982 glBindBuffer(GL_ARRAY_BUFFER,
ID_NONE);
988 glBindBuffer(GL_ARRAY_BUFFER, bufferObjectId);
990 glBindBuffer(GL_ARRAY_BUFFER,
ID_NONE);
996 Console::println(
string(
"GL3Renderer::uploadIndicesBufferObject()::not implemented yet"));
1001 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferObjectId);
1002 glBufferData(GL_ELEMENT_ARRAY_BUFFER, size, data->
getBuffer(),
vbosUsage[bufferObjectId]);
1003 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,
ID_NONE);
1009 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferObjectId);
1014 glBindBuffer(GL_ARRAY_BUFFER, bufferObjectId);
1015 glEnableVertexAttribArray(2);
1016 glVertexAttribPointer(2, 2, GL_FLOAT,
false, 0, 0LL);
1021 glBindBuffer(GL_ARRAY_BUFFER, bufferObjectId);
1022 glEnableVertexAttribArray(0);
1023 glVertexAttribPointer(0, 3, GL_FLOAT,
false, 0, 0LL);
1028 glBindBuffer(GL_ARRAY_BUFFER, bufferObjectId);
1029 glEnableVertexAttribArray(1);
1030 glVertexAttribPointer(1, 3, GL_FLOAT,
false, 0, 0LL);
1035 glBindBuffer(GL_ARRAY_BUFFER, bufferObjectId);
1036 glEnableVertexAttribArray(3);
1037 glVertexAttribPointer(3, 4, GL_FLOAT,
false, 0, 0LL);
1042 glBindBuffer(GL_ARRAY_BUFFER, bufferObjectId);
1043 glEnableVertexAttribArray(4);
1044 glVertexAttribPointer(4, 3, GL_FLOAT,
false, 0, 0LL);
1049 glBindBuffer(GL_ARRAY_BUFFER, bufferObjectId);
1050 glEnableVertexAttribArray(5);
1051 glVertexAttribPointer(5, 3, GL_FLOAT,
false, 0, 0LL);
1055 glBindBuffer(GL_ARRAY_BUFFER, bufferObjectId);
1056 glEnableVertexAttribArray(6);
1057 glEnableVertexAttribArray(7);
1058 glEnableVertexAttribArray(8);
1059 glEnableVertexAttribArray(9);
1060 glVertexAttribPointer(6, 4, GL_FLOAT,
false, 4 * 4 *
sizeof(
float), (
void*)(0 * 4 *
sizeof(
float)));
1061 glVertexAttribPointer(7, 4, GL_FLOAT,
false, 4 * 4 *
sizeof(
float), (
void*)(1 * 4 *
sizeof(
float)));
1062 glVertexAttribPointer(8, 4, GL_FLOAT,
false, 4 * 4 *
sizeof(
float), (
void*)(2 * 4 *
sizeof(
float)));
1063 glVertexAttribPointer(9, 4, GL_FLOAT,
false, 4 * 4 *
sizeof(
float), (
void*)(3 * 4 *
sizeof(
float)));
1064 glVertexAttribDivisor(6, 1);
1065 glVertexAttribDivisor(7, 1);
1066 glVertexAttribDivisor(8, 1);
1067 glVertexAttribDivisor(9, 1);
1071 glBindBuffer(GL_ARRAY_BUFFER, bufferObjectId);
1072 glEnableVertexAttribArray(10);
1073 glVertexAttribPointer(10, 4, GL_FLOAT,
false, 0, 0LL);
1074 glVertexAttribDivisor(10, divisor);
1078 glBindBuffer(GL_ARRAY_BUFFER, bufferObjectId);
1079 glEnableVertexAttribArray(11);
1080 glVertexAttribPointer(11, 4, GL_FLOAT,
false, 0, 0LL);
1081 glVertexAttribDivisor(11, divisor);
1085 glBindBuffer(GL_ARRAY_BUFFER, bufferObjectId);
1086 glEnableVertexAttribArray(12);
1087 glVertexAttribPointer(12, 3, GL_FLOAT,
false, 0, 0LL);
1091 glBindBuffer(GL_ARRAY_BUFFER, bufferObjectId);
1092 glEnableVertexAttribArray(1);
1093 glVertexAttribIPointer(1, 2, GL_UNSIGNED_SHORT, 0, 0LL);
1097 glBindBuffer(GL_ARRAY_BUFFER, bufferObjectId);
1098 glEnableVertexAttribArray(5);
1099 glVertexAttribPointer(5, 1, GL_FLOAT,
false, 0, 0LL);
1103 glBindBuffer(GL_ARRAY_BUFFER, bufferObjectId);
1104 glEnableVertexAttribArray(6);
1105 glVertexAttribIPointer(6, 2, GL_UNSIGNED_SHORT, 0, 0LL);
1106 glVertexAttribDivisor(6, 0);
1111 #define BUFFER_OFFSET(i) ((void*)(i))
1112 glDrawElementsInstanced(GL_TRIANGLES, triangles * 3, GL_UNSIGNED_INT,
BUFFER_OFFSET(
static_cast< int64_t
>(trianglesOffset) * 3LL * 4LL), instances);
1120 #define BUFFER_OFFSET(i) ((void*)(i))
1121 glDrawElements(GL_TRIANGLES, triangles * 3, GL_UNSIGNED_INT,
BUFFER_OFFSET(
static_cast< int64_t
>(trianglesOffset) * 3LL * 4LL));
1128 glDrawArraysInstanced(GL_TRIANGLES, trianglesOffset * 3, triangles * 3, instances);
1136 glDrawArrays(GL_TRIANGLES, trianglesOffset * 3, triangles * 3);
1144 glDrawArrays(GL_POINTS, pointsOffset, points);
1151 glLineWidth(lineWidth);
1156 glDrawArrays(GL_LINES, pointsOffset, points);
1163 glDisableVertexAttribArray(0);
1164 glDisableVertexAttribArray(1);
1165 glDisableVertexAttribArray(2);
1166 glDisableVertexAttribArray(3);
1167 glDisableVertexAttribArray(4);
1168 glDisableVertexAttribArray(5);
1169 glDisableVertexAttribArray(6);
1170 glDisableVertexAttribArray(7);
1171 glDisableVertexAttribArray(8);
1172 glDisableVertexAttribArray(9);
1173 glDisableVertexAttribArray(10);
1174 glDisableVertexAttribArray(11);
1175 glDisableVertexAttribArray(12);
1176 glBindBuffer(GL_ARRAY_BUFFER,
ID_NONE);
1177 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,
ID_NONE);
1182 for (
auto& bufferObjectId: bufferObjectIds)
vbosUsage.erase(bufferObjectId);
1183 glDeleteBuffers(bufferObjectIds.size(), (
const uint32_t*)bufferObjectIds.data());
1195 glActiveTexture(GL_TEXTURE0 + textureUnit);
1201 glReadPixels(x, y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth);
1207 auto pixelBuffer = ByteBuffer::allocate(width * height * 4);
1208 glPixelStorei(GL_PACK_ALIGNMENT, 1);
1209 glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixelBuffer->getBuffer());
1216 glBindTexture(GL_TEXTURE_2D,
ID_NONE);
1217 glBlendEquationSeparate(GL_FUNC_ADD, GL_FUNC_ADD);
1218 glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
1220 glDisable(GL_DEPTH_TEST);
1221 glDisable(GL_CULL_FACE);
1228 glBindTexture(GL_TEXTURE_2D,
ID_NONE);
1229 glDisable(GL_BLEND);
1230 glEnable(GL_DEPTH_TEST);
1231 glEnable(GL_CULL_FACE);
1236 auto error = glGetError();
1237 if (error != GL_NO_ERROR) {
1238 Console::println(
string(
"OpenGL Error: (" + to_string(error) +
") @: " + __FILE__ +
":" + to_string(line)));
1243 #if defined (__APPLE__)
1244 clSkinningParameters.numGroupsX = numGroupsX;
1245 clSkinningParameters.numGroupsY = numGroupsY;
1247 auto& _clSkinningParameters = clSkinningParameters;
1249 array<cl_mem, 8> boundCLMemObjects;
1250 for (
auto i = 0; i < _clSkinningParameters.boundGLBuffers.size(); i++) {
1251 boundCLMemObjects[i] = clCreateFromGLBuffer(clContext, _clSkinningParameters.boundGLBuffersWrite[i] ==
true?CL_MEM_WRITE_ONLY:CL_MEM_READ_ONLY, _clSkinningParameters.boundGLBuffers[i], &clError);
1252 clError = clSetKernelArg(clSkinningKernel, i,
sizeof(cl_mem), &boundCLMemObjects[i]);
1254 clSetKernelArg(clSkinningKernel, 8,
sizeof(cl_int), &_clSkinningParameters.vertexCount);
1255 clSetKernelArg(clSkinningKernel, 9,
sizeof(cl_int), &_clSkinningParameters.matrixCount);
1256 clSetKernelArg(clSkinningKernel, 10,
sizeof(cl_int), &_clSkinningParameters.instanceCount);
1257 size_t local_size[] = {(size_t)16, (
size_t)16};
1258 size_t global_size[] = {(size_t)_clSkinningParameters.numGroupsX * local_size[0], (
size_t)_clSkinningParameters.numGroupsY * local_size[1]};
1259 clEnqueueAcquireGLObjects(clCommandQueue, boundCLMemObjects.size(), boundCLMemObjects.data(), 0,
nullptr,
nullptr);
1260 clEnqueueNDRangeKernel(clCommandQueue, clSkinningKernel, 2,
nullptr, global_size, local_size, 0,
nullptr,
nullptr);
1261 clEnqueueReleaseGLObjects(clCommandQueue, boundCLMemObjects.size(), boundCLMemObjects.data(), 0,
nullptr,
nullptr);
1262 clFinish(clCommandQueue);
1263 clSkinningParameters = CLSkinningParameters();
1265 glDispatchCompute(numGroupsX, numGroupsY, numGroupsZ);
1271 #if defined (__APPLE__)
1275 glMemoryBarrier(GL_ALL_BARRIER_BITS);
1280 #if defined (__APPLE__)
1281 glBindBuffer(GL_ARRAY_BUFFER, bufferObjectId);
1283 glBindBuffer(GL_ARRAY_BUFFER,
ID_NONE);
1286 glBindBuffer(GL_SHADER_STORAGE_BUFFER, bufferObjectId);
1287 glBufferData(GL_SHADER_STORAGE_BUFFER, size, data->
getBuffer(),
vbosUsage[bufferObjectId]);
1288 glBindBuffer(GL_SHADER_STORAGE_BUFFER,
ID_NONE);
1294 #if defined (__APPLE__)
1295 glBindBuffer(GL_ARRAY_BUFFER, bufferObjectId);
1297 glBindBuffer(GL_ARRAY_BUFFER,
ID_NONE);
1300 glBindBuffer(GL_SHADER_STORAGE_BUFFER, bufferObjectId);
1301 glBufferData(GL_SHADER_STORAGE_BUFFER, size, data->
getBuffer(),
vbosUsage[bufferObjectId]);
1302 glBindBuffer(GL_SHADER_STORAGE_BUFFER,
ID_NONE);
1307#if defined (__APPLE__)
1308 inline void GL3Renderer::clBindGLBuffer(int32_t idx, int32_t bufferObjectId,
bool write) {
1309 clSkinningParameters.boundGLBuffers[idx] = bufferObjectId;
1310 clSkinningParameters.boundGLBuffersWrite[idx] = write;
1315 #if defined (__APPLE__)
1316 clBindGLBuffer(0, bufferObjectId,
false);
1318 glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, bufferObjectId);
1323 #if defined (__APPLE__)
1324 clBindGLBuffer(1, bufferObjectId,
false);
1326 glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, bufferObjectId);
1331 #if defined (__APPLE__)
1332 clBindGLBuffer(2, bufferObjectId,
false);
1334 glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, bufferObjectId);
1339 #if defined (__APPLE__)
1340 clBindGLBuffer(3, bufferObjectId,
false);
1342 glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 3, bufferObjectId);
1347 #if defined (__APPLE__)
1348 clBindGLBuffer(4, bufferObjectId,
false);
1350 glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4, bufferObjectId);
1355 #if defined (__APPLE__)
1356 clBindGLBuffer(5, bufferObjectId,
true);
1358 glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 5, bufferObjectId);
1363 #if defined (__APPLE__)
1364 clBindGLBuffer(6, bufferObjectId,
true);
1366 glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 6, bufferObjectId);
1371 #if defined (__APPLE__)
1372 clBindGLBuffer(7, bufferObjectId,
false);
1374 glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 7, bufferObjectId);
PNG texture writer class.
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.
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.
bool deferredShadingAvailable
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 checkGLError(int line)
Checks if GL error did occour.
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 UNIFORM_CL_SKINNING_MATRIX_COUNT
int32_t CLEAR_COLOR_BUFFER_BIT
int32_t UNIFORM_CL_SKINNING_VERTEX_COUNT
int32_t CUBEMAPTEXTUREINDEX_NEGATIVE_X
int32_t CUBEMAPTEXTUREINDEX_POSITIVE_Y
int32_t UNIFORM_CL_SKINNING_INSTANCE_COUNT
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