opengl renderer: Enable and fix renderer Mac support
The following enables the renderer build on darwin. Moved platform specific type declarations from render_api.h to render_api_platform_types.h so it can be included from the objective c code. Fixed subwindow to use EmuGLView which overrides NSView to prevent background drawing of the view.
This commit is contained in:
committed by
Guy Zadickario
parent
2683b10bdd
commit
b68a421908
@@ -17,28 +17,7 @@
|
|||||||
#define _OPENGL_RENDERER_RENDER_API_H
|
#define _OPENGL_RENDERER_RENDER_API_H
|
||||||
|
|
||||||
#include "IOStream.h"
|
#include "IOStream.h"
|
||||||
|
#include "render_api_platform_types.h"
|
||||||
#if defined(_WIN32) || defined(__VC32__) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) /* Win32 and WinCE */
|
|
||||||
#include <windows.h>
|
|
||||||
|
|
||||||
typedef HDC FBNativeDisplayType;
|
|
||||||
typedef HWND FBNativeWindowType;
|
|
||||||
|
|
||||||
#elif defined(__linux__)
|
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
|
||||||
#include <X11/Xutil.h>
|
|
||||||
|
|
||||||
typedef Window FBNativeWindowType;
|
|
||||||
|
|
||||||
#elif defined(__APPLE__)
|
|
||||||
|
|
||||||
typedef void* FBNativeWindowType;
|
|
||||||
|
|
||||||
#else
|
|
||||||
#warning "Unsupported platform"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// initOpenGLRenderer - initialize the OpenGL renderer process.
|
// initOpenGLRenderer - initialize the OpenGL renderer process.
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
#ifndef _RENDER_API_PLATFORM_TYPES_H
|
||||||
|
#define _RENDER_API_PLATFORM_TYPES_H
|
||||||
|
|
||||||
|
#if defined(_WIN32) || defined(__VC32__) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) /* Win32 and WinCE */
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
typedef HDC FBNativeDisplayType;
|
||||||
|
typedef HWND FBNativeWindowType;
|
||||||
|
|
||||||
|
#elif defined(__linux__)
|
||||||
|
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <X11/Xutil.h>
|
||||||
|
|
||||||
|
typedef Window FBNativeWindowType;
|
||||||
|
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
|
||||||
|
typedef void* FBNativeWindowType;
|
||||||
|
|
||||||
|
#else
|
||||||
|
#warning "Unsupported platform"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // of _RENDER_API_PLATFORM_TYPES_H
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
LOCAL_PATH := $(call my-dir)
|
LOCAL_PATH := $(call my-dir)
|
||||||
|
|
||||||
ifneq ($(HOST_OS),darwin)
|
|
||||||
|
|
||||||
### libOpenglRender #################################################
|
### libOpenglRender #################################################
|
||||||
$(call emugl-begin-host-shared-library,libOpenglRender)
|
$(call emugl-begin-host-shared-library,libOpenglRender)
|
||||||
|
|
||||||
@@ -51,5 +49,3 @@ LOCAL_STATIC_LIBRARIES += libutils liblog
|
|||||||
#$(call emugl-export,CFLAGS,-DCHECK_GL_ERROR)
|
#$(call emugl-export,CFLAGS,-DCHECK_GL_ERROR)
|
||||||
|
|
||||||
$(call emugl-end-module)
|
$(call emugl-end-module)
|
||||||
|
|
||||||
endif # HOST_OS != darwin
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ HandleType FrameBuffer::s_nextHandle = 0;
|
|||||||
|
|
||||||
#ifdef WITH_GLES2
|
#ifdef WITH_GLES2
|
||||||
static const char *getGLES2ExtensionString(EGLDisplay p_dpy,
|
static const char *getGLES2ExtensionString(EGLDisplay p_dpy,
|
||||||
FBNativeWindowType p_window)
|
EGLNativeWindowType p_window)
|
||||||
{
|
{
|
||||||
EGLConfig config;
|
EGLConfig config;
|
||||||
EGLSurface surface;
|
EGLSurface surface;
|
||||||
@@ -44,14 +44,12 @@ static const char *getGLES2ExtensionString(EGLDisplay p_dpy,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__linux__) || defined(_WIN32) || defined(__VC32__) && !defined(__CYGWIN__)
|
|
||||||
surface = s_egl.eglCreateWindowSurface(p_dpy, config,
|
surface = s_egl.eglCreateWindowSurface(p_dpy, config,
|
||||||
(EGLNativeWindowType)p_window,
|
p_window,
|
||||||
NULL);
|
NULL);
|
||||||
if (surface == EGL_NO_SURFACE) {
|
if (surface == EGL_NO_SURFACE) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
GLint gl2ContextAttribs[] = {
|
GLint gl2ContextAttribs[] = {
|
||||||
EGL_CONTEXT_CLIENT_VERSION, 2,
|
EGL_CONTEXT_CLIENT_VERSION, 2,
|
||||||
@@ -165,6 +163,8 @@ bool FrameBuffer::initialize(FBNativeWindowType p_window,
|
|||||||
|
|
||||||
fb->m_nativeWindow = p_window;
|
fb->m_nativeWindow = p_window;
|
||||||
|
|
||||||
|
fb->m_subWin = createSubWindow(p_window,&fb->m_subWinDisplay,p_x,p_y,p_width,p_height);
|
||||||
|
|
||||||
//
|
//
|
||||||
// if GLES2 plugin has loaded - try to make GLES2 context and
|
// if GLES2 plugin has loaded - try to make GLES2 context and
|
||||||
// get GLES2 extension string
|
// get GLES2 extension string
|
||||||
@@ -172,7 +172,7 @@ bool FrameBuffer::initialize(FBNativeWindowType p_window,
|
|||||||
const char *gl2Extensions = NULL;
|
const char *gl2Extensions = NULL;
|
||||||
#ifdef WITH_GLES2
|
#ifdef WITH_GLES2
|
||||||
if (fb->m_caps.hasGL2) {
|
if (fb->m_caps.hasGL2) {
|
||||||
gl2Extensions = getGLES2ExtensionString(fb->m_eglDisplay, p_window);
|
gl2Extensions = getGLES2ExtensionString(fb->m_eglDisplay, fb->m_subWin);
|
||||||
if (!gl2Extensions) {
|
if (!gl2Extensions) {
|
||||||
// Could not create GLES2 context - drop GL2 capability
|
// Could not create GLES2 context - drop GL2 capability
|
||||||
fb->m_caps.hasGL2 = false;
|
fb->m_caps.hasGL2 = false;
|
||||||
@@ -209,7 +209,6 @@ bool FrameBuffer::initialize(FBNativeWindowType p_window,
|
|||||||
}
|
}
|
||||||
|
|
||||||
EGLNativeDisplayType dpy;
|
EGLNativeDisplayType dpy;
|
||||||
fb->m_subWin = createSubWindow(p_window,&fb->m_subWinDisplay,p_x,p_y,p_width,p_height);
|
|
||||||
fb->m_eglSurface = s_egl.eglCreateWindowSurface(fb->m_eglDisplay, eglConfig,
|
fb->m_eglSurface = s_egl.eglCreateWindowSurface(fb->m_eglDisplay, eglConfig,
|
||||||
fb->m_subWin,
|
fb->m_subWin,
|
||||||
NULL);
|
NULL);
|
||||||
|
|||||||
@@ -25,11 +25,6 @@
|
|||||||
#include <EGL/egl.h>
|
#include <EGL/egl.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#if defined(__linux__) || defined(_WIN32) || defined(__VC32__) && !defined(__CYGWIN__)
|
|
||||||
#else
|
|
||||||
#warning "Unsupported Platform"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef uint32_t HandleType;
|
typedef uint32_t HandleType;
|
||||||
typedef std::map<HandleType, RenderContextPtr> RenderContextMap;
|
typedef std::map<HandleType, RenderContextPtr> RenderContextMap;
|
||||||
typedef std::map<HandleType, WindowSurfacePtr> WindowSurfaceMap;
|
typedef std::map<HandleType, WindowSurfacePtr> WindowSurfaceMap;
|
||||||
|
|||||||
@@ -16,22 +16,40 @@
|
|||||||
#include "NativeSubWindow.h"
|
#include "NativeSubWindow.h"
|
||||||
#include <Cocoa/Cocoa.h>
|
#include <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* EmuGLView inherit from NSView and override the isOpaque
|
||||||
|
* method to return YES. That prevents drawing of underlying window/view
|
||||||
|
* when the view needs to be redrawn.
|
||||||
|
*/
|
||||||
|
@interface EmuGLView : NSView {
|
||||||
|
} @end
|
||||||
|
|
||||||
|
@implementation EmuGLView
|
||||||
|
|
||||||
|
- (BOOL)isOpaque {
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
||||||
EGLNativeWindowType createSubWindow(FBNativeWindowType p_window,
|
EGLNativeWindowType createSubWindow(FBNativeWindowType p_window,
|
||||||
EGLNativeDisplayType* display_out,
|
EGLNativeDisplayType* display_out,
|
||||||
int x, int y,int width, int height){
|
int x, int y,int width, int height){
|
||||||
NSRect contentRect = NSMakeRect(x, y, width, height);
|
NSRect contentRect = NSMakeRect(x, y, width, height);
|
||||||
NSView *glView = [[NSView alloc] initWithFrame:contentRect];
|
NSView *glView = [[EmuGLView alloc] initWithFrame:contentRect];
|
||||||
if (glView) {
|
if (glView) {
|
||||||
NSWindow *win = (NSWindow *)p_window;
|
NSWindow *win = (NSWindow *)p_window;
|
||||||
[[win contentView] addSubview:glView];
|
[[win contentView] addSubview:glView];
|
||||||
[win makeKeyAndOrderFront:nil];
|
[win makeKeyAndOrderFront:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
return (EGLNativeWindowType)glView;
|
return (EGLNativeWindowType)glView;
|
||||||
}
|
}
|
||||||
|
|
||||||
void destroySubWindow(EGLNativeDisplayType dis,EGLNativeWindowType win){
|
void destroySubWindow(EGLNativeDisplayType dis,EGLNativeWindowType win){
|
||||||
if(win){
|
if(win){
|
||||||
delete win;
|
NSView *glView = (NSView *)win;
|
||||||
|
[glView release];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,11 @@
|
|||||||
#define NATIVE_SUB_WINDOW_H
|
#define NATIVE_SUB_WINDOW_H
|
||||||
|
|
||||||
#include <EGL/egl.h>
|
#include <EGL/egl.h>
|
||||||
#include "libOpenglRender/render_api.h"
|
#include "libOpenglRender/render_api_platform_types.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
EGLNativeWindowType createSubWindow(FBNativeWindowType p_window,
|
EGLNativeWindowType createSubWindow(FBNativeWindowType p_window,
|
||||||
EGLNativeDisplayType* display_out,
|
EGLNativeDisplayType* display_out,
|
||||||
@@ -26,4 +30,8 @@ EGLNativeWindowType createSubWindow(FBNativeWindowType p_window,
|
|||||||
|
|
||||||
void destroySubWindow(EGLNativeDisplayType dis,EGLNativeWindowType win);
|
void destroySubWindow(EGLNativeDisplayType dis,EGLNativeWindowType win);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -228,7 +228,14 @@ void WindowSurface::copyToColorBuffer()
|
|||||||
GL_RGBA, GL_UNSIGNED_BYTE, data);
|
GL_RGBA, GL_UNSIGNED_BYTE, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// XXX: for some reason flipping the image is not required on
|
||||||
|
// Mac. Need to find the reason, currently unkbown.
|
||||||
|
//
|
||||||
|
#ifndef __APPLE__
|
||||||
#define FLIP_BUFFER 1
|
#define FLIP_BUFFER 1
|
||||||
|
#endif
|
||||||
|
|
||||||
#if FLIP_BUFFER
|
#if FLIP_BUFFER
|
||||||
//We need to flip the pixels
|
//We need to flip the pixels
|
||||||
int bpp = 4;
|
int bpp = 4;
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
LOCAL_PATH:=$(call my-dir)
|
LOCAL_PATH:=$(call my-dir)
|
||||||
|
|
||||||
# OS X not supported for now
|
|
||||||
ifneq ($(HOST_OS),darwin)
|
|
||||||
# host renderer process ###########################
|
# host renderer process ###########################
|
||||||
include $(CLEAR_VARS)
|
include $(CLEAR_VARS)
|
||||||
|
|
||||||
@@ -31,4 +29,3 @@ LOCAL_SHARED_LIBRARIES := libOpenglRender \
|
|||||||
lib_renderControl_dec
|
lib_renderControl_dec
|
||||||
|
|
||||||
include $(BUILD_HOST_EXECUTABLE)
|
include $(BUILD_HOST_EXECUTABLE)
|
||||||
endif # HOST_OS != darwin
|
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
LOCAL_PATH:=$(call my-dir)
|
LOCAL_PATH:=$(call my-dir)
|
||||||
|
|
||||||
# For now, OS X is not supported
|
|
||||||
ifneq ($(HOST_OS),darwin)
|
|
||||||
|
|
||||||
$(call emugl-begin-host-executable,emulator_test_renderer)
|
$(call emugl-begin-host-executable,emulator_test_renderer)
|
||||||
$(call emugl-import,libOpenglRender)
|
$(call emugl-import,libOpenglRender)
|
||||||
|
|
||||||
@@ -23,5 +20,3 @@ endif
|
|||||||
LOCAL_STATIC_LIBRARIES += libSDL libSDLmain
|
LOCAL_STATIC_LIBRARIES += libSDL libSDLmain
|
||||||
|
|
||||||
$(call emugl-end-module)
|
$(call emugl-end-module)
|
||||||
|
|
||||||
endif # HOST_OS != darwin
|
|
||||||
|
|||||||
Reference in New Issue
Block a user