am b6b866c5: am 638e7d8b: am 5f82c3ab: am a1b9f9bc: Merge "implementing mac OS support for translator\'s libs"
* commit 'b6b866c5a9f6cca5492b20b9ecbb6ba8b1b1abcf': implementing mac OS support for translator's libs
This commit is contained in:
@@ -14,7 +14,11 @@ ifeq ($(HOST_OS),linux)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(HOST_OS),darwin)
|
ifeq ($(HOST_OS),darwin)
|
||||||
OS_SRCS = EglMacApi.cpp
|
OS_SRCS = EglMacApi.cpp \
|
||||||
|
MacNative.m \
|
||||||
|
MacPixelFormatsAttribs.m
|
||||||
|
|
||||||
|
LOCAL_LDLIBS := -Wl,-framework,AppKit
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(HOST_OS),windows)
|
ifeq ($(HOST_OS),windows)
|
||||||
|
|||||||
@@ -164,9 +164,9 @@ static __translator_getGLESIfaceFunc loadIfaces(const char* libName){
|
|||||||
#elif __linux__
|
#elif __linux__
|
||||||
#define LIB_GLES_CM_NAME "libGLES_CM_translator.so"
|
#define LIB_GLES_CM_NAME "libGLES_CM_translator.so"
|
||||||
#define LIB_GLES_V2_NAME "libGLES_V2_translator.so"
|
#define LIB_GLES_V2_NAME "libGLES_V2_translator.so"
|
||||||
#else
|
#elif __APPLE__
|
||||||
#define LIB_GLES_CM_NAME "libGLES_CM_translator"
|
#define LIB_GLES_CM_NAME "libGLES_CM_translator.dylib"
|
||||||
#define LIB_GLES_V2_NAME "libGLES_V2_translator"
|
#define LIB_GLES_V2_NAME "libGLES_V2_translator.dylib"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
EGLAPI EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay display, EGLint *major, EGLint *minor) {
|
EGLAPI EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay display, EGLint *major, EGLint *minor) {
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2011 The Android Open Source Project
|
* Copyright (C) 2011 The Android Open Source Project
|
||||||
*
|
*
|
||||||
@@ -15,69 +14,177 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
#include "EglOsApi.h"
|
#include "EglOsApi.h"
|
||||||
|
#include "MacNative.h"
|
||||||
|
#define MAX_PBUFFER_MIPMAP_LEVEL 1
|
||||||
|
|
||||||
|
|
||||||
//TODO: implementation for mac for all funcs
|
|
||||||
namespace EglOS {
|
namespace EglOS {
|
||||||
|
|
||||||
EGLNativeDisplayType getDefaultDisplay() {return NULL;}
|
static std::list<EGLNativePixelFormatType> s_nativeConfigs;
|
||||||
|
|
||||||
|
EGLNativeDisplayType getDefaultDisplay() {return 0;}
|
||||||
|
|
||||||
bool releaseDisplay(EGLNativeDisplayType dpy) {
|
bool releaseDisplay(EGLNativeDisplayType dpy) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
EglConfig* pixelFormatToConfig(EGLNativeDisplayType dpy,int renderableType,EGLNativePixelFormatType* frmt){
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void queryConfigs(EGLNativeDisplayType dpy,int renderableType,ConfigsList& listOut) {
|
|
||||||
}
|
|
||||||
|
|
||||||
bool validNativeWin(EGLNativeDisplayType dpy, EGLNativeWindowType win) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static EglConfig* pixelFormatToConfig(int index,int renderableType,EGLNativePixelFormatType* frmt){
|
||||||
|
if(!frmt) return NULL;
|
||||||
|
|
||||||
|
EGLint red,green,blue,alpha,depth,stencil;
|
||||||
|
EGLint supportedSurfaces,visualType,visualId;
|
||||||
|
EGLint transparentType,samples;
|
||||||
|
EGLint tRed,tGreen,tBlue;
|
||||||
|
EGLint pMaxWidth,pMaxHeight,pMaxPixels;
|
||||||
|
EGLint configId,level;
|
||||||
|
EGLint window,pbuffer;
|
||||||
|
EGLint doubleBuffer,colorSize;
|
||||||
|
|
||||||
|
getPixelFormatAttrib(*frmt,MAC_HAS_DOUBLE_BUFFER,&doubleBuffer);
|
||||||
|
if(!doubleBuffer) return NULL; //pixel double buffer
|
||||||
|
|
||||||
|
supportedSurfaces = 0;
|
||||||
|
|
||||||
|
getPixelFormatAttrib(*frmt,MAC_DRAW_TO_WINDOW,&window);
|
||||||
|
getPixelFormatAttrib(*frmt,MAC_DRAW_TO_PBUFFER,&pbuffer);
|
||||||
|
|
||||||
|
if(window) supportedSurfaces |= EGL_WINDOW_BIT;
|
||||||
|
if(pbuffer) supportedSurfaces |= EGL_PBUFFER_BIT;
|
||||||
|
|
||||||
|
if(!supportedSurfaces) return NULL;
|
||||||
|
|
||||||
|
//default values
|
||||||
|
visualId = 0;
|
||||||
|
visualType = EGL_NONE;
|
||||||
|
EGLenum caveat = EGL_NONE;
|
||||||
|
EGLBoolean renderable = EGL_FALSE;
|
||||||
|
pMaxWidth = PBUFFER_MAX_WIDTH;
|
||||||
|
pMaxHeight = PBUFFER_MAX_HEIGHT;
|
||||||
|
pMaxPixels = PBUFFER_MAX_PIXELS;
|
||||||
|
samples = 0;
|
||||||
|
level = 0;
|
||||||
|
tRed = tGreen = tBlue = 0;
|
||||||
|
|
||||||
|
transparentType = EGL_NONE;
|
||||||
|
|
||||||
|
getPixelFormatAttrib(*frmt,MAC_SAMPLES_PER_PIXEL,&samples);
|
||||||
|
getPixelFormatAttrib(*frmt,MAC_COLOR_SIZE,&colorSize);
|
||||||
|
getPixelFormatAttrib(*frmt,MAC_ALPHA_SIZE,&alpha);
|
||||||
|
getPixelFormatAttrib(*frmt,MAC_DEPTH_SIZE,&depth);
|
||||||
|
getPixelFormatAttrib(*frmt,MAC_STENCIL_SIZE,&stencil);
|
||||||
|
|
||||||
|
red = green = blue = (colorSize / 4); //TODO: ask guy if it is OK
|
||||||
|
|
||||||
|
return new EglConfig(red,green,blue,alpha,caveat,(EGLint)index,depth,level,pMaxWidth,pMaxHeight,pMaxPixels,renderable,renderableType,
|
||||||
|
visualId,visualType,samples,stencil,supportedSurfaces,transparentType,tRed,tGreen,tBlue,*frmt);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void initNativeConfigs(){
|
||||||
|
int nConfigs = getNumPixelFormats();
|
||||||
|
if(s_nativeConfigs.empty()){
|
||||||
|
for(int i=0; i < nConfigs ;i++){
|
||||||
|
EGLNativePixelFormatType frmt = getPixelFormat(i);
|
||||||
|
if(frmt){
|
||||||
|
s_nativeConfigs.push_back(frmt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void queryConfigs(EGLNativeDisplayType dpy,int renderableType,ConfigsList& listOut) {
|
||||||
|
int i = 0 ;
|
||||||
|
initNativeConfigs();
|
||||||
|
for(std::list<EGLNativePixelFormatType>::iterator it = s_nativeConfigs.begin(); it != s_nativeConfigs.end();it++){
|
||||||
|
EGLNativePixelFormatType frmt = *it;
|
||||||
|
EglConfig* conf = pixelFormatToConfig(i++,renderableType,&frmt);
|
||||||
|
if(conf){
|
||||||
|
listOut.push_front(conf);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool validNativeWin(EGLNativeDisplayType dpy, EGLNativeWindowType win) {
|
||||||
|
unsigned int width,height;
|
||||||
|
return nsGetWinDims(win,&width,&height);
|
||||||
|
}
|
||||||
|
|
||||||
|
//no support for pixmap in mac
|
||||||
bool validNativePixmap(EGLNativeDisplayType dpy, EGLNativePixmapType pix) {
|
bool validNativePixmap(EGLNativeDisplayType dpy, EGLNativePixmapType pix) {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool checkWindowPixelFormatMatch(EGLNativeDisplayType dpy,EGLNativeWindowType win,EglConfig* cfg,unsigned int* width,unsigned int* height) {
|
bool checkWindowPixelFormatMatch(EGLNativeDisplayType dpy,EGLNativeWindowType win,EglConfig* cfg,unsigned int* width,unsigned int* height) {
|
||||||
return false;
|
int r,g,b;
|
||||||
|
bool ret = nsGetWinDims(win,width,height);
|
||||||
|
|
||||||
|
cfg->getConfAttrib(EGL_RED_SIZE,&r);
|
||||||
|
cfg->getConfAttrib(EGL_GREEN_SIZE,&g);
|
||||||
|
cfg->getConfAttrib(EGL_BLUE_SIZE,&b);
|
||||||
|
bool match = nsCheckColor(win,r + g + b);
|
||||||
|
|
||||||
|
return ret && match;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//no support for pixmap in mac
|
||||||
bool checkPixmapPixelFormatMatch(EGLNativeDisplayType dpy,EGLNativePixmapType pix,EglConfig* cfg,unsigned int* width,unsigned int* height) {
|
bool checkPixmapPixelFormatMatch(EGLNativeDisplayType dpy,EGLNativePixmapType pix,EglConfig* cfg,unsigned int* width,unsigned int* height) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
EGLNativePbufferType createPbuffer(EGLNativeDisplayType dpy,EglConfig* cfg,EglPbufferSurface* srfc){
|
EGLNativePbufferType createPbuffer(EGLNativeDisplayType dpy,EglConfig* cfg,EglPbufferSurface* srfc){
|
||||||
return NULL;
|
EGLint width,height,hasMipmap,tmp;
|
||||||
|
EGLint target,format;
|
||||||
|
srfc->getDim(&width,&height,&tmp);
|
||||||
|
srfc->getTexInfo(&format,&target);
|
||||||
|
srfc->getAttrib(EGL_MIPMAP_TEXTURE,&hasMipmap);
|
||||||
|
EGLint maxMipmap = hasMipmap ? MAX_PBUFFER_MIPMAP_LEVEL:0;
|
||||||
|
return nsCreatePBuffer(target,format,maxMipmap,width,height);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool releasePbuffer(EGLNativeDisplayType dis,EGLNativePbufferType pb) {
|
bool releasePbuffer(EGLNativeDisplayType dis,EGLNativePbufferType pb) {
|
||||||
|
nsDestroyPBuffer(pb);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
EGLNativeContextType createContext(EGLNativeDisplayType dpy,EglConfig* cfg,EGLNativeContextType sharedContext) {
|
EGLNativeContextType createContext(EGLNativeDisplayType dpy,EglConfig* cfg,EGLNativeContextType sharedContext) {
|
||||||
return NULL;
|
return nsCreateContext(cfg->nativeConfig(),sharedContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool destroyContext(EGLNativeDisplayType dpy,EGLNativeContextType ctx) {
|
bool destroyContext(EGLNativeDisplayType dpy,EGLNativeContextType ctx) {
|
||||||
return false;
|
nsDestroyContext(ctx);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool makeCurrent(EGLNativeDisplayType dpy,EglSurface* read,EglSurface* draw,EGLNativeContextType ctx){
|
bool makeCurrent(EGLNativeDisplayType dpy,EglSurface* read,EglSurface* draw,EGLNativeContextType ctx){
|
||||||
|
//dont supporting diffrent read & draw surfaces on Mac
|
||||||
|
if(read->native() != draw->native()) return false;
|
||||||
|
switch(draw->type()){
|
||||||
|
case EglSurface::WINDOW:
|
||||||
|
nsWindowMakeCurrent(ctx,draw->native());
|
||||||
|
break;
|
||||||
|
case EglSurface::PBUFFER:
|
||||||
|
{
|
||||||
|
EGLint hasMipmap;
|
||||||
|
draw->getAttrib(EGL_MIPMAP_TEXTURE,&hasMipmap);
|
||||||
|
int mipmapLevel = hasMipmap ? MAX_PBUFFER_MIPMAP_LEVEL:0;
|
||||||
|
nsPBufferMakeCurrent(ctx,draw->native(),mipmapLevel);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case EglSurface::PIXMAP: // not supported on Mac
|
||||||
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void swapBuffers(EGLNativeDisplayType dpy,EGLNativeWindowType win) {
|
void swapBuffers(EGLNativeDisplayType dpy,EGLNativeWindowType win) {
|
||||||
|
nsSwapBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
void waitNative() {
|
void waitNative(){}
|
||||||
}
|
|
||||||
|
|
||||||
void swapInterval(EGLNativeDisplayType dpy,EGLNativeWindowType win,int interval){
|
void swapInterval(EGLNativeDisplayType dpy,EGLNativeWindowType win,int interval){
|
||||||
|
nsSwapInterval(&interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ public:
|
|||||||
bool destroy(){return m_destroy;};
|
bool destroy(){return m_destroy;};
|
||||||
EglConfig* getConfig(){return m_config;};
|
EglConfig* getConfig(){return m_config;};
|
||||||
unsigned int getHndl(){return m_hndl;};
|
unsigned int getHndl(){return m_hndl;};
|
||||||
|
virtual ~EglSurface(){};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static unsigned int s_nextSurfaceHndl;
|
static unsigned int s_nextSurfaceHndl;
|
||||||
|
|||||||
50
tools/emulator/opengl/host/libs/Translator/EGL/MacNative.h
Normal file
50
tools/emulator/opengl/host/libs/Translator/EGL/MacNative.h
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
#ifndef MAC_NATIVE_H
|
||||||
|
#define MAC_NATIVE_H
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2011 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef enum { // Mac equivalence
|
||||||
|
MAC_HAS_DOUBLE_BUFFER = 5, // NSOpenGLPFADoubleBuffer
|
||||||
|
MAC_DRAW_TO_WINDOW = 80, // NSOpenGLPFAWindow
|
||||||
|
MAC_DRAW_TO_PBUFFER = 90, // NSOpenGLPFAPixelBuffer
|
||||||
|
MAC_SAMPLES_PER_PIXEL = 56, // NSOpenGLPFASamples
|
||||||
|
MAC_COLOR_SIZE = 8, // NSOpenGLPFAColorSize
|
||||||
|
MAC_ALPHA_SIZE = 11, // NSOpenGLPFAAlphaSize
|
||||||
|
MAC_DEPTH_SIZE = 12, // NSOpenGLPFADepthSize
|
||||||
|
MAC_STENCIL_SIZE = 13 // NSOpenGLPFAStencilSize
|
||||||
|
} MacPixelFormatAttribs;
|
||||||
|
|
||||||
|
|
||||||
|
extern "C"{
|
||||||
|
|
||||||
|
int getNumPixelFormats();
|
||||||
|
void* getPixelFormat(int i);
|
||||||
|
void getPixelFormatAttrib(void* pixelFormat,int attrib,int* val);
|
||||||
|
void* nsCreateContext(void* format,void* share);
|
||||||
|
void nsWindowMakeCurrent(void* context,void* nativeWin);
|
||||||
|
void nsPBufferMakeCurrent(void* context,void* nativePBuffer,int level);
|
||||||
|
void nsSwapBuffers();
|
||||||
|
void nsSwapInterval(int *interval);
|
||||||
|
void nsDestroyContext(void* context);
|
||||||
|
void* nsCreatePBuffer(GLenum target,GLenum format,int maxMip,int width,int height);
|
||||||
|
void nsDestroyPBuffer(void* pbuffer);
|
||||||
|
bool nsGetWinDims(void* win,unsigned int* width,unsigned int* height);
|
||||||
|
bool nsCheckColor(void* win,int colorSize);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
137
tools/emulator/opengl/host/libs/Translator/EGL/MacNative.m
Normal file
137
tools/emulator/opengl/host/libs/Translator/EGL/MacNative.m
Normal file
@@ -0,0 +1,137 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2011 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <Cocoa/Cocoa.h>
|
||||||
|
#include <OpenGL/OpenGL.h>
|
||||||
|
#include "MacPixelFormatsAttribs.h"
|
||||||
|
|
||||||
|
|
||||||
|
int getNumPixelFormats(){
|
||||||
|
int size;
|
||||||
|
NSOpenGLPixelFormatAttribute** attrib_lists = getPixelFormatsAttributes(&size);
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* getPixelFormat(int i){
|
||||||
|
int size;
|
||||||
|
NSOpenGLPixelFormatAttribute** attrib_lists = getPixelFormatsAttributes(&size);
|
||||||
|
return [[NSOpenGLPixelFormat alloc] initWithAttributes:attrib_lists[i]];
|
||||||
|
}
|
||||||
|
|
||||||
|
void getPixelFormatAttrib(void* pixelFormat,int attrib,int* val){
|
||||||
|
NSOpenGLPixelFormat *frmt = (NSOpenGLPixelFormat *)pixelFormat;
|
||||||
|
[frmt getValues:val forAttribute:attrib forVirtualScreen:0];
|
||||||
|
}
|
||||||
|
|
||||||
|
void* nsCreateContext(void* format,void* share){
|
||||||
|
NSOpenGLPixelFormat* frmt = (NSOpenGLPixelFormat*)format;
|
||||||
|
return [[NSOpenGLContext alloc] initWithFormat:frmt shareContext:share];
|
||||||
|
}
|
||||||
|
|
||||||
|
void nsPBufferMakeCurrent(void* context,void* nativePBuffer,int level){
|
||||||
|
NSOpenGLContext* ctx = (NSOpenGLContext *)context;
|
||||||
|
NSOpenGLPixelBuffer* pbuff = (NSOpenGLPixelBuffer *)nativePBuffer;
|
||||||
|
if(ctx == nil){
|
||||||
|
[NSOpenGLContext clearCurrentContext];
|
||||||
|
} else {
|
||||||
|
if(pbuff != nil){
|
||||||
|
[ctx clearDrawable];
|
||||||
|
[ctx setPixelBuffer:pbuff cubeMapFace:0 mipMapLevel:level currentVirtualScreen:0];
|
||||||
|
[ctx makeCurrentContext];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void nsWindowMakeCurrent(void* context,void* nativeWin){
|
||||||
|
NSOpenGLContext* ctx = (NSOpenGLContext *)context;
|
||||||
|
NSView* win = (NSView *)nativeWin;
|
||||||
|
if(ctx == nil){
|
||||||
|
[NSOpenGLContext clearCurrentContext];
|
||||||
|
} else {
|
||||||
|
if(win != nil){
|
||||||
|
[ctx clearDrawable];
|
||||||
|
[ctx setView: win];
|
||||||
|
[ctx makeCurrentContext];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void nsSwapBuffers(){
|
||||||
|
NSOpenGLContext* ctx = [NSOpenGLContext currentContext];
|
||||||
|
if(ctx != nil){
|
||||||
|
[ctx flushBuffer];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void nsSwapInterval(int *interval){
|
||||||
|
NSOpenGLContext* ctx = [NSOpenGLContext currentContext];
|
||||||
|
if( ctx != nil){
|
||||||
|
[ctx setValues:interval forParameter:NSOpenGLCPSwapInterval];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void nsDestroyContext(void* context){
|
||||||
|
NSOpenGLContext *ctx = (NSOpenGLContext*)context;
|
||||||
|
if(ctx != nil){
|
||||||
|
[ctx release];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void* nsCreatePBuffer(GLenum target,GLenum format,int maxMip,int width,int height){
|
||||||
|
return [[NSOpenGLPixelBuffer alloc] initWithTextureTarget:target
|
||||||
|
textureInternalFormat:format
|
||||||
|
textureMaxMipMapLevel:maxMip
|
||||||
|
pixelsWide:width pixelsHigh:height];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void nsDestroyPBuffer(void* pbuffer){
|
||||||
|
NSOpenGLPixelBuffer *pbuf = (NSOpenGLPixelBuffer*)pbuffer;
|
||||||
|
if(pbuf != nil){
|
||||||
|
[pbuf release];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool nsGetWinDims(void* win,unsigned int* width,unsigned int* height){
|
||||||
|
NSView* view = (NSView*)win;
|
||||||
|
if(view != nil){
|
||||||
|
NSRect rect = [view bounds];
|
||||||
|
*width = rect.size.width;
|
||||||
|
*height = rect.size.height;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool nsCheckColor(void* win,int colorSize){
|
||||||
|
NSView* view = (NSView*)win;
|
||||||
|
if(view != nil){
|
||||||
|
NSWindow* wnd = [view window];
|
||||||
|
if(wnd != nil){
|
||||||
|
NSWindowDepth limit = [wnd depthLimit];
|
||||||
|
NSWindowDepth defaultLimit = [NSWindow defaultDepthLimit];
|
||||||
|
|
||||||
|
int depth = (limit != 0) ? NSBitsPerPixelFromDepth(limit):
|
||||||
|
NSBitsPerPixelFromDepth(defaultLimit);
|
||||||
|
return depth >= colorSize;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
#ifndef MAC_PIXELS_FORMATS_ATTRIBS_H
|
||||||
|
#define MAC_PIXELS_FORMATS_ATTRIBS_H
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2011 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <Cocoa/Cocoa.h>
|
||||||
|
NSOpenGLPixelFormatAttribute** getPixelFormatsAttributes(int* size);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,214 @@
|
|||||||
|
#include "MacPixelFormatsAttribs.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2011 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static NSOpenGLPixelFormatAttribute attrs32_1[] =
|
||||||
|
{
|
||||||
|
NSOpenGLPFADoubleBuffer,
|
||||||
|
NSOpenGLPFAWindow,
|
||||||
|
NSOpenGLPFAPixelBuffer,
|
||||||
|
NSOpenGLPFAColorSize ,32,
|
||||||
|
NSOpenGLPFADepthSize ,24,
|
||||||
|
NSOpenGLPFAStencilSize ,8,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
static NSOpenGLPixelFormatAttribute attrs32_2[] =
|
||||||
|
{
|
||||||
|
NSOpenGLPFADoubleBuffer,
|
||||||
|
NSOpenGLPFAWindow,
|
||||||
|
NSOpenGLPFAPixelBuffer,
|
||||||
|
NSOpenGLPFAColorSize ,32,
|
||||||
|
NSOpenGLPFAAlphaSize ,8,
|
||||||
|
NSOpenGLPFADepthSize ,24,
|
||||||
|
NSOpenGLPFAStencilSize ,8,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
static NSOpenGLPixelFormatAttribute attrs32_3[] =
|
||||||
|
{
|
||||||
|
NSOpenGLPFADoubleBuffer,
|
||||||
|
NSOpenGLPFAWindow,
|
||||||
|
NSOpenGLPFAPixelBuffer,
|
||||||
|
NSOpenGLPFAColorSize ,32,
|
||||||
|
NSOpenGLPFAAlphaSize ,8,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
static NSOpenGLPixelFormatAttribute attrs32_4[] =
|
||||||
|
{
|
||||||
|
NSOpenGLPFADoubleBuffer,
|
||||||
|
NSOpenGLPFAWindow,
|
||||||
|
NSOpenGLPFAPixelBuffer,
|
||||||
|
NSOpenGLPFAColorSize ,32,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
static NSOpenGLPixelFormatAttribute attrs32_5[] =
|
||||||
|
{
|
||||||
|
NSOpenGLPFADoubleBuffer,
|
||||||
|
NSOpenGLPFAWindow,
|
||||||
|
NSOpenGLPFAPixelBuffer,
|
||||||
|
NSOpenGLPFAColorSize ,32,
|
||||||
|
NSOpenGLPFADepthSize ,24,
|
||||||
|
NSOpenGLPFASamples ,2,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
static NSOpenGLPixelFormatAttribute attrs32_6[] =
|
||||||
|
{
|
||||||
|
NSOpenGLPFADoubleBuffer,
|
||||||
|
NSOpenGLPFAWindow,
|
||||||
|
NSOpenGLPFAPixelBuffer,
|
||||||
|
NSOpenGLPFAColorSize ,32,
|
||||||
|
NSOpenGLPFADepthSize ,24,
|
||||||
|
NSOpenGLPFASamples ,4,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
static NSOpenGLPixelFormatAttribute attrs32_7[] =
|
||||||
|
{
|
||||||
|
NSOpenGLPFADoubleBuffer,
|
||||||
|
NSOpenGLPFAWindow,
|
||||||
|
NSOpenGLPFAPixelBuffer,
|
||||||
|
NSOpenGLPFAColorSize ,32,
|
||||||
|
NSOpenGLPFAAlphaSize ,8,
|
||||||
|
NSOpenGLPFADepthSize ,24,
|
||||||
|
NSOpenGLPFAStencilSize ,8,
|
||||||
|
NSOpenGLPFASamples ,4,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
static NSOpenGLPixelFormatAttribute attrs16_1[] =
|
||||||
|
{
|
||||||
|
NSOpenGLPFADoubleBuffer,
|
||||||
|
NSOpenGLPFAWindow,
|
||||||
|
NSOpenGLPFAPixelBuffer,
|
||||||
|
NSOpenGLPFAColorSize ,16,
|
||||||
|
NSOpenGLPFADepthSize ,24,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
static NSOpenGLPixelFormatAttribute attrs16_2[] =
|
||||||
|
{
|
||||||
|
NSOpenGLPFADoubleBuffer,
|
||||||
|
NSOpenGLPFAWindow,
|
||||||
|
NSOpenGLPFAPixelBuffer,
|
||||||
|
NSOpenGLPFAColorSize ,16,
|
||||||
|
NSOpenGLPFADepthSize ,24,
|
||||||
|
NSOpenGLPFAStencilSize ,8,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
static NSOpenGLPixelFormatAttribute attrs64_1[] =
|
||||||
|
{
|
||||||
|
NSOpenGLPFADoubleBuffer,
|
||||||
|
NSOpenGLPFAWindow,
|
||||||
|
NSOpenGLPFAPixelBuffer,
|
||||||
|
NSOpenGLPFAColorSize ,64,
|
||||||
|
NSOpenGLPFAAlphaSize ,16,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
static NSOpenGLPixelFormatAttribute attrs64_2[] =
|
||||||
|
{
|
||||||
|
NSOpenGLPFADoubleBuffer,
|
||||||
|
NSOpenGLPFAWindow,
|
||||||
|
NSOpenGLPFAPixelBuffer,
|
||||||
|
NSOpenGLPFAColorSize ,64,
|
||||||
|
NSOpenGLPFAAlphaSize ,16,
|
||||||
|
NSOpenGLPFADepthSize ,24,
|
||||||
|
NSOpenGLPFAStencilSize ,8,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
static NSOpenGLPixelFormatAttribute attrs64_3[] =
|
||||||
|
{
|
||||||
|
NSOpenGLPFADoubleBuffer,
|
||||||
|
NSOpenGLPFAWindow,
|
||||||
|
NSOpenGLPFAPixelBuffer,
|
||||||
|
NSOpenGLPFAColorSize ,64,
|
||||||
|
NSOpenGLPFAAlphaSize ,16,
|
||||||
|
NSOpenGLPFADepthSize ,24,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
static NSOpenGLPixelFormatAttribute attrs64_4[] =
|
||||||
|
{
|
||||||
|
NSOpenGLPFADoubleBuffer,
|
||||||
|
NSOpenGLPFAWindow,
|
||||||
|
NSOpenGLPFAPixelBuffer,
|
||||||
|
NSOpenGLPFAColorSize ,64,
|
||||||
|
NSOpenGLPFADepthSize ,24,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
static NSOpenGLPixelFormatAttribute attrs64_5[] =
|
||||||
|
{
|
||||||
|
NSOpenGLPFADoubleBuffer,
|
||||||
|
NSOpenGLPFAWindow,
|
||||||
|
NSOpenGLPFAPixelBuffer,
|
||||||
|
NSOpenGLPFAColorSize ,64,
|
||||||
|
NSOpenGLPFADepthSize ,24,
|
||||||
|
NSOpenGLPFAStencilSize ,8,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
static NSOpenGLPixelFormatAttribute attrs128_1[] =
|
||||||
|
{
|
||||||
|
NSOpenGLPFADoubleBuffer,
|
||||||
|
NSOpenGLPFAWindow,
|
||||||
|
NSOpenGLPFAPixelBuffer,
|
||||||
|
NSOpenGLPFAColorSize ,128,
|
||||||
|
NSOpenGLPFAAlphaSize ,32,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
static NSOpenGLPixelFormatAttribute attrs128_2[] =
|
||||||
|
{
|
||||||
|
NSOpenGLPFADoubleBuffer,
|
||||||
|
NSOpenGLPFAWindow,
|
||||||
|
NSOpenGLPFAPixelBuffer,
|
||||||
|
NSOpenGLPFAColorSize ,128,
|
||||||
|
NSOpenGLPFAAlphaSize ,32,
|
||||||
|
NSOpenGLPFADepthSize ,24,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
NSOpenGLPixelFormatAttribute** getPixelFormatsAttributes(int* size){
|
||||||
|
static NSOpenGLPixelFormatAttribute* arr[] =
|
||||||
|
{
|
||||||
|
attrs16_1,
|
||||||
|
attrs16_2,
|
||||||
|
attrs32_1,
|
||||||
|
attrs32_2,
|
||||||
|
attrs32_3,
|
||||||
|
attrs32_4,
|
||||||
|
attrs32_5,
|
||||||
|
attrs32_6,
|
||||||
|
attrs32_7,
|
||||||
|
attrs64_1,
|
||||||
|
attrs64_2,
|
||||||
|
attrs64_3,
|
||||||
|
attrs64_4,
|
||||||
|
attrs64_5,
|
||||||
|
attrs128_1,
|
||||||
|
attrs128_2
|
||||||
|
};
|
||||||
|
*size = sizeof(arr)/sizeof(arr[0]);
|
||||||
|
return arr;
|
||||||
|
}
|
||||||
@@ -4,8 +4,6 @@ LOCAL_PATH := $(call my-dir)
|
|||||||
include $(CLEAR_VARS)
|
include $(CLEAR_VARS)
|
||||||
|
|
||||||
translator_path := $(LOCAL_PATH)/..
|
translator_path := $(LOCAL_PATH)/..
|
||||||
#exclude darwin builds
|
|
||||||
ifeq (, $(findstring $(HOST_OS), darwin))
|
|
||||||
|
|
||||||
LOCAL_SRC_FILES := \
|
LOCAL_SRC_FILES := \
|
||||||
GLEScmImp.cpp \
|
GLEScmImp.cpp \
|
||||||
@@ -40,4 +38,3 @@ endif
|
|||||||
|
|
||||||
include $(BUILD_HOST_SHARED_LIBRARY)
|
include $(BUILD_HOST_SHARED_LIBRARY)
|
||||||
|
|
||||||
endif
|
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ LOCAL_PATH := $(call my-dir)
|
|||||||
include $(CLEAR_VARS)
|
include $(CLEAR_VARS)
|
||||||
|
|
||||||
translator_path := $(LOCAL_PATH)/..
|
translator_path := $(LOCAL_PATH)/..
|
||||||
#exclude darwin builds
|
|
||||||
ifeq (, $(findstring $(HOST_OS), darwin))
|
|
||||||
|
|
||||||
LOCAL_SRC_FILES := \
|
LOCAL_SRC_FILES := \
|
||||||
GLESv2Imp.cpp \
|
GLESv2Imp.cpp \
|
||||||
@@ -27,4 +25,3 @@ LOCAL_MODULE := libGLES_V2_translator
|
|||||||
|
|
||||||
include $(BUILD_HOST_SHARED_LIBRARY)
|
include $(BUILD_HOST_SHARED_LIBRARY)
|
||||||
|
|
||||||
endif
|
|
||||||
|
|||||||
@@ -29,15 +29,14 @@ typedef void (*GL_FUNC_PTR)();
|
|||||||
static GL_FUNC_PTR getGLFuncAddress(const char *funcName) {
|
static GL_FUNC_PTR getGLFuncAddress(const char *funcName) {
|
||||||
GL_FUNC_PTR ret = NULL;
|
GL_FUNC_PTR ret = NULL;
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
static osUtils::dynLibrary* libGL = osUtils::dynLibrary::open("GL");
|
static osUtils::dynLibrary* libGL = osUtils::dynLibrary::open("libGL.so");
|
||||||
ret = (GL_FUNC_PTR)glXGetProcAddress((const GLubyte*)funcName);
|
ret = (GL_FUNC_PTR)glXGetProcAddress((const GLubyte*)funcName);
|
||||||
#elif defined(WIN32)
|
#elif defined(WIN32)
|
||||||
static osUtils::dynLibrary* libGL = osUtils::dynLibrary::open("opengl32");
|
static osUtils::dynLibrary* libGL = osUtils::dynLibrary::open("opengl32");
|
||||||
ret = (GL_FUNC_PTR)wglGetProcAddress(funcName);
|
ret = (GL_FUNC_PTR)wglGetProcAddress(funcName);
|
||||||
#else //mac
|
#elif defined(__APPLE__)
|
||||||
static osUtils::dynLibrary* libGL = NULL;
|
static osUtils::dynLibrary* libGL = osUtils::dynLibrary::open("libGL.dylib");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(!ret && libGL){
|
if(!ret && libGL){
|
||||||
ret = libGL->findSymbol(funcName);
|
ret = libGL->findSymbol(funcName);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,14 +83,14 @@ typedef HWND EGLNativeWindowType;
|
|||||||
|
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
|
|
||||||
typedef int EGLNativePixelFormatType;
|
typedef void* EGLNativePixelFormatType;
|
||||||
#define PIXEL_FORMAT_INITIALIZER 0
|
#define PIXEL_FORMAT_INITIALIZER NULL
|
||||||
|
typedef void* EGLNativeContextType;
|
||||||
|
typedef void* EGLNativePbufferType;
|
||||||
|
typedef unsigned int EGLNativeDisplayType;
|
||||||
|
typedef void* EGLNativePixmapType;
|
||||||
|
typedef void* EGLNativeWindowType;
|
||||||
|
|
||||||
typedef struct _EGLNativeContextType* EGLNativeContextType;
|
|
||||||
typedef struct _EGLNativePbufferType* EGLNativePbufferType;
|
|
||||||
typedef struct _EGLNativeDisplayType* EGLNativeDisplayType;
|
|
||||||
typedef int EGLNativePixmapType;
|
|
||||||
typedef int EGLNativeWindowType;
|
|
||||||
|
|
||||||
#elif defined(__unix__)
|
#elif defined(__unix__)
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
ifneq ($(HOST_OS),darwin)
|
|
||||||
LOCAL_PATH:= $(call my-dir)
|
LOCAL_PATH:= $(call my-dir)
|
||||||
|
|
||||||
include $(CLEAR_VARS)
|
include $(CLEAR_VARS)
|
||||||
|
|
||||||
#
|
translator_path := $(LOCAL_PATH)/../../../host/libs/Translator
|
||||||
# This is built on linux host only !!!
|
|
||||||
#
|
|
||||||
PREBUILT := $(HOST_PREBUILT_TAG)
|
PREBUILT := $(HOST_PREBUILT_TAG)
|
||||||
SDL_CONFIG ?= prebuilt/$(PREBUILT)/sdl/bin/sdl-config
|
SDL_CONFIG ?= prebuilt/$(PREBUILT)/sdl/bin/sdl-config
|
||||||
SDL_CFLAGS := $(shell $(SDL_CONFIG) --cflags)
|
SDL_CFLAGS := $(shell $(SDL_CONFIG) --cflags)
|
||||||
@@ -14,18 +11,28 @@ SDL_LDLIBS := $(filter-out %.a %.lib,$(shell $(SDL_CONFIG) --static-libs))
|
|||||||
LOCAL_SRC_FILES:= \
|
LOCAL_SRC_FILES:= \
|
||||||
triangleCM.cpp
|
triangleCM.cpp
|
||||||
|
|
||||||
|
|
||||||
LOCAL_SHARED_LIBRARIES := \
|
LOCAL_SHARED_LIBRARIES := \
|
||||||
libGLcommon \
|
libGLcommon \
|
||||||
libEGL_translator \
|
libEGL_translator \
|
||||||
libGLES_CM_translator \
|
libGLES_CM_translator
|
||||||
libGLcommon
|
|
||||||
|
|
||||||
LOCAL_CFLAGS += $(SDL_CFLAGS) -g -O0
|
LOCAL_CFLAGS += $(SDL_CFLAGS) -g -O0
|
||||||
LOCAL_LDLIBS += $(SDL_LDLIBS)
|
LOCAL_LDLIBS += $(SDL_LDLIBS)
|
||||||
|
|
||||||
|
|
||||||
LOCAL_MODULE:= triangleCM
|
LOCAL_MODULE:= triangleCM
|
||||||
LOCAL_MODULE_TAGS := debug
|
LOCAL_MODULE_TAGS := debug
|
||||||
LOCAL_STATIC_LIBRARIES += libSDL libSDLmain
|
LOCAL_STATIC_LIBRARIES += libSDL libSDLmain
|
||||||
|
|
||||||
include $(BUILD_HOST_EXECUTABLE)
|
ifeq ($(HOST_OS),darwin)
|
||||||
|
|
||||||
|
LOCAL_LDLIBS += -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit
|
||||||
|
LOCAL_STATIC_LIBRARIES += libMac_view
|
||||||
|
LOCAL_C_INCLUDES += \
|
||||||
|
$(LOCAL_PATH)/../MacCommon \
|
||||||
|
$(translator_path)/include
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
include $(BUILD_HOST_EXECUTABLE)
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,10 @@
|
|||||||
#include <EGL/egl.h>
|
#include <EGL/egl.h>
|
||||||
#include <GLES/gl.h>
|
#include <GLES/gl.h>
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
extern "C" void * createGLView(void *nsWindowPtr, int x, int y, int width, int height);
|
||||||
|
#endif
|
||||||
|
|
||||||
#undef HAVE_MALLOC_H
|
#undef HAVE_MALLOC_H
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include <SDL_syswm.h>
|
#include <SDL_syswm.h>
|
||||||
@@ -120,8 +124,10 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
HWND windowId = NULL;
|
HWND windowId = NULL;
|
||||||
#else
|
#elif __linux__
|
||||||
Window windowId = NULL;
|
Window windowId = NULL;
|
||||||
|
#elif __APPLE__
|
||||||
|
void* windowId = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// // Inialize SDL window
|
// // Inialize SDL window
|
||||||
@@ -142,8 +148,11 @@ int main(int argc, char **argv)
|
|||||||
SDL_GetWMInfo(&wminfo);
|
SDL_GetWMInfo(&wminfo);
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
windowId = wminfo.window;
|
windowId = wminfo.window;
|
||||||
#else
|
#elif __linux__
|
||||||
windowId = wminfo.info.x11.window;
|
windowId = wminfo.info.x11.window;
|
||||||
|
#elif __APPLE__
|
||||||
|
windowId = createGLView(wminfo.nsWindowPtr,0,0,WINDOW_WIDTH,WINDOW_HEIGHT);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int major,minor,num_config;
|
int major,minor,num_config;
|
||||||
@@ -156,6 +165,7 @@ int main(int argc, char **argv)
|
|||||||
eglChooseConfig(d, attribute_list, configs, 150, &num_config);
|
eglChooseConfig(d, attribute_list, configs, 150, &num_config);
|
||||||
printf("config returned %d\n",num_config);
|
printf("config returned %d\n",num_config);
|
||||||
egl_surface = eglCreateWindowSurface(d,configs[0],windowId,NULL);
|
egl_surface = eglCreateWindowSurface(d,configs[0],windowId,NULL);
|
||||||
|
printf("before creating context..\n");
|
||||||
ctx = eglCreateContext(d,configs[0],EGL_NO_CONTEXT,NULL);
|
ctx = eglCreateContext(d,configs[0],EGL_NO_CONTEXT,NULL);
|
||||||
printf("SURFACE == %p CONTEXT == %p\n",egl_surface,ctx);
|
printf("SURFACE == %p CONTEXT == %p\n",egl_surface,ctx);
|
||||||
if(eglMakeCurrent(d,egl_surface,egl_surface,ctx)!= EGL_TRUE){
|
if(eglMakeCurrent(d,egl_surface,egl_surface,ctx)!= EGL_TRUE){
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
ifneq ($(HOST_OS),darwin)
|
|
||||||
LOCAL_PATH:= $(call my-dir)
|
LOCAL_PATH:= $(call my-dir)
|
||||||
include $(CLEAR_VARS)
|
include $(CLEAR_VARS)
|
||||||
|
|
||||||
#
|
translator_path := $(LOCAL_PATH)/../../../host/libs/Translator
|
||||||
# This is built on linux host only !!!
|
|
||||||
#
|
|
||||||
PREBUILT := $(HOST_PREBUILT_TAG)
|
PREBUILT := $(HOST_PREBUILT_TAG)
|
||||||
SDL_CONFIG ?= prebuilt/$(PREBUILT)/sdl/bin/sdl-config
|
SDL_CONFIG ?= prebuilt/$(PREBUILT)/sdl/bin/sdl-config
|
||||||
SDL_CFLAGS := $(shell $(SDL_CONFIG) --cflags)
|
SDL_CFLAGS := $(shell $(SDL_CONFIG) --cflags)
|
||||||
@@ -13,18 +11,29 @@ SDL_LDLIBS := $(filter-out %.a %.lib,$(shell $(SDL_CONFIG) --static-libs))
|
|||||||
LOCAL_SRC_FILES:= \
|
LOCAL_SRC_FILES:= \
|
||||||
triangleV2.cpp
|
triangleV2.cpp
|
||||||
|
|
||||||
|
|
||||||
LOCAL_SHARED_LIBRARIES := \
|
LOCAL_SHARED_LIBRARIES := \
|
||||||
libGLcommon \
|
libGLcommon \
|
||||||
libEGL_translator \
|
libEGL_translator \
|
||||||
libGLES_V2_translator \
|
libGLES_V2_translator
|
||||||
libGLcommon
|
|
||||||
|
|
||||||
LOCAL_CFLAGS += $(SDL_CFLAGS) -g -O0
|
LOCAL_CFLAGS += $(SDL_CFLAGS) -g -O0
|
||||||
LOCAL_LDLIBS += $(SDL_LDLIBS)
|
LOCAL_LDLIBS += $(SDL_LDLIBS)
|
||||||
|
|
||||||
|
|
||||||
LOCAL_MODULE:= triangleV2
|
LOCAL_MODULE:= triangleV2
|
||||||
LOCAL_MODULE_TAGS := debug
|
LOCAL_MODULE_TAGS := debug
|
||||||
LOCAL_STATIC_LIBRARIES += libSDL libSDLmain
|
LOCAL_STATIC_LIBRARIES += libSDL libSDLmain
|
||||||
|
|
||||||
include $(BUILD_HOST_EXECUTABLE)
|
ifeq ($(HOST_OS),darwin)
|
||||||
|
|
||||||
|
LOCAL_LDLIBS += -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit
|
||||||
|
LOCAL_C_INCLUDES += \
|
||||||
|
$(translator_path)/include \
|
||||||
|
$(LOCAL_PATH)/../MacCommon
|
||||||
|
LOCAL_STATIC_LIBRARIES += libMac_view
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
include $(BUILD_HOST_EXECUTABLE)
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,10 @@
|
|||||||
#include <EGL/egl.h>
|
#include <EGL/egl.h>
|
||||||
#include <GLES2/gl2.h>
|
#include <GLES2/gl2.h>
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
extern "C" void * createGLView(void *nsWindowPtr, int x, int y, int width, int height);
|
||||||
|
#endif
|
||||||
|
|
||||||
#undef HAVE_MALLOC_H
|
#undef HAVE_MALLOC_H
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include <SDL_syswm.h>
|
#include <SDL_syswm.h>
|
||||||
@@ -233,8 +237,10 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
HWND windowId = NULL;
|
HWND windowId = NULL;
|
||||||
#else
|
#elif __linux__
|
||||||
Window windowId = NULL;
|
Window windowId = NULL;
|
||||||
|
#elif __APPLE__
|
||||||
|
void* windowId = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// // Inialize SDL window
|
// // Inialize SDL window
|
||||||
@@ -255,8 +261,10 @@ int main(int argc, char **argv)
|
|||||||
SDL_GetWMInfo(&wminfo);
|
SDL_GetWMInfo(&wminfo);
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
windowId = wminfo.window;
|
windowId = wminfo.window;
|
||||||
#else
|
#elif __linux__
|
||||||
windowId = wminfo.info.x11.window;
|
windowId = wminfo.info.x11.window;
|
||||||
|
#elif __APPLE__
|
||||||
|
windowId = createGLView(wminfo.nsWindowPtr,0,0,WINDOW_WIDTH,WINDOW_HEIGHT);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int major,minor,num_config;
|
int major,minor,num_config;
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
|
||||||
|
LOCAL_PATH := $(call my-dir)
|
||||||
|
|
||||||
|
ifeq ($(HOST_OS),darwin)
|
||||||
|
include $(CLEAR_VARS)
|
||||||
|
|
||||||
|
|
||||||
|
LOCAL_LDLIBS := -Wl,-framework,AppKit
|
||||||
|
|
||||||
|
LOCAL_SRC_FILES := setup_gl.m
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
LOCAL_CFLAGS := -g -O0
|
||||||
|
LOCAL_MODULE_TAGS := debug
|
||||||
|
LOCAL_MODULE := libMac_view
|
||||||
|
|
||||||
|
|
||||||
|
include $(BUILD_HOST_STATIC_LIBRARY)
|
||||||
|
endif
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
|
void * createGLView(void *nsWindowPtr, int x, int y, int width, int height)
|
||||||
|
{
|
||||||
|
NSRect contentRect = NSMakeRect(x, y, width, height);
|
||||||
|
NSView *glView = [[NSView alloc] initWithFrame:contentRect];
|
||||||
|
if (glView == nil) {
|
||||||
|
printf("couldn't create opengl view\n");
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
[glView setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
|
||||||
|
NSWindow *win = (NSWindow *)nsWindowPtr;
|
||||||
|
[[win contentView] addSubview:glView];
|
||||||
|
[win makeKeyAndOrderFront:nil];
|
||||||
|
return (void *)glView;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user