mirror of
https://github.com/gnustep/libs-back.git
synced 2025-02-23 11:51:27 +00:00
Get to work with newer versions of GLX.
Patch by Thomas Gamper <icicle@cg.tuwien.ac.at>, slightly reworked. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@25990 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
bef465dd15
commit
e2c622bad5
4 changed files with 336 additions and 301 deletions
|
@ -1,3 +1,12 @@
|
|||
2008-01-21 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Headers/x11/XGOpenGL.h,
|
||||
* Source/x11/XGGLContext.m,
|
||||
* Source/x11/XGGLFormat.m:
|
||||
Get to work with newer versions of GLX.
|
||||
Patch by Thomas Gamper <icicle@cg.tuwien.ac.at>,
|
||||
slightly reworked.
|
||||
|
||||
2008-01-19 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/win32/WIN32Server.m (-setWindowdevice:forContext:):
|
||||
|
|
|
@ -42,32 +42,44 @@
|
|||
|
||||
@interface XGGLContext : NSOpenGLContext
|
||||
{
|
||||
GLXContext glx_context;
|
||||
GLXWindow glx_drawable;
|
||||
XGXSubWindow *xsubwin;
|
||||
XGGLPixelFormat *format;
|
||||
GLXContext glx_context;
|
||||
GLXWindow glx_drawable;
|
||||
XGXSubWindow *xSubWindow;
|
||||
XGGLPixelFormat *pixelFormat;
|
||||
}
|
||||
|
||||
- (GLXContext)glxcontext;
|
||||
|
||||
@end
|
||||
|
||||
@interface XGGLPixelFormat : NSOpenGLPixelFormat
|
||||
{
|
||||
@public
|
||||
union {
|
||||
GLXFBConfig *tab;
|
||||
XVisualInfo *visual;
|
||||
} conf;
|
||||
int n_elem;
|
||||
@public
|
||||
union
|
||||
{
|
||||
GLXFBConfig *fbconfig;
|
||||
XVisualInfo *visualinfo;
|
||||
} configurations;
|
||||
|
||||
int configurationCount;
|
||||
}
|
||||
|
||||
- (XVisualInfo *)xvinfo;
|
||||
- (GLXContext)createGLXContext: (XGGLContext *)share;
|
||||
- (GLXWindow) drawableForWindow: (Window)xwindowid;
|
||||
|
||||
@end
|
||||
|
||||
static inline int
|
||||
GSglxMinorVersion(Display *dpy)
|
||||
{
|
||||
int major, minor;
|
||||
Bool result;
|
||||
result = glXQueryVersion (dpy, &major, &minor);
|
||||
if (result == False)
|
||||
return -1;
|
||||
|
||||
if (False == glXQueryVersion(dpy, &major, &minor))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return minor;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
#include <AppKit/NSWindow.h>
|
||||
#include "x11/XGServerWindow.h"
|
||||
#include "x11/XGOpenGL.h"
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
//FIXME
|
||||
|
@ -45,40 +44,50 @@
|
|||
|
||||
@interface XGXSubWindow : NSObject
|
||||
{
|
||||
@public
|
||||
Window winid;
|
||||
NSView *attached;
|
||||
@public
|
||||
Window xwindowid;
|
||||
NSView *attached;
|
||||
}
|
||||
|
||||
+ subwindowOnView:(NSView *)view visualinfo:(XVisualInfo *)xVisualInfo;
|
||||
|
||||
- (void) update;
|
||||
+ subwindowOnView: (NSView *) view;
|
||||
|
||||
@end
|
||||
|
||||
@implementation XGXSubWindow
|
||||
/*We assume that the current context is the same and is an XGServer
|
||||
*/
|
||||
- initWithView: (NSView *) view
|
||||
@implementation XGXSubWindow
|
||||
|
||||
//We assume that the current context is the same and is an XGServer
|
||||
- initWithView:(NSView *)view visualinfo:(XVisualInfo *)xVisualInfo
|
||||
{
|
||||
NSRect rect;
|
||||
gswindow_device_t *win_info;
|
||||
XGServer *server;
|
||||
NSWindow *win;
|
||||
NSWindow *window;
|
||||
int x, y, width, height;
|
||||
[super init];
|
||||
int mask;
|
||||
XSetWindowAttributes window_attributes;
|
||||
|
||||
win = [view window];
|
||||
NSAssert(win, @"request of an X window attachment on a view that is not on a NSWindow");
|
||||
self = [super init];
|
||||
if (!self)
|
||||
return nil;
|
||||
|
||||
window = [view window];
|
||||
NSAssert(window, @"request of an X window attachment on a view that is not on a NSWindow");
|
||||
|
||||
if ([view isRotatedOrScaledFromBase])
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Cannot attach an Xwindow to a view that is rotated or scaled"];
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Cannot attach an Xwindow to a view that is rotated or scaled"];
|
||||
}
|
||||
|
||||
server = (XGServer *)GSServerForWindow(win);
|
||||
server = (XGServer *)GSServerForWindow(window);
|
||||
NSAssert(server != nil, NSInternalInconsistencyException);
|
||||
|
||||
NSAssert([server isKindOfClass: [XGServer class]],
|
||||
NSInternalInconsistencyException);
|
||||
NSInternalInconsistencyException);
|
||||
|
||||
win_info = [XGServer _windowWithTag: [win windowNumber]];
|
||||
win_info = [XGServer _windowWithTag: [window windowNumber]];
|
||||
NSAssert(win_info, NSInternalInconsistencyException);
|
||||
|
||||
if ([server handlesWindowDecorations] == YES)
|
||||
|
@ -88,7 +97,7 @@
|
|||
* we must therefore use content view coordinates.
|
||||
*/
|
||||
rect = [view convertRect: [view bounds]
|
||||
toView: [[view window] contentView]];
|
||||
toView: [[view window] contentView]];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -104,32 +113,30 @@
|
|||
width = NSWidth(rect);
|
||||
height = NSHeight(rect);
|
||||
|
||||
|
||||
// winid = XCreateWindow(win_info->display, DefaultRootWindow(win_info->display),
|
||||
// x, y, width, height, 0,
|
||||
// CopyFromParent, InputOutput, CopyFromParent, 0, NULL);
|
||||
window_attributes.border_pixel = 255;
|
||||
window_attributes.colormap = XCreateColormap(win_info->display,
|
||||
win_info->ident,
|
||||
xVisualInfo->visual, AllocNone);
|
||||
window_attributes.event_mask = StructureNotifyMask;
|
||||
|
||||
winid = XCreateWindow(win_info->display, win_info->ident,
|
||||
x, y, width, height, 0,
|
||||
CopyFromParent, InputOutput, CopyFromParent, 0, NULL);
|
||||
mask = CWBorderPixel | CWColormap | CWEventMask;
|
||||
|
||||
xwindowid = XCreateWindow(win_info->display, win_info->ident,
|
||||
x, y, width, height, 0,
|
||||
CopyFromParent, InputOutput, xVisualInfo->visual,
|
||||
mask, &window_attributes);
|
||||
|
||||
// winid = XCreateSimpleWindow(win_info->display, win_info->ident,
|
||||
// x, y, width, height, 2,
|
||||
// 0, 1);
|
||||
|
||||
|
||||
XMapWindow(win_info->display, winid);
|
||||
|
||||
XMapWindow(win_info->display, xwindowid);
|
||||
|
||||
attached = view;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) map
|
||||
{
|
||||
MAKE_DISPLAY(dpy);
|
||||
XMapWindow(dpy, winid);
|
||||
XMapWindow(dpy, xwindowid);
|
||||
}
|
||||
|
||||
- (void) detach
|
||||
|
@ -138,7 +145,7 @@
|
|||
//I assume that the current server is correct.
|
||||
MAKE_DISPLAY(dpy);
|
||||
attached = nil;
|
||||
XDestroyWindow(dpy, winid);
|
||||
XDestroyWindow(dpy, xwindowid);
|
||||
}
|
||||
|
||||
- (void) update
|
||||
|
@ -148,6 +155,7 @@
|
|||
GSDisplayServer *server;
|
||||
NSWindow *win;
|
||||
int x, y, width, height;
|
||||
|
||||
NSAssert(attached, NSInternalInconsistencyException);
|
||||
|
||||
win = [attached window];
|
||||
|
@ -192,7 +200,7 @@
|
|||
height = NSHeight(rect);
|
||||
|
||||
|
||||
XMoveResizeWindow(win_info->display, winid,x, y, width, height);
|
||||
XMoveResizeWindow(win_info->display, xwindowid,x, y, width, height);
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
|
@ -202,9 +210,9 @@
|
|||
[super dealloc];
|
||||
}
|
||||
|
||||
+ subwindowOnView: (NSView *) view
|
||||
+ subwindowOnView:(NSView *)view visualinfo:(XVisualInfo *)xVisualInfo
|
||||
{
|
||||
XGXSubWindow *win = [[self alloc] initWithView: view];
|
||||
XGXSubWindow *win = [[self alloc] initWithView: view visualinfo: xVisualInfo];
|
||||
|
||||
return AUTORELEASE(win);
|
||||
}
|
||||
|
@ -221,10 +229,14 @@ static XGGLContext *currentGLContext;
|
|||
{
|
||||
MAKE_DISPLAY(dpy);
|
||||
|
||||
if (GSglxMinorVersion (dpy) >= 3)
|
||||
glXMakeContextCurrent(dpy, None, None, NULL);
|
||||
if (GSglxMinorVersion(dpy) >= 3)
|
||||
{
|
||||
glXMakeContextCurrent(dpy, None, None, NULL);
|
||||
}
|
||||
else
|
||||
glXMakeCurrent(dpy, None, NULL);
|
||||
{
|
||||
glXMakeCurrent(dpy, None, NULL);
|
||||
}
|
||||
|
||||
currentGLContext = nil;
|
||||
}
|
||||
|
@ -236,19 +248,26 @@ static XGGLContext *currentGLContext;
|
|||
|
||||
- (void) _detach
|
||||
{
|
||||
if (xsubwin)
|
||||
if (xSubWindow)
|
||||
{
|
||||
MAKE_DISPLAY(dpy);
|
||||
|
||||
if (currentGLContext == self)
|
||||
{
|
||||
[XGGLContext clearCurrentContext];
|
||||
}
|
||||
{
|
||||
[XGGLContext clearCurrentContext];
|
||||
}
|
||||
// FIXME:
|
||||
// glXDestroyWindow(dpy, glx_drawable);
|
||||
glx_drawable = None;
|
||||
DESTROY(xsubwin);
|
||||
DESTROY(xSubWindow);
|
||||
}
|
||||
}
|
||||
|
||||
- (GLXContext)glxcontext
|
||||
{
|
||||
return glx_context;
|
||||
}
|
||||
|
||||
- (void)clearDrawable
|
||||
{
|
||||
[self _detach];
|
||||
|
@ -257,13 +276,14 @@ static XGGLContext *currentGLContext;
|
|||
- (void)copyAttributesFromContext:(NSOpenGLContext *)context
|
||||
withMask:(unsigned long)mask
|
||||
{
|
||||
GLXContext other;
|
||||
MAKE_DISPLAY(dpy);
|
||||
if (context == nil || ![context isKindOfClass: [XGGLContext class]])
|
||||
|
||||
if (context == nil || ![context isKindOfClass: [XGGLContext class]])
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"%@ is an invalid context", context];
|
||||
other = ((XGGLContext *)context)->glx_context;
|
||||
glXCopyContext(dpy, other, glx_context, mask);
|
||||
|
||||
glXCopyContext(dpy, ((XGGLContext *)context)->glx_context,
|
||||
glx_context, mask);
|
||||
}
|
||||
|
||||
- (void)createTexture:(unsigned long)target
|
||||
|
@ -277,10 +297,10 @@ static XGGLContext *currentGLContext;
|
|||
- (int)currentVirtualScreen
|
||||
{
|
||||
[self notImplemented: _cmd];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
- (void)flushBuffer
|
||||
{
|
||||
MAKE_DISPLAY(dpy);
|
||||
|
@ -297,32 +317,29 @@ static XGGLContext *currentGLContext;
|
|||
}
|
||||
|
||||
|
||||
- (id)initWithFormat:(NSOpenGLPixelFormat *)_format
|
||||
shareContext:(NSOpenGLContext *)share
|
||||
- (id)initWithFormat: (NSOpenGLPixelFormat *)_format
|
||||
shareContext: (NSOpenGLContext *)share
|
||||
{
|
||||
[super init];
|
||||
self = [super init];
|
||||
if (!self)
|
||||
return nil;
|
||||
|
||||
glx_context = None;
|
||||
|
||||
if (_format && [_format isKindOfClass: [XGGLPixelFormat class]])
|
||||
{
|
||||
MAKE_DISPLAY(dpy);
|
||||
ASSIGN(format, (XGGLPixelFormat *)_format);
|
||||
//FIXME: allow index mode and sharing
|
||||
|
||||
if (GSglxMinorVersion (dpy) >= 3)
|
||||
glx_context = glXCreateNewContext(dpy, format->conf.tab[0],
|
||||
GLX_RGBA_TYPE, NULL, YES);
|
||||
else
|
||||
glx_context = glXCreateContext(dpy, format->conf.visual, 0, GL_TRUE);
|
||||
|
||||
return self;
|
||||
}
|
||||
else
|
||||
if (!_format || ![_format isKindOfClass: [XGGLPixelFormat class]])
|
||||
{
|
||||
NSDebugMLLog(@"GLX", @"invalid format %@", _format);
|
||||
RELEASE(self);
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
ASSIGN(pixelFormat, (XGGLPixelFormat *)_format);
|
||||
|
||||
//FIXME: allow index mode and sharing
|
||||
glx_context = [pixelFormat createGLXContext: (XGGLContext *)share];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
|
@ -330,26 +347,29 @@ static XGGLContext *currentGLContext;
|
|||
{
|
||||
NSDebugMLLog(@"GLX", @"deallocating");
|
||||
[self _detach];
|
||||
RELEASE(format);
|
||||
RELEASE(pixelFormat);
|
||||
|
||||
if (glx_context != None)
|
||||
{
|
||||
MAKE_DISPLAY(dpy);
|
||||
glXDestroyContext(dpy, glx_context);
|
||||
}
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) makeCurrentContext
|
||||
{
|
||||
MAKE_DISPLAY(dpy);
|
||||
if (xsubwin == nil)
|
||||
|
||||
if (xSubWindow == nil)
|
||||
[NSException raise: NSGenericException
|
||||
format: @"GL Context is not bind, cannot be made current"];
|
||||
|
||||
NSAssert(glx_context != None && glx_drawable != None,
|
||||
NSInternalInconsistencyException);
|
||||
|
||||
if (GSglxMinorVersion (dpy) >= 3)
|
||||
if (GSglxMinorVersion(dpy) >= 3)
|
||||
{
|
||||
NSDebugMLLog(@"GLX", @"before glXMakeContextCurrent");
|
||||
glXMakeContextCurrent(dpy, glx_drawable, glx_drawable, glx_context);
|
||||
|
@ -362,103 +382,63 @@ static XGGLContext *currentGLContext;
|
|||
NSDebugMLLog(@"GLX", @"after glXMakeCurrent");
|
||||
}
|
||||
|
||||
// NSAssert(glx_context != None, NSInternalInconsistencyException);
|
||||
|
||||
// glXMakeCurrent(dpy, xsubwin->winid, glx_context);
|
||||
|
||||
currentGLContext = self;
|
||||
}
|
||||
|
||||
|
||||
- (void)setCurrentVirtualScreen:(int)screen
|
||||
{
|
||||
[self notImplemented: _cmd];
|
||||
}
|
||||
|
||||
|
||||
- (void)setFullScreen
|
||||
{
|
||||
[self notImplemented: _cmd];
|
||||
}
|
||||
|
||||
|
||||
- (void)setOffScreen:(void *)baseaddr
|
||||
width:(long)width
|
||||
height:(long)height
|
||||
rowbytes:(long)rowbytes
|
||||
width:(long)width
|
||||
height:(long)height
|
||||
rowbytes:(long)rowbytes
|
||||
{
|
||||
[self notImplemented: _cmd];
|
||||
}
|
||||
|
||||
|
||||
- (void)setValues:(const long *)vals
|
||||
forParameter:(NSOpenGLContextParameter)param
|
||||
{
|
||||
[self notImplemented: _cmd];
|
||||
}
|
||||
|
||||
|
||||
- (void)setView:(NSView *)view
|
||||
{
|
||||
XGXSubWindow *win;
|
||||
MAKE_DISPLAY(dpy);
|
||||
if (!view)
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"setView called with a nil value"];
|
||||
|
||||
NSAssert(format, NSInternalInconsistencyException);
|
||||
win = [XGXSubWindow subwindowOnView: view];
|
||||
ASSIGN(xsubwin, win);
|
||||
glx_drawable = xsubwin->winid;
|
||||
NSAssert(pixelFormat, NSInternalInconsistencyException);
|
||||
|
||||
// {
|
||||
// GLXFBConfig *conf_tab;
|
||||
// int n_elem;
|
||||
// int attrs[] = {
|
||||
// GLX_DOUBLEBUFFER, 1,
|
||||
// GLX_DEPTH_SIZE, 16,
|
||||
// GLX_RED_SIZE, 1,
|
||||
// GLX_BLUE_SIZE, 1,
|
||||
// GLX_GREEN_SIZE, 1,
|
||||
// None
|
||||
// };
|
||||
|
||||
// conf_tab = glXChooseFBConfig(dpy, DefaultScreen(dpy), attrs, &n_elem);
|
||||
// if (n_elem > 0)
|
||||
// {
|
||||
// printf("found %d context\n", n_elem);
|
||||
// // win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 10, 10,
|
||||
// // 800, 600, 1, 0, 1);
|
||||
// glx_drawable = glXCreateWindow(dpy, *conf_tab, xsubwin->winid, NULL);
|
||||
|
||||
// }
|
||||
// else
|
||||
// puts("no context found");
|
||||
ASSIGN(xSubWindow, [XGXSubWindow subwindowOnView: view
|
||||
visualinfo: [pixelFormat xvinfo]]);
|
||||
glx_drawable = [pixelFormat drawableForWindow: xSubWindow->xwindowid];
|
||||
|
||||
|
||||
// }
|
||||
|
||||
//FIXME
|
||||
//The following line should be the good one. But it crashes my X server...
|
||||
|
||||
// glx_drawable = glXCreateWindow(dpy, *format->conf_tab, xsubwin->winid,
|
||||
// NULL);
|
||||
NSDebugMLLog(@"GLX", @"glx_window : %u", glx_drawable);
|
||||
}
|
||||
|
||||
|
||||
- (void)update
|
||||
{
|
||||
[xsubwin update];
|
||||
[xSubWindow update];
|
||||
}
|
||||
|
||||
|
||||
- (NSView *)view
|
||||
{
|
||||
if (xsubwin)
|
||||
return xsubwin->attached;
|
||||
if (xSubWindow)
|
||||
{
|
||||
return xSubWindow->attached;
|
||||
}
|
||||
else
|
||||
return nil;
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
#include <GNUstepGUI/GSDisplayServer.h>
|
||||
#include "x11/XGServer.h"
|
||||
#include "x11/XGOpenGL.h"
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
#define MAKE_DISPLAY(dpy) Display *dpy;\
|
||||
|
@ -42,145 +41,158 @@
|
|||
|
||||
|
||||
@implementation XGGLPixelFormat
|
||||
- (void)getValues:(long *)vals
|
||||
forAttribute:(NSOpenGLPixelFormatAttribute)attrib
|
||||
forVirtualScreen:(int)screen
|
||||
/* FIXME:
|
||||
|
||||
/* FIXME:
|
||||
we assume that the ABI of NSOpenGLPixelFormatAttribute matches the ABI
|
||||
of glX.
|
||||
Apparently, This is true for the most usefull attributes.
|
||||
*/
|
||||
of glX. Apparently, this is true for the most useful attributes.
|
||||
*/
|
||||
|
||||
- (void) getValues: (GLint *)vals
|
||||
forAttribute: (NSOpenGLPixelFormatAttribute)attrib
|
||||
forVirtualScreen: (GLint)screen
|
||||
{
|
||||
MAKE_DISPLAY(dpy);
|
||||
NSAssert(((GSglxMinorVersion (dpy) >= 3)
|
||||
? (void *)conf.tab : (void *)conf.visual)
|
||||
!= NULL
|
||||
&& n_elem > 0, NSInternalInconsistencyException);
|
||||
|
||||
if (GSglxMinorVersion (dpy) >= 3)
|
||||
glXGetFBConfigAttrib(dpy, conf.tab[0], attrib, (int *)vals);
|
||||
NSAssert(((GSglxMinorVersion (dpy) >= 3) ? (void *)configurations.fbconfig : (void *)configurations.visualinfo) != NULL
|
||||
&& configurationCount > 0,
|
||||
NSInternalInconsistencyException);
|
||||
|
||||
if (GSglxMinorVersion(dpy) >= 3)
|
||||
{
|
||||
glXGetFBConfigAttrib(dpy, configurations.fbconfig[0], attrib, vals);
|
||||
}
|
||||
else
|
||||
glXGetConfig(dpy, conf.visual, attrib, (int *)vals);
|
||||
{
|
||||
glXGetConfig(dpy, configurations.visualinfo, attrib, vals);
|
||||
}
|
||||
}
|
||||
|
||||
- (id)initWithAttributes:(NSOpenGLPixelFormatAttribute *)attribs
|
||||
{
|
||||
int v1, v2;
|
||||
int AccumSize;
|
||||
NSOpenGLPixelFormatAttribute *ptr = attribs;
|
||||
NSMutableData *data = [NSMutableData data];
|
||||
MAKE_DISPLAY(dpy);
|
||||
|
||||
#define append(a, b) do {v1 = a;v2 = b;[data appendBytes: &v1 length: sizeof(v1)];\
|
||||
#define append(a, b) do {int v1 = a; int v2 = b; [data appendBytes: &v1 length: sizeof(v1)];\
|
||||
[data appendBytes: &v2 length: sizeof(v2)];} while (0)
|
||||
#define append1(a) do {v1 = a;[data appendBytes: &v1 length: sizeof(v1)];} while (0)
|
||||
|
||||
#define append1(a) do {int v1 = a; [data appendBytes: &v1 length: sizeof(v1)];} while (0)
|
||||
|
||||
if (GSglxMinorVersion (dpy) < 3)
|
||||
{
|
||||
append1 (GLX_RGBA);
|
||||
}
|
||||
else
|
||||
{
|
||||
append(GLX_RENDER_TYPE, GLX_RGBA_BIT);
|
||||
append(GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT|GLX_PIXMAP_BIT);
|
||||
// append(GLX_X_RENDERABLE,YES);
|
||||
//append(GLX_X_VISUAL_TYPE,GLX_TRUE_COLOR);
|
||||
}
|
||||
|
||||
while (*ptr)
|
||||
{
|
||||
switch(*ptr)
|
||||
{
|
||||
// it means all the same on GLX - there is no diffrent here
|
||||
case NSOpenGLPFASingleRenderer:
|
||||
case NSOpenGLPFAAllRenderers:
|
||||
case NSOpenGLPFAAccelerated:
|
||||
append(GLX_USE_GL,YES);
|
||||
break;
|
||||
case NSOpenGLPFADoubleBuffer:
|
||||
append(GLX_DOUBLEBUFFER, YES);
|
||||
break;
|
||||
case NSOpenGLPFAStereo:
|
||||
append(GLX_STEREO, YES);
|
||||
break;
|
||||
case NSOpenGLPFAAuxBuffers:
|
||||
ptr++;
|
||||
append(GLX_AUX_BUFFERS, *ptr);
|
||||
break;
|
||||
case NSOpenGLPFAColorSize:
|
||||
ptr++;
|
||||
append(GLX_RED_SIZE, *ptr);
|
||||
append(GLX_GREEN_SIZE, *ptr);
|
||||
append(GLX_BLUE_SIZE, *ptr);
|
||||
break;
|
||||
case NSOpenGLPFAAlphaSize:
|
||||
ptr++;
|
||||
append(GLX_ALPHA_SIZE, *ptr);
|
||||
break;
|
||||
case NSOpenGLPFADepthSize:
|
||||
ptr++;
|
||||
append(GLX_DEPTH_SIZE, *ptr);
|
||||
break;
|
||||
case NSOpenGLPFAStencilSize:
|
||||
ptr++;
|
||||
append(GLX_STENCIL_SIZE, *ptr);
|
||||
break;
|
||||
case NSOpenGLPFAAccumSize:
|
||||
ptr++;
|
||||
//has to been tested - I did it in that way....
|
||||
//FIXME? I don't understand...
|
||||
//append(GLX_ACCUM_RED_SIZE, *ptr/3);
|
||||
//append(GLX_ACCUM_GREEN_SIZE, *ptr/3);
|
||||
//append(GLX_ACCUM_BLUE_SIZE, *ptr/3);
|
||||
AccumSize=*ptr;
|
||||
switch (AccumSize)
|
||||
{
|
||||
case 8:
|
||||
append(GLX_ACCUM_RED_SIZE, 3);
|
||||
append(GLX_ACCUM_GREEN_SIZE, 3);
|
||||
append(GLX_ACCUM_BLUE_SIZE, 2);
|
||||
append(GLX_ACCUM_ALPHA_SIZE, 0);
|
||||
break;
|
||||
case 15:
|
||||
case 16:
|
||||
append(GLX_ACCUM_RED_SIZE, 5);
|
||||
append(GLX_ACCUM_GREEN_SIZE, 5);
|
||||
append(GLX_ACCUM_BLUE_SIZE, 5);
|
||||
append(GLX_ACCUM_ALPHA_SIZE, 0);
|
||||
break;
|
||||
case 24:
|
||||
append(GLX_ACCUM_RED_SIZE, 8);
|
||||
append(GLX_ACCUM_GREEN_SIZE, 8);
|
||||
append(GLX_ACCUM_BLUE_SIZE, 8);
|
||||
append(GLX_ACCUM_ALPHA_SIZE, 0);
|
||||
break;
|
||||
case 32:
|
||||
append(GLX_ACCUM_RED_SIZE, 8);
|
||||
append(GLX_ACCUM_GREEN_SIZE, 8);
|
||||
append(GLX_ACCUM_BLUE_SIZE, 8);
|
||||
append(GLX_ACCUM_ALPHA_SIZE, 8);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
//can not be handle by X11
|
||||
case NSOpenGLPFAMinimumPolicy:
|
||||
break;
|
||||
// can not be handle by X11
|
||||
case NSOpenGLPFAMaximumPolicy:
|
||||
break;
|
||||
{
|
||||
// it means all the same on GLX - there is no diffrent here
|
||||
case NSOpenGLPFASingleRenderer:
|
||||
case NSOpenGLPFAAllRenderers:
|
||||
case NSOpenGLPFAAccelerated:
|
||||
if (GSglxMinorVersion(dpy) < 3)
|
||||
append(GLX_USE_GL,YES);
|
||||
break;
|
||||
case NSOpenGLPFADoubleBuffer:
|
||||
append(GLX_DOUBLEBUFFER, YES);
|
||||
break;
|
||||
case NSOpenGLPFAStereo:
|
||||
append(GLX_STEREO, YES);
|
||||
break;
|
||||
case NSOpenGLPFAAuxBuffers:
|
||||
ptr++;
|
||||
append(GLX_AUX_BUFFERS, *ptr);
|
||||
break;
|
||||
case NSOpenGLPFAColorSize:
|
||||
ptr++;
|
||||
append(GLX_RED_SIZE, *ptr);
|
||||
append(GLX_GREEN_SIZE, *ptr);
|
||||
append(GLX_BLUE_SIZE, *ptr);
|
||||
break;
|
||||
case NSOpenGLPFAAlphaSize:
|
||||
ptr++;
|
||||
append(GLX_ALPHA_SIZE, *ptr);
|
||||
break;
|
||||
case NSOpenGLPFADepthSize:
|
||||
ptr++;
|
||||
append(GLX_DEPTH_SIZE, *ptr);
|
||||
break;
|
||||
case NSOpenGLPFAStencilSize:
|
||||
ptr++;
|
||||
append(GLX_STENCIL_SIZE, *ptr);
|
||||
break;
|
||||
case NSOpenGLPFAAccumSize:
|
||||
ptr++;
|
||||
//has to been tested - I did it in that way....
|
||||
//FIXME? I don't understand...
|
||||
//append(GLX_ACCUM_RED_SIZE, *ptr/3);
|
||||
//append(GLX_ACCUM_GREEN_SIZE, *ptr/3);
|
||||
//append(GLX_ACCUM_BLUE_SIZE, *ptr/3);
|
||||
AccumSize=*ptr;
|
||||
switch (AccumSize)
|
||||
{
|
||||
case 8:
|
||||
append(GLX_ACCUM_RED_SIZE, 3);
|
||||
append(GLX_ACCUM_GREEN_SIZE, 3);
|
||||
append(GLX_ACCUM_BLUE_SIZE, 2);
|
||||
append(GLX_ACCUM_ALPHA_SIZE, 0);
|
||||
break;
|
||||
case 15:
|
||||
case 16:
|
||||
append(GLX_ACCUM_RED_SIZE, 5);
|
||||
append(GLX_ACCUM_GREEN_SIZE, 5);
|
||||
append(GLX_ACCUM_BLUE_SIZE, 5);
|
||||
append(GLX_ACCUM_ALPHA_SIZE, 0);
|
||||
break;
|
||||
case 24:
|
||||
append(GLX_ACCUM_RED_SIZE, 8);
|
||||
append(GLX_ACCUM_GREEN_SIZE, 8);
|
||||
append(GLX_ACCUM_BLUE_SIZE, 8);
|
||||
append(GLX_ACCUM_ALPHA_SIZE, 0);
|
||||
break;
|
||||
case 32:
|
||||
append(GLX_ACCUM_RED_SIZE, 8);
|
||||
append(GLX_ACCUM_GREEN_SIZE, 8);
|
||||
append(GLX_ACCUM_BLUE_SIZE, 8);
|
||||
append(GLX_ACCUM_ALPHA_SIZE, 8);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
//can not be handle by X11
|
||||
case NSOpenGLPFAMinimumPolicy:
|
||||
break;
|
||||
// can not be handle by X11
|
||||
case NSOpenGLPFAMaximumPolicy:
|
||||
break;
|
||||
|
||||
//FIXME all of this stuff...
|
||||
case NSOpenGLPFAOffScreen:
|
||||
case NSOpenGLPFAFullScreen:
|
||||
case NSOpenGLPFASampleBuffers:
|
||||
case NSOpenGLPFASamples:
|
||||
case NSOpenGLPFAAuxDepthStencil:
|
||||
case NSOpenGLPFARendererID:
|
||||
case NSOpenGLPFANoRecovery:
|
||||
case NSOpenGLPFAClosestPolicy:
|
||||
case NSOpenGLPFARobust:
|
||||
case NSOpenGLPFABackingStore:
|
||||
case NSOpenGLPFAMPSafe:
|
||||
case NSOpenGLPFAWindow:
|
||||
case NSOpenGLPFAMultiScreen:
|
||||
case NSOpenGLPFACompliant:
|
||||
case NSOpenGLPFAScreenMask:
|
||||
case NSOpenGLPFAVirtualScreenCount:
|
||||
break;
|
||||
}
|
||||
//FIXME all of this stuff...
|
||||
case NSOpenGLPFAOffScreen:
|
||||
case NSOpenGLPFAFullScreen:
|
||||
case NSOpenGLPFASampleBuffers:
|
||||
case NSOpenGLPFASamples:
|
||||
case NSOpenGLPFAAuxDepthStencil:
|
||||
case NSOpenGLPFARendererID:
|
||||
case NSOpenGLPFANoRecovery:
|
||||
case NSOpenGLPFAClosestPolicy:
|
||||
case NSOpenGLPFARobust:
|
||||
case NSOpenGLPFABackingStore:
|
||||
case NSOpenGLPFAMPSafe:
|
||||
case NSOpenGLPFAWindow:
|
||||
case NSOpenGLPFAMultiScreen:
|
||||
case NSOpenGLPFACompliant:
|
||||
case NSOpenGLPFAScreenMask:
|
||||
case NSOpenGLPFAVirtualScreenCount:
|
||||
break;
|
||||
}
|
||||
ptr ++;
|
||||
}
|
||||
|
||||
|
@ -188,77 +200,99 @@
|
|||
|
||||
//FIXME, what screen number ?
|
||||
if (GSglxMinorVersion (dpy) >= 3)
|
||||
conf.tab = glXChooseFBConfig(dpy, DefaultScreen(dpy), [data mutableBytes],
|
||||
&n_elem);
|
||||
{
|
||||
configurations.fbconfig = glXChooseFBConfig(dpy, DefaultScreen(dpy),
|
||||
[data mutableBytes],
|
||||
&configurationCount);
|
||||
}
|
||||
else
|
||||
conf.visual = glXChooseVisual(dpy, DefaultScreen(dpy),
|
||||
[data mutableBytes]);
|
||||
{
|
||||
configurations.visualinfo = glXChooseVisual(dpy, DefaultScreen(dpy),
|
||||
[data mutableBytes]);
|
||||
}
|
||||
|
||||
if (((GSglxMinorVersion (dpy) >= 3)
|
||||
? (void *)conf.tab : (void *)conf.visual)
|
||||
== NULL)
|
||||
if (((GSglxMinorVersion (dpy) >= 3) ? (void *)configurations.fbconfig :
|
||||
(void *)configurations.visualinfo) == NULL)
|
||||
{
|
||||
NSDebugMLLog(@"GLX", @"no pixel format found matching what is required");
|
||||
RELEASE(self);
|
||||
|
||||
return nil;
|
||||
}
|
||||
else
|
||||
{
|
||||
NSDebugMLLog(@"GLX", @"We found %d pixel formats", configurationCount);
|
||||
|
||||
NSDebugMLLog(@"GLX", @"We found %d pixel formats", n_elem);
|
||||
#if 0
|
||||
if (GSglxMinorVersion (dpy) >= 3)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < n_elem; ++i)
|
||||
{
|
||||
int val;
|
||||
NSDebugMLLog(@"GLX", @"inspecting %dth", i+1);
|
||||
glXGetFBConfigAttrib(dpy, conf.tab[i], GLX_BUFFER_SIZE, &val);
|
||||
NSDebugMLLog(@"GLX", @"buffer size %d", val);
|
||||
|
||||
|
||||
glXGetFBConfigAttrib(dpy, conf.tab[i], GLX_DOUBLEBUFFER, &val);
|
||||
NSDebugMLLog(@"GLX", @"double buffer %d", val);
|
||||
|
||||
glXGetFBConfigAttrib(dpy, conf.tab[i], GLX_DEPTH_SIZE, &val);
|
||||
NSDebugMLLog(@"GLX", @"depth size %d", val);
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
glXGetConfig(dpy, conf.visual, GLX_BUFFER_SIZE, &val);
|
||||
NSDebugMLLog(@"GLX", @"buffer size %d", val);
|
||||
|
||||
|
||||
glXGetConfig(dpy, conf.visual, GLX_DOUBLEBUFFER, &val);
|
||||
NSDebugMLLog(@"GLX", @"double buffer %d", val);
|
||||
|
||||
glXGetConfig(dpy, conf.visual, GLX_DEPTH_SIZE, &val);
|
||||
NSDebugMLLog(@"GLX", @"depth size %d", val);
|
||||
}
|
||||
#endif
|
||||
return self;
|
||||
}
|
||||
}
|
||||
|
||||
- (XVisualInfo *)xvinfo
|
||||
{
|
||||
MAKE_DISPLAY(dpy);
|
||||
|
||||
if (GSglxMinorVersion(dpy) >= 3)
|
||||
{
|
||||
return glXGetVisualFromFBConfig(dpy, configurations.fbconfig[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return configurations.visualinfo;
|
||||
}
|
||||
}
|
||||
|
||||
- (GLXContext)createGLXContext: (XGGLContext *)share
|
||||
{
|
||||
MAKE_DISPLAY(dpy);
|
||||
|
||||
if (GSglxMinorVersion(dpy) >= 3)
|
||||
{
|
||||
return glXCreateNewContext(dpy, configurations.fbconfig[0],
|
||||
GLX_RGBA_TYPE, [share glxcontext], YES);
|
||||
}
|
||||
else
|
||||
{
|
||||
return glXCreateContext(dpy, configurations.visualinfo,
|
||||
[share glxcontext], GL_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
- (GLXWindow) drawableForWindow: (Window)xwindowid
|
||||
{
|
||||
MAKE_DISPLAY(dpy);
|
||||
|
||||
if (GSglxMinorVersion(dpy) >= 3)
|
||||
{
|
||||
return glXCreateWindow(dpy, configurations.fbconfig[0],
|
||||
xwindowid, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
return xwindowid;
|
||||
}
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
//FIXME
|
||||
//are we sure that X Connection is still up here ?
|
||||
MAKE_DISPLAY(dpy);
|
||||
if (GSglxMinorVersion (dpy) >= 3)
|
||||
XFree (conf.tab);
|
||||
|
||||
if (GSglxMinorVersion(dpy) >= 3)
|
||||
{
|
||||
XFree(configurations.fbconfig);
|
||||
}
|
||||
else
|
||||
XFree (conf.visual);
|
||||
{
|
||||
XFree(configurations.visualinfo);
|
||||
}
|
||||
|
||||
NSDebugMLLog(@"GLX", @"deallocation");
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (int)numberOfVirtualScreens
|
||||
{
|
||||
// [self notImplemented: _cmd];
|
||||
//FIXME
|
||||
//This looks like a reasonable value to return...
|
||||
return 1;
|
||||
|
|
Loading…
Reference in a new issue