mirror of
https://github.com/gnustep/libs-back.git
synced 2025-04-22 15:31:14 +00:00
OpenGL implmentation
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@14998 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
e91e850a33
commit
92d8441bc8
9 changed files with 905 additions and 1 deletions
|
@ -1,3 +1,12 @@
|
|||
2002-11-15 Frederic De Jaeger <dejaeger@free.fr>
|
||||
|
||||
* Source/x11/XGGLFormat.m, Source/x11/XGGLContext.m
|
||||
Headers/x11/XGOpenGL.h: New files.
|
||||
* Source/x11/Makefile: Updated.
|
||||
* configure.ac: add a test for GLX
|
||||
* Source/x11/XGServer.m (glContextClass,
|
||||
glPixelFormatClass): Implement.
|
||||
|
||||
2002-11-08 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
* Source/x11/XGServerEvent.m ([XGServer
|
||||
|
|
54
Headers/x11/XGOpenGL.h
Normal file
54
Headers/x11/XGOpenGL.h
Normal file
|
@ -0,0 +1,54 @@
|
|||
/* -*-ObjC-*- */
|
||||
/* XGOpenGL - openGL management using glX
|
||||
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
|
||||
Author: Frederic De Jaeger
|
||||
Date: Nov 2002
|
||||
|
||||
This file is part of the GNUstep GUI Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; see the file COPYING.LIB.
|
||||
If not, write to the Free Software Foundation,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _GNUstep_H_XGOpenGL
|
||||
#define _GNUstep_H_XGOpenGL
|
||||
|
||||
#include <AppKit/NSOpenGL.h>
|
||||
#include <GL/glx.h>
|
||||
|
||||
@class NSView;
|
||||
@class XGXSubWindow;
|
||||
@class XGGLPixelFormat;
|
||||
|
||||
@interface XGGLContext : NSOpenGLContext
|
||||
{
|
||||
GLXContext glx_context;
|
||||
GLXWindow glx_drawable;
|
||||
XGXSubWindow *xsubwin;
|
||||
XGGLPixelFormat *format;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface XGGLPixelFormat : NSOpenGLPixelFormat
|
||||
{
|
||||
@public
|
||||
GLXFBConfig *conf_tab;
|
||||
int n_elem;
|
||||
}
|
||||
@end
|
||||
|
||||
#endif
|
|
@ -62,7 +62,9 @@ XGDragView.m \
|
|||
XGSlideView.m \
|
||||
XIMInputServer.m \
|
||||
XGBitmapImageRep.m \
|
||||
XWindowBuffer.m
|
||||
XWindowBuffer.m\
|
||||
XGGLFormat.m\
|
||||
XGGLContext.m
|
||||
|
||||
x11_HEADER_FILES_DIR = ../../Headers/x11
|
||||
x11_HEADER_FILES_INSTALL_DIR = gnustep/x11
|
||||
|
|
414
Source/x11/XGGLContext.m
Normal file
414
Source/x11/XGGLContext.m
Normal file
|
@ -0,0 +1,414 @@
|
|||
/* -*- mode:ObjC -*-
|
||||
XGGLContext - backend implementation of NSOpenGLContext
|
||||
|
||||
Copyright (C) 1998,2002 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Frederic De Jaeger
|
||||
Date: Nov 2002
|
||||
|
||||
This file is part of the GNU Objective C User Interface Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
|
||||
#include "config.h"
|
||||
#ifdef HAVE_GLX
|
||||
#include <Foundation/NSDebug.h>
|
||||
#include <Foundation/NSException.h>
|
||||
#include <AppKit/GSDisplayServer.h>
|
||||
#include <AppKit/NSView.h>
|
||||
#include <AppKit/NSWindow.h>
|
||||
#include "x11/XGServerWindow.h"
|
||||
#include "x11/XGOpenGL.h"
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
//FIXME
|
||||
//should I store the display ?
|
||||
#define MAKE_DISPLAY(dpy) Display *dpy;\
|
||||
dpy = [(XGServer *)GSCurrentServer() xDisplay];\
|
||||
NSAssert(dpy != NULL, NSInternalInconsistencyException)
|
||||
|
||||
@interface XGXSubWindow : NSObject
|
||||
{
|
||||
@public
|
||||
Window winid;
|
||||
NSView *attached;
|
||||
}
|
||||
- (void) update;
|
||||
+ subwindowOnView: (NSView *) view;
|
||||
@end
|
||||
|
||||
@implementation XGXSubWindow
|
||||
/*We assume that the current context is the same and is an XGServer
|
||||
*/
|
||||
- initWithView: (NSView *) view
|
||||
{
|
||||
NSRect rect;
|
||||
gswindow_device_t *win_info;
|
||||
XGServer *server;
|
||||
NSWindow *win;
|
||||
int x, y, width, height;
|
||||
[super init];
|
||||
|
||||
win = [view window];
|
||||
NSAssert(win, @"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"];
|
||||
|
||||
server = (XGServer *)GSServerForWindow(win);
|
||||
NSAssert(server != nil, NSInternalInconsistencyException);
|
||||
|
||||
NSAssert([server isKindOfClass: [XGServer class]],
|
||||
NSInternalInconsistencyException);
|
||||
|
||||
win_info = [XGServer _windowWithTag: [win windowNumber]];
|
||||
NSAssert(win_info, NSInternalInconsistencyException);
|
||||
|
||||
rect = [view convertRect: [view bounds] toView: nil];
|
||||
|
||||
x = NSMinX(rect);
|
||||
y = NSHeight(win_info->xframe) - NSMaxY(rect);
|
||||
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);
|
||||
|
||||
winid = XCreateWindow(win_info->display, win_info->ident,
|
||||
x, y, width, height, 0,
|
||||
CopyFromParent, InputOutput, CopyFromParent, 0, NULL);
|
||||
|
||||
|
||||
// winid = XCreateSimpleWindow(win_info->display, win_info->ident,
|
||||
// x, y, width, height, 2,
|
||||
// 0, 1);
|
||||
|
||||
|
||||
XMapWindow(win_info->display, winid);
|
||||
|
||||
|
||||
attached = view;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) map
|
||||
{
|
||||
MAKE_DISPLAY(dpy);
|
||||
XMapWindow(dpy, winid);
|
||||
}
|
||||
|
||||
- (void) detach
|
||||
{
|
||||
//FIXME
|
||||
//I assume that the current server is correct.
|
||||
MAKE_DISPLAY(dpy);
|
||||
attached = nil;
|
||||
XDestroyWindow(dpy, winid);
|
||||
}
|
||||
|
||||
- (void) update
|
||||
{
|
||||
NSRect rect;
|
||||
gswindow_device_t *win_info;
|
||||
GSDisplayServer *server;
|
||||
NSWindow *win;
|
||||
int x, y, width, height;
|
||||
NSAssert(attached, NSInternalInconsistencyException);
|
||||
|
||||
win = [attached window];
|
||||
NSAssert1(win, @"%@'s window is nil now!", attached);
|
||||
|
||||
NSAssert1(![attached isRotatedOrScaledFromBase],
|
||||
@"%@ is rotated or scaled, now!", attached);
|
||||
|
||||
server = GSServerForWindow(win);
|
||||
NSAssert(server != nil, NSInternalInconsistencyException);
|
||||
|
||||
NSAssert([server isKindOfClass: [XGServer class]],
|
||||
NSInternalInconsistencyException);
|
||||
|
||||
//FIXME
|
||||
//we should check that the window hasn't changed, maybe.
|
||||
|
||||
win_info = [XGServer _windowWithTag: [win windowNumber]];
|
||||
NSAssert(win_info, NSInternalInconsistencyException);
|
||||
|
||||
rect = [attached convertRect: [attached bounds] toView: nil];
|
||||
|
||||
x = NSMinX(rect);
|
||||
y = NSHeight(win_info->xframe) - NSMaxY(rect);
|
||||
width = NSWidth(rect);
|
||||
height = NSHeight(rect);
|
||||
|
||||
|
||||
XMoveResizeWindow(win_info->display, winid,x, y, width, height);
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
NSDebugMLLog(@"GLX", @"deallocating");
|
||||
[self detach];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
+ subwindowOnView: (NSView *) view
|
||||
{
|
||||
XGXSubWindow *win = [[self alloc] initWithView: view];
|
||||
|
||||
return AUTORELEASE(win);
|
||||
}
|
||||
@end
|
||||
|
||||
//FIXME:
|
||||
//should be on per thread basis.
|
||||
static XGGLContext *currentGLContext;
|
||||
|
||||
|
||||
@implementation XGGLContext
|
||||
|
||||
+ (void)clearCurrentContext
|
||||
{
|
||||
MAKE_DISPLAY(dpy);
|
||||
|
||||
glXMakeContextCurrent(dpy, None, None, NULL);
|
||||
currentGLContext = nil;
|
||||
}
|
||||
|
||||
+ (NSOpenGLContext *)currentContext
|
||||
{
|
||||
return currentGLContext;
|
||||
}
|
||||
|
||||
- (void) _detach
|
||||
{
|
||||
if( xsubwin )
|
||||
{
|
||||
MAKE_DISPLAY(dpy);
|
||||
if ( currentGLContext == self )
|
||||
{
|
||||
[XGGLContext clearCurrentContext];
|
||||
}
|
||||
// glXDestroyWindow(dpy, glx_drawable);
|
||||
glx_drawable = None;
|
||||
DESTROY(xsubwin);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)clearDrawable
|
||||
{
|
||||
[self _detach];
|
||||
}
|
||||
|
||||
- (void)copyAttributesFromContext:(NSOpenGLContext *)context
|
||||
withMask:(unsigned long)mask
|
||||
{
|
||||
GLXContext other;
|
||||
MAKE_DISPLAY(dpy);
|
||||
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);
|
||||
}
|
||||
|
||||
- (void)createTexture:(unsigned long)target
|
||||
fromView:(NSView*)view
|
||||
internalFormat:(unsigned long)format
|
||||
{
|
||||
[self notImplemented: _cmd];
|
||||
}
|
||||
|
||||
|
||||
- (int)currentVirtualScreen
|
||||
{
|
||||
[self notImplemented: _cmd];
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
- (void)flushBuffer
|
||||
{
|
||||
MAKE_DISPLAY(dpy);
|
||||
|
||||
glXSwapBuffers(dpy, glx_drawable);
|
||||
}
|
||||
|
||||
|
||||
- (void)getValues:(long *)vals
|
||||
forParameter:(NSOpenGLContextParameter)param
|
||||
{
|
||||
// TODO
|
||||
[self notImplemented: _cmd];
|
||||
}
|
||||
|
||||
|
||||
- (id)initWithFormat:(NSOpenGLPixelFormat *)_format
|
||||
shareContext:(NSOpenGLContext *)share
|
||||
{
|
||||
[super init];
|
||||
glx_context = None;
|
||||
NSParameterAssert(format);
|
||||
if( _format && [_format isKindOfClass: [XGGLPixelFormat class]])
|
||||
{
|
||||
MAKE_DISPLAY(dpy);
|
||||
ASSIGN(format, (XGGLPixelFormat *)_format);
|
||||
//FIXME: allow index mode and sharing
|
||||
glx_context = glXCreateNewContext(dpy, format->conf_tab[0],
|
||||
GLX_RGBA_TYPE, NULL, YES);
|
||||
return self;
|
||||
}
|
||||
else
|
||||
{
|
||||
NSDebugMLLog(@"GLX", @"invalid format %@", _format);
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
NSDebugMLLog(@"GLX", @"deallocating");
|
||||
[self _detach];
|
||||
RELEASE(format);
|
||||
if( glx_context != None )
|
||||
{
|
||||
MAKE_DISPLAY(dpy);
|
||||
glXDestroyContext(dpy, glx_context);
|
||||
}
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) makeCurrentContext
|
||||
{
|
||||
MAKE_DISPLAY(dpy);
|
||||
if( xsubwin == nil )
|
||||
[NSException raise: NSGenericException
|
||||
format: @"GL Context is not bind, cannot be made current"];
|
||||
|
||||
NSAssert(glx_context != None && glx_drawable != None,
|
||||
NSInternalInconsistencyException);
|
||||
|
||||
NSDebugMLLog(@"GLX", @"before glXMakeContextCurrent");
|
||||
glXMakeContextCurrent(dpy, glx_drawable, glx_drawable, glx_context);
|
||||
NSDebugMLLog(@"GLX", @"after glXMakeContextCurrent");
|
||||
|
||||
// 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
|
||||
{
|
||||
[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;
|
||||
|
||||
// {
|
||||
// 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");
|
||||
|
||||
|
||||
// }
|
||||
|
||||
//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];
|
||||
}
|
||||
|
||||
|
||||
- (NSView *)view
|
||||
{
|
||||
if(xsubwin)
|
||||
return xsubwin->attached;
|
||||
else
|
||||
return nil;
|
||||
}
|
||||
|
||||
@end
|
||||
#endif
|
197
Source/x11/XGGLFormat.m
Normal file
197
Source/x11/XGGLFormat.m
Normal file
|
@ -0,0 +1,197 @@
|
|||
/* -*- mode:ObjC -*-
|
||||
XGGLContext - backend implementation of NSOpenGLContext
|
||||
|
||||
Copyright (C) 1998,2002 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Frederic De Jaeger
|
||||
Date: Nov 2002
|
||||
|
||||
This file is part of the GNU Objective C User Interface Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#ifdef HAVE_GLX
|
||||
#include <Foundation/NSDebug.h>
|
||||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSData.h>
|
||||
#include <AppKit/GSDisplayServer.h>
|
||||
#include "x11/XGServer.h"
|
||||
#include "x11/XGOpenGL.h"
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
#define MAKE_DISPLAY(dpy) Display *dpy;\
|
||||
dpy = [(XGServer *)GSCurrentServer() xDisplay];\
|
||||
NSAssert(dpy != NULL, NSInternalInconsistencyException)
|
||||
|
||||
|
||||
@implementation XGGLPixelFormat
|
||||
- (void)getValues:(long *)vals
|
||||
forAttribute:(NSOpenGLPixelFormatAttribute)attrib
|
||||
forVirtualScreen:(int)screen
|
||||
/* FIXME:
|
||||
we assume that the ABI of NSOpenGLPixelFormatAttribute matches the ABI
|
||||
of glX.
|
||||
Apparently, This is true for the most usefull attributes.
|
||||
*/
|
||||
{
|
||||
MAKE_DISPLAY(dpy);
|
||||
NSAssert(conf_tab != NULL && n_elem > 0, NSInternalInconsistencyException);
|
||||
glXGetFBConfigAttrib(dpy, conf_tab[0], attrib, (int *)vals);
|
||||
}
|
||||
|
||||
- (id)initWithAttributes:(NSOpenGLPixelFormatAttribute *)attribs
|
||||
{
|
||||
int v1, v2;
|
||||
NSOpenGLPixelFormatAttribute *ptr = attribs;
|
||||
NSMutableData *data = [NSMutableData data];
|
||||
MAKE_DISPLAY(dpy);
|
||||
|
||||
#define append(a, b) v1 = a;v2 = b;[data appendBytes: &v1 length: sizeof(v1)];\
|
||||
[data appendBytes: &v2 length: sizeof(v2)]
|
||||
#define append1(a) v1 = a;[data appendBytes: &v1 length: sizeof(v1)]
|
||||
|
||||
while(*ptr)
|
||||
{
|
||||
switch(*ptr)
|
||||
{
|
||||
// case NSOpenGLPFAAllRenderers:
|
||||
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++;
|
||||
//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);
|
||||
break;
|
||||
case NSOpenGLPFAMinimumPolicy:
|
||||
//FIXME
|
||||
break;
|
||||
case NSOpenGLPFAMaximumPolicy:
|
||||
//FIXME
|
||||
break;
|
||||
|
||||
//FIXME all of this stuff...
|
||||
case NSOpenGLPFAOffScreen:
|
||||
case NSOpenGLPFAFullScreen:
|
||||
case NSOpenGLPFASampleBuffers:
|
||||
case NSOpenGLPFASamples:
|
||||
case NSOpenGLPFAAuxDepthStencil:
|
||||
case NSOpenGLPFARendererID:
|
||||
case NSOpenGLPFASingleRenderer:
|
||||
case NSOpenGLPFANoRecovery:
|
||||
case NSOpenGLPFAAccelerated:
|
||||
case NSOpenGLPFAClosestPolicy:
|
||||
case NSOpenGLPFARobust:
|
||||
case NSOpenGLPFABackingStore:
|
||||
case NSOpenGLPFAMPSafe:
|
||||
case NSOpenGLPFAWindow:
|
||||
case NSOpenGLPFAMultiScreen:
|
||||
case NSOpenGLPFACompliant:
|
||||
case NSOpenGLPFAScreenMask:
|
||||
case NSOpenGLPFAVirtualScreenCount:
|
||||
break;
|
||||
}
|
||||
|
||||
ptr ++;
|
||||
}
|
||||
|
||||
append1(None);
|
||||
|
||||
//FIXME, what screen number ?
|
||||
conf_tab = glXChooseFBConfig(dpy, DefaultScreen(dpy), [data mutableBytes],
|
||||
&n_elem);
|
||||
if ( conf_tab == NULL )
|
||||
{
|
||||
NSDebugMLLog(@"GLX", @"no pixel format found matching what is required");
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
NSDebugMLLog(@"GLX", @"We found %d pixel formats", n_elem);
|
||||
#if 0
|
||||
{
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return self;
|
||||
}
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
//FIXME
|
||||
//are we sure that X Connection is still up here ?
|
||||
XFree(conf_tab);
|
||||
NSDebugMLLog(@"GLX", @"deallocation");
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (int)numberOfVirtualScreens
|
||||
{
|
||||
// [self notImplemented: _cmd];
|
||||
//FIXME
|
||||
//This looks like a reasonable value to return...
|
||||
return 1;
|
||||
}
|
||||
|
||||
@end
|
||||
#endif
|
|
@ -47,6 +47,7 @@
|
|||
|
||||
#include "x11/XGServer.h"
|
||||
#include "x11/XGInputServer.h"
|
||||
#include "x11/XGOpenGL.h"
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
@ -527,4 +528,23 @@ _parse_display_name(NSString *name, int *dn, int *sn)
|
|||
XBell(dpy, 50);
|
||||
}
|
||||
|
||||
- glContextClass
|
||||
{
|
||||
#ifdef HAVE_GLX
|
||||
return [XGGLContext class];
|
||||
#else
|
||||
return nil;
|
||||
#endif
|
||||
}
|
||||
|
||||
- glPixelFormatClass
|
||||
{
|
||||
#ifdef HAVE_GLX
|
||||
return [XGGLPixelFormat class];
|
||||
#else
|
||||
return nil;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
|
|
@ -17,6 +17,9 @@
|
|||
/* Define to 1 if you have the <DPS/dpsNXargs.h> header file. */
|
||||
#undef HAVE_DPS_DPSNXARGS_H
|
||||
|
||||
/* Define if you have the glx library */
|
||||
#undef HAVE_GLX
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
|
|
186
configure
vendored
186
configure
vendored
|
@ -4453,6 +4453,191 @@ CPPFLAGS="${save_header}"
|
|||
LIBS="${save_libs}"
|
||||
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# GLX support
|
||||
#--------------------------------------------------------------------
|
||||
WITH_GLX=no
|
||||
save_header=${CPPFLAGS}
|
||||
save_libs=${LIBS}
|
||||
CPPFLAGS="${GRAPHIC_CFLAGS} ${GRAPHIC_LFLAGS} ${CPPFLAGS}"
|
||||
LIBS="${GRAPHIC_LIBS} ${LIBS}"
|
||||
echo "$as_me:$LINENO: checking for glXMakeContextCurrent in -lGL" >&5
|
||||
echo $ECHO_N "checking for glXMakeContextCurrent in -lGL... $ECHO_C" >&6
|
||||
if test "${ac_cv_lib_GL_glXMakeContextCurrent+set}" = set; then
|
||||
echo $ECHO_N "(cached) $ECHO_C" >&6
|
||||
else
|
||||
ac_check_lib_save_LIBS=$LIBS
|
||||
LIBS="-lGL $LIBS"
|
||||
cat >conftest.$ac_ext <<_ACEOF
|
||||
#line $LINENO "configure"
|
||||
#include "confdefs.h"
|
||||
|
||||
/* Override any gcc2 internal prototype to avoid an error. */
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
/* We use char because int might match the return type of a gcc2
|
||||
builtin and then its argument prototype would still apply. */
|
||||
char glXMakeContextCurrent ();
|
||||
#ifdef F77_DUMMY_MAIN
|
||||
# ifdef __cplusplus
|
||||
extern "C"
|
||||
# endif
|
||||
int F77_DUMMY_MAIN() { return 1; }
|
||||
#endif
|
||||
int
|
||||
main ()
|
||||
{
|
||||
glXMakeContextCurrent ();
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
rm -f conftest.$ac_objext conftest$ac_exeext
|
||||
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
|
||||
(eval $ac_link) 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); } &&
|
||||
{ ac_try='test -s conftest$ac_exeext'
|
||||
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
||||
(eval $ac_try) 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; }; then
|
||||
ac_cv_lib_GL_glXMakeContextCurrent=yes
|
||||
else
|
||||
echo "$as_me: failed program was:" >&5
|
||||
cat conftest.$ac_ext >&5
|
||||
ac_cv_lib_GL_glXMakeContextCurrent=no
|
||||
fi
|
||||
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
|
||||
LIBS=$ac_check_lib_save_LIBS
|
||||
fi
|
||||
echo "$as_me:$LINENO: result: $ac_cv_lib_GL_glXMakeContextCurrent" >&5
|
||||
echo "${ECHO_T}$ac_cv_lib_GL_glXMakeContextCurrent" >&6
|
||||
if test $ac_cv_lib_GL_glXMakeContextCurrent = yes; then
|
||||
have_glx=yes
|
||||
else
|
||||
have_glx=no
|
||||
fi
|
||||
|
||||
if test "${ac_cv_header_GL_glx_h+set}" = set; then
|
||||
echo "$as_me:$LINENO: checking for GL/glx.h" >&5
|
||||
echo $ECHO_N "checking for GL/glx.h... $ECHO_C" >&6
|
||||
if test "${ac_cv_header_GL_glx_h+set}" = set; then
|
||||
echo $ECHO_N "(cached) $ECHO_C" >&6
|
||||
fi
|
||||
echo "$as_me:$LINENO: result: $ac_cv_header_GL_glx_h" >&5
|
||||
echo "${ECHO_T}$ac_cv_header_GL_glx_h" >&6
|
||||
else
|
||||
# Is the header compilable?
|
||||
echo "$as_me:$LINENO: checking GL/glx.h usability" >&5
|
||||
echo $ECHO_N "checking GL/glx.h usability... $ECHO_C" >&6
|
||||
cat >conftest.$ac_ext <<_ACEOF
|
||||
#line $LINENO "configure"
|
||||
#include "confdefs.h"
|
||||
$ac_includes_default
|
||||
#include <GL/glx.h>
|
||||
_ACEOF
|
||||
rm -f conftest.$ac_objext
|
||||
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
|
||||
(eval $ac_compile) 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); } &&
|
||||
{ ac_try='test -s conftest.$ac_objext'
|
||||
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
||||
(eval $ac_try) 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; }; then
|
||||
ac_header_compiler=yes
|
||||
else
|
||||
echo "$as_me: failed program was:" >&5
|
||||
cat conftest.$ac_ext >&5
|
||||
ac_header_compiler=no
|
||||
fi
|
||||
rm -f conftest.$ac_objext conftest.$ac_ext
|
||||
echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
|
||||
echo "${ECHO_T}$ac_header_compiler" >&6
|
||||
|
||||
# Is the header present?
|
||||
echo "$as_me:$LINENO: checking GL/glx.h presence" >&5
|
||||
echo $ECHO_N "checking GL/glx.h presence... $ECHO_C" >&6
|
||||
cat >conftest.$ac_ext <<_ACEOF
|
||||
#line $LINENO "configure"
|
||||
#include "confdefs.h"
|
||||
#include <GL/glx.h>
|
||||
_ACEOF
|
||||
if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
|
||||
(eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
|
||||
ac_status=$?
|
||||
egrep -v '^ *\+' conftest.er1 >conftest.err
|
||||
rm -f conftest.er1
|
||||
cat conftest.err >&5
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); } >/dev/null; then
|
||||
if test -s conftest.err; then
|
||||
ac_cpp_err=$ac_c_preproc_warn_flag
|
||||
else
|
||||
ac_cpp_err=
|
||||
fi
|
||||
else
|
||||
ac_cpp_err=yes
|
||||
fi
|
||||
if test -z "$ac_cpp_err"; then
|
||||
ac_header_preproc=yes
|
||||
else
|
||||
echo "$as_me: failed program was:" >&5
|
||||
cat conftest.$ac_ext >&5
|
||||
ac_header_preproc=no
|
||||
fi
|
||||
rm -f conftest.err conftest.$ac_ext
|
||||
echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
|
||||
echo "${ECHO_T}$ac_header_preproc" >&6
|
||||
|
||||
# So? What about this header?
|
||||
case $ac_header_compiler:$ac_header_preproc in
|
||||
yes:no )
|
||||
{ echo "$as_me:$LINENO: WARNING: GL/glx.h: accepted by the compiler, rejected by the preprocessor!" >&5
|
||||
echo "$as_me: WARNING: GL/glx.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
|
||||
{ echo "$as_me:$LINENO: WARNING: GL/glx.h: proceeding with the preprocessor's result" >&5
|
||||
echo "$as_me: WARNING: GL/glx.h: proceeding with the preprocessor's result" >&2;};;
|
||||
no:yes )
|
||||
{ echo "$as_me:$LINENO: WARNING: GL/glx.h: present but cannot be compiled" >&5
|
||||
echo "$as_me: WARNING: GL/glx.h: present but cannot be compiled" >&2;}
|
||||
{ echo "$as_me:$LINENO: WARNING: GL/glx.h: check for missing prerequisite headers?" >&5
|
||||
echo "$as_me: WARNING: GL/glx.h: check for missing prerequisite headers?" >&2;}
|
||||
{ echo "$as_me:$LINENO: WARNING: GL/glx.h: proceeding with the preprocessor's result" >&5
|
||||
echo "$as_me: WARNING: GL/glx.h: proceeding with the preprocessor's result" >&2;};;
|
||||
esac
|
||||
echo "$as_me:$LINENO: checking for GL/glx.h" >&5
|
||||
echo $ECHO_N "checking for GL/glx.h... $ECHO_C" >&6
|
||||
if test "${ac_cv_header_GL_glx_h+set}" = set; then
|
||||
echo $ECHO_N "(cached) $ECHO_C" >&6
|
||||
else
|
||||
ac_cv_header_GL_glx_h=$ac_header_preproc
|
||||
fi
|
||||
echo "$as_me:$LINENO: result: $ac_cv_header_GL_glx_h" >&5
|
||||
echo "${ECHO_T}$ac_cv_header_GL_glx_h" >&6
|
||||
|
||||
fi
|
||||
|
||||
|
||||
if test "$have_glx" = yes -a "$ac_cv_header_GL_glx_h" = yes; then
|
||||
GRAPHIC_LIBS="-lGL ${GRAPHIC_LIBS}"
|
||||
WITH_GLX=yes
|
||||
|
||||
cat >>confdefs.h <<\_ACEOF
|
||||
#define HAVE_GLX 1
|
||||
_ACEOF
|
||||
|
||||
fi
|
||||
CPPFLAGS="${save_header}"
|
||||
LIBS="${save_libs}"
|
||||
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# XIM support
|
||||
#--------------------------------------------------------------------
|
||||
|
@ -6237,6 +6422,7 @@ s,@X_PRE_LIBS@,$X_PRE_LIBS,;t t
|
|||
s,@X_LIBS@,$X_LIBS,;t t
|
||||
s,@X_EXTRA_LIBS@,$X_EXTRA_LIBS,;t t
|
||||
s,@WITH_XFT@,$WITH_XFT,;t t
|
||||
s,@WITH_GLX@,$WITH_GLX,;t t
|
||||
s,@WITH_WRASTER@,$WITH_WRASTER,;t t
|
||||
s,@GRAPHIC_LIBS@,$GRAPHIC_LIBS,;t t
|
||||
s,@GRAPHIC_CFLAGS@,$GRAPHIC_CFLAGS,;t t
|
||||
|
|
19
configure.ac
19
configure.ac
|
@ -195,6 +195,25 @@ CPPFLAGS="${save_header}"
|
|||
LIBS="${save_libs}"
|
||||
AC_SUBST(WITH_XFT)
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# GLX support
|
||||
#--------------------------------------------------------------------
|
||||
WITH_GLX=no
|
||||
save_header=${CPPFLAGS}
|
||||
save_libs=${LIBS}
|
||||
CPPFLAGS="${GRAPHIC_CFLAGS} ${GRAPHIC_LFLAGS} ${CPPFLAGS}"
|
||||
LIBS="${GRAPHIC_LIBS} ${LIBS}"
|
||||
AC_CHECK_LIB(GL, glXMakeContextCurrent, have_glx=yes, have_glx=no)
|
||||
AC_CHECK_HEADER(GL/glx.h)
|
||||
if test "$have_glx" = yes -a "$ac_cv_header_GL_glx_h" = yes; then
|
||||
GRAPHIC_LIBS="-lGL ${GRAPHIC_LIBS}"
|
||||
WITH_GLX=yes
|
||||
AC_DEFINE(HAVE_GLX,1,[Define if you have the glx library])
|
||||
fi
|
||||
CPPFLAGS="${save_header}"
|
||||
LIBS="${save_libs}"
|
||||
AC_SUBST(WITH_GLX)
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# XIM support
|
||||
#--------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in a new issue