mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-03-01 08:06:04 +00:00
(CGL Context) Some buildfixes
This commit is contained in:
parent
7e20265a4e
commit
6703b26e44
@ -525,10 +525,11 @@ ifeq ($(HAVE_OPENGL), 1)
|
||||
OBJ += libretro-common/glsym/glsym_gl.o
|
||||
ifeq ($(OSX), 1)
|
||||
LIBS += -framework OpenGL
|
||||
OBJ += gfx/drivers_context/cgl_ctx.o
|
||||
else ifneq ($(findstring Win32,$(OS)),)
|
||||
LIBS += -lopengl32 -lgdi32 -lcomdlg32 -lcomctl32
|
||||
OBJ += gfx/drivers_context/wgl_ctx.o \
|
||||
gfx/drivers_wm/win32_shader_dlg.o
|
||||
gfx/drivers_wm/win32_shader_dlg.o
|
||||
else
|
||||
LIBS += -lGL
|
||||
endif
|
||||
|
@ -14,7 +14,9 @@
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* Apple CGL context. */
|
||||
/* Apple CGL context.
|
||||
Based on http://fernlightning.com/doku.php?id=randd:xopengl.
|
||||
*/
|
||||
|
||||
#include <CoreGraphics/CoreGraphics.h>
|
||||
#include <OpenGL/CGLTypes.h>
|
||||
@ -37,10 +39,10 @@ typedef int CGSSurfaceID;
|
||||
extern CGSConnectionID CGSMainConnectionID(void);
|
||||
extern CGError CGSAddSurface(CGSConnectionID cid, CGWindowID wid, CGSSurfaceID *sid);
|
||||
extern CGError CGSSetSurfaceBounds(CGSConnectionID cid, CGWindowID wid, CGSSurfaceID sid, CGRect rect);
|
||||
extern CGError CGSOrderSurface(CGSConnectionID cid, CGWindowID wid, CGSSurface sid, int a, int b);
|
||||
extern CGError CGSOrderSurface(CGSConnectionID cid, CGWindowID wid, CGSSurfaceID sid, int a, int b);
|
||||
|
||||
/* Undocumented CGL */
|
||||
extern CGLError CGLSetSurface(CGLContextObj gl, CGSConnectionID, cid, CGSWindowID wid, CGSSurfaceID sid);
|
||||
extern CGLError CGLSetSurface(CGLContextObj gl, CGSConnectionID cid, CGSWindowID wid, CGSSurfaceID sid);
|
||||
|
||||
typedef struct gfx_ctx_cgl_data
|
||||
{
|
||||
@ -149,7 +151,8 @@ static bool gfx_ctx_cgl_has_windowed(void *data)
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool gfx_ctx_cgl_bind_api(void *data, enum gfx_ctx_api api, unsigned major, unsigned minor)
|
||||
static bool gfx_ctx_cgl_bind_api(void *data, enum gfx_ctx_api api,
|
||||
unsigned major, unsigned minor)
|
||||
{
|
||||
(void)data;
|
||||
(void)api;
|
||||
@ -178,12 +181,12 @@ static void gfx_ctx_cgl_bind_hw_render(void *data, bool enable)
|
||||
|
||||
static CGLContextObj gfx_ctx_cgl_init_create(void)
|
||||
{
|
||||
CGLint num;
|
||||
GLint num;
|
||||
CGLPixelFormatObj pix;
|
||||
CGLContextObj glCtx = NULL;
|
||||
CGLPixelFormatAttribute attributes[] = {
|
||||
kCGLPFAAccelerated,
|
||||
kCGLPFADoublebuffer,
|
||||
kCGLPFADoubleBuffer,
|
||||
(CGLPixelFormatAttribute)0
|
||||
};
|
||||
|
||||
@ -194,13 +197,68 @@ static CGLContextObj gfx_ctx_cgl_init_create(void)
|
||||
return glCtx;
|
||||
}
|
||||
|
||||
static CGSSurfaceID attach_gl_context_to_window(CGLContextObj glCtx,
|
||||
CGSWindowID wid, int *width, int *height)
|
||||
{
|
||||
CFArrayRef wins;
|
||||
CFDictionaryRef win, bnd;
|
||||
GLint params = 0;
|
||||
Float64 w = 0, h = 0;
|
||||
CGSSurfaceID sid = 0;
|
||||
CGSConnectionID cid = CGSMainConnectionID();
|
||||
|
||||
printf("cid:%d wid:%d\n", cid, wid);
|
||||
|
||||
/* determine window size */
|
||||
wins = CGWindowListCopyWindowInfo(kCGWindowListOptionIncludingWindow, wid); /* expect one result only */
|
||||
win = CFArrayGetValueAtIndex(wins, 0);
|
||||
bnd = CFDictionaryGetValue(win, kCGWindowBounds);
|
||||
CFNumberGetValue(CFDictionaryGetValue(bnd, CFSTR("Width")),
|
||||
kCFNumberFloat64Type, &w);
|
||||
CFNumberGetValue(CFDictionaryGetValue(bnd, CFSTR("Height")),
|
||||
kCFNumberFloat64Type, &h);
|
||||
CFRelease(wins);
|
||||
|
||||
/* create a surface. */
|
||||
if(CGSAddSurface(cid, wid, &sid) != kCGErrorSuccess)
|
||||
{
|
||||
printf("ERR: no surface\n");
|
||||
}
|
||||
printf("sid:%d\n", sid);
|
||||
|
||||
/* set surface size, and order it frontmost */
|
||||
if(CGSSetSurfaceBounds(cid, wid, sid, CGRectMake(0, 0, w, h)) != kCGErrorSuccess)
|
||||
printf("ERR: cant set bounds\n");
|
||||
if(CGSOrderSurface(cid, wid, sid, 1, 0) != kCGErrorSuccess)
|
||||
printf("ERR: cant order front\n");
|
||||
|
||||
/* attach context to the surface */
|
||||
if(CGLSetSurface(glCtx, cid, wid, sid) != kCGErrorSuccess)
|
||||
{
|
||||
printf("ERR: cant set surface\n");
|
||||
}
|
||||
|
||||
/* check drawable */
|
||||
CGLGetParameter(glCtx, kCGLCPHasDrawable, ¶ms);
|
||||
if(params != 1)
|
||||
{
|
||||
printf("ERR: no drawable\n");
|
||||
}
|
||||
|
||||
*width = (int)w;
|
||||
*height = (int)h;
|
||||
|
||||
return sid;
|
||||
}
|
||||
|
||||
static bool gfx_ctx_cgl_init(void *data)
|
||||
{
|
||||
CGError err;
|
||||
driver_t *driver = driver_get_ptr();
|
||||
gfx_ctx_cgl_data_t *cgl = (gfx_ctx_cgl_data_t*)calloc(1, sizeof(gfx_ctx_cgl_data_t));
|
||||
|
||||
if (!cgl)
|
||||
goto false;
|
||||
goto error;
|
||||
|
||||
cgl->displayID = CGMainDisplayID();
|
||||
|
||||
@ -214,6 +272,9 @@ static bool gfx_ctx_cgl_init(void *data)
|
||||
if (!cgl->glCtx)
|
||||
goto error;
|
||||
|
||||
attach_gl_context_to_window(cgl->glCtx,
|
||||
CGShieldingWindowID(cgl->displayID), &cgl->width, &cgl->height);
|
||||
|
||||
driver->video_context_data = cgl;
|
||||
|
||||
return true;
|
||||
|
@ -62,6 +62,9 @@ static const gfx_ctx_driver_t *gfx_ctx_drivers[] = {
|
||||
#if defined(HAVE_COCOA) || defined(HAVE_COCOATOUCH)
|
||||
&gfx_ctx_cocoagl,
|
||||
#endif
|
||||
#if defined(__APPLE__)
|
||||
&gfx_ctx_cgl,
|
||||
#endif
|
||||
#if (defined(HAVE_SDL) || defined(HAVE_SDL2)) && defined(HAVE_OPENGL)
|
||||
&gfx_ctx_sdl_gl,
|
||||
#endif
|
||||
|
@ -105,6 +105,8 @@ VIDEO CONTEXT
|
||||
#include "../gfx/drivers_context/bbqnx_ctx.c"
|
||||
#elif defined(EMSCRIPTEN)
|
||||
#include "../gfx/drivers_context/emscriptenegl_ctx.c"
|
||||
#elif defined(__APPLE__)
|
||||
#include "../gfx/drivers_context/cgl_ctx.c"
|
||||
#endif
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user