diff --git a/CMakeLists.txt b/CMakeLists.txt index d201735..5e33fb6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -176,12 +176,12 @@ list (APPEND EXTRA_LIBS "${OPENGL_LIBRARIES}") endif() # ---- GLAD ---- -if(NOT ANDROID) -set(GLAD_EXTENSIONS "GL_EXT_texture_filter_anisotropic,GL_EXT_texture_compression_s3tc, GL_S3_s3tc" CACHE STRING "Gl exts" FORCE) -add_subdirectory(3rdparty/glad) -include_directories(${GLAD_INCLUDE_DIRS}) -list (APPEND EXTRA_LIBS "glad") -endif() +# if(NOT ANDROID) +# set(GLAD_EXTENSIONS "GL_EXT_texture_filter_anisotropic,GL_EXT_texture_compression_s3tc, GL_S3_s3tc" CACHE STRING "Gl exts" FORCE) +# add_subdirectory(3rdparty/glad) +# include_directories(${GLAD_INCLUDE_DIRS}) +# list (APPEND EXTRA_LIBS "glad") +# endif() add_library(kraken STATIC ${SRCS} ${KRAKEN_PUBLIC_HEADERS}) TARGET_LINK_LIBRARIES( kraken ${EXTRA_LIBS} ) diff --git a/kraken/KRCamera.cpp b/kraken/KRCamera.cpp index b36eea5..3834f86 100755 --- a/kraken/KRCamera.cpp +++ b/kraken/KRCamera.cpp @@ -147,7 +147,7 @@ void KRCamera::renderFrame(VkCommandBuffer& commandBuffer, KRSurface& compositeS GL_PUSH_GROUP_MARKER("Generate Shadowmaps"); scene.render(commandBuffer, compositeSurface, this, m_viewport.getVisibleBounds(), m_viewport, KRNode::RENDER_PASS_GENERATE_SHADOWMAPS, false /*settings.bEnableDeferredLighting*/); - GLDEBUG(glViewport(0, 0, (GLsizei)m_viewport.getSize().x, (GLsizei)m_viewport.getSize().y)); + GLDEBUG(glViewport(0, 0, (int)m_viewport.getSize().x, (int)m_viewport.getSize().y)); GL_POP_GROUP_MARKER; } @@ -178,13 +178,13 @@ void KRCamera::renderFrame(VkCommandBuffer& commandBuffer, KRSurface& compositeS // Set render target GLDEBUG(glBindFramebuffer(GL_FRAMEBUFFER, lightAccumulationBuffer)); GLDEBUG(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, compositeDepthTexture, 0)); - GLDEBUG(glViewport(0, 0, (GLsizei)(m_viewport.getSize().x * m_downsample.x), (GLsizei)(m_viewport.getSize().y * m_downsample.y))); + GLDEBUG(glViewport(0, 0, (int)(m_viewport.getSize().x * m_downsample.x), (int)(m_viewport.getSize().y * m_downsample.y))); GLDEBUG(glClearColor(0.0f, 0.0f, 0.0f, 0.0f)); GLDEBUG(glClear(GL_COLOR_BUFFER_BIT)); // Set source to buffers from pass 1 - m_pContext->getTextureManager()->selectTexture(GL_TEXTURE_2D, 6, compositeColorTexture); - m_pContext->getTextureManager()->selectTexture(GL_TEXTURE_2D, 7, compositeDepthTexture); + m_pContext->getTextureManager()->selectTexture(0 /*GL_TEXTURE_2D*/, 6, compositeColorTexture); + m_pContext->getTextureManager()->selectTexture(0 /*GL_TEXTURE_2D*/, 7, compositeDepthTexture); // Render the geometry scene.render(commandBuffer, compositeSurface, this, m_viewport.getVisibleBounds(), m_viewport, KRNode::RENDER_PASS_DEFERRED_LIGHTS, false); @@ -200,7 +200,7 @@ void KRCamera::renderFrame(VkCommandBuffer& commandBuffer, KRSurface& compositeS deferredOpaquePass.begin(commandBuffer, compositeSurface, Vector4::Create(0.0f, 0.0f, 0.0f, 1.0f)); // Set source to buffers from pass 2 - m_pContext->getTextureManager()->selectTexture(GL_TEXTURE_2D, 6, lightAccumulationTexture); + m_pContext->getTextureManager()->selectTexture(0 /*GL_TEXTURE_2D*/, 6, lightAccumulationTexture); // Render the geometry // TODO: At this point, we only want to render octree nodes that produced fragments during the 1st pass into the GBuffer @@ -215,7 +215,7 @@ void KRCamera::renderFrame(VkCommandBuffer& commandBuffer, KRSurface& compositeS GL_PUSH_GROUP_MARKER("Forward Rendering - Opaque"); /* - GLDEBUG(glViewport(0, 0, (GLsizei)(m_viewport.getSize().x * m_downsample.x), (GLsizei)(m_viewport.getSize().y * m_downsample.y))); + GLDEBUG(glViewport(0, 0, (int)(m_viewport.getSize().x * m_downsample.x), (int)(m_viewport.getSize().y * m_downsample.y))); */ // Start render pass @@ -324,9 +324,9 @@ void KRCamera::renderFrame(VkCommandBuffer& commandBuffer, KRSurface& compositeS // Disable z-buffer test GLDEBUG(glDisable(GL_DEPTH_TEST)); - m_pContext->getTextureManager()->selectTexture(GL_TEXTURE_2D, 0, compositeDepthTexture); + m_pContext->getTextureManager()->selectTexture(0 /*GL_TEXTURE_2D*/, 0, compositeDepthTexture); - GLDEBUG(glViewport(0, 0, (GLsizei)volumetricLightingViewport.getSize().x, (GLsizei)volumetricLightingViewport.getSize().y)); + GLDEBUG(glViewport(0, 0, (int)volumetricLightingViewport.getSize().x, (int)volumetricLightingViewport.getSize().y)); } else { // Enable z-buffer test GLDEBUG(glEnable(GL_DEPTH_TEST)); diff --git a/kraken/KREngine-common.h b/kraken/KREngine-common.h index 907f93b..e20a97e 100755 --- a/kraken/KREngine-common.h +++ b/kraken/KREngine-common.h @@ -49,8 +49,7 @@ using namespace kraken; #include #include #include - - +#include #include #include #include @@ -73,6 +72,12 @@ using namespace kraken; #include #include +#include "TargetConditionals.h" +#include +#include +#include +#define KRAKEN_HAVE_BLAS 1 + #endif #include @@ -81,9 +86,11 @@ using namespace kraken; #include #include #include - #include +// NOMINMAX required to prevent windows headers from defining max() and min() macros +#define NOMINMAX + // _USE_MATH_DEFINES must be defined to get M_PI in Windows #define _USE_MATH_DEFINES #include @@ -108,14 +115,6 @@ using std::multimap; using std::stack; using std::queue; -#ifdef __APPLE__ -#include "TargetConditionals.h" -#include -#include -#include -#define KRAKEN_HAVE_BLAS 1 -#endif - #if !defined(__i386__) && defined(__arm__) #define KRAKEN_USE_ARM_NEON @@ -165,17 +164,9 @@ fprintf(stderr, "Error at line number %d, in file %s. Returned %d for call %s\n" #define OSDEBUG(x) x; #endif -#if defined(GL_EXT_debug_marker) && (defined(DEBUG) || defined(_DEBUG)) - -#define GL_PUSH_GROUP_MARKER(x) glPushGroupMarkerEXT(0, x) -#define GL_POP_GROUP_MARKER glPopGroupMarkerEXT() - -#else - #define GL_PUSH_GROUP_MARKER(x) #define GL_POP_GROUP_MARKER -#endif typedef enum { diff --git a/kraken/KRHelpers.h b/kraken/KRHelpers.h index 04e8769..53cf913 100644 --- a/kraken/KRHelpers.h +++ b/kraken/KRHelpers.h @@ -36,19 +36,6 @@ #include "matrix4.h" #include -#if defined(ANDROID) -#include -#include -#elif defined(_WIN32) || defined(_WIN64) -#include -#elif (defined(__linux__) || defined(__unix__) || defined(__posix__)) -#include -#include -#include -#elif defined(__APPLE__) -#include -#include -#endif #include "../3rdparty/tinyxml2/tinyxml2.h" #define KRMIN(x,y) ((x) < (y) ? (x) : (y)) diff --git a/kraken/KRLight.cpp b/kraken/KRLight.cpp index dcf2983..f9782e6 100755 --- a/kraken/KRLight.cpp +++ b/kraken/KRLight.cpp @@ -477,7 +477,7 @@ void KRLight::allocateShadowBuffers(int cBuffers) GLDEBUG(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_EXT, GL_COMPARE_REF_TO_TEXTURE_EXT)); // TODO - Detect GL_EXT_shadow_samplers and only activate if available GLDEBUG(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_EXT, GL_LEQUAL)); // TODO - Detect GL_EXT_shadow_samplers and only activate if available #endif - GLDEBUG(glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, (GLsizei)viewportSize.x, (GLsizei)viewportSize.y, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL)); + GLDEBUG(glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, (int)viewportSize.x, (int)viewportSize.y, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL)); GLDEBUG(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, shadowDepthTexture[iShadow], 0)); } @@ -514,12 +514,12 @@ void KRLight::renderShadowBuffers(RenderInfo& ri) GLDEBUG(glBindFramebuffer(GL_FRAMEBUFFER, shadowFramebuffer[iShadow])); GLDEBUG(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, shadowDepthTexture[iShadow], 0)); - GLDEBUG(glViewport(0, 0, (GLsizei)m_shadowViewports[iShadow].getSize().x, (GLsizei)m_shadowViewports[iShadow].getSize().y)); + GLDEBUG(glViewport(0, 0, (int)m_shadowViewports[iShadow].getSize().x, (int)m_shadowViewports[iShadow].getSize().y)); GLDEBUG(glClearDepthf(0.0f)); GLDEBUG(glClear(GL_DEPTH_BUFFER_BIT)); - GLDEBUG(glViewport(1, 1, (GLsizei)m_shadowViewports[iShadow].getSize().x - 2, (GLsizei)m_shadowViewports[iShadow].getSize().y - 2)); + GLDEBUG(glViewport(1, 1, (int)m_shadowViewports[iShadow].getSize().x - 2, (int)m_shadowViewports[iShadow].getSize().y - 2)); GLDEBUG(glClearDepthf(1.0f)); diff --git a/kraken/KRMesh.cpp b/kraken/KRMesh.cpp index ab1a2e9..1081a24 100755 --- a/kraken/KRMesh.cpp +++ b/kraken/KRMesh.cpp @@ -402,7 +402,7 @@ void KRMesh::createDataBlocks(KRMeshManager::KRVBOData::vbo_type t) int iBuffer = iVertex / MAX_VBO_SIZE; iVertex = iVertex % MAX_VBO_SIZE; while (cVertexes > 0) { - GLsizei cBufferVertexes = iBuffer < cBuffers - 1 ? MAX_VBO_SIZE : vertex_count % MAX_VBO_SIZE; + int cBufferVertexes = iBuffer < cBuffers - 1 ? MAX_VBO_SIZE : vertex_count % MAX_VBO_SIZE; int vertex_size = m_vertex_size; if ((int)mesh.vertex_data_blocks.size() <= vbo_index) { @@ -493,7 +493,7 @@ void KRMesh::renderSubmesh(VkCommandBuffer& commandBuffer, int iSubmesh, KRNode: int iBuffer = iVertex / MAX_VBO_SIZE; iVertex = iVertex % MAX_VBO_SIZE; while (cVertexes > 0) { - GLsizei cBufferVertexes = iBuffer < cBuffers - 1 ? MAX_VBO_SIZE : cVertexes % MAX_VBO_SIZE; + int cBufferVertexes = iBuffer < cBuffers - 1 ? MAX_VBO_SIZE : cVertexes % MAX_VBO_SIZE; KRMeshManager::KRVBOData& vbo_data_block = **vbo_itr++; assert(vbo_data_block.isVBOReady()); diff --git a/kraken/KRPipeline.cpp b/kraken/KRPipeline.cpp index b3c82c8..c74a845 100644 --- a/kraken/KRPipeline.cpp +++ b/kraken/KRPipeline.cpp @@ -641,7 +641,7 @@ void KRPipeline::setPushConstant(PushConstant location, const Matrix4* value, co for (StageInfo& stageInfo : m_stages) { PushConstantInfo& pushConstants = stageInfo.pushConstants; // TODO - Vulkan refactoring - // GLDEBUG(glUniformMatrix4fv(pushConstants.offset[KRPipeline::PushConstant::bone_transforms], (GLsizei)bones.size(), GL_FALSE, bone_mats)); + // GLDEBUG(glUniformMatrix4fv(pushConstants.offset[KRPipeline::PushConstant::bone_transforms], (int)bones.size(), GL_FALSE, bone_mats)); } } @@ -672,7 +672,7 @@ bool KRPipeline::bind(VkCommandBuffer& commandBuffer, KRCamera& camera, const KR int cShadowBuffers = directional_light->getShadowBufferCount(); if (hasPushConstant(PushConstant::shadowtexture1) && cShadowBuffers > 0) { // TODO - Vulkan Refactoring. Note: Sampler needs clamp-to-edge and linear filtering - if (m_pContext->getTextureManager()->selectTexture(GL_TEXTURE_2D, 3, directional_light->getShadowTextures()[0])) { + if (m_pContext->getTextureManager()->selectTexture(0 /*GL_TEXTURE_2D*/, 3, directional_light->getShadowTextures()[0])) { GLDEBUG(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); GLDEBUG(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); } @@ -680,7 +680,7 @@ bool KRPipeline::bind(VkCommandBuffer& commandBuffer, KRCamera& camera, const KR if (hasPushConstant(PushConstant::shadowtexture2) && cShadowBuffers > 1 && camera.settings.m_cShadowBuffers > 1) { // TODO - Vulkan Refactoring. Note: Sampler needs clamp-to-edge and linear filtering - if (m_pContext->getTextureManager()->selectTexture(GL_TEXTURE_2D, 4, directional_light->getShadowTextures()[1])) { + if (m_pContext->getTextureManager()->selectTexture(0 /*GL_TEXTURE_2D*/, 4, directional_light->getShadowTextures()[1])) { GLDEBUG(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); GLDEBUG(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); } @@ -688,7 +688,7 @@ bool KRPipeline::bind(VkCommandBuffer& commandBuffer, KRCamera& camera, const KR if (hasPushConstant(PushConstant::shadowtexture3) && cShadowBuffers > 2 && camera.settings.m_cShadowBuffers > 2) { // TODO - Vulkan Refactoring. Note: Sampler needs clamp-to-edge and linear filtering - if (m_pContext->getTextureManager()->selectTexture(GL_TEXTURE_2D, 5, directional_light->getShadowTextures()[2])) { + if (m_pContext->getTextureManager()->selectTexture(0 /*GL_TEXTURE_2D*/, 5, directional_light->getShadowTextures()[2])) { GLDEBUG(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); GLDEBUG(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); } diff --git a/kraken/KRTextureKTX.cpp b/kraken/KRTextureKTX.cpp index bdb43de..b1d121c 100755 --- a/kraken/KRTextureKTX.cpp +++ b/kraken/KRTextureKTX.cpp @@ -84,7 +84,7 @@ KRTextureKTX::KRTextureKTX(KRContext& context, KRDataBlock* data, std::string na m_min_lod_max_dim = KRMAX(width, height); } -KRTextureKTX::KRTextureKTX(KRContext& context, std::string name, GLenum internal_format, GLenum base_internal_format, int width, int height, const std::list& blocks) : KRTexture2D(context, new KRDataBlock(), name) +KRTextureKTX::KRTextureKTX(KRContext& context, std::string name, unsigned int internal_format, unsigned int base_internal_format, int width, int height, const std::list& blocks) : KRTexture2D(context, new KRDataBlock(), name) { memcpy(m_header.identifier, _KTXFileIdentifier, 12); m_header.endianness = 0x04030201; @@ -193,7 +193,7 @@ bool KRTextureKTX::uploadTexture(KRDevice& device, VkImage& image, int lod_max_d block->lock(); /* * TODO - Vulkan Refactoring - GLDEBUG(glCompressedTexImage2D(target, destination_level, (GLenum)m_header.glInternalFormat, width, height, 0, (GLsizei)block->getSize(), block->getStart())); + GLDEBUG(glCompressedTexImage2D(target, destination_level, (unsigned int)m_header.glInternalFormat, width, height, 0, (int)block->getSize(), block->getStart())); */ block->unlock(); diff --git a/kraken/KRTextureKTX.h b/kraken/KRTextureKTX.h index df400cf..e5336d0 100755 --- a/kraken/KRTextureKTX.h +++ b/kraken/KRTextureKTX.h @@ -37,7 +37,7 @@ class KRTextureKTX : public KRTexture2D { public: KRTextureKTX(KRContext& context, KRDataBlock* data, std::string name); - KRTextureKTX(KRContext& context, std::string name, GLenum internal_format, GLenum base_internal_format, int width, int height, const std::list& blocks); + KRTextureKTX(KRContext& context, std::string name, unsigned int internal_format, unsigned int base_internal_format, int width, int height, const std::list& blocks); virtual ~KRTextureKTX(); virtual std::string getExtension(); diff --git a/kraken/KRTextureManager.cpp b/kraken/KRTextureManager.cpp index a520479..d874a82 100755 --- a/kraken/KRTextureManager.cpp +++ b/kraken/KRTextureManager.cpp @@ -194,7 +194,7 @@ KRTexture* KRTextureManager::getTexture(const std::string& name) } } -bool KRTextureManager::selectTexture(GLenum target, int iTextureUnit, int iTextureHandle) +bool KRTextureManager::selectTexture(unsigned int target, int iTextureUnit, int iTextureHandle) { // TODO - Vulkan Refactoring return true; diff --git a/kraken/KRTextureManager.h b/kraken/KRTextureManager.h index 4453e85..ac2e2c4 100755 --- a/kraken/KRTextureManager.h +++ b/kraken/KRTextureManager.h @@ -52,7 +52,7 @@ public: virtual KRResource* loadResource(const std::string& name, const std::string& extension, KRDataBlock* data) override; virtual KRResource* getResource(const std::string& name, const std::string& extension) override; - bool selectTexture(GLenum target, int iTextureUnit, int iTextureHandle); + bool selectTexture(unsigned int target, int iTextureUnit, int iTextureHandle); KRTexture* loadTexture(const char* szName, const char* szExtension, KRDataBlock* data); KRTexture* getTextureCube(const char* szName); diff --git a/kraken/KRTexturePVR.cpp b/kraken/KRTexturePVR.cpp index 070f8a3..7b6648f 100755 --- a/kraken/KRTexturePVR.cpp +++ b/kraken/KRTexturePVR.cpp @@ -212,7 +212,7 @@ bool KRTexturePVR::uploadTexture(KRDevice& device, VkImage& image, int lod_max_d block->lock(); /* * TODO - Vulkan Refactoring - GLDEBUG(glCompressedTexImage2D(target, destination_level, m_internalFormat, width, height, 0, (GLsizei)block->getSize(), block->getStart())); + GLDEBUG(glCompressedTexImage2D(target, destination_level, m_internalFormat, width, height, 0, (int)block->getSize(), block->getStart())); */ block->unlock(); memoryTransferred += (long)block->getSize(); // memoryTransferred does not include throughput of mipmap levels copied through glCopyTextureLevelsAPPLE diff --git a/kraken/KRTexturePVR.h b/kraken/KRTexturePVR.h index ecf2f0f..a448df1 100755 --- a/kraken/KRTexturePVR.h +++ b/kraken/KRTexturePVR.h @@ -49,7 +49,7 @@ protected: uint32_t m_iWidth; uint32_t m_iHeight; - GLenum m_internalFormat; + unsigned int m_internalFormat; bool m_bHasAlpha; std::list m_blocks; diff --git a/kraken/KRTextureTGA.cpp b/kraken/KRTextureTGA.cpp index 8ffedd7..b34958c 100755 --- a/kraken/KRTextureTGA.cpp +++ b/kraken/KRTextureTGA.cpp @@ -126,7 +126,7 @@ bool KRTextureTGA::uploadTexture(KRDevice& device, VkImage& image, int lod_max_d /* * TODO - Vulkan refactoring to support compressing textures on load - GLenum internal_format = GL_RGBA; + unsigned int internal_format = GL_RGBA; if(compress) { internal_format = pHeader->bitsperpixel == 24 ? GL_COMPRESSED_RGB_S3TC_DXT1_EXT : GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; }