diff options
Diffstat (limited to 'bundles/org.eclipse.swt.opengl/motif/org/eclipse/swt/opengl')
3 files changed, 0 insertions, 554 deletions
diff --git a/bundles/org.eclipse.swt.opengl/motif/org/eclipse/swt/opengl/GLContext.java b/bundles/org.eclipse.swt.opengl/motif/org/eclipse/swt/opengl/GLContext.java deleted file mode 100644 index 29df45c7bd..0000000000 --- a/bundles/org.eclipse.swt.opengl/motif/org/eclipse/swt/opengl/GLContext.java +++ /dev/null @@ -1,303 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.swt.opengl; - - -import org.eclipse.swt.*; -import org.eclipse.swt.graphics.*; -import org.eclipse.swt.internal.motif.*; -import org.eclipse.swt.opengl.internal.motif.*; - -/** - * Instances of <code>GLContext</code> are used to draw on swt <code>Drawable</code>s - * through invocations of provided OpenGL functions. - * <p> - * Application code must explicitly invoke the <code>GLContext.dispose ()</code> - * method to release the operating system resources managed by each instance - * when those instances are no longer required. This is <em>particularly</em> - * important on Windows95 and Windows98 where the operating system has a limited - * number of device contexts available. - * </p> - */ -public class GLContext { - int handle; - int gc; - GCData data; - Drawable drawable; - int selectBufferPtr = 0; - - static final int MSB_FIRST = 1; - static final int LSB_FIRST = 2; - - /** - * Constructs a new instance of this class which has been - * configured to draw on the specified drawable. - * <p> - * You must dispose the <code>GLContext</code> when it is no longer required. - * </p> - * - * @param drawable the drawable to draw on - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the drawable is null</li> - * </ul> - * @exception SWTError <ul> - * <li>ERROR_NO_HANDLES if a handle could not be obtained for gc creation</li> - * <li>ERROR_UNSUPPORTED_DEPTH - if the current display depth is not supported</li> - * </ul> - */ - public GLContext (Drawable drawable) { - if (drawable == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); - this.drawable = drawable; - this.data = new GCData (); - gc = drawable.internal_new_GC (data); - if (gc == 0) SWT.error (SWT.ERROR_NO_HANDLES); - int xDisplay = data.display; - int screen = OS.XDefaultScreen (xDisplay); - int depth = OS.XDefaultDepthOfScreen (OS.XDefaultScreenOfDisplay (xDisplay)); - int attrib [] = { - XGL.GLX_LEVEL, - 0, - XGL.GLX_RGBA, - XGL.GLX_DOUBLEBUFFER, -// XGL.GLX_DEPTH_SIZE, -// depth, - 0 - }; - int infoPtr = XGL.glXChooseVisual (xDisplay, screen, attrib); - if (infoPtr == 0) SWT.error (SWT.ERROR_UNSUPPORTED_DEPTH); - XVisualInfo info = new XVisualInfo (); - XGL.memmove (info, infoPtr, XVisualInfo.sizeof); - OS.XFree (infoPtr); - handle = XGL.glXCreateContext (xDisplay, info, 0, false); - if (handle == 0) SWT.error (SWT.ERROR_NO_HANDLES); - } - - public ImageData convertImageData (ImageData source) { - PaletteData palette = new PaletteData (0xff0000, 0xff00, 0xff); - ImageData newSource = new ImageData (source.width, source.height, 24, palette); - ImageDataUtil.blit ( - 1, - source.data, - source.depth, - source.bytesPerLine, - (source.depth != 16) ? MSB_FIRST : LSB_FIRST, - 0, - 0, - source.width, - source.height, - source.palette.redMask, - source.palette.greenMask, - source.palette.blueMask, - 255, - null, - 0, - 0, - 0, - newSource.data, - newSource.depth, - newSource.bytesPerLine, - (newSource.depth != 16) ? MSB_FIRST : LSB_FIRST, - 0, - 0, - newSource.width, - newSource.height, - newSource.palette.redMask, - newSource.palette.greenMask, - newSource.palette.blueMask, - false, - true); - - return newSource; - } - - /** - * Disposes of the operating system resources associated with - * the receiver. Applications must dispose of all <code>GLContext</code>s - * that they allocate. - */ - public void dispose () { - if (handle == 0) return; - int xDisplay = data.display; - if (XGL.glXGetCurrentContext () == handle) { - XGL.glXMakeCurrent (xDisplay, 0, 0); - } - if (selectBufferPtr != 0) OS.XtFree (selectBufferPtr); - XGL.glXDestroyContext (xDisplay, handle); - handle = 0; - // drawable may be disposed - try { - drawable.internal_dispose_GC (gc, data); - } catch (SWTException e) { - } - gc = 0; - data.display = data.drawable = data.colormap = 0; - /*data.fontList =*/ data.clipRgn = data.renderTable = 0; - drawable = null; - data.device = null; - data.image = null; - //data.codePage = null; - data = null; - } - - public int[] getSelectBuffer (int selectBufferPtr, int[] selectBuffer) { - OS.memmove (selectBuffer, selectBufferPtr, selectBuffer.length * 4); - return selectBuffer; - } - - public int getSelectBufferPtr (int[] selectBuffer) { - if (selectBufferPtr == 0) { - selectBufferPtr = OS.XtMalloc (selectBuffer.length * 4); - } - OS.memmove (selectBufferPtr, selectBuffer, selectBuffer.length * 4); - return selectBufferPtr; - } - - /** - * Returns a boolean indicating whether the receiver is the current - * <code>GLContext</code>. - * - * @return true if the receiver is the current <code>GLContext</code>, - * false otherwise - * @exception SWTError <ul> - * <li>ERROR_GRAPHIC_DISPOSED if the receiver is disposed</li> - * </ul> - */ - public boolean isCurrent () { - if (isDisposed ()) SWT.error (SWT.ERROR_GRAPHIC_DISPOSED); - return XGL.glXGetCurrentContext () == handle; - } - - /** - * Returns a boolean indicating whether the <code>GLContext</code> has been - * disposed. - * <p> - * This method gets the dispose state for the <code>GLContext</code>. - * When a <code>GLContext</code> has been disposed, it is an error to - * invoke any other method using the <code>GLContext</code>. - * - * @return true if the <code>GLContext</code> is disposed, false otherwise - */ - public boolean isDisposed () { - return handle == 0; - } - - /** - * Loads the specified bitmap font. - * - * @param fdata - * @param device - * @param base - * @param first - * @param count - */ - public void loadBitmapFont (FontData fdata, Device device, int base, int startIndex, int length) { - /* Temporary code, due some problems when running on UTF-8 loadBitmapFont () - * is restrict to works only for ascii. - * Note: en_US.ISO8859-1 also code be used. - */ - fdata.setLocale ("C"); - Font font = new Font (device, fdata); - int fontList = font.handle; - int[] buffer = new int [1]; - if (!OS.XmFontListInitFontContext (buffer, fontList)) return; - int context = buffer [0]; - XFontStruct fontStruct = new XFontStruct (); - int fontListEntry; - int[] fontStructPtr = new int [1]; - int[] fontNamePtr = new int [1]; - int xfont = 0; - // go through each entry in the font list - while ((fontListEntry = OS.XmFontListNextEntry (context)) != 0) { - int fontPtr = OS.XmFontListEntryGetFont (fontListEntry, buffer); - if (buffer [0] == OS.XmFONT_IS_FONT) { - // FontList contains a single font - OS.memmove (fontStruct, fontPtr, 20 * 4); - xfont = fontStruct.fid; - } else { - // FontList contains a fontSet - int nFonts = OS.XFontsOfFontSet (fontPtr, fontStructPtr, fontNamePtr); - int[] fontStructs = new int [nFonts]; - OS.memmove (fontStructs, fontStructPtr [0], nFonts * 4); - // Go through each fontStruct in the font set. - for (int i = 0; i < nFonts; i++) { - OS.memmove (fontStruct, fontStructs [i], XFontStruct.sizeof); - xfont = fontStruct.fid; - } - } - } - if (xfont != 0) { - XGL.glXUseXFont (xfont, startIndex, length, base); - } - font.dispose (); - OS.XmFontListFreeFontContext (context); - } - - /** - * Loads the specified outline font. - * - * @param fdata - * @param device - * @param base - * @param first - * @param count - * @param deviation - * @param extrusion - * @param format - * @param lpgmf - */ - public void loadOutlineFont (FontData fdata, Device device, int base, int first, - int count, float deviation, float extrusion, int format, GLYPHMETRICSFLOAT[] lpgmf) { - // stub - } - - /** - * Resizes the receiver. - * - * @param x - * @param y - * @param width - * @param height - */ - public void resize (int x, int y, int width, int height) { - if (height == 0) height = 1; - GL.glViewport (x, y, width, height); - GL.glMatrixMode (GL.GL_PROJECTION); - GL.glLoadIdentity (); - GLU.gluPerspective (45.0f, (float) width / (float) height, 0.1f, 100.0f); - GL.glMatrixMode (GL.GL_MODELVIEW); - GL.glLoadIdentity (); - } - - /** - * Sets the receiver to be the current <code>GLContext</code>. - * - * @exception SWTError <ul> - * <li>ERROR_GRAPHIC_DISPOSED if the receiver is disposed</li> - * </ul> - */ - public void setCurrent () { - if (isDisposed ()) SWT.error (SWT.ERROR_GRAPHIC_DISPOSED); - if (XGL.glXGetCurrentContext () == handle) return; - XGL.glXMakeCurrent (data.display, data.drawable, handle); - } - - /** - * Swaps the receiver's buffers. - * - * @exception SWTError <ul> - * <li>ERROR_GRAPHIC_DISPOSED if the receiver is disposed</li> - * </ul> - */ - public void swapBuffers () { - if (isDisposed ()) SWT.error (SWT.ERROR_GRAPHIC_DISPOSED); - XGL.glXSwapBuffers (data.display, data.drawable); - } -} diff --git a/bundles/org.eclipse.swt.opengl/motif/org/eclipse/swt/opengl/internal/motif/XGL.java b/bundles/org.eclipse.swt.opengl/motif/org/eclipse/swt/opengl/internal/motif/XGL.java deleted file mode 100644 index a5a3e5a264..0000000000 --- a/bundles/org.eclipse.swt.opengl/motif/org/eclipse/swt/opengl/internal/motif/XGL.java +++ /dev/null @@ -1,227 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.swt.opengl.internal.motif; - -import org.eclipse.swt.opengl.Library; - -public class XGL { - -static { - Library.loadLibrary("gl"); -} - -public static final int GLX_VERSION_1_1 = 1; -public static final int GLX_VERSION_1_2 = 1; -public static final int GLX_VERSION_1_3 = 1; - -/* -** Visual Config Attributes (glXGetConfig, glXGetFBConfigAttrib) -*/ -public static final int GLX_USE_GL = 1; /* support GLX rendering */ -public static final int GLX_BUFFER_SIZE = 2; /* depth of the color buffer */ -public static final int GLX_LEVEL = 3; /* level in plane stacking */ -public static final int GLX_RGBA = 4; /* true if RGBA mode */ -public static final int GLX_DOUBLEBUFFER = 5; /* double buffering supported */ -public static final int GLX_STEREO = 6; /* stereo buffering supported */ -public static final int GLX_AUX_BUFFERS = 7; /* number of aux buffers */ -public static final int GLX_RED_SIZE = 8; /* number of red component bits */ -public static final int GLX_GREEN_SIZE = 9; /* number of green component bits */ -public static final int GLX_BLUE_SIZE = 10; /* number of blue component bits */ -public static final int GLX_ALPHA_SIZE = 11; /* number of alpha component bits */ -public static final int GLX_DEPTH_SIZE = 12; /* number of depth bits */ -public static final int GLX_STENCIL_SIZE = 13; /* number of stencil bits */ -public static final int GLX_ACCUM_RED_SIZE = 14; /* number of red accum bits */ -public static final int GLX_ACCUM_GREEN_SIZE = 15; /* number of green accum bits */ -public static final int GLX_ACCUM_BLUE_SIZE = 16; /* number of blue accum bits */ -public static final int GLX_ACCUM_ALPHA_SIZE = 17; /* number of alpha accum bits */ -/* -** FBConfig-specific attributes -*/ -public static final int GLX_X_VISUAL_TYPE = 0x22; -public static final int GLX_CONFIG_CAVEAT = 0x20; /* Like visual_info VISUAL_CAVEAT_EXT */ -public static final int GLX_TRANSPARENT_TYPE = 0x23; -public static final int GLX_TRANSPARENT_INDEX_VALUE = 0x24; -public static final int GLX_TRANSPARENT_RED_VALUE = 0x25; -public static final int GLX_TRANSPARENT_GREEN_VALUE = 0x26; -public static final int GLX_TRANSPARENT_BLUE_VALUE = 0x27; -public static final int GLX_TRANSPARENT_ALPHA_VALUE = 0x28; -public static final int GLX_DRAWABLE_TYPE = 0x8010; -public static final int GLX_RENDER_TYPE = 0x8011; -public static final int GLX_X_RENDERABLE = 0x8012; -public static final int GLX_FBCONFIG_ID = 0x8013; -public static final int GLX_MAX_PBUFFER_WIDTH = 0x8016; -public static final int GLX_MAX_PBUFFER_HEIGHT = 0x8017; -public static final int GLX_MAX_PBUFFER_PIXELS = 0x8018; -public static final int GLX_VISUAL_ID = 0x800B; - -/* -** Error return values from glXGetConfig. Success is indicated by -** a value of 0. -*/ -public static final int GLX_BAD_SCREEN = 1; /* screen # is bad */ -public static final int GLX_BAD_ATTRIBUTE = 2; /* attribute to get is bad */ -public static final int GLX_NO_EXTENSION = 3; /* no glx extension on server */ -public static final int GLX_BAD_VISUAL = 4; /* visual # not known by GLX */ -public static final int GLX_BAD_CONTEXT = 5; /* returned only by import_context EXT? */ -public static final int GLX_BAD_VALUE = 6; /* returned only by glXSwapIntervalSGI? */ -public static final int GLX_BAD_ENUM = 7; /* unused? */ - -/* FBConfig attribute values */ - -/* -** Generic "don't care" value for glX ChooseFBConfig attributes (except -** GLX_LEVEL) -*/ -public static final int GLX_DONT_CARE = 0xFFFFFFFF; - -/* GLX_RENDER_TYPE bits */ -public static final int GLX_RGBA_BIT = 0x00000001; -public static final int GLX_COLOR_INDEX_BIT = 0x00000002; - -/* GLX_DRAWABLE_TYPE bits */ -public static final int GLX_WINDOW_BIT = 0x00000001; -public static final int GLX_PIXMAP_BIT = 0x00000002; -public static final int GLX_PBUFFER_BIT = 0x00000004; - -/* GLX_CONFIG_CAVEAT attribute values */ -public static final int GLX_NONE = 0x8000; -public static final int GLX_SLOW_CONFIG = 0x8001; -public static final int GLX_NON_CONFORMANT_CONFIG = 0x800D; - -/* GLX_X_VISUAL_TYPE attribute values */ -public static final int GLX_TRUE_COLOR = 0x8002; -public static final int GLX_DIRECT_COLOR = 0x8003; -public static final int GLX_PSEUDO_COLOR = 0x8004; -public static final int GLX_STATIC_COLOR = 0x8005; -public static final int GLX_GRAY_SCALE = 0x8006; -public static final int GLX_STATIC_GRAY = 0x8007; - -/* GLX_TRANSPARENT_TYPE attribute values */ -/* public static final int GLX_NONE 0x8000 */ -public static final int GLX_TRANSPARENT_RGB = 0x8008; -public static final int GLX_TRANSPARENT_INDEX = 0x8009; - -/* glXCreateGLXPbuffer attributes */ -public static final int GLX_PRESERVED_CONTENTS = 0x801B; -public static final int GLX_LARGEST_PBUFFER = 0x801C; -public static final int GLX_PBUFFER_HEIGHT = 0x8040; /* New for GLX 1.3 */ -public static final int GLX_PBUFFER_WIDTH = 0x8041; /* New for GLX 1.3 */ - -/* glXQueryGLXPBuffer attributes */ -public static final int GLX_WIDTH = 0x801D; -public static final int GLX_HEIGHT = 0x801E; -public static final int GLX_EVENT_MASK = 0x801F; - -/* glXCreateNewContext render_type attribute values */ -public static final int GLX_RGBA_TYPE = 0x8014; -public static final int GLX_COLOR_INDEX_TYPE = 0x8015; - -/* glXQueryContext attributes */ -/* public static final int GLX_FBCONFIG_ID 0x8013 */ -/* public static final int GLX_RENDER_TYPE 0x8011 */ -public static final int GLX_SCREEN = 0x800C; - -/* glXSelectEvent event mask bits */ -public static final int GLX_PBUFFER_CLOBBER_MASK = 0x08000000; - -/* GLXPbufferClobberEvent event_type values */ -public static final int GLX_DAMAGED = 0x8020; -public static final int GLX_SAVED = 0x8021; - -/* GLXPbufferClobberEvent draw_type values */ -public static final int GLX_WINDOW = 0x8022; -public static final int GLX_PBUFFER = 0x8023; - -/* GLXPbufferClobberEvent buffer_mask bits */ -public static final int GLX_FRONT_LEFT_BUFFER_BIT = 0x00000001; -public static final int GLX_FRONT_RIGHT_BUFFER_BIT = 0x00000002; -public static final int GLX_BACK_LEFT_BUFFER_BIT = 0x00000004; -public static final int GLX_BACK_RIGHT_BUFFER_BIT = 0x00000008; -public static final int GLX_AUX_BUFFERS_BIT = 0x00000010; -public static final int GLX_DEPTH_BUFFER_BIT = 0x00000020; -public static final int GLX_STENCIL_BUFFER_BIT = 0x00000040; -public static final int GLX_ACCUM_BUFFER_BIT = 0x00000080; - -/* -** Extension return values from glXGetConfig. These are also -** accepted as parameter values for glXChooseVisual. -*/ - -public static final int GLX_X_VISUAL_TYPE_EXT = 0x22; /* visual_info extension type */ -public static final int GLX_TRANSPARENT_TYPE_EXT = 0x23; /* visual_info extension */ -public static final int GLX_TRANSPARENT_INDEX_VALUE_EXT = 0x24; /* visual_info extension */ -public static final int GLX_TRANSPARENT_RED_VALUE_EXT = 0x25; /* visual_info extension */ -public static final int GLX_TRANSPARENT_GREEN_VALUE_EXT = 0x26; /* visual_info extension */ -public static final int GLX_TRANSPARENT_BLUE_VALUE_EXT = 0x27; /* visual_info extension */ -public static final int GLX_TRANSPARENT_ALPHA_VALUE_EXT = 0x28; /* visual_info extension */ - -/* Property values for visual_type */ -public static final int GLX_TRUE_COLOR_EXT = 0x8002; -public static final int GLX_DIRECT_COLOR_EXT = 0x8003; -public static final int GLX_PSEUDO_COLOR_EXT = 0x8004; -public static final int GLX_STATIC_COLOR_EXT = 0x8005; -public static final int GLX_GRAY_SCALE_EXT = 0x8006; -public static final int GLX_STATIC_GRAY_EXT = 0x8007; - -/* Property values for transparent pixel */ -public static final int GLX_NONE_EXT = 0x8000; -public static final int GLX_TRANSPARENT_RGB_EXT = 0x8008; -public static final int GLX_TRANSPARENT_INDEX_EXT = 0x8009; - -/* Property values for visual_rating */ -public static final int GLX_VISUAL_CAVEAT_EXT = 0x20; /* visual_rating extension type */ -public static final int GLX_SLOW_VISUAL_EXT = 0x8001; -public static final int GLX_NON_CONFORMANT_VISUAL_EXT = 0x800D; - -/* -** Names for attributes to glXGetClientString. -*/ -public static final int GLX_VENDOR = 0x1; -public static final int GLX_VERSION = 0x2; -public static final int GLX_EXTENSIONS = 0x3; - -/* -** Names for attributes to glXQueryContextInfoEXT. -*/ -public static final int GLX_SHARE_CONTEXT_EXT = 0x800A; /* id of share context */ -public static final int GLX_VISUAL_ID_EXT = 0x800B; /* id of context's visual */ -public static final int GLX_SCREEN_EXT = 0x800C; /* screen number */ - -/* GLX Extension Strings */ -public static final int GLX_EXT_import_context = 1; -public static final int GLX_EXT_visual_info = 1; -public static final int GLX_EXT_visual_rating = 1; -public static final int GLX_ARB_get_proc_address = 1; - -public static final native int glXChooseVisual(int dpy, int screen, int[] attribList); -public static final native void glXCopyContext(int dpy, int src, int dst, int mask); -//public static final native int glXCreateContext(int dpy, int vis, int shareList, boolean direct); -public static final native int glXCreateContext(int dpy, XVisualInfo vis, int shareList, boolean direct); -public static final native int glXCreateGLXPixmap(int dpy, XVisualInfo vis, int pixmap); -public static final native void glXDestroyContext(int dpy, int ctx); -public static final native void glXDestroyGLXPixmap(int dpy, int pix); -public static final native int glXGetConfig(int dpy, XVisualInfo vis, int attrib, int[] value); -public static final native int glXGetCurrentContext(); -public static final native int glXGetCurrentDrawable(); -public static final native boolean glXIsDirect(int dpy, int ctx); -public static final native boolean glXMakeCurrent(int dpy, int drawable, int ctx); -public static final native boolean glXQueryExtension(int dpy, int[] errorBase, int[] eventBase); -public static final native boolean glXQueryVersion(int dpy, int[] major, int[] minor); -public static final native void glXSwapBuffers(int dpy, int drawable); -public static final native void glXUseXFont(int font, int first, int count, int listBase); -public static final native void glXWaitGL(); -public static final native void glXWaitX(); -public static final native int glXGetClientString(int dpy, int name); -public static final native int glXQueryServerString(int dpy, int screen, int name); -public static final native int glXQueryExtensionsString(int dpy, int screen); -public static final native void memmove(XVisualInfo dest, int src, int size); - -} diff --git a/bundles/org.eclipse.swt.opengl/motif/org/eclipse/swt/opengl/internal/motif/XVisualInfo.java b/bundles/org.eclipse.swt.opengl/motif/org/eclipse/swt/opengl/internal/motif/XVisualInfo.java deleted file mode 100644 index 028032dce4..0000000000 --- a/bundles/org.eclipse.swt.opengl/motif/org/eclipse/swt/opengl/internal/motif/XVisualInfo.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.swt.opengl.internal.motif; - - -public class XVisualInfo { - public int visual; - public int visualid; - public int screen; - public int depth; - public int cclass; - public int red_mask, green_mask, blue_mask; - public int colormap_size; - public int bits_per_rgb; - public static final int sizeof = 40; -} |