Kore Update

This commit is contained in:
Gorochu
2026-06-09 12:45:01 -07:00
parent a2d5c9aea4
commit 7558d03739
371 changed files with 30188 additions and 7466 deletions

View File

@ -29,7 +29,7 @@
** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
** THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef KORE_WINDOWS
#ifdef KINC_WINDOWS
#include <GL/glew.h>
#if defined(GLEW_OSMESA)

View File

@ -7,7 +7,7 @@
using namespace Kore;
#if defined(KORE_WINDOWS) || (defined(KORE_LINUX) && defined(GL_VERSION_4_3)) || (defined(KORE_ANDROID) && defined(GL_ES_VERSION_3_1))
#if defined(KINC_WINDOWS) || (defined(KINC_LINUX) && defined(GL_VERSION_4_3)) || (defined(KINC_ANDROID) && defined(GL_ES_VERSION_3_1))
#define HAS_COMPUTE
#endif

View File

@ -12,7 +12,7 @@ Graphics3::IndexBuffer::IndexBuffer(int indexCount) : IndexBufferImpl(indexCount
glGenBuffers(1, &bufferId);
glCheckErrors();
data = new int[indexCount];
#if defined(KORE_ANDROID) || defined(KORE_PI)
#if defined(KINC_ANDROID) || defined(KINC_RASPBERRY_PI)
shortData = new u16[indexCount];
#endif
}
@ -27,13 +27,13 @@ int *Graphics3::IndexBuffer::lock() {
}
void Graphics3::IndexBuffer::unlock() {
#if defined(KORE_ANDROID) || defined(KORE_PI)
#if defined(KINC_ANDROID) || defined(KINC_RASPBERRY_PI)
for (int i = 0; i < myCount; ++i)
shortData[i] = (u16)data[i];
#endif
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferId);
glCheckErrors();
#if defined(KORE_ANDROID) || defined(KORE_PI)
#if defined(KINC_ANDROID) || defined(KINC_RASPBERRY_PI)
glBufferData(GL_ELEMENT_ARRAY_BUFFER, myCount * 2, shortData, GL_STATIC_DRAW);
glCheckErrors();
#else

View File

@ -11,7 +11,7 @@ namespace Kore {
IndexBufferImpl(int count);
void unset();
#if defined(KORE_ANDROID) || defined(KORE_PI)
#if defined(KINC_ANDROID) || defined(KINC_RASPBERRY_PI)
u16 *shortData;
#endif
int *data;

View File

@ -7,11 +7,11 @@
#include <cassert>
#include <cstdio>
#ifdef KORE_IOS
#ifdef KINC_IOS
#include <OpenGLES/ES1/glext.h>
#endif
#ifdef KORE_WINDOWS
#ifdef KINC_WINDOWS
#include <GL/wglew.h>
#define WIN32_LEAN_AND_MEAN
@ -25,13 +25,13 @@
using namespace Kore;
namespace Kore {
#if !defined(KORE_IOS) && !defined(KORE_ANDROID)
#if !defined(KINC_IOS) && !defined(KINC_ANDROID)
extern bool programUsesTessellation;
#endif
}
namespace {
#ifdef KORE_WINDOWS
#ifdef KINC_WINDOWS
HINSTANCE instance = 0;
HDC deviceContexts[10] = {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr};
HGLRC glContexts[10] = {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr};
@ -57,13 +57,13 @@ namespace {
mat4 world;
} g_wvpTransform;
#if defined(KORE_OPENGL_ES) && defined(KORE_ANDROID) && KORE_ANDROID_API >= 18
#if defined(KINC_OPENGL_ES) && defined(KINC_ANDROID) && KINC_ANDROID_API >= 18
void *glesDrawBuffers;
#endif
}
void Graphics3::destroy(int windowId) {
#ifdef KORE_WINDOWS
#ifdef KINC_WINDOWS
if (glContexts[windowId]) {
if (!wglMakeCurrent(nullptr, nullptr)) {
// MessageBox(NULL,"Release Of DC And RC Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
@ -88,7 +88,7 @@ void Graphics3::destroy(int windowId) {
#undef CreateWindow
#ifdef KORE_WINDOWS
#ifdef KINC_WINDOWS
namespace Kore {
namespace System {
extern int currentDeviceId;
@ -96,12 +96,12 @@ namespace Kore {
}
#endif
#ifdef KORE_WINDOWS
#ifdef KINC_WINDOWS
void Graphics3::setup() {}
#endif
void Graphics3::init(int windowId, int depthBufferBits, int stencilBufferBits, bool vsync) {
#ifdef KORE_WINDOWS
#ifdef KINC_WINDOWS
HWND windowHandle = (HWND)System::windowHandle(windowId);
#ifndef VR_RIFT
@ -195,7 +195,7 @@ void Graphics3::init(int windowId, int depthBufferBits, int stencilBufferBits, b
}
#endif
#ifdef KORE_WINDOWS
#ifdef KINC_WINDOWS
if (windowId == 0) {
// TODO (DK) check if we actually want vsync
if (wglSwapIntervalEXT != nullptr)
@ -203,11 +203,11 @@ void Graphics3::init(int windowId, int depthBufferBits, int stencilBufferBits, b
}
#endif
#if defined(KORE_IOS)
#if defined(KINC_IOS)
glGenVertexArraysOES(1, &arrayId[windowId]);
#elif defined(KORE_MACOS)
#elif defined(KINC_MACOS)
glGenVertexArraysAPPLE(1, &arrayId[windowId]);
#elif !defined(KORE_ANDROID) && !defined(KORE_EMSCRIPTEN) && !defined(KORE_TIZEN) && !defined(KORE_PI)
#elif !defined(KINC_ANDROID) && !defined(KINC_EMSCRIPTEN) && !defined(KINC_RASPBERRY_PI)
glGenVertexArrays(1, &arrayId[windowId]);
#endif
glCheckErrors();
@ -218,7 +218,7 @@ void Graphics3::init(int windowId, int depthBufferBits, int stencilBufferBits, b
_renderTargetHeight = _height;
renderToBackbuffer = true;
#if defined(KORE_OPENGL_ES) && defined(KORE_ANDROID) && KORE_ANDROID_API >= 18
#if defined(KINC_OPENGL_ES) && defined(KINC_ANDROID) && KINC_ANDROID_API >= 18
glesDrawBuffers = (void *)eglGetProcAddress("glDrawBuffers");
#endif
}
@ -313,8 +313,8 @@ void Graphics3::drawIndexedVertices() {
}
void Graphics3::drawIndexedVertices(int start, int count) {
#ifdef KORE_OPENGL_ES
#if defined(KORE_ANDROID) || defined(KORE_PI)
#ifdef KINC_OPENGL_ES
#if defined(KINC_ANDROID) || defined(KINC_RASPBERRY_PI)
glDrawElements(GL_TRIANGLES, count, GL_UNSIGNED_SHORT, (void *)(start * sizeof(GL_UNSIGNED_SHORT)));
#else
glDrawElements(GL_TRIANGLES, count, GL_UNSIGNED_INT, (void *)(start * sizeof(GL_UNSIGNED_INT)));
@ -329,18 +329,18 @@ void Graphics3::drawIndexedVertices(int start, int count) {
}
void Graphics3::swapBuffers(int contextId) {
#ifdef KORE_WINDOWS
#ifdef KINC_WINDOWS
::SwapBuffers(deviceContexts[contextId]);
#else
System::swapBuffers(contextId);
#endif
}
#ifdef KORE_IOS
#ifdef KINC_IOS
void beginGL();
#endif
#if defined(KORE_WINDOWS)
#if defined(KINC_WINDOWS)
void Graphics3::makeCurrent(int contextId) {
wglMakeCurrent(deviceContexts[contextId], glContexts[contextId]);
}
@ -363,11 +363,11 @@ void Graphics3::begin(int contextId) {
glViewport(0, 0, _width, _height);
#ifdef KORE_IOS
#ifdef KINC_IOS
beginGL();
#endif
#ifdef KORE_ANDROID
#ifdef KINC_ANDROID
// if rendered to a texture, strange things happen if the backbuffer is not cleared
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
@ -477,7 +477,7 @@ void Graphics3::setStencilParameters(ZCompareMode compareMode, StencilAction bot
//#endif
}*/
#ifdef KORE_WINDOWS
#ifdef KINC_WINDOWS
void Graphics3::clearCurrent() {
wglMakeCurrent(nullptr, nullptr);
}
@ -508,7 +508,7 @@ void Graphics3::clear(uint flags, uint color, float depth, int stencil) {
glDepthMask(GL_TRUE);
glCheckErrors();
}
#ifdef KORE_OPENGL_ES
#ifdef KINC_OPENGL_ES
glClearDepthf(depth);
#else
glClearDepth(depth);
@ -1029,9 +1029,9 @@ void Graphics3::setRenderTarget(RenderTarget *texture, int num, int additionalTa
GLenum buffers[16];
for (int i = 0; i <= additionalTargets; ++i)
buffers[i] = GL_COLOR_ATTACHMENT0 + i;
#if defined(KORE_OPENGL_ES) && defined(KORE_ANDROID) && KORE_ANDROID_API >= 18
#if defined(KINC_OPENGL_ES) && defined(KINC_ANDROID) && KINC_ANDROID_API >= 18
((void (*)(GLsizei, GLenum *))glesDrawBuffers)(additionalTargets + 1, buffers);
#elif !defined(KORE_OPENGL_ES)
#elif !defined(KINC_OPENGL_ES)
glDrawBuffers(additionalTargets + 1, buffers);
#endif
}

View File

@ -148,8 +148,8 @@ void Graphics4::Program::link(VertexStructure **structures, int count) {
delete[] errormessage;
}
#ifndef KORE_OPENGL_ES
#ifndef KORE_LINUX
#ifndef KINC_OPENGL_ES
#ifndef KINC_LINUX
/* if (tessellationControlShader != nullptr) {
glPatchParameteri(GL_PATCH_VERTICES, 3);
glCheckErrors();
@ -159,7 +159,7 @@ void Graphics4::Program::link(VertexStructure **structures, int count) {
}
void Graphics4::Program::set() {
#ifndef KORE_OPENGL_ES
#ifndef KINC_OPENGL_ES
programUsesTessellation = tessellationControlShader != nullptr;
#endif
glUseProgram(programId);

View File

@ -4,7 +4,7 @@
#include <Kore/Graphics3/Graphics.h>
#include <Kore/Log.h>
#include <Kore/System.h>
#ifdef KORE_ANDROID
#ifdef KINC_ANDROID
#include <GLContext.h>
#endif
using namespace Kore;
@ -36,8 +36,8 @@ namespace {
}
bool nonPow2RenderTargetsSupported() {
#ifdef KORE_OPENGL_ES
#ifdef KORE_ANDROID
#ifdef KINC_OPENGL_ES
#ifdef KINC_ANDROID
if (ndk_helper::GLContext::GetInstance()->GetGLVersion() >= 3.0)
return true;
else
@ -53,7 +53,7 @@ namespace {
void RenderTargetImpl::setupDepthStencil(int depthBufferBits, int stencilBufferBits, int width, int height) {
if (depthBufferBits > 0 && stencilBufferBits > 0) {
#ifdef KORE_OPENGL_ES
#ifdef KINC_OPENGL_ES
GLenum internalFormat = GL_DEPTH24_STENCIL8_OES;
#else
GLenum internalFormat;
@ -69,7 +69,7 @@ void RenderTargetImpl::setupDepthStencil(int depthBufferBits, int stencilBufferB
// glCheckErrors();
// glRenderbufferStorage(GL_RENDERBUFFER, internalFormat, width, height);
// glCheckErrors();
// #ifdef KORE_OPENGL_ES
// #ifdef KINC_OPENGL_ES
// glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, _depthRenderbuffer);
// glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, _depthRenderbuffer);
// #else
@ -90,7 +90,7 @@ void RenderTargetImpl::setupDepthStencil(int depthBufferBits, int stencilBufferB
glCheckErrors();
glBindFramebuffer(GL_FRAMEBUFFER, _framebuffer);
glCheckErrors();
#ifdef KORE_OPENGL_ES
#ifdef KINC_OPENGL_ES
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, _depthTexture, 0);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, _depthTexture, 0);
#else
@ -160,23 +160,23 @@ Graphics3::RenderTarget::RenderTarget(int width, int height, int depthBufferBits
glCheckErrors();
switch (format) {
#ifndef KORE_MACOS
#ifndef KINC_MACOS
case Target128BitFloat:
#ifdef KORE_OPENGL_ES
#ifdef KINC_OPENGL_ES
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F_EXT, texWidth, texHeight, 0, GL_RGBA, GL_FLOAT, 0);
#else
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, texWidth, texHeight, 0, GL_RGBA, GL_FLOAT, 0);
#endif
break;
case Target64BitFloat:
#ifdef KORE_OPENGL_ES
#ifdef KINC_OPENGL_ES
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_EXT, texWidth, texHeight, 0, GL_RGBA, GL_HALF_FLOAT, 0);
#else
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, texWidth, texHeight, 0, GL_RGBA, GL_HALF_FLOAT, 0);
#endif
break;
case Target16BitDepth:
#ifdef KORE_OPENGL_ES
#ifdef KINC_OPENGL_ES
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
#endif

View File

@ -26,7 +26,7 @@ namespace {
case Graphics3::Image::RGB24:
return GL_RGB;
case Graphics3::Image::Grey8:
#ifdef KORE_OPENGL_ES
#ifdef KINC_OPENGL_ES
return GL_LUMINANCE;
#else
return GL_RED;
@ -49,7 +49,7 @@ namespace {
case Graphics3::Image::RGB24:
return GL_RGB;
case Graphics3::Image::Grey8:
#ifdef KORE_OPENGL_ES
#ifdef KINC_OPENGL_ES
return GL_LUMINANCE;
#else
return GL_RED;
@ -187,14 +187,14 @@ void Graphics3::Texture::init(const char *format, bool readable) {
u8 *conversionBuffer = nullptr;
if (compressed) {
#if defined(KORE_IOS)
#if defined(KINC_IOS)
texWidth = Kore::max(texWidth, texHeight);
texHeight = Kore::max(texWidth, texHeight);
if (texWidth < 8)
texWidth = 8;
if (texHeight < 8)
texHeight = 8;
#elif defined(KORE_ANDROID)
#elif defined(KINC_ANDROID)
texWidth = width;
texHeight = height;
#endif
@ -204,7 +204,7 @@ void Graphics3::Texture::init(const char *format, bool readable) {
convertImageToPow2(this->format, (u8 *)data, width, height, conversionBuffer, texWidth, texHeight);
}
#ifdef KORE_ANDROID
#ifdef KINC_ANDROID
external_oes = false;
#endif
@ -219,9 +219,9 @@ void Graphics3::Texture::init(const char *format, bool readable) {
bool isHdr = convertedType == GL_FLOAT;
if (compressed) {
#ifdef KORE_IOS
#ifdef KINC_IOS
glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, texWidth, texHeight, 0, texWidth * texHeight / 2, data);
// #elif defined(KORE_ANDROID)
// #elif defined(KINC_ANDROID)
// u8 blockX = internalFormat >> 8;
// u8 blockY = internalFormat & 0xff;
// glCompressedTexImage2D(GL_TEXTURE_2D, 0, astcFormat(blockX, blockY), texWidth, texHeight, 0, dataSize, data);
@ -263,7 +263,7 @@ void Graphics3::Texture::init(const char *format, bool readable) {
}
Graphics3::Texture::Texture(int width, int height, Image::Format format, bool readable) : Image(width, height, format, readable) {
#ifdef KORE_IOS
#ifdef KINC_IOS
texWidth = width;
texHeight = height;
#else
@ -278,7 +278,7 @@ Graphics3::Texture::Texture(int width, int height, Image::Format format, bool re
#endif
// conversionBuffer = new u8[texWidth * texHeight * 4];
#ifdef KORE_ANDROID
#ifdef KINC_ANDROID
external_oes = false;
#endif
@ -324,7 +324,7 @@ Graphics3::Texture::Texture(int width, int height, int depth, Graphics3::Image::
#endif
}
#ifdef KORE_ANDROID
#ifdef KINC_ANDROID
Texture::Texture(unsigned texid) : Image(1023, 684, Image::RGBA32, false) {
texture = texid;
external_oes = true;
@ -342,7 +342,7 @@ void Graphics3::Texture::_set(TextureUnit unit) {
GLenum target = depth > 1 ? GL_TEXTURE_3D : GL_TEXTURE_2D;
glActiveTexture(GL_TEXTURE0 + unit.unit);
glCheckErrors();
#ifdef KORE_ANDROID
#ifdef KINC_ANDROID
if (external_oes) {
glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture);
glCheckErrors();
@ -408,7 +408,7 @@ void Graphics3::Texture::clear(int x, int y, int z, int width, int height, int d
#endif
}
#ifdef KORE_IOS
#ifdef KINC_IOS
void Texture::upload(u8 *data) {
glBindTexture(GL_TEXTURE_2D, texture);
glCheckErrors();

View File

@ -17,7 +17,7 @@ namespace Kore {
// static TreeMap<Image, Texture*> images;
public:
unsigned int texture;
#ifdef KORE_ANDROID
#ifdef KINC_ANDROID
bool external_oes;
#endif

View File

@ -15,7 +15,7 @@ namespace Kore {
int myCount;
int myStride;
uint bufferId;
// #if defined KORE_ANDROID || defined KORE_EMSCRIPTEN || defined KORE_TIZEN
// #if defined KINC_ANDROID || defined KINC_EMSCRIPTEN
Graphics4::VertexStructure structure;
// #endif
int instanceDataStepRate;

View File

@ -1,37 +1,37 @@
#pragma once
#ifdef KORE_WINDOWS
#ifdef KINC_WINDOWS
#include <GL/gl.h>
#include <GL/glew.h>
#endif
#ifdef KORE_MACOS
#ifdef KINC_MACOS
#include <OpenGL/gl.h>
#include <OpenGL/glext.h>
#endif
#ifdef KORE_IOS
#ifdef KINC_IOS
#import <OpenGLES/ES2/gl.h>
#import <OpenGLES/ES2/glext.h>
#import <OpenGLES/ES3/gl.h>
#endif
#ifdef KORE_ANDROID
#ifdef KINC_ANDROID
#include <EGL/egl.h>
#if KORE_ANDROID_API >= 18
#if KINC_ANDROID_API >= 18
#include <GLES3/gl3.h>
#endif
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#endif
#ifdef KORE_EMSCRIPTEN
#ifdef KINC_EMSCRIPTEN
#define GL_GLEXT_PROTOTYPES
#define EGL_EGLEXT_PROTOTYPES
#include <GL/gl.h>
#endif
#ifdef KORE_LINUX
#ifdef KINC_LINUX
#include <X11/X.h>
#include <X11/Xlib.h>
#define GL_GLEXT_PROTOTYPES
@ -40,20 +40,16 @@
#include <GL/glx.h>
#endif
#ifdef KORE_PI
#ifdef KINC_RASPBERRY_PI
// #define GL_GLEXT_PROTOTYPES
#include "EGL/egl.h"
#include "EGL/eglext.h"
#include "GLES2/gl2.h"
#endif
#ifdef KORE_TIZEN
#include <gl2.h>
#endif
#include <Kore/Log.h>
#if defined(NDEBUG) || defined(KORE_OSX) || defined(KORE_IOS) || defined(KORE_ANDROID) || 1 // Calling glGetError too early means trouble
#if defined(NDEBUG) || defined(KINC_OSX) || defined(KINC_IOS) || defined(KINC_ANDROID) || 1 // Calling glGetError too early means trouble
#define glCheckErrors() \
{}
#else