Skip to content

Commit

Permalink
Clean up the KINC/KORE define chaos
Browse files Browse the repository at this point in the history
  • Loading branch information
RobDangerous committed Mar 26, 2024
1 parent 556e2fb commit ea5a2a1
Show file tree
Hide file tree
Showing 106 changed files with 623 additions and 625 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@
#include <AudioClient.h>
#include <Windows.h>
#include <initguid.h>
#ifdef KORE_WINRT
#ifdef KINC_WINRT
#include <mfapi.h>
#endif
#include <mmdeviceapi.h>
#include <wrl/implements.h>

using namespace Kore;

#ifdef KORE_WINRT
#ifdef KINC_WINRT
using namespace ::Microsoft::WRL;
using namespace Windows::Media::Devices;
using namespace Windows::Storage::Streams;
Expand Down Expand Up @@ -57,7 +55,7 @@ namespace {
bool initDefaultDevice();
void audioThread(LPVOID);

#ifdef KORE_WINRT
#ifdef KINC_WINRT
class AudioRenderer : public RuntimeClass<RuntimeClassFlags<ClassicCom>, FtmBase, IActivateAudioInterfaceCompletionHandler> {
public:
STDMETHOD(ActivateCompleted)(IActivateAudioInterfaceAsyncOperation *operation) {
Expand All @@ -77,7 +75,7 @@ namespace {
#endif

bool initDefaultDevice() {
#ifdef KORE_WINRT
#ifdef KINC_WINRT
HRESULT hr = S_OK;
#else
if (renderClient != NULL) {
Expand Down Expand Up @@ -250,7 +248,7 @@ namespace {

} // namespace

#ifndef KORE_WINRT
#ifndef KINC_WINRT
extern "C" void kinc_windows_co_initialize(void);
#endif

Expand All @@ -274,7 +272,7 @@ void kinc_a2_init() {
audioProcessingDoneEvent = CreateEvent(0, FALSE, FALSE, 0);
kinc_affirm(audioProcessingDoneEvent != 0);

#ifdef KORE_WINRT
#ifdef KINC_WINRT
renderer = Make<AudioRenderer>();

IActivateAudioInterfaceAsyncOperation *asyncOp;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifdef KORE_WINDOWSAPP
#ifdef KINC_WINDOWSAPP

#include <Kore/Audio3/TextToSpeech.h>
#include <Kore/Log.h>
Expand Down
2 changes: 1 addition & 1 deletion Backends/Graphics3/OpenGL1/Sources/GL/glew.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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_PI)
shortData = new u16[indexCount];
#endif
}
Expand All @@ -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_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_PI)
glBufferData(GL_ELEMENT_ARRAY_BUFFER, myCount * 2, shortData, GL_STATIC_DRAW);
glCheckErrors();
#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Kore {
IndexBufferImpl(int count);
void unset();

#if defined(KORE_ANDROID) || defined(KORE_PI)
#if defined(KINC_ANDROID) || defined(KINC_PI)
u16 *shortData;
#endif
int *data;
Expand Down
50 changes: 25 additions & 25 deletions Backends/Graphics3/OpenGL1/Sources/kinc/backend/OpenGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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};
Expand All @@ -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);
Expand All @@ -88,20 +88,20 @@ void Graphics3::destroy(int windowId) {

#undef CreateWindow

#ifdef KORE_WINDOWS
#ifdef KINC_WINDOWS
namespace Kore {
namespace System {
extern int currentDeviceId;
}
}
#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
Expand Down Expand Up @@ -195,19 +195,19 @@ 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)
wglSwapIntervalEXT(1);
}
#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_TIZEN) && !defined(KINC_PI)
glGenVertexArrays(1, &arrayId[windowId]);
#endif
glCheckErrors();
Expand All @@ -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
}
Expand Down Expand Up @@ -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_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)));
Expand All @@ -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]);
}
Expand All @@ -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);
Expand Down Expand Up @@ -477,7 +477,7 @@ void Graphics3::setStencilParameters(ZCompareMode compareMode, StencilAction bot
//#endif
}*/

#ifdef KORE_WINDOWS
#ifdef KINC_WINDOWS
void Graphics3::clearCurrent() {
wglMakeCurrent(nullptr, nullptr);
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ea5a2a1

Please sign in to comment.