Remove g4
This commit is contained in:
@@ -235,12 +235,7 @@ static void updateImage(kinc_video_t *video) {
|
||||
|
||||
if (pixelBuffer != NULL) {
|
||||
CVPixelBufferLockBaseAddress(pixelBuffer, 0);
|
||||
#ifdef KINC_OPENGL
|
||||
kinc_g4_texture_upload(&video->impl.image, (uint8_t *)CVPixelBufferGetBaseAddress(pixelBuffer),
|
||||
(int)(CVPixelBufferGetBytesPerRow(pixelBuffer) / 4));
|
||||
#else
|
||||
kinc_g4_texture_upload(&video->impl.image, (uint8_t *)CVPixelBufferGetBaseAddress(pixelBuffer), (int)(CVPixelBufferGetBytesPerRow(pixelBuffer)));
|
||||
#endif
|
||||
CVPixelBufferUnlockBaseAddress(pixelBuffer, 0);
|
||||
}
|
||||
CFRelease(buffer);
|
||||
|
||||
@@ -1,21 +1,13 @@
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
#ifdef KINC_METAL
|
||||
#import <Metal/Metal.h>
|
||||
#import <QuartzCore/CAMetalLayer.h>
|
||||
#else
|
||||
#import <OpenGLES/ES1/gl.h>
|
||||
#import <OpenGLES/ES1/glext.h>
|
||||
#endif
|
||||
#ifndef KINC_TVOS
|
||||
#import <CoreMotion/CMMotionManager.h>
|
||||
#endif
|
||||
|
||||
struct kinc_g5_render_target;
|
||||
|
||||
@interface GLView : UIView <UIKeyInput> {
|
||||
@private
|
||||
#ifdef KINC_METAL
|
||||
id<MTLDevice> device;
|
||||
id<MTLCommandQueue> commandQueue;
|
||||
id<MTLCommandBuffer> commandBuffer;
|
||||
@@ -24,14 +16,8 @@ struct kinc_g5_render_target;
|
||||
id<MTLLibrary> library;
|
||||
MTLRenderPassDescriptor *renderPassDescriptor;
|
||||
id<MTLTexture> depthTexture;
|
||||
#else
|
||||
EAGLContext *context;
|
||||
GLuint defaultFramebuffer, colorRenderbuffer, depthStencilRenderbuffer;
|
||||
#endif
|
||||
|
||||
#ifndef KINC_TVOS
|
||||
CMMotionManager *motionManager;
|
||||
#endif
|
||||
bool hasAccelerometer;
|
||||
float lastAccelerometerX, lastAccelerometerY, lastAccelerometerZ;
|
||||
}
|
||||
@@ -40,11 +26,9 @@ struct kinc_g5_render_target;
|
||||
- (void)end;
|
||||
- (void)showKeyboard;
|
||||
- (void)hideKeyboard;
|
||||
#ifdef KINC_METAL
|
||||
- (CAMetalLayer *)metalLayer;
|
||||
- (id<MTLDevice>)metalDevice;
|
||||
- (id<MTLLibrary>)metalLibrary;
|
||||
- (id<MTLCommandQueue>)metalQueue;
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
||||
@@ -10,10 +10,6 @@
|
||||
#include <kinc/input/surface.h>
|
||||
#include <kinc/system.h>
|
||||
|
||||
#ifdef KINC_OPENGL
|
||||
#include <kinc/backend/graphics4/OpenGLWindow.h>
|
||||
#endif
|
||||
|
||||
static const int touchmaxcount = 20;
|
||||
static void *touches[touchmaxcount];
|
||||
|
||||
@@ -63,21 +59,10 @@ int kinc_window_height(int window) {
|
||||
|
||||
@implementation GLView
|
||||
|
||||
#ifdef KINC_METAL
|
||||
+ (Class)layerClass {
|
||||
return [CAMetalLayer class];
|
||||
}
|
||||
#else
|
||||
+ (Class)layerClass {
|
||||
return [CAEAGLLayer class];
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef KINC_OPENGL
|
||||
extern int kinc_ios_gl_framebuffer;
|
||||
#endif
|
||||
|
||||
#ifdef KINC_METAL
|
||||
- (void)hoverGesture:(UIHoverGestureRecognizer *)recognizer {
|
||||
CGPoint point = [recognizer locationInView:self];
|
||||
float x = point.x * self.contentScaleFactor;
|
||||
@@ -113,102 +98,15 @@ extern int kinc_ios_gl_framebuffer;
|
||||
|
||||
return self;
|
||||
}
|
||||
#else
|
||||
- (id)initWithFrame:(CGRect)frame {
|
||||
self = [super initWithFrame:(CGRect)frame];
|
||||
self.contentScaleFactor = [UIScreen mainScreen].scale;
|
||||
|
||||
backingWidth = frame.size.width * self.contentScaleFactor;
|
||||
backingHeight = frame.size.height * self.contentScaleFactor;
|
||||
|
||||
initTouches();
|
||||
|
||||
CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer;
|
||||
|
||||
eaglLayer.opaque = YES;
|
||||
eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking,
|
||||
kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil];
|
||||
|
||||
context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
|
||||
|
||||
if (!context || ![EAGLContext setCurrentContext:context]) {
|
||||
//[self release];
|
||||
return nil;
|
||||
}
|
||||
|
||||
glGenFramebuffersOES(1, &defaultFramebuffer);
|
||||
glBindFramebufferOES(GL_FRAMEBUFFER_OES, defaultFramebuffer);
|
||||
kinc_ios_gl_framebuffer = defaultFramebuffer;
|
||||
|
||||
glGenRenderbuffersOES(1, &colorRenderbuffer);
|
||||
glBindRenderbufferOES(GL_RENDERBUFFER_OES, colorRenderbuffer);
|
||||
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, colorRenderbuffer);
|
||||
|
||||
glGenRenderbuffersOES(1, &depthStencilRenderbuffer);
|
||||
glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthStencilRenderbuffer);
|
||||
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthStencilRenderbuffer);
|
||||
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_STENCIL_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthStencilRenderbuffer);
|
||||
|
||||
// Start acceletometer
|
||||
hasAccelerometer = false;
|
||||
#ifndef KINC_TVOS
|
||||
motionManager = [[CMMotionManager alloc] init];
|
||||
if ([motionManager isAccelerometerAvailable]) {
|
||||
motionManager.accelerometerUpdateInterval = 0.033;
|
||||
[motionManager startAccelerometerUpdates];
|
||||
hasAccelerometer = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef KINC_TVOS
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onKeyboardHide:) name:UIKeyboardWillHideNotification object:nil];
|
||||
#endif
|
||||
|
||||
return self;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef KINC_METAL
|
||||
- (void)begin {
|
||||
}
|
||||
#else
|
||||
- (void)begin {
|
||||
[EAGLContext setCurrentContext:context];
|
||||
// glBindFramebufferOES(GL_FRAMEBUFFER_OES, defaultFramebuffer);
|
||||
// glViewport(0, 0, backingWidth, backingHeight);
|
||||
|
||||
#ifndef KINC_TVOS
|
||||
// Accelerometer updates
|
||||
if (hasAccelerometer) {
|
||||
|
||||
CMAcceleration acc = motionManager.accelerometerData.acceleration;
|
||||
|
||||
if (acc.x != lastAccelerometerX || acc.y != lastAccelerometerY || acc.z != lastAccelerometerZ) {
|
||||
|
||||
kinc_internal_on_acceleration(acc.x, acc.y, acc.z);
|
||||
|
||||
lastAccelerometerX = acc.x;
|
||||
lastAccelerometerY = acc.y;
|
||||
lastAccelerometerZ = acc.z;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef KINC_METAL
|
||||
- (void)end {
|
||||
}
|
||||
#else
|
||||
- (void)end {
|
||||
glBindRenderbufferOES(GL_RENDERBUFFER_OES, colorRenderbuffer);
|
||||
[context presentRenderbuffer:GL_RENDERBUFFER_OES]; // crash at end
|
||||
}
|
||||
#endif
|
||||
|
||||
void kinc_internal_call_resize_callback(int window, int width, int height);
|
||||
|
||||
#ifdef KINC_METAL
|
||||
- (void)layoutSubviews {
|
||||
backingWidth = self.frame.size.width * self.contentScaleFactor;
|
||||
backingHeight = self.frame.size.height * self.contentScaleFactor;
|
||||
@@ -218,56 +116,9 @@ void kinc_internal_call_resize_callback(int window, int width, int height);
|
||||
|
||||
kinc_internal_call_resize_callback(0, backingWidth, backingHeight);
|
||||
}
|
||||
#else
|
||||
- (void)layoutSubviews {
|
||||
glBindRenderbufferOES(GL_RENDERBUFFER_OES, colorRenderbuffer);
|
||||
[context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(CAEAGLLayer *)self.layer];
|
||||
|
||||
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth);
|
||||
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);
|
||||
|
||||
printf("backingWitdh/Height: %i, %i\n", backingWidth, backingHeight);
|
||||
|
||||
glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthStencilRenderbuffer);
|
||||
glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH24_STENCIL8_OES, backingWidth, backingHeight);
|
||||
|
||||
if (glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) {
|
||||
NSLog(@"Failed to make complete framebuffer object %x", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES));
|
||||
}
|
||||
|
||||
kinc_internal_call_resize_callback(0, backingWidth, backingHeight);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef KINC_METAL
|
||||
- (void)dealloc {
|
||||
}
|
||||
#else
|
||||
- (void)dealloc {
|
||||
if (defaultFramebuffer) {
|
||||
glDeleteFramebuffersOES(1, &defaultFramebuffer);
|
||||
defaultFramebuffer = 0;
|
||||
}
|
||||
|
||||
if (colorRenderbuffer) {
|
||||
glDeleteRenderbuffersOES(1, &colorRenderbuffer);
|
||||
colorRenderbuffer = 0;
|
||||
}
|
||||
|
||||
if (depthStencilRenderbuffer) {
|
||||
glDeleteRenderbuffersOES(1, &depthStencilRenderbuffer);
|
||||
depthStencilRenderbuffer = 0;
|
||||
}
|
||||
|
||||
if ([EAGLContext currentContext] == context)
|
||||
[EAGLContext setCurrentContext:nil];
|
||||
|
||||
//[context release];
|
||||
context = nil;
|
||||
|
||||
//[super dealloc];
|
||||
}
|
||||
#endif
|
||||
|
||||
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||
for (UITouch *touch in touches) {
|
||||
@@ -439,7 +290,6 @@ static bool shiftDown = false;
|
||||
kinc_keyboard_hide();
|
||||
}
|
||||
|
||||
#ifdef KINC_METAL
|
||||
- (CAMetalLayer *)metalLayer {
|
||||
return (CAMetalLayer *)self.layer;
|
||||
}
|
||||
@@ -455,6 +305,5 @@ static bool shiftDown = false;
|
||||
- (id<MTLCommandQueue>)metalQueue {
|
||||
return commandQueue;
|
||||
}
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
#import <OpenGLES/ES1/glext.h>
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
#ifndef KINC_TVOS
|
||||
#import <CoreMotion/CMMotionManager.h>
|
||||
#endif
|
||||
|
||||
@interface GLViewController : UIViewController <UIDocumentPickerDelegate, UIDropInteractionDelegate> {
|
||||
@private
|
||||
|
||||
@@ -1,15 +1,5 @@
|
||||
#ifdef KINC_METAL
|
||||
#import <MetalKit/MTKView.h>
|
||||
#else
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <OpenGL/CGLContext.h>
|
||||
#import <OpenGL/OpenGL.h>
|
||||
#import <OpenGL/gl.h>
|
||||
#import <OpenGL/glext.h>
|
||||
#import <OpenGL/glu.h>
|
||||
#endif
|
||||
|
||||
#ifdef KINC_METAL
|
||||
#import <MetalKit/MTKView.h>
|
||||
|
||||
struct kinc_g5_render_target;
|
||||
|
||||
@@ -20,28 +10,10 @@ struct kinc_g5_render_target;
|
||||
id<MTLLibrary> library;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// (DK) context sharing
|
||||
// www.cocoabuilder.com/archive/cocoa/29573-sharing-opengl-context.html
|
||||
// basically:
|
||||
// -don't use NSOpenGLView, but implement all that by hand
|
||||
// -use -initWithFormat:shareContext: (NSOpenGLContext) to setup the shared contexts
|
||||
@interface BasicOpenGLView : NSOpenGLView {
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef KINC_METAL
|
||||
- (CAMetalLayer *)metalLayer;
|
||||
- (id<MTLDevice>)metalDevice;
|
||||
- (id<MTLLibrary>)metalLibrary;
|
||||
- (id<MTLCommandQueue>)metalQueue;
|
||||
#else
|
||||
- (void)prepareOpenGL;
|
||||
- (void)switchBuffers;
|
||||
+ (NSOpenGLPixelFormat *)basicPixelFormat;
|
||||
#endif
|
||||
|
||||
- (void)keyDown:(NSEvent *)theEvent;
|
||||
- (void)keyUp:(NSEvent *)theEvent;
|
||||
|
||||
@@ -5,9 +5,7 @@
|
||||
#include <kinc/input/pen.h>
|
||||
#include <kinc/system.h>
|
||||
|
||||
#ifdef KINC_METAL
|
||||
#include <kinc/graphics5/graphics.h>
|
||||
#endif
|
||||
|
||||
@implementation BasicOpenGLView
|
||||
|
||||
@@ -16,34 +14,6 @@ static bool ctrl = false;
|
||||
static bool alt = false;
|
||||
static bool cmd = false;
|
||||
|
||||
#ifndef KINC_METAL
|
||||
+ (NSOpenGLPixelFormat *)basicPixelFormat {
|
||||
// TODO (DK) pass via argument in
|
||||
int aa = 1; // Kore::Application::the()->antialiasing();
|
||||
if (aa > 0) {
|
||||
NSOpenGLPixelFormatAttribute attributes[] = {NSOpenGLPFADoubleBuffer, NSOpenGLPFADepthSize,
|
||||
(NSOpenGLPixelFormatAttribute)24, // 16 bit depth buffer
|
||||
NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core,
|
||||
NSOpenGLPFASupersample, NSOpenGLPFASampleBuffers,
|
||||
(NSOpenGLPixelFormatAttribute)1, NSOpenGLPFASamples,
|
||||
(NSOpenGLPixelFormatAttribute)aa, NSOpenGLPFAStencilSize,
|
||||
(NSOpenGLPixelFormatAttribute)8, (NSOpenGLPixelFormatAttribute)0};
|
||||
return [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes];
|
||||
}
|
||||
else {
|
||||
NSOpenGLPixelFormatAttribute attributes[] = {
|
||||
NSOpenGLPFADoubleBuffer, NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute)24, // 16 bit depth buffer
|
||||
NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core, NSOpenGLPFAStencilSize,
|
||||
(NSOpenGLPixelFormatAttribute)8, (NSOpenGLPixelFormatAttribute)0};
|
||||
return [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)switchBuffers {
|
||||
[[self openGLContext] flushBuffer];
|
||||
}
|
||||
#endif
|
||||
|
||||
- (void)flagsChanged:(NSEvent *)theEvent {
|
||||
if (shift) {
|
||||
kinc_internal_keyboard_trigger_key_up(KINC_KEY_SHIFT);
|
||||
@@ -393,32 +363,9 @@ static bool controlKeyMouseButton = false;
|
||||
return YES;
|
||||
}
|
||||
|
||||
#ifndef KINC_METAL
|
||||
- (void)prepareOpenGL {
|
||||
const GLint swapInt = 1;
|
||||
[[self openGLContext] setValues:&swapInt forParameter:NSOpenGLCPSwapInterval];
|
||||
[super prepareOpenGL];
|
||||
}
|
||||
#endif
|
||||
|
||||
- (void)update { // window resizes, moves and display changes (resize, depth and display config change)
|
||||
#ifdef KINC_OPENGL
|
||||
[super update];
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef KINC_METAL
|
||||
- (id)initWithFrame:(NSRect)frameRect {
|
||||
NSOpenGLPixelFormat *pf = [BasicOpenGLView basicPixelFormat];
|
||||
self = [super initWithFrame:frameRect pixelFormat:pf];
|
||||
|
||||
[self prepareOpenGL];
|
||||
[[self openGLContext] makeCurrentContext];
|
||||
[self setWantsBestResolutionOpenGLSurface:YES];
|
||||
return self;
|
||||
}
|
||||
#else
|
||||
|
||||
- (id)initWithFrame:(NSRect)frameRect {
|
||||
self = [super initWithFrame:frameRect];
|
||||
|
||||
@@ -438,7 +385,6 @@ static bool controlKeyMouseButton = false;
|
||||
|
||||
return self;
|
||||
}
|
||||
#endif
|
||||
|
||||
- (BOOL)acceptsFirstResponder {
|
||||
return YES;
|
||||
@@ -456,7 +402,6 @@ static bool controlKeyMouseButton = false;
|
||||
[self setFrameSize:size];
|
||||
}
|
||||
|
||||
#ifdef KINC_METAL
|
||||
- (CAMetalLayer *)metalLayer {
|
||||
return (CAMetalLayer *)self.layer;
|
||||
}
|
||||
@@ -472,7 +417,6 @@ static bool controlKeyMouseButton = false;
|
||||
- (id<MTLCommandQueue>)metalQueue {
|
||||
return commandQueue;
|
||||
}
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -3,9 +3,6 @@
|
||||
#include <kinc/global.h>
|
||||
|
||||
#include <kinc/backend/graphics4/compute.h>
|
||||
#ifdef KINC_OPENGL
|
||||
#include <kinc/graphics4/vertexbuffer.h>
|
||||
#endif
|
||||
#include <kinc/graphics4/graphics.h>
|
||||
|
||||
/*! \file compute.h
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#ifndef OPENGL_1_X
|
||||
|
||||
#include "graphics.h"
|
||||
|
||||
@@ -18,5 +17,3 @@ bool kinc_g5_fullscreen = false;
|
||||
// VertexBuffer* vertexBuffers[1] = {&vertexBuffer};
|
||||
// setVertexBuffers(vertexBuffers, 1);
|
||||
//}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user