From d7ee23f9b2387ca8d7f3b2468f8c833639ced504 Mon Sep 17 00:00:00 2001 From: Ioannis Tsakpinis Date: Tue, 19 Aug 2008 16:46:03 +0000 Subject: [PATCH] Added support for OpenGL 3.0 functionality Added support for OpenGL 3.0 context creation (MAJOR/MINOR versions, DEBUG mode, FORWARD_COMBATIBLE mode) Added support for OpenGL 3.0 context sharing Added support for OpenGL 3.0 extension detection Improved support for floating point PixelFormats (ARB_color_buffer_float) Added support for packed floating point PixelFormats (EXT_packed_float) Added support for sRGB PixelFormats (ARB_framebuffer_sRGB) Added support for pseudo-FORWARD_COMBATIBLE mode (deprecated functions not loaded) Added support for EXT_direct_state_access --- src/java/org/lwjgl/BufferChecks.java | 7 +- .../org/lwjgl/NondirectBufferWrapper.java | 2 +- src/java/org/lwjgl/opengl/AWTGLCanvas.java | 167 ++- src/java/org/lwjgl/opengl/AWTSurfaceLock.java | 4 +- src/java/org/lwjgl/opengl/AWTUtil.java | 2 +- src/java/org/lwjgl/opengl/Context.java | 111 +- src/java/org/lwjgl/opengl/ContextAttribs.java | 213 +++ .../lwjgl/opengl/ContextImplementation.java | 19 +- src/java/org/lwjgl/opengl/Display.java | 446 ++++--- .../lwjgl/opengl/DisplayImplementation.java | 14 +- src/java/org/lwjgl/opengl/GLChecks.java | 8 +- src/java/org/lwjgl/opengl/GLContext.java | 179 +-- .../org/lwjgl/opengl/KeyboardEventQueue.java | 2 +- .../opengl/LinuxAWTGLCanvasPeerInfo.java | 4 +- .../org/lwjgl/opengl/LinuxContextAttribs.java | 83 ++ .../opengl/LinuxContextImplementation.java | 37 +- src/java/org/lwjgl/opengl/LinuxDisplay.java | 63 +- .../lwjgl/opengl/LinuxDisplayPeerInfo.java | 6 +- src/java/org/lwjgl/opengl/LinuxEvent.java | 58 +- src/java/org/lwjgl/opengl/LinuxKeyboard.java | 6 +- src/java/org/lwjgl/opengl/LinuxMouse.java | 10 +- .../lwjgl/opengl/LinuxPbufferPeerInfo.java | 2 +- src/java/org/lwjgl/opengl/LinuxPeerInfo.java | 2 +- .../opengl/MacOSXAWTGLCanvasPeerInfo.java | 2 +- .../lwjgl/opengl/MacOSXCanvasListener.java | 4 +- .../lwjgl/opengl/MacOSXCanvasPeerInfo.java | 2 +- .../lwjgl/opengl/MacOSXContextAttribs.java | 83 ++ .../opengl/MacOSXContextImplementation.java | 35 +- .../lwjgl/opengl/MacOSXDisplayPeerInfo.java | 2 +- .../lwjgl/opengl/MacOSXPbufferPeerInfo.java | 2 +- src/java/org/lwjgl/opengl/MacOSXPeerInfo.java | 2 +- src/java/org/lwjgl/opengl/Pbuffer.java | 29 +- src/java/org/lwjgl/opengl/PeerInfo.java | 4 +- src/java/org/lwjgl/opengl/PixelFormat.java | 289 ++++- .../opengl/WindowsAWTGLCanvasPeerInfo.java | 2 +- .../lwjgl/opengl/WindowsContextAttribs.java | 81 ++ .../opengl/WindowsContextImplementation.java | 28 +- src/java/org/lwjgl/opengl/WindowsDisplay.java | 32 +- .../lwjgl/opengl/WindowsDisplayPeerInfo.java | 6 +- .../org/lwjgl/opengl/WindowsFileVersion.java | 2 +- .../org/lwjgl/opengl/WindowsKeyboard.java | 10 +- src/java/org/lwjgl/opengl/WindowsMouse.java | 6 +- .../lwjgl/opengl/WindowsPbufferPeerInfo.java | 6 +- .../org/lwjgl/opengl/WindowsPeerInfo.java | 2 +- .../ContextCapabilitiesGenerator.java | 154 ++- .../ContextGeneratorProcessorFactory.java | 9 +- .../org/lwjgl/util/generator/Dependent.java | 47 + .../lwjgl/util/generator/DeprecatedGL.java | 46 + src/java/org/lwjgl/util/generator/GLtime.java | 47 + .../util/generator/JavaMethodsGenerator.java | 2 + src/native/linux/context.c | 61 +- src/native/linux/extgl_glx.c | 28 +- src/native/linux/extgl_glx.h | 37 +- ..._lwjgl_opengl_LinuxContextImplementation.c | 30 +- src/native/macosx/context.m | 4 + ...lwjgl_opengl_MacOSXContextImplementation.m | 2 +- src/native/windows/context.c | 48 +- src/native/windows/context.h | 2 +- src/native/windows/extgl_wgl.c | 16 +- src/native/windows/extgl_wgl.h | 34 + ...wjgl_opengl_WindowsContextImplementation.c | 78 +- .../org_lwjgl_opengl_WindowsPeerInfo.c | 29 +- .../org/lwjgl/opengl/ARB_imaging.java | 33 + .../org/lwjgl/opengl/ARB_window_pos.java | 11 + .../lwjgl/opengl/EXT_direct_state_access.java | 1140 +++++++++++++++++ .../org/lwjgl/opengl/EXT_secondary_color.java | 3 +- .../lwjgl/opengl/EXT_transform_feedback.java | 4 +- src/templates/org/lwjgl/opengl/GL11.java | 166 ++- src/templates/org/lwjgl/opengl/GL13.java | 16 +- src/templates/org/lwjgl/opengl/GL14.java | 15 + src/templates/org/lwjgl/opengl/GL20.java | 2 +- src/templates/org/lwjgl/opengl/GL30.java | 912 +++++++++++++ .../lwjgl/opengl/NV_conditional_render.java | 2 +- 73 files changed, 4235 insertions(+), 817 deletions(-) create mode 100644 src/java/org/lwjgl/opengl/ContextAttribs.java create mode 100644 src/java/org/lwjgl/opengl/LinuxContextAttribs.java create mode 100644 src/java/org/lwjgl/opengl/MacOSXContextAttribs.java create mode 100644 src/java/org/lwjgl/opengl/WindowsContextAttribs.java create mode 100644 src/java/org/lwjgl/util/generator/Dependent.java create mode 100644 src/java/org/lwjgl/util/generator/DeprecatedGL.java create mode 100644 src/java/org/lwjgl/util/generator/GLtime.java create mode 100644 src/templates/org/lwjgl/opengl/EXT_direct_state_access.java create mode 100644 src/templates/org/lwjgl/opengl/GL30.java diff --git a/src/java/org/lwjgl/BufferChecks.java b/src/java/org/lwjgl/BufferChecks.java index 22e53508..2fe3c7c6 100644 --- a/src/java/org/lwjgl/BufferChecks.java +++ b/src/java/org/lwjgl/BufferChecks.java @@ -56,11 +56,6 @@ public class BufferChecks { private BufferChecks() { } - /** - * Default buffer size for most buffer checks. - */ - private static final int DEFAULT_BUFFER_SIZE = 4; - /** * Helper methods to ensure a function pointer is not-null (0) */ @@ -129,7 +124,7 @@ public class BufferChecks { private static void throwBufferSizeException(Buffer buf, int size) { throw new IllegalArgumentException("Number of remaining buffer elements is " + buf.remaining() + ", must be at least " + size); } - + /** * Helper method to ensure a buffer is big enough to receive data from a * glGet* operation. diff --git a/src/java/org/lwjgl/NondirectBufferWrapper.java b/src/java/org/lwjgl/NondirectBufferWrapper.java index ea0200cf..5b73e2e0 100644 --- a/src/java/org/lwjgl/NondirectBufferWrapper.java +++ b/src/java/org/lwjgl/NondirectBufferWrapper.java @@ -52,7 +52,7 @@ public final class NondirectBufferWrapper { private final static int INITIAL_BUFFER_SIZE = 1; private final static ThreadLocal thread_buffer = new ThreadLocal() { - protected final Object initialValue() { + protected Object initialValue() { return new CachedBuffers(INITIAL_BUFFER_SIZE); } }; diff --git a/src/java/org/lwjgl/opengl/AWTGLCanvas.java b/src/java/org/lwjgl/opengl/AWTGLCanvas.java index c0a1e776..4e38941c 100644 --- a/src/java/org/lwjgl/opengl/AWTGLCanvas.java +++ b/src/java/org/lwjgl/opengl/AWTGLCanvas.java @@ -31,33 +31,29 @@ */ package org.lwjgl.opengl; -import java.awt.Canvas; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.GraphicsDevice; -import java.awt.GraphicsEnvironment; -import java.awt.Point; +import org.lwjgl.LWJGLException; +import org.lwjgl.LWJGLUtil; +import org.lwjgl.Sys; + +import java.awt.*; import java.awt.event.ComponentEvent; import java.awt.event.ComponentListener; import java.awt.event.HierarchyEvent; import java.awt.event.HierarchyListener; -import org.lwjgl.LWJGLException; -import org.lwjgl.LWJGLUtil; -import org.lwjgl.Sys; - /** - *

+ *

* An AWT rendering context. - *

- * @version $Revision$ + *

+ * * @author $Author$ - * $Id$ + * $Id$ + * @version $Revision$ */ public class AWTGLCanvas extends Canvas implements Drawable, ComponentListener, HierarchyListener { private static final long serialVersionUID = 1L; - + private final static AWTCanvasImplementation implementation; private boolean update_context; private Object SYNC_LOCK = new Object(); @@ -67,7 +63,10 @@ public class AWTGLCanvas extends Canvas implements Drawable, ComponentListener, /** The drawable to share context with */ private final Drawable drawable; - + + /** The ContextAttribs to use when creating the context */ + private final ContextAttribs attribs; + /** Context handle */ private PeerInfo peer_info; private Context context; @@ -87,7 +86,7 @@ public class AWTGLCanvas extends Canvas implements Drawable, ComponentListener, } static AWTCanvasImplementation createImplementation() { - switch (LWJGLUtil.getPlatform()) { + switch ( LWJGLUtil.getPlatform() ) { case LWJGLUtil.PLATFORM_LINUX: return new LinuxCanvasImplementation(); case LWJGLUtil.PLATFORM_WINDOWS: @@ -100,25 +99,21 @@ public class AWTGLCanvas extends Canvas implements Drawable, ComponentListener, } private void setUpdate() { - synchronized(SYNC_LOCK) { + synchronized ( SYNC_LOCK ) { update_context = true; } } - /** - * This method should only be called internally. - */ + /** This method should only be called internally. */ public Context getContext() { return context; } - - /** - * Constructor using the default PixelFormat. - */ + + /** Constructor using the default PixelFormat. */ public AWTGLCanvas() throws LWJGLException { this(new PixelFormat()); } - + /** * Create an AWTGLCanvas with the requested PixelFormat on the default GraphicsDevice. * @@ -131,7 +126,7 @@ public class AWTGLCanvas extends Canvas implements Drawable, ComponentListener, /** * Create an AWTGLCanvas with the requested PixelFormat on the default GraphicsDevice. * - * @param device the device to create the canvas on. + * @param device the device to create the canvas on. * @param pixel_format The desired pixel format. May not be null */ public AWTGLCanvas(GraphicsDevice device, PixelFormat pixel_format) throws LWJGLException { @@ -141,94 +136,99 @@ public class AWTGLCanvas extends Canvas implements Drawable, ComponentListener, /** * Create an AWTGLCanvas with the requested PixelFormat on the specified GraphicsDevice. * - * @param device the device to create the canvas on. + * @param device the device to create the canvas on. * @param pixel_format The desired pixel format. May not be null - * @param drawable The Drawable to share context with + * @param drawable The Drawable to share context with */ public AWTGLCanvas(GraphicsDevice device, PixelFormat pixel_format, Drawable drawable) throws LWJGLException { + this(device, pixel_format, drawable, null); + } + + /** + * Create an AWTGLCanvas with the requested PixelFormat on the specified GraphicsDevice. + * + * @param device the device to create the canvas on. + * @param pixel_format The desired pixel format. May not be null + * @param drawable The Drawable to share context with + * @param attribs The ContextAttribs to use when creating the context. (optional, may be null) + */ + public AWTGLCanvas(GraphicsDevice device, PixelFormat pixel_format, Drawable drawable, ContextAttribs attribs) throws LWJGLException { super(implementation.findConfiguration(device, pixel_format)); - if (pixel_format == null) + if ( pixel_format == null ) throw new NullPointerException("Pixel format must be non-null"); addHierarchyListener(this); addComponentListener(this); this.drawable = drawable; this.pixel_format = pixel_format; + this.attribs = attribs; } - + /* (non-Javadoc) - * @see java.awt.Canvas#addNotify() - */ + * @see java.awt.Canvas#addNotify() + */ public void addNotify() { super.addNotify(); } - + /* (non-Javadoc) - * @see java.awt.Component#removeNotify() - */ + * @see java.awt.Component#removeNotify() + */ public void removeNotify() { - synchronized (SYNC_LOCK) { + synchronized ( SYNC_LOCK ) { destroyContext(); super.removeNotify(); } - } - - /** - * Set swap interval. - */ + } + + /** Set swap interval. */ public void setSwapInterval(int swap_interval) { - synchronized(SYNC_LOCK) { - if (context == null) + synchronized ( SYNC_LOCK ) { + if ( context == null ) throw new IllegalStateException("Canvas not yet displayable"); Context.setSwapInterval(swap_interval); } } - - /** - * Enable vsync - */ + + /** Enable vsync */ public void setVSyncEnabled(boolean enabled) { setSwapInterval(enabled ? 1 : 0); } - - /** - * Swap the canvas' buffer - */ + + /** Swap the canvas' buffer */ public void swapBuffers() throws LWJGLException { - synchronized(SYNC_LOCK) { - if (context == null) + synchronized ( SYNC_LOCK ) { + if ( context == null ) throw new IllegalStateException("Canvas not yet displayable"); Context.swapBuffers(); } } - + public void releaseContext() throws LWJGLException { - synchronized(SYNC_LOCK) { - if (context == null) + synchronized ( SYNC_LOCK ) { + if ( context == null ) throw new IllegalStateException("Canvas not yet displayable"); - if (context.isCurrent()) + if ( context.isCurrent() ) Context.releaseCurrentContext(); } } - + /** * Make the canvas' context current. It is highly recommended that the context * is only made current inside the AWT thread (for example in an overridden paintGL()). */ public void makeCurrent() throws LWJGLException { - synchronized(SYNC_LOCK) { - if (context == null) + synchronized ( SYNC_LOCK ) { + if ( context == null ) throw new IllegalStateException("Canvas not yet displayable"); context.makeCurrent(); } } - - /** - * Destroy the OpenGL context. This happens when the component becomes undisplayable - */ + + /** Destroy the OpenGL context. This happens when the component becomes undisplayable */ private void destroyContext() { - synchronized(SYNC_LOCK) { + synchronized ( SYNC_LOCK ) { try { - if (context != null) { + if ( context != null ) { context.forceDestroy(); context = null; reentry_count = 0; @@ -243,15 +243,13 @@ public class AWTGLCanvas extends Canvas implements Drawable, ComponentListener, /** * Override this to do initialising of the context. - * It will be called once from paint(), immediately after + * It will be called once from paint(), immediately after * the context is created and made current. */ protected void initGL() { } - /** - * Override this to do painting - */ + /** Override this to do painting */ protected void paintGL() { } @@ -261,36 +259,36 @@ public class AWTGLCanvas extends Canvas implements Drawable, ComponentListener, */ public final void paint(Graphics g) { LWJGLException exception = null; - synchronized (SYNC_LOCK) { - if (!isDisplayable()) + synchronized ( SYNC_LOCK ) { + if ( !isDisplayable() ) return; try { - if (peer_info == null) { + if ( peer_info == null ) { this.peer_info = implementation.createPeerInfo(this, pixel_format); } peer_info.lockAndGetHandle(); try { - if (context == null) { - this.context = new Context(peer_info, drawable != null ? drawable.getContext() : null); + if ( context == null ) { + this.context = new Context(peer_info, attribs, drawable != null ? drawable.getContext() : null); first_run = true; } - if (reentry_count == 0) + if ( reentry_count == 0 ) context.makeCurrent(); reentry_count++; try { - if (update_context) { + if ( update_context ) { context.update(); update_context = false; } - if (first_run) { + if ( first_run ) { first_run = false; initGL(); } paintGL(); } finally { reentry_count--; - if (reentry_count == 0) + if ( reentry_count == 0 ) Context.releaseCurrentContext(); } } finally { @@ -300,7 +298,7 @@ public class AWTGLCanvas extends Canvas implements Drawable, ComponentListener, exception = e; } } - if (exception != null) + if ( exception != null ) exceptionOccurred(exception); } @@ -314,9 +312,7 @@ public class AWTGLCanvas extends Canvas implements Drawable, ComponentListener, LWJGLUtil.log("Unhandled exception occurred, skipping paint(): " + exception); } - /** - * override update to avoid clearing - */ + /** override update to avoid clearing */ public void update(Graphics g) { paint(g); } @@ -363,4 +359,5 @@ public class AWTGLCanvas extends Canvas implements Drawable, ComponentListener, public void hierarchyChanged(HierarchyEvent e) { setUpdate(); } -} + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opengl/AWTSurfaceLock.java b/src/java/org/lwjgl/opengl/AWTSurfaceLock.java index 91116ef8..8d5927ee 100644 --- a/src/java/org/lwjgl/opengl/AWTSurfaceLock.java +++ b/src/java/org/lwjgl/opengl/AWTSurfaceLock.java @@ -54,7 +54,7 @@ final class AWTSurfaceLock { private boolean firstLockSucceeded = false; - public AWTSurfaceLock() { + AWTSurfaceLock() { lock_buffer = createHandle(); } @@ -98,7 +98,7 @@ final class AWTSurfaceLock { private static native boolean lockAndInitHandle(ByteBuffer lock_buffer, Canvas component) throws LWJGLException; - protected void unlock() throws LWJGLException { + void unlock() throws LWJGLException { nUnlock(lock_buffer); } diff --git a/src/java/org/lwjgl/opengl/AWTUtil.java b/src/java/org/lwjgl/opengl/AWTUtil.java index 9a5429e8..11855231 100644 --- a/src/java/org/lwjgl/opengl/AWTUtil.java +++ b/src/java/org/lwjgl/opengl/AWTUtil.java @@ -113,7 +113,7 @@ final class AWTUtil { final GraphicsConfiguration config = component.getGraphicsConfiguration(); if (config != null) { PointerInfo pointer_info = (PointerInfo)AccessController.doPrivileged(new PrivilegedExceptionAction() { - public final Object run() throws Exception { + public Object run() throws Exception { return MouseInfo.getPointerInfo(); } }); diff --git a/src/java/org/lwjgl/opengl/Context.java b/src/java/org/lwjgl/opengl/Context.java index 1635172a..39688e6d 100644 --- a/src/java/org/lwjgl/opengl/Context.java +++ b/src/java/org/lwjgl/opengl/Context.java @@ -31,43 +31,44 @@ */ package org.lwjgl.opengl; -import java.nio.ByteBuffer; - import org.lwjgl.LWJGLException; import org.lwjgl.LWJGLUtil; import org.lwjgl.Sys; +import java.nio.ByteBuffer; +import java.nio.IntBuffer; + /** *

* Context encapsulates an OpenGL context. *

- * + *

* This class is thread-safe. * * @author elias_naur * @version $Revision$ - * $Id$ + * $Id$ */ final class Context { - /** - * The platform specific implementation of context methods - */ + + /** The platform specific implementation of context methods */ private final static ContextImplementation implementation; /** The current Context */ private final static ThreadLocal current_context_local = new ThreadLocal(); - - /** - * Handle to the native GL rendering context - */ + + /** Handle to the native GL rendering context */ private final ByteBuffer handle; private final PeerInfo peer_info; + private final IntBuffer attribList; + private final boolean forwardCombatible; + /** Whether the context has been destroyed */ private boolean destroyed; private boolean destroy_requested; - + /** The thread that has this context current, or null. */ private Thread thread; @@ -77,7 +78,7 @@ final class Context { } private static ContextImplementation createImplementation() { - switch (LWJGLUtil.getPlatform()) { + switch ( LWJGLUtil.getPlatform() ) { case LWJGLUtil.PLATFORM_LINUX: return new LinuxContextImplementation(); case LWJGLUtil.PLATFORM_WINDOWS: @@ -97,20 +98,26 @@ final class Context { return (Context)current_context_local.get(); } - /** - * Create a context with the specified peer info and shared context - */ - public Context(PeerInfo peer_info, Context shared_context) throws LWJGLException { + /** Create a context with the specified peer info and shared context */ + Context(PeerInfo peer_info, ContextAttribs attribs, Context shared_context) throws LWJGLException { Context context_lock = shared_context != null ? shared_context : this; - // If shared_context is not null, synchronize on it to make sure it is not deleted + // If shared_context is not null, synchronize on it to make sure it is not deleted // while this context is created. Otherwise, simply synchronize on ourself to avoid NPE - synchronized (context_lock) { - if (shared_context != null && shared_context.destroyed) + synchronized ( context_lock ) { + if ( shared_context != null && shared_context.destroyed ) throw new IllegalArgumentException("Shared context is destroyed"); GLContext.loadOpenGLLibrary(); try { this.peer_info = peer_info; - this.handle = implementation.create(peer_info, shared_context != null ? shared_context.handle : null); + if ( attribs != null ) { + attribList = attribs.getAttribList(); + forwardCombatible = attribs.isForwardCombatible(); + } else { + attribList = null; + forwardCombatible = false; + } + + this.handle = implementation.create(peer_info, attribList, shared_context != null ? shared_context.handle : null); } catch (LWJGLException e) { GLContext.unloadOpenGLLibrary(); throw e; @@ -118,16 +125,14 @@ final class Context { } } - /** - * Release the current context (if any). After this call, no context is current. - */ + /** Release the current context (if any). After this call, no context is current. */ public static void releaseCurrentContext() throws LWJGLException { Context current_context = getCurrentContext(); - if (current_context != null) { + if ( current_context != null ) { implementation.releaseCurrentContext(); GLContext.useContext(null); current_context_local.set(null); - synchronized (current_context) { + synchronized ( current_context ) { current_context.thread = null; current_context.checkDestroy(); } @@ -141,64 +146,56 @@ final class Context { * on every releaseCurrentContext results in artifacts. */ public synchronized void releaseDrawable() throws LWJGLException { - if (destroyed) + if ( destroyed ) throw new IllegalStateException("Context is destroyed"); implementation.releaseDrawable(getHandle()); } - /** - * Update the context. Should be called whenever it's drawable is moved or resized - */ + /** Update the context. Should be called whenever it's drawable is moved or resized */ public synchronized void update() { - if (destroyed) + if ( destroyed ) throw new IllegalStateException("Context is destroyed"); implementation.update(getHandle()); } - - /** - * Swap the buffers on the current context. Only valid for double-buffered contexts - */ + + /** Swap the buffers on the current context. Only valid for double-buffered contexts */ public static void swapBuffers() throws LWJGLException { implementation.swapBuffers(); } - + private boolean canAccess() { return thread == null || Thread.currentThread() == thread; } private void checkAccess() { - if (!canAccess()) + if ( !canAccess() ) throw new IllegalStateException("From thread " + Thread.currentThread() + ": " + thread + " already has the context current"); } - /** - * Make the context current - */ + /** Make the context current */ public synchronized void makeCurrent() throws LWJGLException { checkAccess(); - if (destroyed) + if ( destroyed ) throw new IllegalStateException("Context is destroyed"); thread = Thread.currentThread(); current_context_local.set(this); implementation.makeCurrent(peer_info, handle); - GLContext.useContext(this); + GLContext.useContext(this, forwardCombatible); } ByteBuffer getHandle() { return handle; } - /** - * Query whether the context is current - */ + /** Query whether the context is current */ public synchronized boolean isCurrent() throws LWJGLException { - if (destroyed) + if ( destroyed ) throw new IllegalStateException("Context is destroyed"); return implementation.isCurrent(handle); } private void checkDestroy() { - if (!destroyed && destroy_requested) { + if ( !destroyed && destroy_requested ) { try { releaseDrawable(); implementation.destroy(peer_info, handle); @@ -215,16 +212,13 @@ final class Context { * Set the buffer swap interval. This call is a best-attempt at changing * the monitor swap interval, which is the minimum periodicity of color buffer swaps, * measured in video frame periods, and is not guaranteed to be successful. - * + *

* A video frame period is the time required to display a full frame of video data. - * - * @param sync true to synchronize; false to ignore synchronization */ public static void setSwapInterval(int value) { implementation.setSwapInterval(value); } - - + /** * Destroy the context. This method behaves the same as destroy() with the extra * requirement that the context must be either current to the current thread or not @@ -234,24 +228,25 @@ final class Context { checkAccess(); destroy(); } - + /** * Request destruction of the Context. If the context is current, no context will be current after this call. * The context is destroyed when no thread has it current. */ public synchronized void destroy() throws LWJGLException { - if (destroyed) + if ( destroyed ) return; destroy_requested = true; boolean was_current = isCurrent(); int error = GL11.GL_NO_ERROR; - if (was_current) { - if (GLContext.getCapabilities() != null && GLContext.getCapabilities().OpenGL11) + if ( was_current ) { + if ( GLContext.getCapabilities() != null && GLContext.getCapabilities().OpenGL11 ) error = GL11.glGetError(); releaseCurrentContext(); } checkDestroy(); - if (was_current && error != GL11.GL_NO_ERROR) + if ( was_current && error != GL11.GL_NO_ERROR ) throw new OpenGLException(error); } -} + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opengl/ContextAttribs.java b/src/java/org/lwjgl/opengl/ContextAttribs.java new file mode 100644 index 00000000..d1f3483f --- /dev/null +++ b/src/java/org/lwjgl/opengl/ContextAttribs.java @@ -0,0 +1,213 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +import org.lwjgl.BufferUtils; +import org.lwjgl.LWJGLUtil; + +import java.nio.IntBuffer; + +/** + * This class represents the context attributes passed to CreateContextAttribs of the XGL_create_context extension. + * These attributes can be used to indicate at context creation which OpenGL interface will be used. This includes the + * OpenGL version, the layer plane on which rendering takes place and also optional debug and forward combatibility modes. + * (read the XGL_create_context spec for details) + *

+ * Use of this class is optional. If an OpenGL context is created without passing an instance of this class + * (or XGL_create_context is not supported), the old context creation code will be used. Use of ContextAttribs is required + * to create an OpenGL 3.0 or newer context. Support for debug and forward compatible mobes is not guaranteed by the OpenGL + * implementation. Developers may encounter debug contexts being the same as non-debug contexts or forward combatible + * contexts having support for deprecated functionality. + *

+ * Warning: This functionality is currently available on the Windows platform only. However, if the forwardCombatible + * attribute is used, LWJGL will not load the deprecated functionality (as defined in the OpenGL 3.0 specification). This + * means that developers can start working on cleaning up their applications without an OpenGL 3.0 complaint driver. + * + * @author spasi + */ +public abstract class ContextAttribs { + + private int majorVersion; + private int minorVersion; + + private int layerPlane; + + private boolean debug; + private boolean forwardCombatible; + + protected ContextAttribs(final int majorVersion, final int minorVersion) { + if ( majorVersion < 0 || + 3 < majorVersion || + minorVersion < 0 || + (majorVersion == 3 && 0 < minorVersion) || + (majorVersion == 2 && 1 < minorVersion) || + (majorVersion == 1 && 5 < minorVersion) ) + throw new IllegalArgumentException("Invalid OpenGL version specified: " + majorVersion + '.' + minorVersion); + + this.majorVersion = majorVersion; + this.minorVersion = minorVersion; + + this.layerPlane = 0; + + this.debug = false; + this.forwardCombatible = false; + } + + protected ContextAttribs(final ContextAttribs attribs) { + this.majorVersion = attribs.majorVersion; + this.minorVersion = attribs.minorVersion; + + this.layerPlane = attribs.layerPlane; + + this.debug = attribs.debug; + this.forwardCombatible = attribs.forwardCombatible; + } + + public static ContextAttribs create() { + return create(1, 0); + } + + public static ContextAttribs create(final int majorVersion, final int minorVersion) { + switch ( LWJGLUtil.getPlatform() ) { + case LWJGLUtil.PLATFORM_LINUX: + return new LinuxContextAttribs(majorVersion, minorVersion); + case LWJGLUtil.PLATFORM_WINDOWS: + return new WindowsContextAttribs(majorVersion, minorVersion); + case LWJGLUtil.PLATFORM_MACOSX: + return new MacOSXContextAttribs(majorVersion, minorVersion); + default: + throw new IllegalStateException("Unsupported platform"); + } + } + + private static ContextAttribs create(final ContextAttribs attribs) { + switch ( LWJGLUtil.getPlatform() ) { + case LWJGLUtil.PLATFORM_LINUX: + return new LinuxContextAttribs(attribs); + case LWJGLUtil.PLATFORM_WINDOWS: + return new WindowsContextAttribs(attribs); + case LWJGLUtil.PLATFORM_MACOSX: + return new MacOSXContextAttribs(attribs); + default: + throw new IllegalStateException("Unsupported platform"); + } + } + + public final int getMajorVersion() { + return majorVersion; + } + + public final int getMinorVersion() { + return minorVersion; + } + + public final int getLayerPlane() { + return layerPlane; + } + + public final boolean isDebug() { + return debug; + } + + public final boolean isForwardCombatible() { + return forwardCombatible; + } + + public final ContextAttribs withLayer(final int layerPlane) { + if ( layerPlane < 0 ) + throw new IllegalArgumentException("Invalid layer plane specified: " + layerPlane); + + final ContextAttribs attribs = create(this); + attribs.layerPlane = layerPlane; + return attribs; + } + + public final ContextAttribs withDebug(final boolean debug) { + final ContextAttribs attribs = create(this); + attribs.debug = debug; + return attribs; + } + + public final ContextAttribs withForwardCombatible(final boolean forwardCombatible) { + final ContextAttribs attribs = create(this); + attribs.forwardCombatible = forwardCombatible; + return attribs; + } + + protected abstract int getMajorVersionAttrib(); + + protected abstract int getMinorVersionAttrib(); + + protected abstract int getLayerPlaneAttrib(); + + protected abstract int getFlagsAttrib(); + + protected abstract int getDebugBit(); + + protected abstract int getForwardCombatibleBit(); + + final IntBuffer getAttribList() { + int attribCount = 0; + + if ( !(majorVersion == 1 && minorVersion == 0) ) + attribCount += 2; + if ( 0 < layerPlane ) + attribCount++; + + int flags = 0; + if ( debug ) + flags |= getDebugBit(); + if ( forwardCombatible ) + flags |= getForwardCombatibleBit(); + if ( 0 < flags ) + attribCount++; + + if ( attribCount == 0 ) + return null; + + final IntBuffer attribs = BufferUtils.createIntBuffer((attribCount * 2) + 1); + + if ( !(majorVersion == 1 && minorVersion == 0) ) { + attribs.put(getMajorVersionAttrib()).put(majorVersion); + attribs.put(getMinorVersionAttrib()).put(minorVersion); + } + if ( 0 < layerPlane ) + attribs.put(getLayerPlaneAttrib()).put(layerPlane); + if ( 0 < flags ) + attribs.put(getFlagsAttrib()).put(flags); + + attribs.put(0); + attribs.rewind(); + return attribs; + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opengl/ContextImplementation.java b/src/java/org/lwjgl/opengl/ContextImplementation.java index 9f96506f..62a828d9 100644 --- a/src/java/org/lwjgl/opengl/ContextImplementation.java +++ b/src/java/org/lwjgl/opengl/ContextImplementation.java @@ -32,6 +32,7 @@ package org.lwjgl.opengl; import java.nio.ByteBuffer; +import java.nio.IntBuffer; import org.lwjgl.LWJGLException; @@ -48,42 +49,42 @@ interface ContextImplementation { /** * Create a context. */ - public ByteBuffer create(PeerInfo peer_info, ByteBuffer shared_context_handle) throws LWJGLException; + ByteBuffer create(PeerInfo peer_info, IntBuffer attribs, ByteBuffer shared_context_handle) throws LWJGLException; /** * Swap the buffers of the current context. Only valid for double-buffered contexts. */ - public void swapBuffers() throws LWJGLException; + void swapBuffers() throws LWJGLException; /** * Release the context from its drawable, if any. */ - public void releaseDrawable(ByteBuffer context_handle) throws LWJGLException; + void releaseDrawable(ByteBuffer context_handle) throws LWJGLException; /** * Release the current context (if any). After this call, no context is current. */ - public void releaseCurrentContext() throws LWJGLException; + void releaseCurrentContext() throws LWJGLException; /** * Update the context. Should be called whenever it's drawable is moved or resized */ - public void update(ByteBuffer context_handle); + void update(ByteBuffer context_handle); /** * Query whether the context is current */ - public void makeCurrent(PeerInfo peer_info, ByteBuffer handle) throws LWJGLException; + void makeCurrent(PeerInfo peer_info, ByteBuffer handle) throws LWJGLException; /** * Query whether the context is current */ - public boolean isCurrent(ByteBuffer handle) throws LWJGLException; + boolean isCurrent(ByteBuffer handle) throws LWJGLException; - public void setSwapInterval(int value); + void setSwapInterval(int value); /** * Destroys the Context. */ - public void destroy(PeerInfo peer_info, ByteBuffer handle) throws LWJGLException; + void destroy(PeerInfo peer_info, ByteBuffer handle) throws LWJGLException; } diff --git a/src/java/org/lwjgl/opengl/Display.java b/src/java/org/lwjgl/opengl/Display.java index aa66549a..3c3a3b8e 100644 --- a/src/java/org/lwjgl/opengl/Display.java +++ b/src/java/org/lwjgl/opengl/Display.java @@ -43,17 +43,6 @@ package org.lwjgl.opengl; * @author foo */ -import java.nio.ByteBuffer; -import java.nio.FloatBuffer; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.util.Arrays; -import java.util.HashSet; -import java.awt.Canvas; -import java.awt.event.ComponentListener; -import java.awt.event.ComponentAdapter; -import java.awt.event.ComponentEvent; - import org.lwjgl.BufferUtils; import org.lwjgl.LWJGLException; import org.lwjgl.LWJGLUtil; @@ -62,12 +51,24 @@ import org.lwjgl.input.Controllers; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; +import java.awt.*; +import java.awt.event.ComponentAdapter; +import java.awt.event.ComponentEvent; +import java.awt.event.ComponentListener; +import java.nio.ByteBuffer; +import java.nio.FloatBuffer; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.util.Arrays; +import java.util.HashSet; + public final class Display { + private static final Thread shutdown_hook = new Thread() { - public void run() { - reset(); - } - }; + public void run() { + reset(); + } + }; /** The display implementor */ private static final DisplayImplementation display_impl; @@ -86,7 +87,7 @@ public final class Display { /** X coordinate of the window */ private static int x = -1; - + /** Cached window icons, for when Display is recreated */ private static ByteBuffer[] cached_icons; @@ -117,8 +118,8 @@ public final class Display { private static boolean parent_resized; private static ComponentListener component_listener = new ComponentAdapter() { - public final void componentResized(ComponentEvent e) { - synchronized (GlobalLock.lock) { + public void componentResized(ComponentEvent e) { + synchronized ( GlobalLock.lock ) { parent_resized = true; } } @@ -135,7 +136,7 @@ public final class Display { } drawable = new Drawable() { public Context getContext() { - synchronized (GlobalLock.lock) { + synchronized ( GlobalLock.lock ) { return isCreated() ? context : null; } } @@ -152,7 +153,7 @@ public final class Display { } private static DisplayImplementation createDisplayImplementation() { - switch (LWJGLUtil.getPlatform()) { + switch ( LWJGLUtil.getPlatform() ) { case LWJGLUtil.PLATFORM_LINUX: return new LinuxDisplay(); case LWJGLUtil.PLATFORM_WINDOWS: @@ -164,9 +165,7 @@ public final class Display { } } - /** - * Only constructed by ourselves - */ + /** Only constructed by ourselves */ private Display() { } @@ -176,7 +175,7 @@ public final class Display { * given mode is not guaranteed to be available nor is it guaranteed to be within the * current monitor specs (this is especially a problem with the frequency parameter). * Furthermore, it is not guaranteed that create() will detect an illegal display mode. - * + *

* The only certain way to check * is to call create() and make sure it works. * Only non-palette-indexed modes are returned (ie. bpp will be 16, 24, or 32). @@ -186,10 +185,10 @@ public final class Display { * @return an array of all display modes the system reckons it can handle. */ public static DisplayMode[] getAvailableDisplayModes() throws LWJGLException { - synchronized (GlobalLock.lock) { + synchronized ( GlobalLock.lock ) { DisplayMode[] unfilteredModes = display_impl.getAvailableDisplayModes(); - if (unfilteredModes == null) { + if ( unfilteredModes == null ) { return new DisplayMode[0]; } @@ -208,10 +207,11 @@ public final class Display { /** * Return the current display mode, as set by setDisplayMode(). + * * @return The current display mode */ public static DisplayMode getDisplayMode() { - synchronized (GlobalLock.lock) { + synchronized ( GlobalLock.lock ) { return current_mode; } } @@ -224,20 +224,21 @@ public final class Display { * is also reset. * * @param mode The new display mode to set + * * @throws LWJGLException if the display mode could not be set */ public static void setDisplayMode(DisplayMode mode) throws LWJGLException { - synchronized (GlobalLock.lock) { - if (mode == null) + synchronized ( GlobalLock.lock ) { + if ( mode == null ) throw new NullPointerException("mode must be non-null"); current_mode = mode; - if (isCreated()) { + if ( isCreated() ) { destroyWindow(); // If mode is not fullscreen capable, make sure we are in windowed mode - if (!mode.isFullscreen()) + if ( !mode.isFullscreen() ) resetFullscreen(); try { - if (fullscreen) + if ( fullscreen ) switchDisplayMode(); createWindow(); makeCurrentAndSetSwapInterval(); @@ -256,9 +257,9 @@ public final class Display { } private static int getWindowX() { - if (!fullscreen && parent == null) { + if ( !fullscreen && parent == null ) { // if no display location set, center window - if (x == -1) { + if ( x == -1 ) { return Math.max(0, (initial_mode.getWidth() - current_mode.getWidth()) / 2); } else { return x; @@ -269,9 +270,9 @@ public final class Display { } private static int getWindowY() { - if (!fullscreen && parent == null) { + if ( !fullscreen && parent == null ) { // if no display location set, center window - if (y == -1) { + if ( y == -1 ) { return Math.max(0, (initial_mode.getHeight() - current_mode.getHeight()) / 2); } else { return y; @@ -286,24 +287,24 @@ public final class Display { * A native context must exist, and it will be attached to the window. */ private static void createWindow() throws LWJGLException { - if (window_created) { + if ( window_created ) { return; } Canvas tmp_parent = fullscreen ? null : parent; - if (tmp_parent != null && !tmp_parent.isDisplayable()) // Only a best effort check, since the parent can turn undisplayable hereafter + if ( tmp_parent != null && !tmp_parent.isDisplayable() ) // Only a best effort check, since the parent can turn undisplayable hereafter throw new LWJGLException("Parent.isDisplayable() must be true"); - if (tmp_parent != null) { + if ( tmp_parent != null ) { tmp_parent.addComponentListener(component_listener); } DisplayMode mode = getEffectiveMode(); display_impl.createWindow(mode, fullscreen, tmp_parent, getWindowX(), getWindowY()); window_created = true; - + setTitle(title); initControls(); - + // set cached window icon if exists - if(cached_icons != null) { + if ( cached_icons != null ) { setIcon(cached_icons); } else { setIcon(new ByteBuffer[] { LWJGLUtil.LWJGLIcon32x32, LWJGLUtil.LWJGLIcon16x16 }); @@ -312,7 +313,7 @@ public final class Display { private static void releaseDrawable() { try { - if (context != null && context.isCurrent()) { + if ( context != null && context.isCurrent() ) { Context.releaseCurrentContext(); context.releaseDrawable(); } @@ -322,19 +323,19 @@ public final class Display { } private static void destroyWindow() { - if (!window_created) { + if ( !window_created ) { return; } - if (parent != null) { + if ( parent != null ) { parent.removeComponentListener(component_listener); } releaseDrawable(); // Automatically destroy keyboard & mouse - if (Mouse.isCreated()) { + if ( Mouse.isCreated() ) { Mouse.destroy(); } - if (Keyboard.isCreated()) { + if ( Keyboard.isCreated() ) { Keyboard.destroy(); } display_impl.destroyWindow(); @@ -342,7 +343,7 @@ public final class Display { } private static void switchDisplayMode() throws LWJGLException { - if (!current_mode.isFullscreen()) { + if ( !current_mode.isFullscreen() ) { throw new IllegalStateException("Only modes acquired from getAvailableDisplayModes() can be used for fullscreen display"); } display_impl.switchDisplayMode(current_mode); @@ -352,36 +353,36 @@ public final class Display { * Set the display configuration to the specified gamma, brightness and contrast. * The configuration changes will be reset when destroy() is called. * - * @param gamma The gamma value + * @param gamma The gamma value * @param brightness The brightness value between -1.0 and 1.0, inclusive - * @param contrast The contrast, larger than 0.0. + * @param contrast The contrast, larger than 0.0. */ public static void setDisplayConfiguration(float gamma, float brightness, float contrast) throws LWJGLException { - synchronized (GlobalLock.lock) { - if (!isCreated()) { + synchronized ( GlobalLock.lock ) { + if ( !isCreated() ) { throw new LWJGLException("Display not yet created."); } - if (brightness < -1.0f || brightness > 1.0f) + if ( brightness < -1.0f || brightness > 1.0f ) throw new IllegalArgumentException("Invalid brightness value"); - if (contrast < 0.0f) + if ( contrast < 0.0f ) throw new IllegalArgumentException("Invalid contrast value"); int rampSize = display_impl.getGammaRampLength(); - if (rampSize == 0) { + if ( rampSize == 0 ) { throw new LWJGLException("Display configuration not supported"); } FloatBuffer gammaRamp = BufferUtils.createFloatBuffer(rampSize); - for (int i = 0; i < rampSize; i++) { - float intensity = (float)i/(rampSize - 1); + for ( int i = 0; i < rampSize; i++ ) { + float intensity = (float)i / (rampSize - 1); // apply gamma float rampEntry = (float)java.lang.Math.pow(intensity, gamma); // apply brightness rampEntry += brightness; // apply contrast - rampEntry = (rampEntry - 0.5f)*contrast + 0.5f; + rampEntry = (rampEntry - 0.5f) * contrast + 0.5f; // Clamp entry to [0, 1] - if (rampEntry > 1.0f) + if ( rampEntry > 1.0f ) rampEntry = 1.0f; - else if (rampEntry < 0.0f) + else if ( rampEntry < 0.0f ) rampEntry = 0.0f; gammaRamp.put(i, rampEntry); } @@ -401,13 +402,13 @@ public final class Display { long timeNow; long gapTo; long savedTimeLate; - synchronized (GlobalLock.lock) { + synchronized ( GlobalLock.lock ) { gapTo = Sys.getTimerResolution() / fps + timeThen; timeNow = Sys.getTime(); savedTimeLate = timeLate; } - while (gapTo > timeNow + savedTimeLate) { + while ( gapTo > timeNow + savedTimeLate ) { try { Thread.sleep(1); } catch (InterruptedException e) { @@ -415,8 +416,8 @@ public final class Display { timeNow = Sys.getTime(); } - synchronized (GlobalLock.lock) { - if (gapTo < timeNow) + synchronized ( GlobalLock.lock ) { + if ( gapTo < timeNow ) timeLate = timeNow - gapTo; else timeLate = 0; @@ -425,29 +426,25 @@ public final class Display { } } - /** - * @return the title of the window - */ + /** @return the title of the window */ public static String getTitle() { - synchronized (GlobalLock.lock) { + synchronized ( GlobalLock.lock ) { return title; } } private static void resetFullscreen() { - synchronized (GlobalLock.lock) { - if (Display.fullscreen) { + synchronized ( GlobalLock.lock ) { + if ( Display.fullscreen ) { Display.fullscreen = false; display_impl.resetDisplayMode(); } } } - /** - * Return the last parent set with setParent(). - */ + /** Return the last parent set with setParent(). */ public static Canvas getParent() { - synchronized (GlobalLock.lock) { + synchronized ( GlobalLock.lock ) { return parent; } } @@ -461,17 +458,16 @@ public final class Display { * and it is difficult to predict which AWT thread will process any given AWT event.

* While the Display is in fullscreen mode, the current parent will be ignored. Additionally, when a non null parent is specified, * the Dispaly will inherit the size of the parent, disregarding the currently set display mode.

- * */ public static void setParent(Canvas parent) throws LWJGLException { - synchronized (GlobalLock.lock) { - if (Display.parent != parent) { + synchronized ( GlobalLock.lock ) { + if ( Display.parent != parent ) { Display.parent = parent; - if (!isCreated()) + if ( !isCreated() ) return; destroyWindow(); try { - if (fullscreen) { + if ( fullscreen ) { switchDisplayMode(); } else { display_impl.resetDisplayMode(); @@ -496,18 +492,19 @@ public final class Display { * mode returned by getDisplayMode(). The native cursor position is also reset. * * @param fullscreen Specify the fullscreen mode of the context. + * * @throws LWJGLException If fullscreen is true, and the current DisplayMode instance is not - * from getAvailableDisplayModes() or if the mode switch fails. + * from getAvailableDisplayModes() or if the mode switch fails. */ public static void setFullscreen(boolean fullscreen) throws LWJGLException { - synchronized (GlobalLock.lock) { - if (Display.fullscreen != fullscreen) { + synchronized ( GlobalLock.lock ) { + if ( Display.fullscreen != fullscreen ) { Display.fullscreen = fullscreen; - if (!isCreated()) + if ( !isCreated() ) return; destroyWindow(); try { - if (fullscreen) { + if ( fullscreen ) { switchDisplayMode(); } else { display_impl.resetDisplayMode(); @@ -524,58 +521,51 @@ public final class Display { } } - /** - * @return whether the Display is in fullscreen mode - */ + /** @return whether the Display is in fullscreen mode */ public static boolean isFullscreen() { - synchronized (GlobalLock.lock) { + synchronized ( GlobalLock.lock ) { return fullscreen; } } /** * Set the title of the window. This may be ignored by the underlying OS. + * * @param newTitle The new window title */ public static void setTitle(String newTitle) { - synchronized (GlobalLock.lock) { - if (newTitle == null) { + synchronized ( GlobalLock.lock ) { + if ( newTitle == null ) { newTitle = ""; } title = newTitle; - if (isCreated()) + if ( isCreated() ) display_impl.setTitle(title); } } - /** - * @return true if the user or operating system has asked the window to close - */ + /** @return true if the user or operating system has asked the window to close */ public static boolean isCloseRequested() { - synchronized (GlobalLock.lock) { - if (!isCreated()) + synchronized ( GlobalLock.lock ) { + if ( !isCreated() ) throw new IllegalStateException("Cannot determine close requested state of uncreated window"); return display_impl.isCloseRequested(); } } - /** - * @return true if the window is visible, false if not - */ + /** @return true if the window is visible, false if not */ public static boolean isVisible() { - synchronized (GlobalLock.lock) { - if (!isCreated()) + synchronized ( GlobalLock.lock ) { + if ( !isCreated() ) throw new IllegalStateException("Cannot determine minimized state of uncreated window"); return display_impl.isVisible(); } } - /** - * @return true if window is active, that is, the foreground display of the operating system. - */ + /** @return true if window is active, that is, the foreground display of the operating system. */ public static boolean isActive() { - synchronized (GlobalLock.lock) { - if (!isCreated()) + synchronized ( GlobalLock.lock ) { + if ( !isCreated() ) throw new IllegalStateException("Cannot determine focused state of uncreated window"); return display_impl.isActive(); } @@ -589,11 +579,11 @@ public final class Display { * redraw when it returns true. The flag is cleared when update() or isDirty() is called. * * @return true if the window has been damaged by external changes - * and needs to repaint itself + * and needs to repaint itself */ public static boolean isDirty() { - synchronized (GlobalLock.lock) { - if (!isCreated()) + synchronized ( GlobalLock.lock ) { + if ( !isCreated() ) throw new IllegalStateException("Cannot determine dirty state of uncreated window"); return display_impl.isDirty(); } @@ -605,8 +595,8 @@ public final class Display { * this method if update() is called periodically. */ public static void processMessages() { - synchronized (GlobalLock.lock) { - if (!isCreated()) + synchronized ( GlobalLock.lock ) { + if ( !isCreated() ) throw new IllegalStateException("Display not created"); display_impl.update(); @@ -616,11 +606,12 @@ public final class Display { /** * Swap the display buffers. This method is called from update(), and should normally not be called by * the application. + * * @throws OpenGLException if an OpenGL error has occured since the last call to GL11.glGetError() */ public static void swapBuffers() throws LWJGLException { - synchronized (GlobalLock.lock) { - if (!isCreated()) + synchronized ( GlobalLock.lock ) { + if ( !isCreated() ) throw new IllegalStateException("Display not created"); Util.checkGLError(); @@ -631,16 +622,17 @@ public final class Display { /** * Update the window. This calls processMessages(), and if the window is visible * clears the dirty flag and calls swapBuffers() and finally polls the input devices. + * * @throws OpenGLException if an OpenGL error has occured since the last call to GL11.glGetError() */ public static void update() { - synchronized (GlobalLock.lock) { - if (!isCreated()) + synchronized ( GlobalLock.lock ) { + if ( !isCreated() ) throw new IllegalStateException("Display not created"); processMessages(); // We paint only when the window is visible or dirty - if (display_impl.isVisible() || display_impl.isDirty()) { + if ( display_impl.isVisible() || display_impl.isDirty() ) { try { swapBuffers(); } catch (LWJGLException e) { @@ -649,7 +641,7 @@ public final class Display { } pollDevices(); - if (parent_resized) { + if ( parent_resized ) { reshape(); parent_resized = false; } @@ -658,16 +650,16 @@ public final class Display { static void pollDevices() { // Poll the input devices while we're here - if (Mouse.isCreated()) { + if ( Mouse.isCreated() ) { Mouse.poll(); Mouse.updateCursor(); } - - if (Keyboard.isCreated()) { + + if ( Keyboard.isCreated() ) { Keyboard.poll(); } - - if(Controllers.isCreated()) { + + if ( Controllers.isCreated() ) { Controllers.poll(); } } @@ -678,62 +670,27 @@ public final class Display { * @throws LWJGLException If the context could not be released */ public static void releaseContext() throws LWJGLException { - synchronized (GlobalLock.lock) { - if (!isCreated()) + synchronized ( GlobalLock.lock ) { + if ( !isCreated() ) throw new IllegalStateException("Display is not created"); - if (context.isCurrent()) + if ( context.isCurrent() ) Context.releaseCurrentContext(); } } - + /** * Make the Display the current rendering context for GL calls. * * @throws LWJGLException If the context could not be made current */ public static void makeCurrent() throws LWJGLException { - synchronized (GlobalLock.lock) { - if (!isCreated()) + synchronized ( GlobalLock.lock ) { + if ( !isCreated() ) throw new IllegalStateException("Display is not created"); context.makeCurrent(); } } - /** - * Create the OpenGL context. If isFullscreen() is true or if windowed - * context are not supported on the platform, the display mode will be switched to the mode returned by - * getDisplayMode(), and a fullscreen context will be created. If isFullscreen() is false, a windowed context - * will be created with the dimensions given in the mode returned by getDisplayMode(). If a context can't be - * created with the given parameters, a LWJGLException will be thrown. - * - *

The window created will be set up in orthographic 2D projection, with 1:1 pixel ratio with GL coordinates. - * - * @throws LWJGLException - */ - public static void create() throws LWJGLException { - synchronized (GlobalLock.lock) { - create(new PixelFormat()); - } - } - - /** - * Create the OpenGL context with the given minimum parameters. If isFullscreen() is true or if windowed - * context are not supported on the platform, the display mode will be switched to the mode returned by - * getDisplayMode(), and a fullscreen context will be created. If isFullscreen() is false, a windowed context - * will be created with the dimensions given in the mode returned by getDisplayMode(). If a context can't be - * created with the given parameters, a LWJGLException will be thrown. - * - *

The window created will be set up in orthographic 2D projection, with 1:1 pixel ratio with GL coordinates. - * - * @param pixel_format Describes the minimum specifications the context must fulfill. - * @throws LWJGLException - */ - public static void create(PixelFormat pixel_format) throws LWJGLException { - synchronized (GlobalLock.lock) { - create(pixel_format, null); - } - } - private static void removeShutdownHook() { AccessController.doPrivileged(new PrivilegedAction() { public Object run() { @@ -752,35 +709,113 @@ public final class Display { }); } + /** + * Create the OpenGL context. If isFullscreen() is true or if windowed + * context are not supported on the platform, the display mode will be switched to the mode returned by + * getDisplayMode(), and a fullscreen context will be created. If isFullscreen() is false, a windowed context + * will be created with the dimensions given in the mode returned by getDisplayMode(). If a context can't be + * created with the given parameters, a LWJGLException will be thrown. + *

+ *

The window created will be set up in orthographic 2D projection, with 1:1 pixel ratio with GL coordinates. + * + * @throws LWJGLException + */ + public static void create() throws LWJGLException { + synchronized ( GlobalLock.lock ) { + create(new PixelFormat()); + } + } + /** * Create the OpenGL context with the given minimum parameters. If isFullscreen() is true or if windowed * context are not supported on the platform, the display mode will be switched to the mode returned by * getDisplayMode(), and a fullscreen context will be created. If isFullscreen() is false, a windowed context * will be created with the dimensions given in the mode returned by getDisplayMode(). If a context can't be * created with the given parameters, a LWJGLException will be thrown. - * + *

*

The window created will be set up in orthographic 2D projection, with 1:1 pixel ratio with GL coordinates. * * @param pixel_format Describes the minimum specifications the context must fulfill. - * @param shared_drawable The Drawable to share context with or null. + * + * @throws LWJGLException + */ + public static void create(PixelFormat pixel_format) throws LWJGLException { + synchronized ( GlobalLock.lock ) { + create(pixel_format, null, null); + } + } + + /** + * Create the OpenGL context with the given minimum parameters. If isFullscreen() is true or if windowed + * context are not supported on the platform, the display mode will be switched to the mode returned by + * getDisplayMode(), and a fullscreen context will be created. If isFullscreen() is false, a windowed context + * will be created with the dimensions given in the mode returned by getDisplayMode(). If a context can't be + * created with the given parameters, a LWJGLException will be thrown. + *

+ *

The window created will be set up in orthographic 2D projection, with 1:1 pixel ratio with GL coordinates. + * + * @param pixel_format Describes the minimum specifications the context must fulfill. + * @param shared_drawable The Drawable to share context with. (optional, may be null) + * * @throws LWJGLException */ public static void create(PixelFormat pixel_format, Drawable shared_drawable) throws LWJGLException { - synchronized (GlobalLock.lock) { - if (isCreated()) + synchronized ( GlobalLock.lock ) { + create(pixel_format, shared_drawable, null); + } + } + + /** + * Create the OpenGL context with the given minimum parameters. If isFullscreen() is true or if windowed + * context are not supported on the platform, the display mode will be switched to the mode returned by + * getDisplayMode(), and a fullscreen context will be created. If isFullscreen() is false, a windowed context + * will be created with the dimensions given in the mode returned by getDisplayMode(). If a context can't be + * created with the given parameters, a LWJGLException will be thrown. + *

+ *

The window created will be set up in orthographic 2D projection, with 1:1 pixel ratio with GL coordinates. + * + * @param pixel_format Describes the minimum specifications the context must fulfill. + * @param attribs The ContextAttribs to use when creating the context. (optional, may be null) + * + * @throws LWJGLException + */ + public static void create(PixelFormat pixel_format, ContextAttribs attribs) throws LWJGLException { + synchronized ( GlobalLock.lock ) { + create(pixel_format, null, attribs); + } + } + + /** + * Create the OpenGL context with the given minimum parameters. If isFullscreen() is true or if windowed + * context are not supported on the platform, the display mode will be switched to the mode returned by + * getDisplayMode(), and a fullscreen context will be created. If isFullscreen() is false, a windowed context + * will be created with the dimensions given in the mode returned by getDisplayMode(). If a context can't be + * created with the given parameters, a LWJGLException will be thrown. + *

+ *

The window created will be set up in orthographic 2D projection, with 1:1 pixel ratio with GL coordinates. + * + * @param pixel_format Describes the minimum specifications the context must fulfill. + * @param shared_drawable The Drawable to share context with. (optional, may be null) + * @param attribs The ContextAttribs to use when creating the context. (optional, may be null) + * + * @throws LWJGLException + */ + public static void create(PixelFormat pixel_format, Drawable shared_drawable, ContextAttribs attribs) throws LWJGLException { + synchronized ( GlobalLock.lock ) { + if ( isCreated() ) throw new IllegalStateException("Only one LWJGL context may be instantiated at any one time."); - if (pixel_format == null) + if ( pixel_format == null ) throw new NullPointerException("pixel_format cannot be null"); removeShutdownHook(); registerShutdownHook(); - if (fullscreen) + if ( fullscreen ) switchDisplayMode(); try { peer_info = display_impl.createPeerInfo(pixel_format); try { createWindow(); try { - context = new Context(peer_info, shared_drawable != null ? shared_drawable.getContext() : null); + context = new Context(peer_info, attribs, shared_drawable != null ? shared_drawable.getContext() : null); try { makeCurrentAndSetSwapInterval(); initContext(); @@ -819,40 +854,38 @@ public final class Display { return display_impl; } - /** - * Gets a boolean property as a privileged action. - */ + /** Gets a boolean property as a privileged action. */ static boolean getPrivilegedBoolean(final String property_name) { Boolean value = (Boolean)AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + public Object run() { return new Boolean(Boolean.getBoolean(property_name)); } }); return value.booleanValue(); } - + private static void initControls() { // Automatically create mouse, keyboard and controller - if (!getPrivilegedBoolean("org.lwjgl.opengl.Display.noinput")) { - if (!Mouse.isCreated() && !getPrivilegedBoolean("org.lwjgl.opengl.Display.nomouse")) { + if ( !getPrivilegedBoolean("org.lwjgl.opengl.Display.noinput") ) { + if ( !Mouse.isCreated() && !getPrivilegedBoolean("org.lwjgl.opengl.Display.nomouse") ) { try { Mouse.create(); } catch (LWJGLException e) { - if (LWJGLUtil.DEBUG) { + if ( LWJGLUtil.DEBUG ) { e.printStackTrace(System.err); } else { - LWJGLUtil.log("Failed to create Mouse: "+e); + LWJGLUtil.log("Failed to create Mouse: " + e); } } } - if (!Keyboard.isCreated() && !getPrivilegedBoolean("org.lwjgl.opengl.Display.nokeyboard")) { + if ( !Keyboard.isCreated() && !getPrivilegedBoolean("org.lwjgl.opengl.Display.nokeyboard") ) { try { Keyboard.create(); } catch (LWJGLException e) { - if (LWJGLUtil.DEBUG) { + if ( LWJGLUtil.DEBUG ) { e.printStackTrace(System.err); } else { - LWJGLUtil.log("Failed to create Keyboard: "+e); + LWJGLUtil.log("Failed to create Keyboard: " + e); } } } @@ -864,8 +897,8 @@ public final class Display { * regardless of whether the Display was the current rendering context. */ public static void destroy() { - synchronized (GlobalLock.lock) { - if (!isCreated()) { + synchronized ( GlobalLock.lock ) { + if ( !isCreated() ) { return; } @@ -904,11 +937,9 @@ public final class Display { current_mode = initial_mode; } - /** - * @return true if the window's native peer has been created - */ + /** @return true if the window's native peer has been created */ public static boolean isCreated() { - synchronized (GlobalLock.lock) { + synchronized ( GlobalLock.lock ) { return window_created; } } @@ -917,27 +948,27 @@ public final class Display { * Set the buffer swap interval. This call is a best-attempt at changing * the monitor swap interval, which is the minimum periodicity of color buffer swaps, * measured in video frame periods, and is not guaranteed to be successful. - * + *

* A video frame period is the time required to display a full frame of video data. * * @param value The swap interval in frames, 0 to disable */ public static void setSwapInterval(int value) { - synchronized (GlobalLock.lock) { + synchronized ( GlobalLock.lock ) { swap_interval = value; - if (isCreated()) + if ( isCreated() ) Context.setSwapInterval(swap_interval); } } - - + /** * Enable or disable vertical monitor synchronization. This call is a best-attempt at changing * the vertical refresh synchronization of the monitor, and is not guaranteed to be successful. + * * @param sync true to synchronize; false to ignore synchronization */ public static void setVSyncEnabled(boolean sync) { - synchronized (GlobalLock.lock) { + synchronized ( GlobalLock.lock ) { setSwapInterval(sync ? 1 : 0); } } @@ -948,12 +979,13 @@ public final class Display { * to position the window such that it would extend off the screen, the window * is simply placed as close to the edge as possible. *
noteIf no location has been specified (or x == y == -1) the window will be centered + * * @param new_x The new window location on the x axis * @param new_y The new window location on the y axis */ public static void setLocation(int new_x, int new_y) { - synchronized (GlobalLock.lock) { - if (fullscreen) { + synchronized ( GlobalLock.lock ) { + if ( fullscreen ) { return; } @@ -962,7 +994,7 @@ public final class Display { y = new_y; // offset if already created - if(isCreated()) { + if ( isCreated() ) { reshape(); } } @@ -976,10 +1008,11 @@ public final class Display { /** * Get the driver adapter string. This is a unique string describing the actual card's hardware, eg. "Geforce2", "PS2", * "Radeon9700". If the adapter cannot be determined, this function returns null. + * * @return a String */ public static String getAdapter() { - synchronized (GlobalLock.lock) { + synchronized ( GlobalLock.lock ) { return display_impl.getAdapter(); } } @@ -987,14 +1020,14 @@ public final class Display { /** * Get the driver version. This is a vendor/adapter specific version string. If the version cannot be determined, * this function returns null. + * * @return a String */ public static String getVersion() { - synchronized (GlobalLock.lock) { + synchronized ( GlobalLock.lock ) { return display_impl.getVersion(); } } - /** * Sets one or more icons for the Display. @@ -1004,21 +1037,22 @@ public final class Display { *

  • Mac OS X should be supplied one 128x128 icon
  • * * The implementation will use the supplied ByteBuffers with image data in RGBA and perform any conversions nescesarry for the specific platform. - *

    + *

    * NOTE: The display will make a deep copy of the supplied byte buffer array, for the purpose - * of recreating the icons when you go back and forth fullscreen mode. You therefore only need to + * of recreating the icons when you go back and forth fullscreen mode. You therefore only need to * set the icon once per instance. * * @param icons Array of icons in RGBA mode. Pass the icons in order of preference. + * * @return number of icons used, or 0 if display hasn't been created */ public static int setIcon(ByteBuffer[] icons) { - synchronized (GlobalLock.lock) { + synchronized ( GlobalLock.lock ) { // make deep copy so we dont rely on the supplied buffers later on // don't recache! - if(cached_icons != icons) { + if ( cached_icons != icons ) { cached_icons = new ByteBuffer[icons.length]; - for(int i=0;i @@ -158,5 +158,5 @@ interface DisplayImplementation extends InputImplementation { * @param icons Array of icons in RGBA mode * @return number of icons used. */ - public int setIcon(ByteBuffer[] icons); + int setIcon(ByteBuffer[] icons); } diff --git a/src/java/org/lwjgl/opengl/GLChecks.java b/src/java/org/lwjgl/opengl/GLChecks.java index e52af2a7..b5df002d 100644 --- a/src/java/org/lwjgl/opengl/GLChecks.java +++ b/src/java/org/lwjgl/opengl/GLChecks.java @@ -71,13 +71,19 @@ class GLChecks { return scratch_buffer.get(0); } + static int getNamedBufferObjectSize(ContextCapabilities caps, int buffer) { + IntBuffer scratch_buffer = caps.scratch_int_buffer; + EXTDirectStateAccess.glGetNamedBufferParameterEXT(buffer, GL15.GL_BUFFER_SIZE, scratch_buffer); + return scratch_buffer.get(0); + } + private static boolean checkBufferObject(ContextCapabilities caps, int buffer_enum, boolean state) { IntBuffer scratch_buffer = caps.scratch_int_buffer; GL11.glGetInteger(buffer_enum, scratch_buffer); boolean is_enabled = scratch_buffer.get(0) != 0; return state == is_enabled; } - + /** Helper method to ensure that array buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */ static void ensureArrayVBOdisabled(ContextCapabilities caps) { if(StateTracker.getReferencesStack(caps).getReferences().arrayBuffer != 0) diff --git a/src/java/org/lwjgl/opengl/GLContext.java b/src/java/org/lwjgl/opengl/GLContext.java index ae457280..c494de08 100644 --- a/src/java/org/lwjgl/opengl/GLContext.java +++ b/src/java/org/lwjgl/opengl/GLContext.java @@ -31,38 +31,35 @@ */ package org.lwjgl.opengl; -import java.lang.reflect.Method; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.security.PrivilegedExceptionAction; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.StringTokenizer; -import java.util.WeakHashMap; - +import org.lwjgl.BufferUtils; import org.lwjgl.LWJGLException; import org.lwjgl.LWJGLUtil; import org.lwjgl.Sys; +import java.lang.reflect.Method; +import java.nio.IntBuffer; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.security.PrivilegedExceptionAction; +import java.util.*; + /** *

    * Manages GL contexts. Before any rendering is done by a LWJGL system, a call should be made to GLContext.useContext() with a * context. This will ensure that GLContext has an accurate reflection of the current context's capabilities and function * pointers. - * + *

    * This class is thread-safe in the sense that multiple threads can safely call all public methods. The class is also * thread-aware in the sense that it tracks a per-thread current context (including capabilities and function pointers). * That way, multiple threads can have multiple contexts current and render to them concurrently. * * @author elias_naur * @version $Revision$ - * $Id$ + * $Id$ */ public final class GLContext { - /** - * Maps threads to their current context's ContextCapabilities, if any - */ + + /** Maps threads to their current context's ContextCapabilities, if any */ private final static ThreadLocal current_capabilities = new ThreadLocal(); /** @@ -71,18 +68,18 @@ public final class GLContext { * for the function pointers of gl functions. However, the 'current_capabilities' ThreadLocal * is (relatively) expensive to look up, and since most OpenGL applications use are single threaded * rendering, the following two is an optimization for this case. - * + *

    * ThreadLocals can be thought of as a mapping between threads and values, so the idea * is to use a lock-less cache of mappings between threads and the current ContextCapabilities. The cache * could be any size, but in our case, we want a single sized cache for optimal performance * in the single threaded case. - * + *

    * 'fast_path_cache' is the most recent ContextCapabilities (potentially null) and its owner. By * recent I mean the last thread setting the value in setCapabilities(). When getCapabilities() * is called, a check to see if the current is the owner of the ContextCapabilities instance in * fast_path_cache. If so, the instance is returned, if not, some thread has since taken ownership * of the cache entry and the slower current_capabilities ThreadLocal is queried instead. - * + *

    * No locks are needed in get/setCapabilities, because even though fast_path_cache can be accessed * from multiple threads at once, we are guaranteed by the JVM spec that its value is always valid. * Furthermore, if the ownership test in getCapabilities() succeeds, the cache entry can only contain @@ -120,7 +117,7 @@ public final class GLContext { public static ContextCapabilities getCapabilities() { CapabilitiesCacheEntry recent_cache_entry = fast_path_cache; // Check owner of cache entry - if (recent_cache_entry.owner == Thread.currentThread()) { + if ( recent_cache_entry.owner == Thread.currentThread() ) { /* The owner ship test succeeded, so the cache must contain the current ContextCapabilities instance * assert recent_cache_entry.capabilities == getThreadLocalCapabilities(); */ @@ -143,7 +140,7 @@ public final class GLContext { current_capabilities.set(capabilities); CapabilitiesCacheEntry thread_cache_entry = (CapabilitiesCacheEntry)thread_cache_entries.get(); - if (thread_cache_entry == null) { + if ( thread_cache_entry == null ) { thread_cache_entry = new CapabilitiesCacheEntry(); thread_cache_entries.set(thread_cache_entry); } @@ -163,8 +160,8 @@ public final class GLContext { return System.getProperty("os.name"); } }); - for (int i = 0; i < os_prefixes.length; i++) - if (os_name.startsWith(os_prefixes[i])) { + for ( int i = 0; i < os_prefixes.length; i++ ) + if ( os_name.startsWith(os_prefixes[i]) ) { String platform_function_name = function.replaceFirst(function_prefix, os_function_prefixes[i]); long address = getFunctionAddress(platform_function_name); return address; @@ -172,9 +169,7 @@ public final class GLContext { return 0; } - /** - * Helper method to get a pointer to a named function in the OpenGL library - */ + /** Helper method to get a pointer to a named function in the OpenGL library */ static native long getFunctionAddress(String name); /** @@ -183,21 +178,17 @@ public final class GLContext { * @return A Set containing all available extension strings. */ static Set getSupportedExtensions() { - Set supported_extensions = new HashSet(); - String extensions_string = GL11.glGetString(GL11.GL_EXTENSIONS); - if (extensions_string == null) - throw new IllegalStateException("glGetString(GL_EXTENSIONS) returned null - is there a context current?"); - StringTokenizer tokenizer = new StringTokenizer(extensions_string); - while ( tokenizer.hasMoreTokens() ) { - String extension_string = tokenizer.nextToken(); - supported_extensions.add(extension_string); - } - String version = GL11.glGetString(GL11.GL_VERSION); - if (version == null) + final Set supported_extensions = new HashSet(); + + // Detect OpenGL version first + + final String version = GL11.glGetString(GL11.GL_VERSION); + if ( version == null ) throw new IllegalStateException("glGetString(GL_VERSION) returned null - possibly caused by missing current context."); - StringTokenizer version_tokenizer = new StringTokenizer(version, ". "); - String major_string = version_tokenizer.nextToken(); - String minor_string = version_tokenizer.nextToken(); + + final StringTokenizer version_tokenizer = new StringTokenizer(version, ". "); + final String major_string = version_tokenizer.nextToken(); + final String minor_string = version_tokenizer.nextToken(); int majorVersion = 0; int minorVersion = 0; @@ -208,39 +199,47 @@ public final class GLContext { LWJGLUtil.log("The major and/or minor OpenGL version is malformed: " + e.getMessage()); } - if (majorVersion >= 2) { - // ----------------------[ 2.X ]---------------------- - switch (minorVersion) { - case 1: - supported_extensions.add("OpenGL21"); - // Intentional fall through - case 0: - supported_extensions.add("OpenGL20"); - } - // ----------------------[ 1.X ]---------------------- - supported_extensions.add("OpenGL11"); - supported_extensions.add("OpenGL12"); - supported_extensions.add("OpenGL13"); - supported_extensions.add("OpenGL14"); + // ----------------------[ 3.X ]---------------------- + if ( 3 <= majorVersion ) + supported_extensions.add("OpenGL30"); + + // ----------------------[ 2.X ]---------------------- + if ( 2 < majorVersion || (2 == majorVersion && 1 <= minorVersion) ) + supported_extensions.add("OpenGL21"); + if ( 2 <= majorVersion ) + supported_extensions.add("OpenGL20"); + + // ----------------------[ 1.X ]---------------------- + if ( 1 < majorVersion || 5 <= minorVersion ) supported_extensions.add("OpenGL15"); - } else if (majorVersion == 1) { - switch (minorVersion) { - case 5: - supported_extensions.add("OpenGL15"); - // Intentional fall through - case 4: - supported_extensions.add("OpenGL14"); - // Intentional fall through - case 3: - supported_extensions.add("OpenGL13"); - // Intentional fall through - case 2: - supported_extensions.add("OpenGL12"); - // Intentional fall through - case 1: - supported_extensions.add("OpenGL11"); - } + if ( 1 < majorVersion || 4 <= minorVersion ) + supported_extensions.add("OpenGL14"); + if ( 1 < majorVersion || 3 <= minorVersion ) + supported_extensions.add("OpenGL13"); + if ( 1 < majorVersion || 2 <= minorVersion ) + supported_extensions.add("OpenGL12"); + if ( 1 < majorVersion || 1 <= minorVersion ) + supported_extensions.add("OpenGL11"); + + if ( majorVersion < 3 ) { + // Parse EXTENSIONS string + final String extensions_string = GL11.glGetString(GL11.GL_EXTENSIONS); + if ( extensions_string == null ) + throw new IllegalStateException("glGetString(GL_EXTENSIONS) returned null - is there a context current?"); + + final StringTokenizer tokenizer = new StringTokenizer(extensions_string); + while ( tokenizer.hasMoreTokens() ) + supported_extensions.add(tokenizer.nextToken()); + } else { + // Use forward compatible indexed EXTENSIONS + final IntBuffer buffer = BufferUtils.createIntBuffer(16); + GL11.glGetInteger(GL30.GL_NUM_EXTENSIONS, buffer); + final int extensionCount = buffer.get(0); + + for ( int i = 0; i < extensionCount; i++ ) + supported_extensions.add(GL30.glGetStringi(GL11.GL_EXTENSIONS, i)); } + return supported_extensions; } @@ -250,7 +249,7 @@ public final class GLContext { */ static void initNativeStubs(final Class extension_class, Set supported_extensions, String ext_name) { resetNativeStubs(extension_class); - if (supported_extensions.contains(ext_name)) { + if ( supported_extensions.contains(ext_name) ) { try { AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws Exception { @@ -281,32 +280,53 @@ public final class GLContext { * @throws LWJGLException if context non-null, and the gl library can't be loaded or the basic GL11 functions can't be loaded */ public static synchronized void useContext(Object context) throws LWJGLException { - if (context == null) { + useContext(context, false); + } + + /** + * Makes a GL context the current LWJGL context by loading GL function pointers. The context must be current before a call to + * this method! Instead it simply ensures that the current context is reflected accurately by GLContext's extension caps and + * function pointers. Use useContext(null) when no context is active.

    If the context is the same as last time, then this is + * a no-op.

    If the context has not been encountered before it will be fully initialized from scratch. Otherwise a cached set + * of caps and function pointers will be used.

    The reference to the context is held in a weak reference; therefore if no + * strong reference exists to the GL context it will automatically be forgotten by the VM at an indeterminate point in the + * future, freeing up a little RAM. + *

    If forwardCombatible is true, function pointers of deprecated GL11-GL21 functionality will not be loaded. Calling a deprecated + * function using the specified context will result in an IllegalStateException. + * + * @param context The context object, which uniquely identifies a GL context. If context is null, the native stubs are + * unloaded. + * @param forwardCombatible If the context is a forward combatible context (does not expose deprecated functionality, see XGL_ARB_create_context) + * + * @throws LWJGLException if context non-null, and the gl library can't be loaded or the basic GL11 functions can't be loaded + */ + public static synchronized void useContext(Object context, boolean forwardCombatible) throws LWJGLException { + if ( context == null ) { ContextCapabilities.unloadAllStubs(); setCapabilities(null); - if (did_auto_load) + if ( did_auto_load ) unloadOpenGLLibrary(); return; } - if (gl_ref_count == 0) { + if ( gl_ref_count == 0 ) { loadOpenGLLibrary(); did_auto_load = true; } try { ContextCapabilities capabilities = (ContextCapabilities)capability_cache.get(context); - if (capabilities == null) { + if ( capabilities == null ) { /* * The capabilities object registers itself as current. This behaviour is caused * by a chicken-and-egg situation where the constructor needs to call GL functions * as part of its capability discovery, but GL functions cannot be called before * a capabilities object has been set. */ - new ContextCapabilities(); + new ContextCapabilities(forwardCombatible); capability_cache.put(context, getCapabilities()); } else setCapabilities(capabilities); } catch (LWJGLException e) { - if (did_auto_load) + if ( did_auto_load ) unloadOpenGLLibrary(); throw e; } @@ -314,7 +334,7 @@ public final class GLContext { /** If the OpenGL reference count is 0, the library is loaded. The reference count is then incremented. */ public static synchronized void loadOpenGLLibrary() throws LWJGLException { - if (gl_ref_count == 0) + if ( gl_ref_count == 0 ) nLoadOpenGLLibrary(); gl_ref_count++; } @@ -328,7 +348,7 @@ public final class GLContext { * Unload the native OpenGL library unless we're on linux, since * some drivers (NVIDIA proprietary) crash on exit when unloading the library. */ - if (gl_ref_count == 0 && LWJGLUtil.getPlatform() != LWJGLUtil.PLATFORM_LINUX) + if ( gl_ref_count == 0 && LWJGLUtil.getPlatform() != LWJGLUtil.PLATFORM_LINUX ) nUnloadOpenGLLibrary(); } @@ -338,6 +358,7 @@ public final class GLContext { static native void resetNativeStubs(Class clazz); private final static class CapabilitiesCacheEntry { + Thread owner; ContextCapabilities capabilities; } diff --git a/src/java/org/lwjgl/opengl/KeyboardEventQueue.java b/src/java/org/lwjgl/opengl/KeyboardEventQueue.java index c4cdc3d5..54d7319f 100644 --- a/src/java/org/lwjgl/opengl/KeyboardEventQueue.java +++ b/src/java/org/lwjgl/opengl/KeyboardEventQueue.java @@ -247,7 +247,7 @@ final class KeyboardEventQueue extends EventQueue implements KeyListener { KEY_MAP[KeyEvent.VK_Z] = Keyboard.KEY_Z; } - public KeyboardEventQueue(Component component) { + KeyboardEventQueue(Component component) { super(Keyboard.EVENT_SIZE); this.component = component; } diff --git a/src/java/org/lwjgl/opengl/LinuxAWTGLCanvasPeerInfo.java b/src/java/org/lwjgl/opengl/LinuxAWTGLCanvasPeerInfo.java index 9d29958a..b7267c1e 100644 --- a/src/java/org/lwjgl/opengl/LinuxAWTGLCanvasPeerInfo.java +++ b/src/java/org/lwjgl/opengl/LinuxAWTGLCanvasPeerInfo.java @@ -48,10 +48,10 @@ final class LinuxAWTGLCanvasPeerInfo extends LinuxPeerInfo { private final AWTSurfaceLock awt_surface = new AWTSurfaceLock(); private int screen = -1; - public LinuxAWTGLCanvasPeerInfo(Canvas component) { + LinuxAWTGLCanvasPeerInfo(Canvas component) { this.component = component; } - + protected void doLockAndInitHandle() throws LWJGLException { ByteBuffer surface_handle = awt_surface.lockAndGetHandle(component); if (screen == -1) { diff --git a/src/java/org/lwjgl/opengl/LinuxContextAttribs.java b/src/java/org/lwjgl/opengl/LinuxContextAttribs.java new file mode 100644 index 00000000..5c4f0803 --- /dev/null +++ b/src/java/org/lwjgl/opengl/LinuxContextAttribs.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +/** + * An implementation of ContextAttribs using GLX_create_context. + *

    + * ---- WIP - GLX_create_context has not been defined yet ---- + * + * @author spasi + */ +final class LinuxContextAttribs extends ContextAttribs { + + private static final int GLX_CONTEXT_MAJOR_VERSION_ARB = 0x2091; + private static final int GLX_CONTEXT_MINOR_VERSION_ARB = 0x2092; + private static final int GLX_CONTEXT_LAYER_PLANE_ARB = 0x2093; + private static final int GLX_CONTEXT_FLAGS_ARB = 0x2094; + + private static final int GLX_CONTEXT_DEBUG_BIT_ARB = 0x0001; + private static final int GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB = 0x0002; + + LinuxContextAttribs(final int majorVersion, final int minorVersion) { + super(majorVersion, minorVersion); + } + + LinuxContextAttribs(final ContextAttribs attribs) { + super(attribs); + } + + protected int getMajorVersionAttrib() { + return GLX_CONTEXT_MAJOR_VERSION_ARB; + } + + protected int getMinorVersionAttrib() { + return GLX_CONTEXT_MINOR_VERSION_ARB; + } + + protected int getLayerPlaneAttrib() { + return GLX_CONTEXT_LAYER_PLANE_ARB; + } + + protected int getFlagsAttrib() { + return GLX_CONTEXT_FLAGS_ARB; + } + + protected int getDebugBit() { + return GLX_CONTEXT_DEBUG_BIT_ARB; + } + + protected int getForwardCombatibleBit() { + return GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB; + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opengl/LinuxContextImplementation.java b/src/java/org/lwjgl/opengl/LinuxContextImplementation.java index c5a36bd4..48feedb8 100644 --- a/src/java/org/lwjgl/opengl/LinuxContextImplementation.java +++ b/src/java/org/lwjgl/opengl/LinuxContextImplementation.java @@ -31,23 +31,24 @@ */ package org.lwjgl.opengl; -import java.nio.ByteBuffer; - import org.lwjgl.LWJGLException; +import java.nio.ByteBuffer; +import java.nio.IntBuffer; + /** - * * @author elias_naur * @version $Revision$ - * $Id$ + * $Id$ */ final class LinuxContextImplementation implements ContextImplementation { - public ByteBuffer create(PeerInfo peer_info, ByteBuffer shared_context_handle) throws LWJGLException { + + public ByteBuffer create(PeerInfo peer_info, IntBuffer attribs, ByteBuffer shared_context_handle) throws LWJGLException { LinuxDisplay.lockAWT(); try { ByteBuffer peer_handle = peer_info.lockAndGetHandle(); try { - return nCreate(peer_handle, shared_context_handle); + return nCreate(peer_handle, attribs, shared_context_handle); } finally { peer_info.unlock(); } @@ -56,16 +57,16 @@ final class LinuxContextImplementation implements ContextImplementation { } } - private static native ByteBuffer nCreate(ByteBuffer peer_handle, ByteBuffer shared_context_handle) throws LWJGLException; + private static native ByteBuffer nCreate(ByteBuffer peer_handle, IntBuffer attribs, ByteBuffer shared_context_handle) throws LWJGLException; public void releaseDrawable(ByteBuffer context_handle) throws LWJGLException { } - + public void swapBuffers() throws LWJGLException { Context current_context = Context.getCurrentContext(); - if (current_context == null) + if ( current_context == null ) throw new IllegalStateException("No context is current"); - synchronized (current_context) { + synchronized ( current_context ) { PeerInfo current_peer_info = current_context.getPeerInfo(); LinuxDisplay.lockAWT(); try { @@ -80,13 +81,14 @@ final class LinuxContextImplementation implements ContextImplementation { } } } + private static native void nSwapBuffers(ByteBuffer peer_info_handle) throws LWJGLException; public void releaseCurrentContext() throws LWJGLException { Context current_context = Context.getCurrentContext(); - if (current_context == null) + if ( current_context == null ) throw new IllegalStateException("No context is current"); - synchronized (current_context) { + synchronized ( current_context ) { PeerInfo current_peer_info = current_context.getPeerInfo(); LinuxDisplay.lockAWT(); try { @@ -101,6 +103,7 @@ final class LinuxContextImplementation implements ContextImplementation { } } } + private static native void nReleaseCurrentContext(ByteBuffer peer_info_handle) throws LWJGLException; public void update(ByteBuffer context_handle) { @@ -119,8 +122,9 @@ final class LinuxContextImplementation implements ContextImplementation { LinuxDisplay.unlockAWT(); } } + private static native void nMakeCurrent(ByteBuffer peer_handle, ByteBuffer context_handle) throws LWJGLException; - + public boolean isCurrent(ByteBuffer handle) throws LWJGLException { LinuxDisplay.lockAWT(); try { @@ -130,18 +134,20 @@ final class LinuxContextImplementation implements ContextImplementation { LinuxDisplay.unlockAWT(); } } + private static native boolean nIsCurrent(ByteBuffer context_handle) throws LWJGLException; public void setSwapInterval(int value) { Context current_context = Context.getCurrentContext(); - if (current_context == null) + if ( current_context == null ) throw new IllegalStateException("No context is current"); - synchronized (current_context) { + synchronized ( current_context ) { LinuxDisplay.lockAWT(); nSetSwapInterval(current_context.getHandle(), value); LinuxDisplay.unlockAWT(); } } + private static native void nSetSwapInterval(ByteBuffer context_handle, int value); public void destroy(PeerInfo peer_info, ByteBuffer handle) throws LWJGLException { @@ -157,5 +163,6 @@ final class LinuxContextImplementation implements ContextImplementation { LinuxDisplay.unlockAWT(); } } + private static native void nDestroy(ByteBuffer peer_handle, ByteBuffer context_handle) throws LWJGLException; } diff --git a/src/java/org/lwjgl/opengl/LinuxDisplay.java b/src/java/org/lwjgl/opengl/LinuxDisplay.java index 201cd161..294f6b46 100644 --- a/src/java/org/lwjgl/opengl/LinuxDisplay.java +++ b/src/java/org/lwjgl/opengl/LinuxDisplay.java @@ -81,7 +81,7 @@ final class LinuxDisplay implements DisplayImplementation { /** Current window mode */ private static int current_window_mode = WINDOWED; - + /** Display mode switching API */ private static final int XRANDR = 10; private static final int XF86VIDMODE = 11; @@ -91,7 +91,7 @@ final class LinuxDisplay implements DisplayImplementation { private static long display; private static long current_window; private static long saved_error_handler; - + private static int display_connection_usage_count = 0; /** Event buffer */ @@ -136,13 +136,13 @@ final class LinuxDisplay implements DisplayImplementation { private LinuxMouse mouse; private final FocusListener focus_listener = new FocusListener() { - public final void focusGained(FocusEvent e) { + public void focusGained(FocusEvent e) { synchronized (GlobalLock.lock) { parent_focused = true; parent_focus_changed = true; } } - public final void focusLost(FocusEvent e) { + public void focusLost(FocusEvent e) { synchronized (GlobalLock.lock) { parent_focused = false; parent_focus_changed = true; @@ -167,7 +167,7 @@ final class LinuxDisplay implements DisplayImplementation { } } private static native ByteBuffer nGetCurrentGammaRamp(long display, int screen) throws LWJGLException; - + private static int getBestDisplayModeExtension() { int result; if (isXrandrSupported()) { @@ -182,7 +182,7 @@ final class LinuxDisplay implements DisplayImplementation { } return result; } - + private static boolean isXrandrSupported() { if (Display.getPrivilegedBoolean("LWJGL_DISABLE_XRANDR")) return false; @@ -240,7 +240,7 @@ final class LinuxDisplay implements DisplayImplementation { } } private static native boolean nIsNetWMFullscreenSupported(long display, int screen) throws LWJGLException; - + /* Since Xlib is not guaranteed to be thread safe, we need a way to synchronize LWJGL * Xlib calls with AWT Xlib calls. Fortunately, JAWT implements Lock()/Unlock() to * do just that. @@ -253,7 +253,7 @@ final class LinuxDisplay implements DisplayImplementation { } } private static native void nLockAWT() throws LWJGLException; - + static void unlockAWT() { try { nUnlockAWT(); @@ -303,7 +303,7 @@ final class LinuxDisplay implements DisplayImplementation { closeDisplay(display); resetErrorHandler(saved_error_handler); display = 0; - GLContext.unloadOpenGLLibrary(); + GLContext.unloadOpenGLLibrary(); }*/ } @@ -322,7 +322,7 @@ final class LinuxDisplay implements DisplayImplementation { } else return WINDOWED; } - + static long getDisplay() { if (display_connection_usage_count <= 0) throw new InternalError("display_connection_usage_count = " + display_connection_usage_count); @@ -345,7 +345,7 @@ final class LinuxDisplay implements DisplayImplementation { } } static native int nUngrabKeyboard(long display); - + private void grabKeyboard() { if (!keyboard_grabbed) { int res = nGrabKeyboard(getDisplay(), getWindow()); @@ -354,7 +354,7 @@ final class LinuxDisplay implements DisplayImplementation { } } static native int nGrabKeyboard(long display, long window); - + private void grabPointer() { if (!pointer_grabbed) { int result = nGrabPointer(getDisplay(), getWindow(), None); @@ -394,7 +394,7 @@ final class LinuxDisplay implements DisplayImplementation { } updateCursor(); } - + private void updateCursor() { long cursor; if (shouldGrab()) { @@ -405,7 +405,7 @@ final class LinuxDisplay implements DisplayImplementation { nDefineCursor(getDisplay(), getWindow(), cursor); } private static native void nDefineCursor(long display, long window, long cursor_handle); - + private boolean isLegacyFullscreen() { return current_window_mode == FULLSCREEN_LEGACY; } @@ -484,7 +484,7 @@ final class LinuxDisplay implements DisplayImplementation { ByteBuffer parent_peer_info_handle = parent_peer_info.lockAndGetHandle(); try { return parent_peer_info.getDrawable(); - } finally { + } finally { parent_peer_info.unlock(); } } @@ -548,8 +548,7 @@ final class LinuxDisplay implements DisplayImplementation { public void resetDisplayMode() { lockAWT(); try { - if(current_mode != saved_mode) - switchDisplayMode(saved_mode); + switchDisplayMode(saved_mode); if (isXF86VidModeSupported()) doSetGamma(saved_gamma); } catch (LWJGLException e) { @@ -646,7 +645,7 @@ final class LinuxDisplay implements DisplayImplementation { current_mode = saved_mode; saved_gamma = getCurrentGammaRamp(); current_gamma = saved_gamma; - return current_mode; + return saved_mode; } finally { unlockAWT(); } @@ -665,7 +664,7 @@ final class LinuxDisplay implements DisplayImplementation { unlockAWT(); } } - + /** Assumes extension == XRANDR */ private static native DisplayMode nGetCurrentXRandrMode(long display, int screen) throws LWJGLException; @@ -703,7 +702,7 @@ final class LinuxDisplay implements DisplayImplementation { peer_info = new LinuxDisplayPeerInfo(pixel_format); return peer_info; } - + static native void setInputFocus(long display, long window, long time); private void relayEventToParent(LinuxEvent event_buffer, int event_mask) { @@ -828,7 +827,7 @@ final class LinuxDisplay implements DisplayImplementation { mouse = null; updateInputGrab(); } - + public void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons) { lockAWT(); try { @@ -837,7 +836,7 @@ final class LinuxDisplay implements DisplayImplementation { unlockAWT(); } } - + public void readMouse(ByteBuffer buffer) { lockAWT(); try { @@ -846,7 +845,7 @@ final class LinuxDisplay implements DisplayImplementation { unlockAWT(); } } - + public void setCursorPosition(int x, int y) { lockAWT(); try { @@ -949,7 +948,7 @@ final class LinuxDisplay implements DisplayImplementation { private boolean shouldWarpPointer() { return pointer_grabbed && shouldGrab(); } - + public int getNativeCursorCapabilities() { lockAWT(); try { @@ -976,7 +975,7 @@ final class LinuxDisplay implements DisplayImplementation { unlockAWT(); } } - + public int getMinCursorSize() { lockAWT(); try { @@ -1012,7 +1011,7 @@ final class LinuxDisplay implements DisplayImplementation { } } private static native int nGetMaxCursorSize(long display, long window); - + /* Keyboard */ public void createKeyboard() throws LWJGLException { lockAWT(); @@ -1022,7 +1021,7 @@ final class LinuxDisplay implements DisplayImplementation { unlockAWT(); } } - + public void destroyKeyboard() { lockAWT(); try { @@ -1032,7 +1031,7 @@ final class LinuxDisplay implements DisplayImplementation { unlockAWT(); } } - + public void pollKeyboard(ByteBuffer keyDownBuffer) { lockAWT(); try { @@ -1050,7 +1049,7 @@ final class LinuxDisplay implements DisplayImplementation { unlockAWT(); } } - + private static native long nCreateCursor(long display, int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, int images_offset, IntBuffer delays, int delays_offset) throws LWJGLException; private static long createBlankCursor() { @@ -1088,7 +1087,7 @@ final class LinuxDisplay implements DisplayImplementation { } } static native void nDestroyCursor(long display, long cursorHandle); - + public int getPbufferCapabilities() { lockAWT(); try { @@ -1128,7 +1127,7 @@ final class LinuxDisplay implements DisplayImplementation { public void releaseTexImageFromPbuffer(PeerInfo handle, int buffer) { throw new UnsupportedOperationException(); } - + private static ByteBuffer convertIcon(ByteBuffer icon, int width, int height) { ByteBuffer icon_rgb = BufferUtils.createByteBuffer(icon.capacity()); int x; @@ -1212,7 +1211,7 @@ final class LinuxDisplay implements DisplayImplementation { unlockAWT(); } } - + private static native void nSetWindowIcon(long display, long window, ByteBuffer icon_rgb, int icon_rgb_size, ByteBuffer icon_mask, int icon_mask_size, int width, int height); public int getWidth() { diff --git a/src/java/org/lwjgl/opengl/LinuxDisplayPeerInfo.java b/src/java/org/lwjgl/opengl/LinuxDisplayPeerInfo.java index 898a8526..3dbfd2ed 100644 --- a/src/java/org/lwjgl/opengl/LinuxDisplayPeerInfo.java +++ b/src/java/org/lwjgl/opengl/LinuxDisplayPeerInfo.java @@ -42,7 +42,7 @@ import org.lwjgl.LWJGLException; * $Id$ */ final class LinuxDisplayPeerInfo extends LinuxPeerInfo { - public LinuxDisplayPeerInfo(PixelFormat pixel_format) throws LWJGLException { + LinuxDisplayPeerInfo(PixelFormat pixel_format) throws LWJGLException { LinuxDisplay.lockAWT(); try { GLContext.loadOpenGLLibrary(); @@ -63,7 +63,7 @@ final class LinuxDisplayPeerInfo extends LinuxPeerInfo { } } private static native void initDefaultPeerInfo(long display, int screen, ByteBuffer peer_info_handle, PixelFormat pixel_format) throws LWJGLException; - + protected void doLockAndInitHandle() throws LWJGLException { LinuxDisplay.lockAWT(); try { @@ -73,7 +73,7 @@ final class LinuxDisplayPeerInfo extends LinuxPeerInfo { } } private static native void initDrawable(long window, ByteBuffer peer_info_handle); - + protected void doUnlock() throws LWJGLException { // NO-OP } diff --git a/src/java/org/lwjgl/opengl/LinuxEvent.java b/src/java/org/lwjgl/opengl/LinuxEvent.java index fd6d751f..a29b76ec 100644 --- a/src/java/org/lwjgl/opengl/LinuxEvent.java +++ b/src/java/org/lwjgl/opengl/LinuxEvent.java @@ -55,12 +55,12 @@ final class LinuxEvent { private final ByteBuffer event_buffer; - public LinuxEvent() { + LinuxEvent() { this.event_buffer = createEventBuffer(); } private static native ByteBuffer createEventBuffer(); - public final void copyFrom(LinuxEvent event) { + public void copyFrom(LinuxEvent event) { int pos = event_buffer.position(); int event_pos = event.event_buffer.position(); event_buffer.put(event.event_buffer); @@ -68,137 +68,137 @@ final class LinuxEvent { event.event_buffer.position(event_pos); } - public final static native int getPending(long display); + public static native int getPending(long display); - public final void sendEvent(long display, long window, boolean propagate, long event_mask) { + public void sendEvent(long display, long window, boolean propagate, long event_mask) { nSendEvent(event_buffer, display, window, propagate, event_mask); } private static native void nSendEvent(ByteBuffer event_buffer, long display, long window, boolean propagate, long event_mask); - public final boolean filterEvent(long window) { + public boolean filterEvent(long window) { return nFilterEvent(event_buffer, window); } private static native boolean nFilterEvent(ByteBuffer event_buffer, long window); - public final void nextEvent(long display) { + public void nextEvent(long display) { nNextEvent(display, event_buffer); } private static native void nNextEvent(long display, ByteBuffer event_buffer); - public final int getType() { + public int getType() { return nGetType(event_buffer); } private static native int nGetType(ByteBuffer event_buffer); - public final long getWindow() { + public long getWindow() { return nGetWindow(event_buffer); } private static native long nGetWindow(ByteBuffer event_buffer); - public final void setWindow(long window) { + public void setWindow(long window) { nSetWindow(event_buffer, window); } private static native void nSetWindow(ByteBuffer event_buffer, long window); /* Focus methods */ - public final int getFocusMode() { + public int getFocusMode() { return nGetFocusMode(event_buffer); } private static native int nGetFocusMode(ByteBuffer event_buffer); - public final int getFocusDetail() { + public int getFocusDetail() { return nGetFocusDetail(event_buffer); } private static native int nGetFocusDetail(ByteBuffer event_buffer); /* ClientMessage methods */ - public final long getClientMessageType() { + public long getClientMessageType() { return nGetClientMessageType(event_buffer); } private static native long nGetClientMessageType(ByteBuffer event_buffer); - public final int getClientData(int index) { + public int getClientData(int index) { return nGetClientData(event_buffer, index); } private static native int nGetClientData(ByteBuffer event_buffer, int index); - public final int getClientFormat() { + public int getClientFormat() { return nGetClientFormat(event_buffer); } private static native int nGetClientFormat(ByteBuffer event_buffer); /* Button methods */ - public final long getButtonTime() { + public long getButtonTime() { return nGetButtonTime(event_buffer); } private static native long nGetButtonTime(ByteBuffer event_buffer); - public final int getButtonState() { + public int getButtonState() { return nGetButtonState(event_buffer); } private static native int nGetButtonState(ByteBuffer event_buffer); - public final int getButtonType() { + public int getButtonType() { return nGetButtonType(event_buffer); } private static native int nGetButtonType(ByteBuffer event_buffer); - public final int getButtonButton() { + public int getButtonButton() { return nGetButtonButton(event_buffer); } private static native int nGetButtonButton(ByteBuffer event_buffer); - public final long getButtonRoot() { + public long getButtonRoot() { return nGetButtonRoot(event_buffer); } private static native long nGetButtonRoot(ByteBuffer event_buffer); - public final int getButtonXRoot() { + public int getButtonXRoot() { return nGetButtonXRoot(event_buffer); } private static native int nGetButtonXRoot(ByteBuffer event_buffer); - public final int getButtonYRoot() { + public int getButtonYRoot() { return nGetButtonYRoot(event_buffer); } private static native int nGetButtonYRoot(ByteBuffer event_buffer); - public final int getButtonX() { + public int getButtonX() { return nGetButtonX(event_buffer); } private static native int nGetButtonX(ByteBuffer event_buffer); - public final int getButtonY() { + public int getButtonY() { return nGetButtonY(event_buffer); } private static native int nGetButtonY(ByteBuffer event_buffer); /* Key methods */ - - public final long getKeyAddress() { + + public long getKeyAddress() { return nGetKeyAddress(event_buffer); } private static native long nGetKeyAddress(ByteBuffer event_buffer); - public final long getKeyTime() { + public long getKeyTime() { return nGetKeyTime(event_buffer); } private static native int nGetKeyTime(ByteBuffer event_buffer); - public final int getKeyType() { + public int getKeyType() { return nGetKeyType(event_buffer); } private static native int nGetKeyType(ByteBuffer event_buffer); - public final int getKeyKeyCode() { + public int getKeyKeyCode() { return nGetKeyKeyCode(event_buffer); } private static native int nGetKeyKeyCode(ByteBuffer event_buffer); - public final int getKeyState() { + public int getKeyState() { return nGetKeyState(event_buffer); } private static native int nGetKeyState(ByteBuffer event_buffer); diff --git a/src/java/org/lwjgl/opengl/LinuxKeyboard.java b/src/java/org/lwjgl/opengl/LinuxKeyboard.java index 8d727f4a..99665037 100644 --- a/src/java/org/lwjgl/opengl/LinuxKeyboard.java +++ b/src/java/org/lwjgl/opengl/LinuxKeyboard.java @@ -56,7 +56,7 @@ final class LinuxKeyboard { private final long xim; private final long xic; - + private final int numlock_mask; private final int modeswitch_mask; private final int caps_lock_mask; @@ -80,7 +80,7 @@ final class LinuxKeyboard { private long deferred_nanos; private byte deferred_key_state; - public LinuxKeyboard(long display, long window) { + LinuxKeyboard(long display, long window) { long modifier_map = getModifierMapping(display); int tmp_numlock_mask = 0; int tmp_modeswitch_mask = 0; @@ -194,7 +194,7 @@ final class LinuxKeyboard { return num_chars; } private static native int lookupString(long event_ptr, ByteBuffer buffer, ByteBuffer compose_status); - + private int lookupStringUnicode(long event_ptr, int[] translation_buffer) { int status = utf8LookupString(xic, event_ptr, native_translation_buffer, native_translation_buffer.position(), native_translation_buffer.remaining()); if (status != XLookupChars && status != XLookupBoth) diff --git a/src/java/org/lwjgl/opengl/LinuxMouse.java b/src/java/org/lwjgl/opengl/LinuxMouse.java index 2c9b5712..407d9268 100644 --- a/src/java/org/lwjgl/opengl/LinuxMouse.java +++ b/src/java/org/lwjgl/opengl/LinuxMouse.java @@ -54,7 +54,7 @@ final class LinuxMouse { private final static int Button3 = 3; private final static int Button4 = 4; private final static int Button5 = 5; - + private final static int ButtonPress = 4; private final static int ButtonRelease = 5; @@ -74,7 +74,7 @@ final class LinuxMouse { private EventQueue event_queue; private long last_event_nanos; - public LinuxMouse(long display, long window, long input_window) throws LWJGLException { + LinuxMouse(long display, long window, long input_window) throws LWJGLException { this.display = display; this.window = window; this.input_window = input_window; @@ -191,7 +191,7 @@ final class LinuxMouse { private static native int nGetWindowWidth(long display, long window); private static native long nQueryPointer(long display, long window, IntBuffer result); - + public void setCursorPosition(int x, int y) { nWarpCursor(display, window, x, transformY(y)); } @@ -200,7 +200,7 @@ final class LinuxMouse { private void handlePointerMotion(boolean grab, boolean warp_pointer, long millis, long root_window, int x_root, int y_root, int x, int y) { doHandlePointerMotion(grab, warp_pointer, root_window, x_root, y_root, x, y, millis*1000000); } - + private void handleButton(boolean grab, int button, byte state, long nanos) { byte button_num; switch (button) { @@ -259,7 +259,7 @@ final class LinuxMouse { break; } } - + private void resetCursor(int x, int y) { last_x = x; last_y = transformY(y); diff --git a/src/java/org/lwjgl/opengl/LinuxPbufferPeerInfo.java b/src/java/org/lwjgl/opengl/LinuxPbufferPeerInfo.java index b3066028..3828c014 100644 --- a/src/java/org/lwjgl/opengl/LinuxPbufferPeerInfo.java +++ b/src/java/org/lwjgl/opengl/LinuxPbufferPeerInfo.java @@ -42,7 +42,7 @@ import org.lwjgl.LWJGLException; * $Id$ */ final class LinuxPbufferPeerInfo extends LinuxPeerInfo { - public LinuxPbufferPeerInfo(int width, int height, PixelFormat pixel_format) throws LWJGLException { + LinuxPbufferPeerInfo(int width, int height, PixelFormat pixel_format) throws LWJGLException { LinuxDisplay.lockAWT(); try { GLContext.loadOpenGLLibrary(); diff --git a/src/java/org/lwjgl/opengl/LinuxPeerInfo.java b/src/java/org/lwjgl/opengl/LinuxPeerInfo.java index 78cb902a..ea1aecec 100644 --- a/src/java/org/lwjgl/opengl/LinuxPeerInfo.java +++ b/src/java/org/lwjgl/opengl/LinuxPeerInfo.java @@ -40,7 +40,7 @@ import java.nio.ByteBuffer; * $Id$ */ abstract class LinuxPeerInfo extends PeerInfo { - public LinuxPeerInfo() { + LinuxPeerInfo() { super(createHandle()); } private static native ByteBuffer createHandle(); diff --git a/src/java/org/lwjgl/opengl/MacOSXAWTGLCanvasPeerInfo.java b/src/java/org/lwjgl/opengl/MacOSXAWTGLCanvasPeerInfo.java index fb8c5574..04428dd6 100644 --- a/src/java/org/lwjgl/opengl/MacOSXAWTGLCanvasPeerInfo.java +++ b/src/java/org/lwjgl/opengl/MacOSXAWTGLCanvasPeerInfo.java @@ -44,7 +44,7 @@ import java.awt.Canvas; final class MacOSXAWTGLCanvasPeerInfo extends MacOSXCanvasPeerInfo { private final Canvas component; - public MacOSXAWTGLCanvasPeerInfo(Canvas component, PixelFormat pixel_format, boolean support_pbuffer) throws LWJGLException { + MacOSXAWTGLCanvasPeerInfo(Canvas component, PixelFormat pixel_format, boolean support_pbuffer) throws LWJGLException { super(pixel_format, support_pbuffer); this.component = component; } diff --git a/src/java/org/lwjgl/opengl/MacOSXCanvasListener.java b/src/java/org/lwjgl/opengl/MacOSXCanvasListener.java index 9d8e31e9..c0111bf6 100644 --- a/src/java/org/lwjgl/opengl/MacOSXCanvasListener.java +++ b/src/java/org/lwjgl/opengl/MacOSXCanvasListener.java @@ -48,7 +48,7 @@ final class MacOSXCanvasListener implements ComponentListener, HierarchyListener private int height; private boolean context_update; - public MacOSXCanvasListener(Canvas canvas) { + MacOSXCanvasListener(Canvas canvas) { this.canvas = canvas; canvas.addComponentListener(this); canvas.addHierarchyListener(this); @@ -58,7 +58,7 @@ final class MacOSXCanvasListener implements ComponentListener, HierarchyListener public void disableListeners() { // Mac OS X applets will hang in Display.destroy() when parented when removing the listeners directly java.awt.EventQueue.invokeLater(new Runnable() { - public final void run() { + public void run() { canvas.removeComponentListener(MacOSXCanvasListener.this); canvas.removeHierarchyListener(MacOSXCanvasListener.this); } diff --git a/src/java/org/lwjgl/opengl/MacOSXCanvasPeerInfo.java b/src/java/org/lwjgl/opengl/MacOSXCanvasPeerInfo.java index afb604d0..46d7d79a 100644 --- a/src/java/org/lwjgl/opengl/MacOSXCanvasPeerInfo.java +++ b/src/java/org/lwjgl/opengl/MacOSXCanvasPeerInfo.java @@ -45,7 +45,7 @@ import org.lwjgl.LWJGLException; abstract class MacOSXCanvasPeerInfo extends MacOSXPeerInfo { private final AWTSurfaceLock awt_surface = new AWTSurfaceLock(); - public MacOSXCanvasPeerInfo(PixelFormat pixel_format, boolean support_pbuffer) throws LWJGLException { + protected MacOSXCanvasPeerInfo(PixelFormat pixel_format, boolean support_pbuffer) throws LWJGLException { super(pixel_format, true, true, support_pbuffer, true); } diff --git a/src/java/org/lwjgl/opengl/MacOSXContextAttribs.java b/src/java/org/lwjgl/opengl/MacOSXContextAttribs.java new file mode 100644 index 00000000..0baea275 --- /dev/null +++ b/src/java/org/lwjgl/opengl/MacOSXContextAttribs.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +/** + * An implementation of ContextAttribs for MacOS X. + *

    + * ---- WIP - No XGL_create_context has been defined for MacOS X yet ---- + * + * @author spasi + */ +final class MacOSXContextAttribs extends ContextAttribs { + + private static final int XGL_CONTEXT_MAJOR_VERSION_ARB = 0x2091; + private static final int XGL_CONTEXT_MINOR_VERSION_ARB = 0x2092; + private static final int XGL_CONTEXT_LAYER_PLANE_ARB = 0x2093; + private static final int XGL_CONTEXT_FLAGS_ARB = 0x2094; + + private static final int XGL_CONTEXT_DEBUG_BIT_ARB = 0x0001; + private static final int XGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB = 0x0002; + + MacOSXContextAttribs(final int majorVersion, final int minorVersion) { + super(majorVersion, minorVersion); + } + + MacOSXContextAttribs(final ContextAttribs attribs) { + super(attribs); + } + + protected int getMajorVersionAttrib() { + return XGL_CONTEXT_MAJOR_VERSION_ARB; + } + + protected int getMinorVersionAttrib() { + return XGL_CONTEXT_MINOR_VERSION_ARB; + } + + protected int getLayerPlaneAttrib() { + return XGL_CONTEXT_LAYER_PLANE_ARB; + } + + protected int getFlagsAttrib() { + return XGL_CONTEXT_FLAGS_ARB; + } + + protected int getDebugBit() { + return XGL_CONTEXT_DEBUG_BIT_ARB; + } + + protected int getForwardCombatibleBit() { + return XGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB; + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opengl/MacOSXContextImplementation.java b/src/java/org/lwjgl/opengl/MacOSXContextImplementation.java index 88fa0a66..69317b68 100644 --- a/src/java/org/lwjgl/opengl/MacOSXContextImplementation.java +++ b/src/java/org/lwjgl/opengl/MacOSXContextImplementation.java @@ -31,56 +31,62 @@ */ package org.lwjgl.opengl; -import java.nio.ByteBuffer; - import org.lwjgl.LWJGLException; +import java.nio.ByteBuffer; +import java.nio.IntBuffer; + /** - * * @author elias_naur * @version $Revision$ - * $Id$ + * $Id$ */ final class MacOSXContextImplementation implements ContextImplementation { - public ByteBuffer create(PeerInfo peer_info, ByteBuffer shared_context_handle) throws LWJGLException { + + public ByteBuffer create(PeerInfo peer_info, IntBuffer attribs, ByteBuffer shared_context_handle) throws LWJGLException { ByteBuffer peer_handle = peer_info.lockAndGetHandle(); try { - return nCreate(peer_handle, shared_context_handle); + return nCreate(peer_handle, attribs, shared_context_handle); } finally { peer_info.unlock(); } } - private static native ByteBuffer nCreate(ByteBuffer peer_handle, ByteBuffer shared_context_handle) throws LWJGLException; + + private static native ByteBuffer nCreate(ByteBuffer peer_handle, IntBuffer attribs, ByteBuffer shared_context_handle) throws LWJGLException; public void swapBuffers() throws LWJGLException { Context current_context = Context.getCurrentContext(); - if (current_context == null) + if ( current_context == null ) throw new IllegalStateException("No context is current"); - synchronized (current_context) { + synchronized ( current_context ) { nSwapBuffers(current_context.getHandle()); } } + private static native void nSwapBuffers(ByteBuffer context_handle) throws LWJGLException; public void update(ByteBuffer context_handle) { nUpdate(context_handle); } + private static native void nUpdate(ByteBuffer context_handle); public void releaseCurrentContext() throws LWJGLException { nReleaseCurrentContext(); } + private static native void nReleaseCurrentContext() throws LWJGLException; public void releaseDrawable(ByteBuffer context_handle) throws LWJGLException { clearDrawable(context_handle); } + private static native void clearDrawable(ByteBuffer handle) throws LWJGLException; static void resetView(PeerInfo peer_info, Context context) throws LWJGLException { ByteBuffer peer_handle = peer_info.lockAndGetHandle(); try { - synchronized (context) { + synchronized ( context ) { clearDrawable(context.getHandle()); setView(peer_handle, context.getHandle()); } @@ -88,7 +94,7 @@ final class MacOSXContextImplementation implements ContextImplementation { peer_info.unlock(); } } - + public void makeCurrent(PeerInfo peer_info, ByteBuffer handle) throws LWJGLException { ByteBuffer peer_handle = peer_info.lockAndGetHandle(); try { @@ -98,25 +104,30 @@ final class MacOSXContextImplementation implements ContextImplementation { peer_info.unlock(); } } + private static native void setView(ByteBuffer peer_handle, ByteBuffer context_handle) throws LWJGLException; + private static native void nMakeCurrent(ByteBuffer context_handle) throws LWJGLException; public boolean isCurrent(ByteBuffer handle) throws LWJGLException { boolean result = nIsCurrent(handle); return result; } + private static native boolean nIsCurrent(ByteBuffer context_handle) throws LWJGLException; public void setSwapInterval(int value) { Context current_context = Context.getCurrentContext(); - synchronized (current_context) { + synchronized ( current_context ) { nSetSwapInterval(current_context.getHandle(), value); } } + private static native void nSetSwapInterval(ByteBuffer context_handle, int value); public void destroy(PeerInfo peer_info, ByteBuffer handle) throws LWJGLException { nDestroy(handle); } + private static native void nDestroy(ByteBuffer context_handle) throws LWJGLException; } diff --git a/src/java/org/lwjgl/opengl/MacOSXDisplayPeerInfo.java b/src/java/org/lwjgl/opengl/MacOSXDisplayPeerInfo.java index 8a16aabb..4cd7af28 100644 --- a/src/java/org/lwjgl/opengl/MacOSXDisplayPeerInfo.java +++ b/src/java/org/lwjgl/opengl/MacOSXDisplayPeerInfo.java @@ -44,7 +44,7 @@ import org.lwjgl.LWJGLException; final class MacOSXDisplayPeerInfo extends MacOSXCanvasPeerInfo { private boolean locked = false; - public MacOSXDisplayPeerInfo(PixelFormat pixel_format, boolean support_pbuffer) throws LWJGLException { + MacOSXDisplayPeerInfo(PixelFormat pixel_format, boolean support_pbuffer) throws LWJGLException { super(pixel_format, support_pbuffer); } diff --git a/src/java/org/lwjgl/opengl/MacOSXPbufferPeerInfo.java b/src/java/org/lwjgl/opengl/MacOSXPbufferPeerInfo.java index 7456fac2..9995bbb9 100644 --- a/src/java/org/lwjgl/opengl/MacOSXPbufferPeerInfo.java +++ b/src/java/org/lwjgl/opengl/MacOSXPbufferPeerInfo.java @@ -42,7 +42,7 @@ import org.lwjgl.LWJGLException; * $Id$ */ final class MacOSXPbufferPeerInfo extends MacOSXPeerInfo { - public MacOSXPbufferPeerInfo(int width, int height, PixelFormat pixel_format) throws LWJGLException { + MacOSXPbufferPeerInfo(int width, int height, PixelFormat pixel_format) throws LWJGLException { super(pixel_format, false, false, true, false); nCreate(getHandle(), width, height); } diff --git a/src/java/org/lwjgl/opengl/MacOSXPeerInfo.java b/src/java/org/lwjgl/opengl/MacOSXPeerInfo.java index aa77b23f..a8618f6b 100644 --- a/src/java/org/lwjgl/opengl/MacOSXPeerInfo.java +++ b/src/java/org/lwjgl/opengl/MacOSXPeerInfo.java @@ -43,7 +43,7 @@ import org.lwjgl.LWJGLUtil; * $Id$ */ abstract class MacOSXPeerInfo extends PeerInfo { - public MacOSXPeerInfo(PixelFormat pixel_format, boolean use_display_bpp, boolean support_window, boolean support_pbuffer, boolean double_buffered) throws LWJGLException { + MacOSXPeerInfo(PixelFormat pixel_format, boolean use_display_bpp, boolean support_window, boolean support_pbuffer, boolean double_buffered) throws LWJGLException { super(createHandle()); if (pixel_format.isFloatingPoint() && !LWJGLUtil.isMacOSXEqualsOrBetterThan(10, 4)) throw new LWJGLException("Floating point pixel format requested, but is not supported"); diff --git a/src/java/org/lwjgl/opengl/Pbuffer.java b/src/java/org/lwjgl/opengl/Pbuffer.java index a63d92d3..e0a40561 100644 --- a/src/java/org/lwjgl/opengl/Pbuffer.java +++ b/src/java/org/lwjgl/opengl/Pbuffer.java @@ -197,6 +197,31 @@ public final class Pbuffer implements Drawable { * with the Display context (if created). */ public Pbuffer(int width, int height, PixelFormat pixel_format, RenderTexture renderTexture, Drawable shared_drawable) throws LWJGLException { + this(width, height, pixel_format, renderTexture, shared_drawable, null); + } + + /** + * Create an instance of a Pbuffer with a unique OpenGL context. The buffer is single-buffered. + *

    + * NOTE: The Pbuffer will have its own context that shares display lists and textures with shared_context, + * or, if shared_context is null, the Display context if it is created. The Pbuffer + * will have its own OpenGL state. Therefore, state changes to a pbuffer will not be seen in the window context and vice versa. + *

    + * The renderTexture parameter defines the necessary state for enabling render-to-texture. When this parameter is null, + * render-to-texture is not available. Before using render-to-texture, the Pbuffer capabilities must be queried to ensure that + * it is supported. Currently only windows platform can support this feature, so it is recommended that EXT_framebuffer_object + * or similar is used if available, for maximum portability. + *

    + * + * @param width Pbuffer width + * @param height Pbuffer height + * @param pixel_format Minimum Pbuffer context properties + * @param renderTexture + * @param shared_drawable If non-null the Pbuffer will share display lists and textures with it. Otherwise, the Pbuffer will share + * with the Display context (if created). + * @param attribs The ContextAttribs to use when creating the context. (optional, may be null) + */ + public Pbuffer(int width, int height, PixelFormat pixel_format, RenderTexture renderTexture, Drawable shared_drawable, ContextAttribs attribs) throws LWJGLException { if (pixel_format == null) throw new NullPointerException("Pixel format must be non-null"); this.width = width; @@ -210,7 +235,7 @@ public final class Pbuffer implements Drawable { if (display_drawable != null) shared_context = display_drawable.getContext(); } - this.context = new Context(peer_info, shared_context); + this.context = new Context(peer_info, attribs, shared_context); } private static PeerInfo createPbuffer(int width, int height, PixelFormat pixel_format, RenderTexture renderTexture) throws LWJGLException { @@ -229,7 +254,7 @@ public final class Pbuffer implements Drawable { public Context getContext() { return context; } - + private void checkDestroyed() { if (destroyed) throw new IllegalStateException("Pbuffer is destroyed"); diff --git a/src/java/org/lwjgl/opengl/PeerInfo.java b/src/java/org/lwjgl/opengl/PeerInfo.java index b55e1276..98d919aa 100644 --- a/src/java/org/lwjgl/opengl/PeerInfo.java +++ b/src/java/org/lwjgl/opengl/PeerInfo.java @@ -51,10 +51,10 @@ abstract class PeerInfo { this.handle = handle; } - private final void lockAndInitHandle() throws LWJGLException { + private void lockAndInitHandle() throws LWJGLException { doLockAndInitHandle(); } - + public synchronized final void unlock() throws LWJGLException { if (lock_count <= 0) throw new IllegalStateException("PeerInfo not locked!"); diff --git a/src/java/org/lwjgl/opengl/PixelFormat.java b/src/java/org/lwjgl/opengl/PixelFormat.java index bcb0c0e4..bb8d3faa 100644 --- a/src/java/org/lwjgl/opengl/PixelFormat.java +++ b/src/java/org/lwjgl/opengl/PixelFormat.java @@ -1,31 +1,31 @@ -/* +/* * Copyright (c) 2002-2008 LWJGL Project * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are + * modification, are permitted provided that the following conditions are * met: - * - * * Redistributions of source code must retain the above copyright + * + * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ @@ -35,42 +35,51 @@ package org.lwjgl.opengl; * This class describes pixel format properties for an OpenGL context. Instances * of this class is used as arguments to Display.create(), Pbuffer.create() and * AWTGLCanvas, to indicate minimum required properties. - * + *

    + * Instants of this class are immutable. An example of the expected way to set + * the PixelFormat property values is the following: + * PixelFormat pf = new PixelFormat().withDepth(24).withSamples(4).withSRGB(true); + *

    * WARNING: Some pixel formats are known to cause troubles on certain buggy drivers. - * Example: Under Windows, specifying samples != 0 will enable the ARB - * pixel format selection path, which could trigger a crash. + * Example: Under Windows, specifying samples != 0 will enable the ARB + * pixel format selection path, which could trigger a crash. * * @author elias_naur@sourceforge.net * @version $Revision$ */ public final class PixelFormat { + /** - * The number of bits per pixel, exluding alpha. + * The number of bits per pixel, exluding alpha. * This parameter is ignored in Display.create(). */ - private final int bpp; + private int bpp; /** The number of alpha bits. */ - private final int alpha; - /** The number of depth buffer bits*/ - private final int depth; + private int alpha; + /** The number of depth buffer bits */ + private int depth; /** The number of stencil bits */ - private final int stencil; + private int stencil; /** * The number of samples to use in anti-aliasing. * 0 means that anti-aliasing is disabled. */ - private final int samples; - /** The number of auxilliary buffers */ - private final int num_aux_buffers; + private int samples; + /** The number of auxiliary buffers */ + private int num_aux_buffers; /** The number of bits per pixel in the accumulation buffer */ - private final int accum_bpp; + private int accum_bpp; /** The number of alpha bits in the accumulation buffer */ - private final int accum_alpha; + private int accum_alpha; /** Whether this format requires a stereo buffer */ - private final boolean stereo; + private boolean stereo; /** Whether this format specifies a floating point format */ - private final boolean floating_point; + private boolean floating_point; + /** Whether this format specifies a packed floating point format (32 bit unsigned - R11F_G11F_B10F) */ + private boolean floating_point_packed; + /** Whether this format specifies an sRGB format */ + private boolean sRGB; /** * Default pixel format is minimum 8 bits depth, and no alpha @@ -101,51 +110,269 @@ public final class PixelFormat { this.alpha = alpha; this.depth = depth; this.stencil = stencil; + this.samples = samples; + this.num_aux_buffers = num_aux_buffers; + this.accum_bpp = accum_bpp; this.accum_alpha = accum_alpha; + this.stereo = stereo; + this.floating_point = floating_point; + this.floating_point_packed = false; + this.sRGB = false; + } + + private PixelFormat(final PixelFormat pf) { + this.bpp = pf.bpp; + this.alpha = pf.alpha; + this.depth = pf.depth; + this.stencil = pf.stencil; + + this.samples = pf.samples; + + this.num_aux_buffers = pf.num_aux_buffers; + + this.accum_bpp = pf.accum_bpp; + this.accum_alpha = pf.accum_alpha; + + this.stereo = pf.stereo; + + this.floating_point = pf.floating_point; + this.floating_point_packed = pf.floating_point_packed; + this.sRGB = pf.sRGB; } public int getBitsPerPixel() { return bpp; } + /** + * Returns a new PixelFormat object with the same properties as this PixelFormat and the new bits per pixel value. + * + * @param bpp the new bits per pixel value. + * + * @return the new PixelFormat + */ + public PixelFormat withBitsPerPixel(final int bpp) { + if ( bpp < 0 ) + throw new IllegalArgumentException("Invalid number of bits per pixel specified: " + bpp); + + final PixelFormat pf = new PixelFormat(this); + pf.bpp = bpp; + return pf; + } + public int getAlphaBits() { return alpha; } + /** + * Returns a new PixelFormat object with the same properties as this PixelFormat and the new alpha bits value. + * + * @param alpha the new alpha bits value. + * + * @return the new PixelFormat + */ + public PixelFormat withAlphaBits(final int alpha) { + if ( alpha < 0 ) + throw new IllegalArgumentException("Invalid number of alpha bits specified: " + alpha); + + final PixelFormat pf = new PixelFormat(this); + pf.alpha = alpha; + return pf; + } + public int getDepthBits() { return depth; } + /** + * Returns a new PixelFormat object with the same properties as this PixelFormat and the new depth bits value. + * + * @param depth the new depth bits value. + * + * @return the new PixelFormat + */ + public PixelFormat withDepthBits(final int depth) { + if ( depth < 0 ) + throw new IllegalArgumentException("Invalid number of depth bits specified: " + depth); + + final PixelFormat pf = new PixelFormat(this); + pf.depth = depth; + return pf; + } + public int getStencilBits() { return stencil; } + /** + * Returns a new PixelFormat object with the same properties as this PixelFormat and the new stencil bits value. + * + * @param stencil the new stencil bits value. + * + * @return the new PixelFormat + */ + public PixelFormat withStencilBits(final int stencil) { + if ( stencil < 0 ) + throw new IllegalArgumentException("Invalid number of stencil bits specified: " + stencil); + + final PixelFormat pf = new PixelFormat(this); + pf.stencil = stencil; + return pf; + } + public int getSamples() { return samples; } + /** + * Returns a new PixelFormat object with the same properties as this PixelFormat and the new samples value. + * + * @param samples the new samples value. + * + * @return the new PixelFormat + */ + public PixelFormat withSamples(final int samples) { + if ( samples < 0 ) + throw new IllegalArgumentException("Invalid number of samples specified: " + samples); + + final PixelFormat pf = new PixelFormat(this); + pf.samples = samples; + return pf; + } + public int getAuxBuffers() { return num_aux_buffers; } + /** + * Returns a new PixelFormat object with the same properties as this PixelFormat and the new auxiliary buffers value. + * + * @param num_aux_buffers the new auxiliary buffers value. + * + * @return the new PixelFormat + */ + public PixelFormat withAuxBuffers(final int num_aux_buffers) { + if ( num_aux_buffers < 0 ) + throw new IllegalArgumentException("Invalid number of auxiliary buffers specified: " + num_aux_buffers); + + final PixelFormat pf = new PixelFormat(this); + pf.num_aux_buffers = num_aux_buffers; + return pf; + } + public int getAccumulationBitsPerPixel() { return accum_bpp; } + /** + * Returns a new PixelFormat object with the same properties as this PixelFormat and the new bits per pixel in the accumulation buffer value. + * + * @param accum_bpp the new bits per pixel in the accumulation buffer value. + * + * @return the new PixelFormat + */ + public PixelFormat withAccumulationBitsPerPixel(final int accum_bpp) { + if ( accum_bpp < 0 ) + throw new IllegalArgumentException("Invalid number of bits per pixel in the accumulation buffer specified: " + accum_bpp); + + final PixelFormat pf = new PixelFormat(this); + pf.accum_bpp = accum_bpp; + return pf; + } + public int getAccumulationAlpha() { return accum_alpha; } + /** + * Returns a new PixelFormat object with the same properties as this PixelFormat and the new alpha bits in the accumulation buffer value. + * + * @param accum_alpha the new alpha bits in the accumulation buffer value. + * + * @return the new PixelFormat + */ + public PixelFormat withAccumulationAlpha(final int accum_alpha) { + if ( accum_alpha < 0 ) + throw new IllegalArgumentException("Invalid number of alpha bits in the accumulation buffer specified: " + accum_alpha); + + final PixelFormat pf = new PixelFormat(this); + pf.accum_alpha = accum_alpha; + return pf; + } + public boolean isStereo() { return stereo; } - + + /** + * Returns a new PixelFormat object with the same properties as this PixelFormat and the new stereo value. + * + * @param stereo the new stereo value. + * + * @return the new PixelFormat + */ + public PixelFormat withStereo(final boolean stereo) { + final PixelFormat pf = new PixelFormat(this); + pf.stereo = stereo; + return pf; + } + public boolean isFloatingPoint() { return floating_point; } -} + + /** + * Returns a new PixelFormat object with the same properties as this PixelFormat and the new floating point value. + * If floating_point is true, floating_point_packed will be reset to false. + * + * @param floating_point the new floating point value. + * + * @return the new PixelFormat + */ + public PixelFormat withFloatingPoint(final boolean floating_point) { + final PixelFormat pf = new PixelFormat(this); + pf.floating_point = floating_point; + if ( floating_point ) + pf.floating_point_packed = false; + return pf; + } + + /** + * Returns a new PixelFormat object with the same properties as this PixelFormat and the new packed floating point value. + * If floating_point_packed is true, floating_point will be reset to false. + * + * @param floating_point_packed the new packed floating point value. + * + * @return the new PixelFormat + */ + public PixelFormat withFloatingPointPacked(final boolean floating_point_packed) { + final PixelFormat pf = new PixelFormat(this); + pf.floating_point_packed = floating_point_packed; + if ( floating_point_packed ) + pf.floating_point = false; + return pf; + } + + public boolean isSRGB() { + return sRGB; + } + + /** + * Returns a new PixelFormat object with the same properties as this PixelFormat and the new sRGB value. + * + * @param sRGB the new floating point value. + * + * @return the new PixelFormat + */ + public PixelFormat withSRGB(final boolean sRGB) { + final PixelFormat pf = new PixelFormat(this); + pf.sRGB = sRGB; + return pf; + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opengl/WindowsAWTGLCanvasPeerInfo.java b/src/java/org/lwjgl/opengl/WindowsAWTGLCanvasPeerInfo.java index 7a317812..c3d3feff 100644 --- a/src/java/org/lwjgl/opengl/WindowsAWTGLCanvasPeerInfo.java +++ b/src/java/org/lwjgl/opengl/WindowsAWTGLCanvasPeerInfo.java @@ -49,7 +49,7 @@ final class WindowsAWTGLCanvasPeerInfo extends WindowsPeerInfo { private final PixelFormat pixel_format; private boolean has_pixel_format= false; - public WindowsAWTGLCanvasPeerInfo(Canvas component, PixelFormat pixel_format) { + WindowsAWTGLCanvasPeerInfo(Canvas component, PixelFormat pixel_format) { this.component = component; this.pixel_format = pixel_format; } diff --git a/src/java/org/lwjgl/opengl/WindowsContextAttribs.java b/src/java/org/lwjgl/opengl/WindowsContextAttribs.java new file mode 100644 index 00000000..79a79192 --- /dev/null +++ b/src/java/org/lwjgl/opengl/WindowsContextAttribs.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +/** + * An implementation of ContextAttribs using WGL_create_context. + * + * @author spasi + */ +final class WindowsContextAttribs extends ContextAttribs { + + private static final int WGL_CONTEXT_MAJOR_VERSION_ARB = 0x2091; + private static final int WGL_CONTEXT_MINOR_VERSION_ARB = 0x2092; + private static final int WGL_CONTEXT_LAYER_PLANE_ARB = 0x2093; + private static final int WGL_CONTEXT_FLAGS_ARB = 0x2094; + + private static final int WGL_CONTEXT_DEBUG_BIT_ARB = 0x0001; + private static final int WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB = 0x0002; + + WindowsContextAttribs(final int majorVersion, final int minorVersion) { + super(majorVersion, minorVersion); + } + + WindowsContextAttribs(final ContextAttribs attribs) { + super(attribs); + } + + protected int getMajorVersionAttrib() { + return WGL_CONTEXT_MAJOR_VERSION_ARB; + } + + protected int getMinorVersionAttrib() { + return WGL_CONTEXT_MINOR_VERSION_ARB; + } + + protected int getLayerPlaneAttrib() { + return WGL_CONTEXT_LAYER_PLANE_ARB; + } + + protected int getFlagsAttrib() { + return WGL_CONTEXT_FLAGS_ARB; + } + + protected int getDebugBit() { + return WGL_CONTEXT_DEBUG_BIT_ARB; + } + + protected int getForwardCombatibleBit() { + return WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB; + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opengl/WindowsContextImplementation.java b/src/java/org/lwjgl/opengl/WindowsContextImplementation.java index ec762392..c0169667 100644 --- a/src/java/org/lwjgl/opengl/WindowsContextImplementation.java +++ b/src/java/org/lwjgl/opengl/WindowsContextImplementation.java @@ -31,33 +31,35 @@ */ package org.lwjgl.opengl; -import java.nio.ByteBuffer; - import org.lwjgl.LWJGLException; import org.lwjgl.LWJGLUtil; +import java.nio.ByteBuffer; +import java.nio.IntBuffer; + /** - * * @author elias_naur * @version $Revision$ - * $Id$ + * $Id$ */ final class WindowsContextImplementation implements ContextImplementation { - public ByteBuffer create(PeerInfo peer_info, ByteBuffer shared_context_handle) throws LWJGLException { + + public ByteBuffer create(PeerInfo peer_info, IntBuffer attribs, ByteBuffer shared_context_handle) throws LWJGLException { ByteBuffer peer_handle = peer_info.lockAndGetHandle(); try { - return nCreate(peer_handle, shared_context_handle); + return nCreate(peer_handle, attribs, shared_context_handle); } finally { peer_info.unlock(); } } - private static native ByteBuffer nCreate(ByteBuffer peer_handle, ByteBuffer shared_context_handle) throws LWJGLException; + + private static native ByteBuffer nCreate(ByteBuffer peer_handle, IntBuffer attribs_handle, ByteBuffer shared_context_handle) throws LWJGLException; public void swapBuffers() throws LWJGLException { Context current_context = Context.getCurrentContext(); - if (current_context == null) + if ( current_context == null ) throw new IllegalStateException("No context is current"); - synchronized (current_context) { + synchronized ( current_context ) { PeerInfo current_peer_info = current_context.getPeerInfo(); ByteBuffer peer_handle = current_peer_info.lockAndGetHandle(); try { @@ -67,6 +69,7 @@ final class WindowsContextImplementation implements ContextImplementation { } } } + private static native void nSwapBuffers(ByteBuffer peer_info_handle) throws LWJGLException; public void releaseDrawable(ByteBuffer context_handle) throws LWJGLException { @@ -78,6 +81,7 @@ final class WindowsContextImplementation implements ContextImplementation { public void releaseCurrentContext() throws LWJGLException { nReleaseCurrentContext(); } + private static native void nReleaseCurrentContext() throws LWJGLException; public void makeCurrent(PeerInfo peer_info, ByteBuffer handle) throws LWJGLException { @@ -88,24 +92,28 @@ final class WindowsContextImplementation implements ContextImplementation { peer_info.unlock(); } } + private static native void nMakeCurrent(ByteBuffer peer_handle, ByteBuffer context_handle) throws LWJGLException; public boolean isCurrent(ByteBuffer handle) throws LWJGLException { boolean result = nIsCurrent(handle); return result; } + private static native boolean nIsCurrent(ByteBuffer context_handle) throws LWJGLException; public void setSwapInterval(int value) { boolean success = nSetSwapInterval(value); - if (!success) + if ( !success ) LWJGLUtil.log("Failed to set swap interval"); Util.checkGLError(); } + private static native boolean nSetSwapInterval(int value); public void destroy(PeerInfo peer_info, ByteBuffer handle) throws LWJGLException { nDestroy(handle); } + private static native void nDestroy(ByteBuffer context_handle) throws LWJGLException; } diff --git a/src/java/org/lwjgl/opengl/WindowsDisplay.java b/src/java/org/lwjgl/opengl/WindowsDisplay.java index 81578d5e..246b50c9 100644 --- a/src/java/org/lwjgl/opengl/WindowsDisplay.java +++ b/src/java/org/lwjgl/opengl/WindowsDisplay.java @@ -150,7 +150,7 @@ final class WindowsDisplay implements DisplayImplementation { private long small_icon; private long large_icon; - public WindowsDisplay() { + WindowsDisplay() { current_display = this; } @@ -191,7 +191,7 @@ final class WindowsDisplay implements DisplayImplementation { private native long nCreateWindow(boolean fullscreen, int x, int y, int width, int height, boolean undecorated, boolean child_window, long parent_hwnd) throws LWJGLException; private static boolean isUndecorated() { - return Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated"); + return Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated"); } private static long getHwnd(Canvas parent) throws LWJGLException { @@ -200,7 +200,7 @@ final class WindowsDisplay implements DisplayImplementation { ByteBuffer parent_peer_info_handle = parent_peer_info.lockAndGetHandle(); try { return parent_peer_info.getHwnd(); - } finally { + } finally { parent_peer_info.unlock(); } } @@ -350,7 +350,7 @@ final class WindowsDisplay implements DisplayImplementation { } return null; } - + public String getVersion() { String driver = getAdapter(); if (driver != null) { @@ -449,11 +449,11 @@ final class WindowsDisplay implements DisplayImplementation { public void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons) { mouse.poll(coord_buffer, buttons); } - + public void readMouse(ByteBuffer buffer) { mouse.read(buffer); } - + public void grabMouse(boolean grab) { mouse.grab(grab, shouldGrab()); updateCursor(); @@ -540,11 +540,11 @@ final class WindowsDisplay implements DisplayImplementation { keyboard.destroy(); keyboard = null; } - + public void pollKeyboard(ByteBuffer keyDownBuffer) { keyboard.poll(keyDownBuffer); } - + public void readKeyboard(ByteBuffer buffer) { keyboard.read(buffer); } @@ -576,7 +576,7 @@ final class WindowsDisplay implements DisplayImplementation { } } private native int nGetPbufferCapabilities(PixelFormat format) throws LWJGLException; - + public boolean isBufferLost(PeerInfo handle) { return ((WindowsPbufferPeerInfo)handle).isBufferLost(); } @@ -586,7 +586,7 @@ final class WindowsDisplay implements DisplayImplementation { IntBuffer pBufferAttribs) throws LWJGLException { return new WindowsPbufferPeerInfo(width, height, pixel_format, pixelFormatCaps, pBufferAttribs); } - + public void setPbufferAttrib(PeerInfo handle, int attrib, int value) { ((WindowsPbufferPeerInfo)handle).setPbufferAttrib(attrib, value); } @@ -594,11 +594,11 @@ final class WindowsDisplay implements DisplayImplementation { public void bindTexImageToPbuffer(PeerInfo handle, int buffer) { ((WindowsPbufferPeerInfo)handle).bindTexImageToPbuffer(buffer); } - + public void releaseTexImageFromPbuffer(PeerInfo handle, int buffer) { ((WindowsPbufferPeerInfo)handle).releaseTexImageFromPbuffer(buffer); } - + private void freeSmallIcon() { if (small_icon != 0) { destroyIcon(small_icon); @@ -629,12 +629,12 @@ final class WindowsDisplay implements DisplayImplementation { boolean done_small = false; boolean done_large = false; int used = 0; - + int small_icon_size = 16; int large_icon_size = 32; for (int i=0;i>> 15) & 0x1; + int key_state = (GetKeyState(virt_key) >>> 15) & 0x1; int lwjgl_code = WindowsKeycodes.mapVirtualKeyToLWJGLCode(virt_key); return (key_down_buffer[lwjgl_code] == 1 - state) && (key_state == state); } diff --git a/src/java/org/lwjgl/opengl/WindowsMouse.java b/src/java/org/lwjgl/opengl/WindowsMouse.java index f2b1d0d3..6aa33544 100644 --- a/src/java/org/lwjgl/opengl/WindowsMouse.java +++ b/src/java/org/lwjgl/opengl/WindowsMouse.java @@ -63,7 +63,7 @@ final class WindowsMouse { private int last_x; private int last_y; - public WindowsMouse(long hwnd) throws LWJGLException { + WindowsMouse(long hwnd) throws LWJGLException { this.hwnd = hwnd; this.mouse_button_count = WindowsDisplay.getSystemMetrics(WindowsDisplay.SM_CMOUSEBUTTONS); this.has_wheel = WindowsDisplay.getSystemMetrics(WindowsDisplay.SM_MOUSEWHEELPRESENT) != 0; @@ -109,7 +109,7 @@ final class WindowsMouse { } accum_dx = accum_dy = accum_dwheel = 0; } - + private void putMouseEventWithCoords(byte button, byte state, int coord1, int coord2, int dz, long nanos) { mouse_event.clear(); mouse_event.put(button).put(state).putInt(coord1).putInt(coord2).putInt(dz).putLong(nanos); @@ -149,7 +149,7 @@ final class WindowsMouse { if (mouse_grabbed) { mouse_grabbed = false; WindowsDisplay.resetCursorClipping(); - } + } } event_queue.clearEvents(); } diff --git a/src/java/org/lwjgl/opengl/WindowsPbufferPeerInfo.java b/src/java/org/lwjgl/opengl/WindowsPbufferPeerInfo.java index 50f039d2..840cdf3c 100644 --- a/src/java/org/lwjgl/opengl/WindowsPbufferPeerInfo.java +++ b/src/java/org/lwjgl/opengl/WindowsPbufferPeerInfo.java @@ -43,7 +43,7 @@ import org.lwjgl.LWJGLException; * $Id$ */ final class WindowsPbufferPeerInfo extends WindowsPeerInfo { - public WindowsPbufferPeerInfo(int width, int height, PixelFormat pixel_format, IntBuffer pixelFormatCaps, IntBuffer pBufferAttribs) throws LWJGLException { + WindowsPbufferPeerInfo(int width, int height, PixelFormat pixel_format, IntBuffer pixelFormatCaps, IntBuffer pBufferAttribs) throws LWJGLException { nCreate(getHandle(), width, height, pixel_format, pixelFormatCaps, pBufferAttribs); } private static native void nCreate(ByteBuffer handle, int width, int height, PixelFormat pixel_format, IntBuffer pixelFormatCaps, IntBuffer pBufferAttribs) throws LWJGLException; @@ -62,12 +62,12 @@ final class WindowsPbufferPeerInfo extends WindowsPeerInfo { nBindTexImageToPbuffer(getHandle(), buffer); } private static native void nBindTexImageToPbuffer(ByteBuffer handle, int buffer); - + public void releaseTexImageFromPbuffer(int buffer) { nReleaseTexImageFromPbuffer(getHandle(), buffer); } private static native void nReleaseTexImageFromPbuffer(ByteBuffer handle, int buffer); - + public void destroy() { nDestroy(getHandle()); } diff --git a/src/java/org/lwjgl/opengl/WindowsPeerInfo.java b/src/java/org/lwjgl/opengl/WindowsPeerInfo.java index bd602271..89fcaabb 100644 --- a/src/java/org/lwjgl/opengl/WindowsPeerInfo.java +++ b/src/java/org/lwjgl/opengl/WindowsPeerInfo.java @@ -43,7 +43,7 @@ import org.lwjgl.LWJGLException; * $Id$ */ abstract class WindowsPeerInfo extends PeerInfo { - public WindowsPeerInfo() { + protected WindowsPeerInfo() { super(createHandle()); } private static native ByteBuffer createHandle(); diff --git a/src/java/org/lwjgl/util/generator/ContextCapabilitiesGenerator.java b/src/java/org/lwjgl/util/generator/ContextCapabilitiesGenerator.java index 6131ecd2..62d6da09 100644 --- a/src/java/org/lwjgl/util/generator/ContextCapabilitiesGenerator.java +++ b/src/java/org/lwjgl/util/generator/ContextCapabilitiesGenerator.java @@ -37,20 +37,21 @@ import java.util.Arrays; import java.util.Collection; import java.util.EnumSet; import java.util.Iterator; +import java.lang.annotation.Annotation; import com.sun.mirror.declaration.InterfaceDeclaration; import com.sun.mirror.declaration.MethodDeclaration; import com.sun.mirror.type.InterfaceType; /** - * * Generator visitor for the context capabilities generator tool * * @author elias_naur * @version $Revision$ - * $Id$ + * $Id$ */ public class ContextCapabilitiesGenerator { + private final static String STUBS_LOADED_NAME = "loaded_stubs"; private final static String ALL_INIT_METHOD_NAME = "initAllStubs"; private final static String POINTER_INITIALIZER_POSTFIX = "_initNativeFunctionAddresses"; @@ -63,18 +64,18 @@ public class ContextCapabilitiesGenerator { writer.println("\tfinal StateTracker tracker;"); writer.println("\tfinal IntBuffer scratch_int_buffer = BufferUtils.createIntBuffer(16);"); writer.println(); - if (!context_specific) { + if ( !context_specific ) { writer.println("\tprivate static boolean " + STUBS_LOADED_NAME + " = false;"); } } public static void generateInitializerPrologue(PrintWriter writer) { - writer.println("\t" + Utils.CONTEXT_CAPS_CLASS_NAME + "() throws LWJGLException {"); - writer.println("\t\tSet " + CACHED_EXTS_VAR_NAME + " = " + ALL_INIT_METHOD_NAME + "();"); + writer.println("\t" + Utils.CONTEXT_CAPS_CLASS_NAME + "(boolean forwardCombatible) throws LWJGLException {"); + writer.println("\t\tSet " + CACHED_EXTS_VAR_NAME + " = " + ALL_INIT_METHOD_NAME + "(forwardCombatible);"); } private static String translateFieldName(String interface_name) { - if (interface_name.startsWith("GL")) + if ( interface_name.startsWith("GL") ) return CORE_PREFIX + interface_name; else return EXTENSION_PREFIX + interface_name; @@ -82,9 +83,9 @@ public class ContextCapabilitiesGenerator { public static void generateSuperClassAdds(PrintWriter writer, InterfaceDeclaration d) { Collection super_interfaces = d.getSuperinterfaces(); - if (super_interfaces.size() > 1) + if ( super_interfaces.size() > 1 ) throw new RuntimeException(d + " extends more than one other interface"); - if (super_interfaces.size() == 1) { + if ( super_interfaces.size() == 1 ) { InterfaceType super_interface = super_interfaces.iterator().next(); writer.print("\t\tif (" + CACHED_EXTS_VAR_NAME + ".contains(\""); writer.println(translateFieldName(d.getSimpleName()) + "\"))"); @@ -99,9 +100,9 @@ public class ContextCapabilitiesGenerator { writer.print(CACHED_EXTS_VAR_NAME + ".contains(\""); writer.print(translated_field_name + "\")"); Collection super_interfaces = d.getSuperinterfaces(); - if (super_interfaces.size() > 1) + if ( super_interfaces.size() > 1 ) throw new RuntimeException(d + " extends more than one other interface"); - if (super_interfaces.size() == 1) { + if ( super_interfaces.size() == 1 ) { InterfaceType super_interface = super_interfaces.iterator().next(); writer.println(); writer.print("\t\t\t&& " + CACHED_EXTS_VAR_NAME + ".contains(\""); @@ -113,23 +114,26 @@ public class ContextCapabilitiesGenerator { private static String getAddressesInitializerName(String class_name) { return class_name + POINTER_INITIALIZER_POSTFIX; } - + public static void generateInitStubsPrologue(PrintWriter writer, boolean context_specific) { - writer.println("\tprivate Set " + ALL_INIT_METHOD_NAME + "() throws LWJGLException {"); - if (!context_specific) { + writer.println("\tprivate Set " + ALL_INIT_METHOD_NAME + "(boolean forwardCombatible) throws LWJGLException {"); + if ( !context_specific ) { writer.println("\t\tif (" + STUBS_LOADED_NAME + ")"); writer.println("\t\t\treturn GLContext.getSupportedExtensions();"); writer.println("\t\torg.lwjgl.opengl.GL11." + Utils.STUB_INITIALIZER_NAME + "();"); } else { - writer.println("\t\tif (!" + getAddressesInitializerName("GL11") + "())"); + writer.println("\t\tif (!" + getAddressesInitializerName("GL11") + "(forwardCombatible))"); writer.println("\t\t\tthrow new LWJGLException(\"GL11 not supported\");"); } + // Try to initialize GL30.glGetStringi here, in case we have created an OpenGL 3.0 context + // (it will be used in GLContext.getSupportedExtensions) + writer.println("\t\tGL30_glGetStringi_pointer = GLContext.getFunctionAddress(\"glGetStringi\");"); writer.println("\t\tGLContext.setCapabilities(this);"); writer.println("\t\tSet " + CACHED_EXTS_VAR_NAME + " = GLContext.getSupportedExtensions();"); } public static void generateInitStubsEpilogue(PrintWriter writer, boolean context_specific) { - if (!context_specific) { + if ( !context_specific ) { writer.println("\t\t" + STUBS_LOADED_NAME + " = true;"); } writer.println("\t\treturn " + CACHED_EXTS_VAR_NAME + ";"); @@ -137,19 +141,28 @@ public class ContextCapabilitiesGenerator { } public static void generateUnloadStubs(PrintWriter writer, InterfaceDeclaration d) { - if (d.getMethods().size() > 0) { + if ( d.getMethods().size() > 0 ) { writer.print("\t\tGLContext.resetNativeStubs(" + Utils.getSimpleClassName(d)); writer.println(".class);"); } } public static void generateInitStubs(PrintWriter writer, InterfaceDeclaration d, boolean context_specific) { - if (d.getMethods().size() > 0) { - if (context_specific) { + if ( d.getMethods().size() > 0 ) { + if ( context_specific ) { writer.print("\t\tif (" + CACHED_EXTS_VAR_NAME + ".contains(\""); writer.print(translateFieldName(d.getSimpleName()) + "\")"); - writer.println(" && !" + getAddressesInitializerName(d.getSimpleName()) + "())"); - writer.print("\t\t\t" + CACHED_EXTS_VAR_NAME + ".remove(\""); + writer.print(" && !" + getAddressesInitializerName(d.getSimpleName()) + "("); + if ( d.getAnnotation(DeprecatedGL.class) != null ) + writer.print("forwardCombatible"); + if ( d.getAnnotation(Dependent.class) != null ) { + if ( d.getAnnotation(DeprecatedGL.class) != null ) + writer.print(","); + writer.print("supported_extensions"); + } + writer.println("))"); + //writer.print("\t\t\t" + CACHED_EXTS_VAR_NAME + ".remove(\""); + writer.print("\t\t\tremove(" + CACHED_EXTS_VAR_NAME + ", \""); writer.println(translateFieldName(d.getSimpleName()) + "\");"); } else { writer.print("\t\tGLContext." + Utils.STUB_INITIALIZER_NAME + "(" + Utils.getSimpleClassName(d)); @@ -157,7 +170,7 @@ public class ContextCapabilitiesGenerator { } } } - + private static void generateAddExtension(PrintWriter writer, InterfaceDeclaration d) { writer.print(CACHED_EXTS_VAR_NAME + ".add(\""); writer.println(translateFieldName(d.getSimpleName()) + "\");"); @@ -165,46 +178,71 @@ public class ContextCapabilitiesGenerator { public static void generateAddressesInitializers(PrintWriter writer, InterfaceDeclaration d) { Iterator methods = d.getMethods().iterator(); - if (methods.hasNext()) { - writer.println("\tprivate boolean " + getAddressesInitializerName(d.getSimpleName()) + "() {"); - writer.println("\t\treturn "); - while (methods.hasNext()) { - MethodDeclaration method = methods.next(); - writer.print("\t\t\t(" + Utils.getFunctionAddressName(d, method) + " = "); - PlatformDependent platform_dependent = method.getAnnotation(PlatformDependent.class); - if (platform_dependent != null) { - EnumSet platform_set = EnumSet.copyOf(Arrays.asList(platform_dependent.value())); - writer.print("GLContext.getPlatformSpecificFunctionAddress(\""); - writer.print(Platform.ALL.getPrefix() + "\", "); - writer.print("new String[]{"); - Iterator platforms = platform_set.iterator(); - while (platforms.hasNext()) { - writer.print("\"" + platforms.next().getOSPrefix() + "\""); - if(platforms.hasNext()) - writer.print(", "); - } - writer.print("}, new String[]{"); - platforms = platform_set.iterator(); - while (platforms.hasNext()) { - writer.print("\"" + platforms.next().getPrefix() + "\""); - if(platforms.hasNext()) - writer.print(", "); - } - writer.print("}, "); - } else - writer.print("GLContext.getFunctionAddress("); - writer.print("\"" + method.getSimpleName() + "\")) != 0"); - if (methods.hasNext()) - writer.println(" &&"); - } - writer.println(";"); - writer.println("\t}"); - writer.println(); + if ( !methods.hasNext() ) + return; + + writer.print("\tprivate boolean " + getAddressesInitializerName(d.getSimpleName()) + "("); + + DeprecatedGL deprecated = d.getAnnotation(DeprecatedGL.class); + Dependent dependent = d.getAnnotation(Dependent.class); + if ( deprecated != null ) + writer.print("boolean forwardCombatible"); + if ( dependent != null ) { + if ( deprecated != null ) + writer.print(","); + writer.print("Set supported_extensions"); } + + writer.println(") {"); + writer.println("\t\treturn "); + while ( methods.hasNext() ) { + MethodDeclaration method = methods.next(); + deprecated = method.getAnnotation(DeprecatedGL.class); + dependent = method.getAnnotation(Dependent.class); + + writer.print("\t\t\t("); + if ( deprecated != null ) + writer.print("forwardCombatible || "); + if ( dependent != null ) + writer.print("!supported_extensions.contains(\"" + dependent.value() + "\") || "); + if ( deprecated != null || dependent != null ) + writer.print('('); + writer.print(Utils.getFunctionAddressName(d, method) + " = "); + PlatformDependent platform_dependent = method.getAnnotation(PlatformDependent.class); + if ( platform_dependent != null ) { + EnumSet platform_set = EnumSet.copyOf(Arrays.asList(platform_dependent.value())); + writer.print("GLContext.getPlatformSpecificFunctionAddress(\""); + writer.print(Platform.ALL.getPrefix() + "\", "); + writer.print("new String[]{"); + Iterator platforms = platform_set.iterator(); + while ( platforms.hasNext() ) { + writer.print("\"" + platforms.next().getOSPrefix() + "\""); + if ( platforms.hasNext() ) + writer.print(", "); + } + writer.print("}, new String[]{"); + platforms = platform_set.iterator(); + while ( platforms.hasNext() ) { + writer.print("\"" + platforms.next().getPrefix() + "\""); + if ( platforms.hasNext() ) + writer.print(", "); + } + writer.print("}, "); + } else + writer.print("GLContext.getFunctionAddress("); + writer.print("\"" + method.getSimpleName() + "\")) != 0"); + if ( deprecated != null || dependent != null ) + writer.print(')'); + if ( methods.hasNext() ) + writer.println(" &&"); + } + writer.println(";"); + writer.println("\t}"); + writer.println(); } public static void generateSymbolAddresses(PrintWriter writer, InterfaceDeclaration d) { - for (MethodDeclaration method : d.getMethods()) { + for ( MethodDeclaration method : d.getMethods() ) { writer.println("\tlong " + Utils.getFunctionAddressName(d, method) + ";"); } } @@ -212,4 +250,4 @@ public class ContextCapabilitiesGenerator { public static void generateField(PrintWriter writer, InterfaceDeclaration d) { writer.println("\tpublic final boolean " + translateFieldName(d.getSimpleName()) + ";"); } -} +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/ContextGeneratorProcessorFactory.java b/src/java/org/lwjgl/util/generator/ContextGeneratorProcessorFactory.java index 9a040062..645027c0 100644 --- a/src/java/org/lwjgl/util/generator/ContextGeneratorProcessorFactory.java +++ b/src/java/org/lwjgl/util/generator/ContextGeneratorProcessorFactory.java @@ -64,7 +64,7 @@ import com.sun.mirror.util.DeclarationFilter; */ public class ContextGeneratorProcessorFactory implements AnnotationProcessorFactory, RoundCompleteListener { private static boolean first_round = true; - + // Process any set of annotations private static final Collection supportedAnnotations = unmodifiableCollection(Arrays.asList("*")); @@ -114,6 +114,7 @@ public class ContextGeneratorProcessorFactory implements AnnotationProcessorFact writer.println("package org.lwjgl.opengl;"); writer.println(); writer.println("import org.lwjgl.LWJGLException;"); + writer.println("import org.lwjgl.LWJGLUtil;"); writer.println("import org.lwjgl.BufferUtils;"); writer.println("import java.util.Set;"); writer.println("import java.nio.IntBuffer;"); @@ -139,6 +140,12 @@ public class ContextGeneratorProcessorFactory implements AnnotationProcessorFact } writer.println(); } + + writer.println("\tprivate static void remove(Set supported_extensions, String extension) {"); + writer.println("\t\tLWJGLUtil.log(extension + \" was reported as available but an entry point is missing\");"); + writer.println("\t\tsupported_extensions.remove(extension);"); + writer.println("\t}\n"); + ContextCapabilitiesGenerator.generateInitStubsPrologue(writer, context_specific); for (TypeDeclaration typedecl : interface_decls) { InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl; diff --git a/src/java/org/lwjgl/util/generator/Dependent.java b/src/java/org/lwjgl/util/generator/Dependent.java new file mode 100644 index 00000000..1741823a --- /dev/null +++ b/src/java/org/lwjgl/util/generator/Dependent.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.util.generator; + +/** + * Use this annotation on extensions with functionality that depends on the presence of other extensions. + * Functions in such extensions marked with this annotation will only be loaded if the specified extension is present. + * + * @author spasi + */ + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +@Target({ ElementType.TYPE, ElementType.METHOD }) +public @interface Dependent { + String value() default ""; +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/DeprecatedGL.java b/src/java/org/lwjgl/util/generator/DeprecatedGL.java new file mode 100644 index 00000000..21f0fcba --- /dev/null +++ b/src/java/org/lwjgl/util/generator/DeprecatedGL.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.util.generator; + +/** + * Use this annotation on extensions with deprecated functionality. + * Functions in such extensions marked with this annotation will not be loaded in a forward combatible context. + * + * @author spasi + */ + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +@Target({ ElementType.TYPE, ElementType.METHOD }) +public @interface DeprecatedGL { +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/GLtime.java b/src/java/org/lwjgl/util/generator/GLtime.java new file mode 100644 index 00000000..81506f1d --- /dev/null +++ b/src/java/org/lwjgl/util/generator/GLtime.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.util.generator; + +/** + * Unsigned binary representing an absolute absolute or relative time interval. + * Precision is nanoseconds but accuracy is implementation-dependent. + * + * @author spasi + */ + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +@NativeType +@Target({ElementType.PARAMETER, ElementType.METHOD}) +public @interface GLtime { +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java b/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java index 70d0f159..d933c8b9 100644 --- a/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java +++ b/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java @@ -283,6 +283,8 @@ public class JavaMethodsGenerator { result = method_name.substring(0, method_name.length() - (postfix.length() + 1 + extension_postfix.length())); else if (method_name.endsWith(postfix + extension_postfix)) result = method_name.substring(0, method_name.length() - (postfix.length() + extension_postfix.length())); + else if ( method_name.endsWith("_v" + extension_postfix) ) + result = method_name.substring(0, method_name.length() - (2 + extension_postfix.length())); else if (method_name.endsWith("v" + extension_postfix)) result = method_name.substring(0, method_name.length() - (1 + extension_postfix.length())); else diff --git a/src/native/linux/context.c b/src/native/linux/context.c index 6d5e5300..37ec2fea 100644 --- a/src/native/linux/context.c +++ b/src/native/linux/context.c @@ -1,35 +1,35 @@ -/* +/* * Copyright (c) 2002-2008 LWJGL Project * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are + * modification, are permitted provided that the following conditions are * met: - * - * * Redistributions of source code must retain the above copyright + * + * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + /** * $Id$ * @@ -122,14 +122,25 @@ static GLXFBConfig *chooseVisualGLX13FromBPP(JNIEnv *env, Display *disp, int scr int num_aux_buffers = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "num_aux_buffers", "I")); int accum_bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_bpp", "I")); int accum_alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_alpha", "I")); + bool stereo = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stereo", "Z")); bool floating_point = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z")); + bool floating_point_packed = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point_packed", "Z")); + bool sRGB = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "sRGB", "Z")); int bpe = convertToBPE(bpp); int accum_bpe = convertToBPE(accum_bpp); attrib_list_t attrib_list; initAttribList(&attrib_list); - int render_type = floating_point ? GLX_RGBA_FLOAT_BIT : GLX_RGBA_BIT; + int render_type; + + if ( floating_point ) + render_type = GLX_RGBA_FLOAT_BIT; + else if ( floating_point_packed ) + render_type = GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT; + else + render_type = GLX_RGBA_BIT; + putAttrib(&attrib_list, GLX_RENDER_TYPE); putAttrib(&attrib_list, render_type); putAttrib(&attrib_list, GLX_DOUBLEBUFFER); putAttrib(&attrib_list, double_buffer ? True : False); putAttrib(&attrib_list, GLX_DRAWABLE_TYPE); putAttrib(&attrib_list, drawable_type); @@ -152,6 +163,9 @@ static GLXFBConfig *chooseVisualGLX13FromBPP(JNIEnv *env, Display *disp, int scr putAttrib(&attrib_list, GLX_SAMPLE_BUFFERS_ARB); putAttrib(&attrib_list, 1); putAttrib(&attrib_list, GLX_SAMPLES_ARB); putAttrib(&attrib_list, samples); } + if (sRGB) { + putAttrib(&attrib_list, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB); putAttrib(&attrib_list, True); + } putAttrib(&attrib_list, None); putAttrib(&attrib_list, None); int num_formats = 0; GLXFBConfig* configs = lwjgl_glXChooseFBConfig(disp, screen, attrib_list.attribs, &num_formats); @@ -188,7 +202,9 @@ static XVisualInfo *chooseVisualGLXFromBPP(JNIEnv *env, Display *disp, int scree int num_aux_buffers = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "num_aux_buffers", "I")); int accum_bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_bpp", "I")); int accum_alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_alpha", "I")); + bool stereo = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stereo", "Z")); + bool sRGB = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "sRGB", "Z")); int bpe = convertToBPE(bpp); int accum_bpe = convertToBPE(accum_bpp); @@ -214,6 +230,8 @@ static XVisualInfo *chooseVisualGLXFromBPP(JNIEnv *env, Display *disp, int scree putAttrib(&attrib_list, GLX_SAMPLE_BUFFERS_ARB); putAttrib(&attrib_list, 1); putAttrib(&attrib_list, GLX_SAMPLES_ARB); putAttrib(&attrib_list, samples); } + if (sRGB) + putAttrib(&attrib_list, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB); putAttrib(&attrib_list, None); return lwjgl_glXChooseVisual(disp, screen, attrib_list.attribs); } @@ -272,10 +290,21 @@ bool initPeerInfo(JNIEnv *env, jobject peer_info_handle, Display *display, int s return false; } bool floating_point = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z")); - if (floating_point && !extension_flags.GLX_ARB_fbconfig_float) { + if (floating_point && !(extension_flags.GLX13 && extension_flags.GLX_ARB_fbconfig_float)) { // We need GLX13 to support floating point throwException(env, "Floating point specified but there's no support for GLX_ARB_fbconfig_float"); return false; } + bool floating_point_packed = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point_packed", "Z")); + if (floating_point_packed && !(extension_flags.GLX13 && extension_flags.GLX_EXT_fbconfig_packed_float)) { // We need GLX13 to support packed floating point + throwException(env, "Packed floating point specified but there's no support for GLX_EXT_fbconfig_packed_float"); + return false; + } + bool sRGB = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "sRGB", "Z")); + if (sRGB && !extension_flags.GLX_ARB_framebuffer_sRGB) { + throwException(env, "sRGB specified but there's no support for GLX_ARB_framebuffer_sRGB"); + return false; + } + peer_info->glx13 = extension_flags.GLX13; if (peer_info->glx13) { GLXFBConfig *configs = chooseVisualGLX13(env, display, screen, pixel_format, use_display_bpp, drawable_type, double_buffered); diff --git a/src/native/linux/extgl_glx.c b/src/native/linux/extgl_glx.c index b4ac803c..98bfb072 100644 --- a/src/native/linux/extgl_glx.c +++ b/src/native/linux/extgl_glx.c @@ -1,31 +1,31 @@ -/* +/* * Copyright (c) 2002-2008 LWJGL Project * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are + * modification, are permitted provided that the following conditions are * met: - * - * * Redistributions of source code must retain the above copyright + * + * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ @@ -148,6 +148,8 @@ static void extgl_InitGLXSupportedExtensions(Display *disp, int screen, GLXExten extension_flags->GLX_SGI_swap_control = symbols_flags.GLX_SGI_swap_control && GLXQueryExtension(disp, screen, "GLX_SGI_swap_control"); extension_flags->GLX_ARB_multisample = GLXQueryExtension(disp, screen, "GLX_ARB_multisample"); extension_flags->GLX_ARB_fbconfig_float = GLXQueryExtension(disp, screen, "GLX_ARB_fbconfig_float"); + extension_flags->GLX_EXT_fbconfig_packed_float = GLXQueryExtension(disp, screen, "GLX_EXT_fbconfig_packed_float"); + extension_flags->GLX_ARB_framebuffer_sRGB = GLXQueryExtension(disp, screen, "GLX_ARB_framebuffer_sRGB") || GLXQueryExtension(disp, screen, "GLX_EXT_framebuffer_sRGB"); } bool extgl_Open(JNIEnv *env) { diff --git a/src/native/linux/extgl_glx.h b/src/native/linux/extgl_glx.h index e8370075..b4196b03 100644 --- a/src/native/linux/extgl_glx.h +++ b/src/native/linux/extgl_glx.h @@ -1,35 +1,35 @@ -/* +/* * Copyright (c) 2002-2008 LWJGL Project * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are + * modification, are permitted provided that the following conditions are * met: - * - * * Redistributions of source code must retain the above copyright + * + * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #ifndef EXTGL_GLX_H #define EXTGL_GLX_H @@ -256,6 +256,13 @@ #define GLX_RGBA_FLOAT_TYPE 0x20B9 #define GLX_RGBA_FLOAT_BIT 0x0004 +/* GLX_ARB_fbconfig_float */ +#define GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT 0x20B1 +#define GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT 0x00000008 + +/* GLX_ARB_framebuffer_sRGB */ +#define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20B2 + typedef XID GLXContextID; typedef XID GLXPixmap; typedef XID GLXDrawable; @@ -324,6 +331,8 @@ typedef struct { bool GLX_SGI_swap_control; bool GLX_ARB_multisample; bool GLX_ARB_fbconfig_float; + bool GLX_EXT_fbconfig_packed_float; + bool GLX_ARB_framebuffer_sRGB; } GLXExtensions; /* Add _ to global symbols to avoid symbol clash with the OpenGL library */ diff --git a/src/native/linux/org_lwjgl_opengl_LinuxContextImplementation.c b/src/native/linux/org_lwjgl_opengl_LinuxContextImplementation.c index 1580e29a..05e25203 100644 --- a/src/native/linux/org_lwjgl_opengl_LinuxContextImplementation.c +++ b/src/native/linux/org_lwjgl_opengl_LinuxContextImplementation.c @@ -1,31 +1,31 @@ -/* +/* * Copyright (c) 2002-2008 LWJGL Project * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are + * modification, are permitted provided that the following conditions are * met: - * - * * Redistributions of source code must retain the above copyright + * + * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ @@ -110,7 +110,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nSetSwap } JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nCreate - (JNIEnv *env , jclass clazz, jobject peer_handle, jobject shared_context_handle) { + (JNIEnv *env , jclass clazz, jobject peer_handle, jobject attribs, jobject shared_context_handle) { jobject context_handle = newJavaManagedByteBuffer(env, sizeof(X11Context)); if (context_handle == NULL) { throwException(env, "Could not allocate handle buffer"); @@ -127,7 +127,7 @@ JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nCrea if (shared_context_handle != NULL) { X11Context *shared_context_info = (*env)->GetDirectBufferAddress(env, shared_context_handle); shared_context = shared_context_info->context; - } + } if (peer_info->glx13) { createContextGLX13(env, peer_info, context_info, shared_context); } else { diff --git a/src/native/macosx/context.m b/src/native/macosx/context.m index d84724a0..f737c0a3 100644 --- a/src/native/macosx/context.m +++ b/src/native/macosx/context.m @@ -104,6 +104,10 @@ NSOpenGLPixelFormat *choosePixelFormat(JNIEnv *env, jobject pixel_format, bool u int accum_alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_alpha", "I")); bool stereo = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stereo", "Z")); bool floating_point = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z")); + // TODO: Add floating_point_packed attribute below + bool floating_point_packed = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point_packed", "Z")); + // TODO: Add sRGB attribute below + bool sRGB = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "sRGB", "Z")); attrib_list_t attribs; jboolean allow_software_acceleration = getBooleanProperty(env, "org.lwjgl.opengl.Display.allowSoftwareOpenGL"); diff --git a/src/native/macosx/org_lwjgl_opengl_MacOSXContextImplementation.m b/src/native/macosx/org_lwjgl_opengl_MacOSXContextImplementation.m index b0354d1f..aab4ec41 100644 --- a/src/native/macosx/org_lwjgl_opengl_MacOSXContextImplementation.m +++ b/src/native/macosx/org_lwjgl_opengl_MacOSXContextImplementation.m @@ -48,7 +48,7 @@ typedef struct { } MacOSXContext; JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_MacOSXContextImplementation_nCreate - (JNIEnv *env, jclass clazz, jobject peer_info_handle, jobject shared_context_handle) { + (JNIEnv *env, jclass clazz, jobject peer_info_handle, jobject attribs, jobject shared_context_handle) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; MacOSXPeerInfo *peer_info; MacOSXContext *shared_context_info; diff --git a/src/native/windows/context.c b/src/native/windows/context.c index 354f21e7..e0429fde 100644 --- a/src/native/windows/context.c +++ b/src/native/windows/context.c @@ -193,7 +193,7 @@ static int convertToBPE(int bpp) { return bpe; } -static int findPixelFormatARBFromBPP(JNIEnv *env, HDC hdc, WGLExtensions *extensions, jobject pixel_format, jobject pixelFormatCaps, int bpp, bool window, bool pbuffer, bool double_buffer, bool floating_point) { +static int findPixelFormatARBFromBPP(JNIEnv *env, HDC hdc, WGLExtensions *extensions, jobject pixel_format, jobject pixelFormatCaps, int bpp, bool window, bool pbuffer, bool double_buffer) { jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format); int alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "alpha", "I")); int depth = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "depth", "I")); @@ -202,8 +202,13 @@ static int findPixelFormatARBFromBPP(JNIEnv *env, HDC hdc, WGLExtensions *extens int num_aux_buffers = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "num_aux_buffers", "I")); int accum_bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_bpp", "I")); int accum_alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_alpha", "I")); + jboolean stereo = (*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stereo", "Z")); - int pixel_type = floating_point ? WGL_TYPE_RGBA_FLOAT_ARB : WGL_TYPE_RGBA_ARB; + jboolean floating_point = (*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z")); + jboolean floating_point_packed = (*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point_packed", "Z")); + jboolean sRGB = (*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "sRGB", "Z")); + + int pixel_type; int iPixelFormat; unsigned int num_formats_returned; attrib_list_t attrib_list; @@ -212,6 +217,13 @@ static int findPixelFormatARBFromBPP(JNIEnv *env, HDC hdc, WGLExtensions *extens BOOL result; jlong i; int bpe = convertToBPE(bpp); + + if ( floating_point ) + pixel_type = WGL_TYPE_RGBA_FLOAT_ARB; + else if ( floating_point_packed ) + pixel_type = WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT; + else + pixel_type = WGL_TYPE_RGBA_ARB; initAttribList(&attrib_list); if (window) { @@ -240,6 +252,7 @@ static int findPixelFormatARBFromBPP(JNIEnv *env, HDC hdc, WGLExtensions *extens putAttrib(&attrib_list, WGL_ACCUM_ALPHA_BITS_ARB); putAttrib(&attrib_list, accum_alpha); putAttrib(&attrib_list, WGL_STEREO_ARB); putAttrib(&attrib_list, stereo ? TRUE : FALSE); putAttrib(&attrib_list, WGL_AUX_BUFFERS_ARB); putAttrib(&attrib_list, num_aux_buffers); + putAttrib(&attrib_list, WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB); putAttrib(&attrib_list, sRGB ? TRUE : FALSE); // Assume caller checked extension availability if (pixelFormatCaps != NULL) { pixelFormatCaps_ptr = (GLuint *)(*env)->GetDirectBufferAddress(env, pixelFormatCaps); @@ -258,14 +271,14 @@ static int findPixelFormatARBFromBPP(JNIEnv *env, HDC hdc, WGLExtensions *extens return iPixelFormat; } -static int findPixelFormatARB(JNIEnv *env, HDC hdc, WGLExtensions *extensions, jobject pixel_format, jobject pixelFormatCaps, bool use_hdc_bpp, bool window, bool pbuffer, bool double_buffer, bool floating_point) { +static int findPixelFormatARB(JNIEnv *env, HDC hdc, WGLExtensions *extensions, jobject pixel_format, jobject pixelFormatCaps, bool use_hdc_bpp, bool window, bool pbuffer, bool double_buffer) { int bpp; int iPixelFormat; int fallback_bpp = 16; jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format); if (use_hdc_bpp) { bpp = GetDeviceCaps(hdc, BITSPIXEL); - iPixelFormat = findPixelFormatARBFromBPP(env, hdc, extensions, pixel_format, pixelFormatCaps, bpp, window, pbuffer, double_buffer, floating_point); + iPixelFormat = findPixelFormatARBFromBPP(env, hdc, extensions, pixel_format, pixelFormatCaps, bpp, window, pbuffer, double_buffer); if ((*env)->ExceptionOccurred(env)) { (*env)->ExceptionClear(env); printfDebugJava(env, "Failed to find ARB pixel format with HDC depth %d, falling back to %d\n", bpp, fallback_bpp); @@ -274,7 +287,7 @@ static int findPixelFormatARB(JNIEnv *env, HDC hdc, WGLExtensions *extensions, j return iPixelFormat; } else bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "bpp", "I")); - return findPixelFormatARBFromBPP(env, hdc, extensions, pixel_format, pixelFormatCaps, bpp, window, pbuffer, double_buffer, floating_point); + return findPixelFormatARBFromBPP(env, hdc, extensions, pixel_format, pixelFormatCaps, bpp, window, pbuffer, double_buffer); } /* @@ -381,7 +394,7 @@ static int findPixelFormatDefault(JNIEnv *env, HDC hdc, jobject pixel_format, bo return findPixelFormatFromBPP(env, hdc, pixel_format, bpp, double_buffer); } -static bool validateAndGetExtensions(JNIEnv *env, WGLExtensions *extensions, HDC dummy_hdc, HGLRC dummy_hglrc, int samples, bool floating_point, jobject pixelFormatCaps) { +static bool validateAndGetExtensions(JNIEnv *env, WGLExtensions *extensions, HDC dummy_hdc, HGLRC dummy_hglrc, int samples, bool floating_point, bool floating_point_packed, bool sRGB, jobject pixelFormatCaps) { if (!wglMakeCurrent(dummy_hdc, dummy_hglrc)) { throwException(env, "Could not bind context to dummy window"); return false; @@ -405,6 +418,14 @@ static bool validateAndGetExtensions(JNIEnv *env, WGLExtensions *extensions, HDC throwException(env, "No support for WGL_ARB_pixel_format_float nor WGL_ATI_pixel_format_float"); return false; } + if (floating_point_packed && !(extensions->WGL_EXT_pixel_format_packed_float)) { + throwException(env, "No support for WGL_EXT_pixel_format_packed_float"); + return false; + } + if (sRGB && !(extensions->WGL_ARB_framebuffer_sRGB)) { + throwException(env, "No support for WGL_ARB_framebuffer_sRGB"); + return false; + } if (pixelFormatCaps != NULL && !extensions->WGL_ARB_render_texture) { throwException(env, "No support for WGL_ARB_render_texture"); return false; @@ -412,7 +433,7 @@ static bool validateAndGetExtensions(JNIEnv *env, WGLExtensions *extensions, HDC return true; } -int findPixelFormatOnDC(JNIEnv *env, HDC hdc, int origin_x, int origin_y, jobject pixel_format, jobject pixelFormatCaps, bool use_hdc_bpp, bool window, bool pbuffer, bool double_buffer, bool floating_point) { +int findPixelFormatOnDC(JNIEnv *env, HDC hdc, int origin_x, int origin_y, jobject pixel_format, jobject pixelFormatCaps, bool use_hdc_bpp, bool window, bool pbuffer, bool double_buffer) { HGLRC dummy_hglrc; HDC saved_current_hdc; HGLRC saved_current_hglrc; @@ -421,8 +442,13 @@ int findPixelFormatOnDC(JNIEnv *env, HDC hdc, int origin_x, int origin_y, jobjec HDC dummy_hdc; int pixel_format_id; jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format); + int samples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "samples", "I")); - bool use_arb_selection = samples > 0 || floating_point || pbuffer || pixelFormatCaps != NULL; + bool floating_point = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z")); + bool floating_point_packed = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point_packed", "Z")); + bool sRGB = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "sRGB", "Z")); + bool use_arb_selection = samples > 0 || floating_point || floating_point_packed || sRGB || pbuffer || pixelFormatCaps != NULL; + pixel_format_id = findPixelFormatDefault(env, hdc, pixel_format, use_hdc_bpp, double_buffer); if (!(*env)->ExceptionOccurred(env) && use_arb_selection) { dummy_hwnd = createDummyWindow(origin_x, origin_y); @@ -444,8 +470,8 @@ int findPixelFormatOnDC(JNIEnv *env, HDC hdc, int origin_x, int origin_y, jobjec // Save the current HDC and HGLRC to avoid disruption saved_current_hdc = wglGetCurrentDC(); saved_current_hglrc = wglGetCurrentContext(); - if (validateAndGetExtensions(env, &extensions, dummy_hdc, dummy_hglrc, samples, floating_point, pixelFormatCaps)) { - pixel_format_id = findPixelFormatARB(env, hdc, &extensions, pixel_format, pixelFormatCaps, use_hdc_bpp, window, pbuffer, double_buffer, floating_point); + if (validateAndGetExtensions(env, &extensions, dummy_hdc, dummy_hglrc, samples, floating_point, floating_point_packed, sRGB, pixelFormatCaps)) { + pixel_format_id = findPixelFormatARB(env, hdc, &extensions, pixel_format, pixelFormatCaps, use_hdc_bpp, window, pbuffer, double_buffer); } wglMakeCurrent(saved_current_hdc, saved_current_hglrc); wglDeleteContext(dummy_hglrc); @@ -469,4 +495,4 @@ HWND createDummyWindow(int origin_x, int origin_y) { if (!registerDummyWindow()) return NULL; return createWindow(_CONTEXT_PRIVATE_CLASS_NAME, origin_x, origin_y, 1, 1, false, false, false, NULL); -} +} \ No newline at end of file diff --git a/src/native/windows/context.h b/src/native/windows/context.h index 83ef668a..5e8167f5 100644 --- a/src/native/windows/context.h +++ b/src/native/windows/context.h @@ -91,6 +91,6 @@ extern void getWindowFlags(DWORD *windowflags_return, DWORD *exstyle_return, boo */ extern HWND createWindow(LPCTSTR window_class_name, int x, int y, int width, int height, bool fullscreen, bool undecorated, bool child_window, HWND parent); -extern int findPixelFormatOnDC(JNIEnv *env, HDC hdc, int origin_x, int origin_y, jobject pixel_format, jobject pixelFormatCaps, bool use_hdc_bpp, bool window, bool pbuffer, bool double_buffer, bool floating_point); +extern int findPixelFormatOnDC(JNIEnv *env, HDC hdc, int origin_x, int origin_y, jobject pixel_format, jobject pixelFormatCaps, bool use_hdc_bpp, bool window, bool pbuffer, bool double_buffer); #endif diff --git a/src/native/windows/extgl_wgl.c b/src/native/windows/extgl_wgl.c index 0ae140ac..017e4cc7 100644 --- a/src/native/windows/extgl_wgl.c +++ b/src/native/windows/extgl_wgl.c @@ -129,6 +129,14 @@ static void extgl_InitWGLARBMakeCurrentRead(WGLExtensions *extensions) { extensions->WGL_ARB_make_current_read = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); } +static void extgl_InitWGLARBCreateContext(WGLExtensions *extensions) { + ExtFunction functions[] = { + {"wglCreateContextAttribsARB", (void **)&extensions->wglCreateContextAttribsARB} + }; + if (extensions->WGL_ARB_create_context) + extensions->WGL_ARB_create_context = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); +} + static void extgl_InitSupportedWGLExtensions(WGLExtensions *extensions) { extensions->WGL_ARB_buffer_region = WGLQueryExtension(extensions, "WGL_ARB_buffer_region"); extensions->WGL_ARB_make_current_read = WGLQueryExtension(extensions, "WGL_ARB_make_current_read"); @@ -141,6 +149,9 @@ static void extgl_InitSupportedWGLExtensions(WGLExtensions *extensions) { extensions->WGL_EXT_swap_control = WGLQueryExtension(extensions, "WGL_EXT_swap_control"); extensions->WGL_NV_render_depth_texture = WGLQueryExtension(extensions, "WGL_NV_render_depth_texture"); extensions->WGL_NV_render_texture_rectangle = WGLQueryExtension(extensions, "WGL_NV_render_texture_rectangle"); + extensions->WGL_ARB_framebuffer_sRGB = WGLQueryExtension(extensions, "WGL_ARB_framebuffer_sRGB") || WGLQueryExtension(extensions, "WGL_EXT_framebuffer_sRGB"); + extensions->WGL_EXT_pixel_format_packed_float = WGLQueryExtension(extensions, "WGL_EXT_pixel_format_packed_float"); + extensions->WGL_ARB_create_context = WGLQueryExtension(extensions, "WGL_ARB_create_context"); } static void extgl_InitWGLEXTExtensionsString(WGLExtensions *extensions) { @@ -160,7 +171,7 @@ static void extgl_InitWGLARBExtensionsString(WGLExtensions *extensions) { void extgl_InitWGL(WGLExtensions *extensions) { extgl_InitWGLARBExtensionsString(extensions); extgl_InitWGLEXTExtensionsString(extensions); - + extgl_InitSupportedWGLExtensions(extensions); extgl_InitWGLARBMakeCurrentRead(extensions); @@ -168,4 +179,5 @@ void extgl_InitWGL(WGLExtensions *extensions) { extgl_InitWGLARBRenderTexture(extensions); extgl_InitWGLARBPixelFormat(extensions); extgl_InitWGLARBPbuffer(extensions); -} + extgl_InitWGLARBCreateContext(extensions); +} \ No newline at end of file diff --git a/src/native/windows/extgl_wgl.h b/src/native/windows/extgl_wgl.h index ef568dbe..43c06b44 100644 --- a/src/native/windows/extgl_wgl.h +++ b/src/native/windows/extgl_wgl.h @@ -172,6 +172,34 @@ typedef HDC (APIENTRY * wglGetCurrentReadDCARBPROC) (void); #define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0 +/*------------------------------------------------------------------*/ +/*------------ WGL_ARB_framebuffer_sRGB ----------------------------*/ +/*------------------------------------------------------------------*/ + +#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9 + +/*---------------------------------------------------------------------------*/ +/*------------ WGL_EXT_pixel_format_packed_float ----------------------------*/ +/*---------------------------------------------------------------------------*/ + +#define WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT 0x20A8 + +/*----------------------------------------------------------------*/ +/*------------ WGL_ARB_create_context ----------------------------*/ +/*----------------------------------------------------------------*/ + +#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 +#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 +#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093 +#define WGL_CONTEXT_FLAGS_ARB 0x2094 + +#define WGL_CONTEXT_DEBUG_BIT_ARB 0x0001 +#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002 + +#define ERROR_INVALID_VERSION_ARB 0x2095 + +typedef HGLRC (APIENTRY * wglCreateContextAttribsARBPROC) (HDC hDC, HGLRC hShareContext, const int *attribList); + typedef struct { bool WGL_ARB_buffer_region; bool WGL_ARB_extensions_string; @@ -186,6 +214,10 @@ typedef struct { bool WGL_NV_render_texture_rectangle; bool WGL_ARB_pixel_format_float; bool WGL_ATI_pixel_format_float; + bool WGL_ARB_framebuffer_sRGB; + bool WGL_EXT_pixel_format_packed_float; + bool WGL_ARB_create_context; + wglGetExtensionsStringEXTPROC wglGetExtensionsStringEXT; wglGetExtensionsStringARBPROC wglGetExtensionsStringARB; @@ -209,6 +241,8 @@ typedef struct { wglMakeContextCurrentARBPROC wglMakeContextCurrentARB; wglGetCurrentReadDCARBPROC wglGetCurrentReadDCARB; + + wglCreateContextAttribsARBPROC wglCreateContextAttribsARB; } WGLExtensions; extern void extgl_InitWGL(WGLExtensions *extensions); diff --git a/src/native/windows/org_lwjgl_opengl_WindowsContextImplementation.c b/src/native/windows/org_lwjgl_opengl_WindowsContextImplementation.c index 56e684c7..a13b3039 100644 --- a/src/native/windows/org_lwjgl_opengl_WindowsContextImplementation.c +++ b/src/native/windows/org_lwjgl_opengl_WindowsContextImplementation.c @@ -1,31 +1,31 @@ -/* +/* * Copyright (c) 2002-2008 LWJGL Project * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are + * modification, are permitted provided that the following conditions are * met: - * - * * Redistributions of source code must retain the above copyright + * + * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ @@ -40,6 +40,7 @@ #include #include "org_lwjgl_opengl_WindowsContextImplementation.h" #include "context.h" +#include "extgl_wgl.h" #include "common_tools.h" typedef struct { @@ -47,32 +48,73 @@ typedef struct { } WindowsContext; JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nCreate - (JNIEnv *env, jclass clazz, jobject peer_info_handle, jobject shared_context_handle) { + (JNIEnv *env, jclass clazz, jobject peer_info_handle, jobject attribs, jobject shared_context_handle) { WindowsPeerInfo *peer_info; WindowsContext *shared_context_info; WindowsContext *context_info; HGLRC context; HGLRC shared_context = NULL; + + // -- We need to create a temporary context to detect the presence of WGL_ARB_create_context + HDC saved_current_hdc; + HGLRC saved_current_hglrc; + WGLExtensions extensions; + const int *attribList = attribs == NULL ? NULL : ((const int *)(*env)->GetDirectBufferAddress(env, attribs)); + jobject context_handle = newJavaManagedByteBuffer(env, sizeof(WindowsContext)); if (context_handle == NULL) { throwException(env, "Could not create handle buffer"); return NULL; } + peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); + if (shared_context_handle != NULL) { + shared_context_info = (WindowsContext *)(*env)->GetDirectBufferAddress(env, shared_context_handle); + shared_context = shared_context_info->context; + } + + // Create the context context = wglCreateContext(peer_info->drawable_hdc); if (context == NULL) { throwException(env, "Could not create context"); return NULL; } - if (shared_context_handle != NULL) { - shared_context_info = (WindowsContext *)(*env)->GetDirectBufferAddress(env, shared_context_handle); - shared_context = shared_context_info->context; - if (!wglShareLists(shared_context, context)) { + + // Save the current HDC and HGLRC to avoid disruption + saved_current_hdc = wglGetCurrentDC(); + saved_current_hglrc = wglGetCurrentContext(); + + // Make context current and detect extensions + if (!wglMakeCurrent(peer_info->drawable_hdc, context)) { + throwException(env, "Could not bind dummy context"); + return NULL; + } + extgl_InitWGL(&extensions); + + // Restore previous context + wglMakeCurrent(saved_current_hdc, saved_current_hglrc); + + // + if ( extensions.WGL_ARB_create_context ) { // We support WGL_ARB_create_context, use the new context creation routine + // If we have no context to share and no special attributes, we don't have to recreate the context - wglCreateContext is equivalent to wglCreateContextAttribs(hdc,0,NULL). + if ( shared_context != NULL || attribList != NULL ) { + // Delete the oldschool context + wglDeleteContext(context); + // Create a new context using WGL_ARB_create_context + context = (HGLRC)extensions.wglCreateContextAttribsARB(peer_info->drawable_hdc, shared_context, attribList); + if (context == NULL) { + throwException(env, "Could not create context (WGL_ARB_create_context)"); + return NULL; + } + } + } else { // We don't support WGL_ARB_create_context, use the old context creation routine + if (shared_context != NULL && !wglShareLists(shared_context, context)) { // Use wglShareLists to share context data wglDeleteContext(context); throwException(env, "Could not share contexts"); return NULL; } } + context_info = (WindowsContext *)(*env)->GetDirectBufferAddress(env, context_handle); context_info->context = context; return context_handle; diff --git a/src/native/windows/org_lwjgl_opengl_WindowsPeerInfo.c b/src/native/windows/org_lwjgl_opengl_WindowsPeerInfo.c index 3ce421a5..ff803ae4 100644 --- a/src/native/windows/org_lwjgl_opengl_WindowsPeerInfo.c +++ b/src/native/windows/org_lwjgl_opengl_WindowsPeerInfo.c @@ -1,31 +1,31 @@ -/* +/* * Copyright (c) 2002-2008 LWJGL Project * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are + * modification, are permitted provided that the following conditions are * met: - * - * * Redistributions of source code must retain the above copyright + * + * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ @@ -51,8 +51,7 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsPeerInfo_nChoosePixelFormat (JNIEnv *env, jclass clazz, jlong hdc_ptr, jint origin_x, jint origin_y, jobject pixel_format, jobject pixel_format_caps, jboolean use_hdc_bpp, jboolean window, jboolean pbuffer, jboolean double_buffer) { HDC hdc = (HDC)(INT_PTR)hdc_ptr; jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format); - bool floating_point = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z")); - return findPixelFormatOnDC(env, hdc, origin_x, origin_y, pixel_format, pixel_format_caps, use_hdc_bpp, window, pbuffer, double_buffer, floating_point); + return findPixelFormatOnDC(env, hdc, origin_x, origin_y, pixel_format, pixel_format_caps, use_hdc_bpp, window, pbuffer, double_buffer); } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsPeerInfo_setPixelFormat diff --git a/src/templates/org/lwjgl/opengl/ARB_imaging.java b/src/templates/org/lwjgl/opengl/ARB_imaging.java index eb35a1fe..56a081ed 100644 --- a/src/templates/org/lwjgl/opengl/ARB_imaging.java +++ b/src/templates/org/lwjgl/opengl/ARB_imaging.java @@ -45,6 +45,7 @@ import java.nio.*; */ @Extension(postfix = "") +@DeprecatedGL public interface ARB_imaging { int GL_CONSTANT_COLOR = 0x8001; @@ -124,6 +125,7 @@ public interface ARB_imaging { int GL_MINMAX_SINK = 0x8030; int GL_TABLE_TOO_LARGE = 0x8031; + @DeprecatedGL void glColorTable(@GLenum int target, @GLenum int internalFormat, @GLsizei int width, @GLenum int format, @GLenum int type, @BufferObject(BufferKind.UnpackPBO) @Check("256") @@ -132,6 +134,7 @@ public interface ARB_imaging { @GLfloat @GLdouble Buffer data); + @DeprecatedGL void glColorSubTable(@GLenum int target, @GLsizei int start, @GLsizei int count, @GLenum int format, @GLenum int type, @BufferObject(BufferKind.UnpackPBO) @Check("256") @@ -141,15 +144,20 @@ public interface ARB_imaging { @GLdouble Buffer data); @StripPostfix("params") + @DeprecatedGL void glColorTableParameteriv(@GLenum int target, @GLenum int pname, @Check("4") @Const IntBuffer params); @StripPostfix("params") + @DeprecatedGL void glColorTableParameterfv(@GLenum int target, @GLenum int pname, @Check("4") @Const FloatBuffer params); + @DeprecatedGL void glCopyColorSubTable(@GLenum int target, @GLsizei int start, int x, int y, @GLsizei int width); + @DeprecatedGL void glCopyColorTable(@GLenum int target, @GLenum int internalformat, int x, int y, @GLsizei int width); + @DeprecatedGL void glGetColorTable(@GLenum int target, @GLenum int format, @GLenum int type, @OutParameter @Check("256") @@ -158,19 +166,24 @@ public interface ARB_imaging { @GLdouble Buffer data); @StripPostfix("params") + @DeprecatedGL void glGetColorTableParameteriv(@GLenum int target, @GLenum int pname, @Check("4") IntBuffer params); @StripPostfix("params") + @DeprecatedGL void glGetColorTableParameterfv(@GLenum int target, @GLenum int pname, @Check("4") FloatBuffer params); void glBlendEquation(@GLenum int mode); void glBlendColor(@GLclampf float red, @GLclampf float green, @GLclampf float blue, @GLclampf float alpha); + @DeprecatedGL void glHistogram(@GLenum int target, @GLsizei int width, @GLenum int internalformat, boolean sink); + @DeprecatedGL void glResetHistogram(@GLenum int target); + @DeprecatedGL void glGetHistogram(@GLenum int target, boolean reset, @GLenum int format, @GLenum int type, @OutParameter @BufferObject(BufferKind.PackPBO) @@ -182,15 +195,20 @@ public interface ARB_imaging { @GLdouble Buffer values); @StripPostfix("params") + @DeprecatedGL void glGetHistogramParameterfv(@GLenum int target, @GLenum int pname, @OutParameter @Check("256") FloatBuffer params); @StripPostfix("params") + @DeprecatedGL void glGetHistogramParameteriv(@GLenum int target, @GLenum int pname, @OutParameter @Check("256") IntBuffer params); + @DeprecatedGL void glMinmax(@GLenum int target, @GLenum int internalformat, boolean sink); + @DeprecatedGL void glResetMinmax(@GLenum int target); + @DeprecatedGL void glGetMinmax(@GLenum int target, boolean reset, @GLenum int format, @GLenum int types, @OutParameter @BufferObject(BufferKind.PackPBO) @@ -202,11 +220,14 @@ public interface ARB_imaging { @GLdouble Buffer values); @StripPostfix("params") + @DeprecatedGL void glGetMinmaxParameterfv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); @StripPostfix("params") + @DeprecatedGL void glGetMinmaxParameteriv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); + @DeprecatedGL void glConvolutionFilter1D(@GLenum int target, @GLenum int internalformat, @GLsizei int width, @GLenum int format, @GLenum int type, @BufferObject(BufferKind.UnpackPBO) @Check("GLChecks.calculateImageStorage(image, format, type, width, 1, 1)") @@ -217,6 +238,7 @@ public interface ARB_imaging { @GLfloat @GLdouble Buffer image); + @DeprecatedGL void glConvolutionFilter2D(@GLenum int target, @GLenum int internalformat, @GLsizei int width, @GLsizei int height, @GLenum int format, @GLenum int type, @BufferObject(BufferKind.UnpackPBO) @Check("GLChecks.calculateImageStorage(image, format, type, width, height, 1)") @@ -225,21 +247,28 @@ public interface ARB_imaging { @GLshort @GLint Buffer image); + @DeprecatedGL void glConvolutionParameterf(@GLenum int target, @GLenum int pname, float params); @StripPostfix("params") + @DeprecatedGL void glConvolutionParameterfv(@GLenum int target, @GLenum int pname, @Check("4") @Const FloatBuffer params); + @DeprecatedGL void glConvolutionParameteri(@GLenum int target, @GLenum int pname, int params); @StripPostfix("params") + @DeprecatedGL void glConvolutionParameteriv(@GLenum int target, @GLenum int pname, @Check("4") @Const IntBuffer params); + @DeprecatedGL void glCopyConvolutionFilter1D(@GLenum int target, @GLenum int internalformat, int x, int y, @GLsizei int width); + @DeprecatedGL void glCopyConvolutionFilter2D(@GLenum int target, @GLenum int internalformat, int x, int y, @GLsizei int width, @GLsizei int height); // TODO: check buffer size valid + @DeprecatedGL void glGetConvolutionFilter(@GLenum int target, @GLenum int format, @GLenum int type, @OutParameter @BufferObject(BufferKind.PackPBO) @@ -251,12 +280,15 @@ public interface ARB_imaging { @GLdouble Buffer image); @StripPostfix("params") + @DeprecatedGL void glGetConvolutionParameterfv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); @StripPostfix("params") + @DeprecatedGL void glGetConvolutionParameteriv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); // TODO: check buffer size valid + @DeprecatedGL void glSeparableFilter2D(@GLenum int target, @GLenum int internalformat, @GLsizei int width, @GLsizei int height, @GLenum int format, @GLenum int type, @BufferObject(BufferKind.UnpackPBO) @Check @@ -276,6 +308,7 @@ public interface ARB_imaging { @GLdouble Buffer column); // TODO: check buffer size valid + @DeprecatedGL void glGetSeparableFilter(@GLenum int target, @GLenum int format, @GLenum int type, @OutParameter @BufferObject(BufferKind.PackPBO) diff --git a/src/templates/org/lwjgl/opengl/ARB_window_pos.java b/src/templates/org/lwjgl/opengl/ARB_window_pos.java index c3bcb2b5..5527c398 100644 --- a/src/templates/org/lwjgl/opengl/ARB_window_pos.java +++ b/src/templates/org/lwjgl/opengl/ARB_window_pos.java @@ -31,21 +31,32 @@ */ package org.lwjgl.opengl; +import org.lwjgl.util.generator.DeprecatedGL; + +@DeprecatedGL public interface ARB_window_pos { + @DeprecatedGL void glWindowPos2fARB(float x, float y); + @DeprecatedGL void glWindowPos2dARB(double x, double y); + @DeprecatedGL void glWindowPos2iARB(int x, int y); + @DeprecatedGL void glWindowPos2sARB(short x, short y); + @DeprecatedGL void glWindowPos3fARB(float x, float y, float z); + @DeprecatedGL void glWindowPos3dARB(double x, double y, double z); + @DeprecatedGL void glWindowPos3iARB(int x, int y, int z); + @DeprecatedGL void glWindowPos3sARB(short x, short y, short z); } diff --git a/src/templates/org/lwjgl/opengl/EXT_direct_state_access.java b/src/templates/org/lwjgl/opengl/EXT_direct_state_access.java new file mode 100644 index 00000000..b407b707 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/EXT_direct_state_access.java @@ -0,0 +1,1140 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +import org.lwjgl.util.generator.*; + +import java.nio.*; + +@Dependent +@DeprecatedGL +public interface EXT_direct_state_access { + + /* + OpenGL 1.1: New client commands + */ + + @DeprecatedGL + void glClientAttribDefaultEXT(@GLbitfield int mask); + + @DeprecatedGL + void glPushClientAttribDefaultEXT(@GLbitfield int mask); + + /* + OpenGL 1.0: New matrix commands add "Matrix" prefix to name, + drops "Matrix" suffix from name, and add initial "enum matrixMode" + parameter + */ + + @StripPostfix("m") + @DeprecatedGL + void glMatrixLoadfEXT(@GLenum int matrixMode, @Check("16") @Const FloatBuffer m); + + @StripPostfix("m") + @DeprecatedGL + void glMatrixLoaddEXT(@GLenum int matrixMode, @Check("16") @Const DoubleBuffer m); + + @StripPostfix("m") + @DeprecatedGL + void glMatrixMultfEXT(@GLenum int matrixMode, @Check("16") @Const FloatBuffer m); + + @StripPostfix("m") + @DeprecatedGL + void glMatrixMultdEXT(@GLenum int matrixMode, @Check("16") @Const DoubleBuffer m); + + @DeprecatedGL + void glMatrixLoadIdentityEXT(@GLenum int matrixMode); + + @DeprecatedGL + void glMatrixRotatefEXT(@GLenum int matrixMode, float angle, float x, float y, float z); + + @DeprecatedGL + void glMatrixRotatedEXT(@GLenum int matrixMode, double angle, double x, double y, double z); + + @DeprecatedGL + void glMatrixScalefEXT(@GLenum int matrixMode, float x, float y, float z); + + @DeprecatedGL + void glMatrixScaledEXT(@GLenum int matrixMode, double x, double y, double z); + + @DeprecatedGL + void glMatrixTranslatefEXT(@GLenum int matrixMode, float x, float y, float z); + + @DeprecatedGL + void glMatrixTranslatedEXT(@GLenum int matrixMode, double x, double y, double z); + + @DeprecatedGL + void glMatrixOrthoEXT(@GLenum int matrixMode, double l, double r, double b, double t, double n, double f); + + @DeprecatedGL + void glMatrixFrustumEXT(@GLenum int matrixMode, double l, double r, double b, double t, double n, double f); + + @DeprecatedGL + void glMatrixPushEXT(@GLenum int matrixMode); + + @DeprecatedGL + void glMatrixPopEXT(@GLenum int matrixMode); + + /* + OpenGL 1.1: New texture object commands and queries replace "Tex" + in name with "Texture" and add initial "uint texture" parameter + */ + + void glTextureParameteriEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, int param); + + @StripPostfix("param") + void glTextureParameterivEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, @Check("4") @Const IntBuffer param); + + void glTextureParameterfEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, float param); + + @StripPostfix("param") + void glTextureParameterfvEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, @Check("4") @Const FloatBuffer param); + + void glTextureImage1DEXT(@GLuint int texture, @GLenum int target, int level, + int internalformat, @GLsizei int width, int border, @GLenum int format, @GLenum int type, + @BufferObject(BufferKind.UnpackPBO) + @Check(value = "GLChecks.calculateTexImage1DStorage(pixels, format, type, width)", canBeNull = true) + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer pixels); + + void glTextureImage2DEXT(@GLuint int texture, @GLenum int target, int level, + int internalformat, @GLsizei int width, @GLsizei int height, int border, @GLenum int format, @GLenum int type, + @BufferObject(BufferKind.UnpackPBO) + @Check(value = "GLChecks.calculateTexImage2DStorage(pixels, format, type, width, height)", canBeNull = true) + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer pixels); + + void glTextureSubImage1DEXT(@GLuint int texture, @GLenum int target, int level, + int xoffset, @GLsizei int width, @GLenum int format, @GLenum int type, + @BufferObject(BufferKind.UnpackPBO) + @Check("GLChecks.calculateImageStorage(pixels, format, type, width, 1, 1)") + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer pixels); + + void glTextureSubImage2DEXT(@GLuint int texture, @GLenum int target, int level, + int xoffset, int yoffset, @GLsizei int width, @GLsizei int height, @GLenum int format, @GLenum int type, + @BufferObject(BufferKind.UnpackPBO) + @Check("GLChecks.calculateImageStorage(pixels, format, type, width, height, 1)") + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer pixels); + + void glCopyTextureImage1DEXT(@GLuint int texture, @GLenum int target, int level, @GLenum int internalformat, int x, int y, @GLsizei int width, int border); + + void glCopyTextureImage2DEXT(@GLuint int texture, @GLenum int target, int level, @GLenum int internalformat, int x, int y, @GLsizei int width, @GLsizei int height, int border); + + void glCopyTextureSubImage1DEXT(@GLuint int texture, @GLenum int target, int level, int xoffset, int x, int y, @GLsizei int width); + + void glCopyTextureSubImage2DEXT(@GLuint int texture, @GLenum int target, int level, int xoffset, int yoffset, int x, int y, @GLsizei int width, @GLsizei int height); + + void glGetTextureImageEXT(@GLuint int texture, @GLenum int target, int level, + @GLenum int format, @GLenum int type, + @OutParameter + @BufferObject(BufferKind.PackPBO) + @Check("GLChecks.calculateImageStorage(pixels, format, type, 1, 1, 1)") + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer pixels); + + @StripPostfix("params") + void glGetTextureParameterfvEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, @OutParameter @Check("4")FloatBuffer params); + + @StripPostfix("params") + void glGetTextureParameterivEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, @OutParameter @Check("4")IntBuffer params); + + @StripPostfix("params") + void glGetTextureLevelParameterfvEXT(@GLuint int texture, @GLenum int target, int level, @GLenum int pname, @OutParameter @Check("4")FloatBuffer params); + + @StripPostfix("params") + void glGetTextureLevelParameterivEXT(@GLuint int texture, @GLenum int target, int level, @GLenum int pname, @OutParameter @Check("4")IntBuffer params); + + /* + OpenGL 1.2: New 3D texture object commands replace "Tex" in name with + "Texture" and adds initial "uint texture" parameter + */ + + @Dependent("OpenGL12") + void glTextureImage3DEXT(@GLuint int texture, @GLenum int target, int level, + int internalformat, @GLsizei int width, @GLsizei int height, @GLsizei int depth, int border, @GLenum int format, @GLenum int type, + @BufferObject(BufferKind.UnpackPBO) + @Check(value = "GLChecks.calculateTexImage3DStorage(pixels, format, type, width, height, depth)", canBeNull = true) + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer pixels); + + @Dependent("OpenGL12") + void glTextureSubImage3DEXT(@GLuint int texture, @GLenum int target, int level, + int xoffset, int yoffset, int zoffset, @GLsizei int width, @GLsizei int height, @GLsizei int depth, @GLenum int format, @GLenum int type, + @BufferObject(BufferKind.UnpackPBO) + @Check("GLChecks.calculateImageStorage(pixels, format, type, width, height, depth)") + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer pixels); + + @Dependent("OpenGL12") + void glCopyTextureSubImage3DEXT(@GLuint int texture, @GLenum int target, int level, + int xoffset, int yoffset, int zoffset, int x, int y, @GLsizei int width, @GLsizei int height); + + /* + OpenGL 1.2.1: New multitexture commands and queries prefix "Multi" + before "Tex" and add an initial "enum texunit" parameter (to identify + the texture unit + */ + + @Dependent("OpenGL13") + void glBindMultiTextureEXT(@GLenum int texunit, @GLenum int target, @GLuint int texture); + + @Dependent("OpenGL13") + @DeprecatedGL + void glMultiTexCoordPointerEXT(@GLenum int texunit, int size, @AutoType("pointer") @GLenum int type, @GLsizei int stride, + @BufferObject(BufferKind.ArrayVBO) + @Check + @Const + @GLfloat + @GLdouble + Buffer pointer); + + @Dependent("OpenGL13") + @DeprecatedGL + void glMultiTexEnvfEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, float param); + + @Dependent("OpenGL13") + @StripPostfix("params") + @DeprecatedGL + void glMultiTexEnvfvEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Check("4") @Const FloatBuffer params); + + @Dependent("OpenGL13") + @DeprecatedGL + void glMultiTexEnviEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, int param); + + @Dependent("OpenGL13") + @StripPostfix("params") + @DeprecatedGL + void glMultiTexEnvivEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Check("4") @Const IntBuffer params); + + @Dependent("OpenGL13") + @DeprecatedGL + void glMultiTexGendEXT(@GLenum int texunit, @GLenum int coord, @GLenum int pname, double param); + + @Dependent("OpenGL13") + @StripPostfix("params") + @DeprecatedGL + void glMultiTexGendvEXT(@GLenum int texunit, @GLenum int coord, @GLenum int pname, @Check("4") @Const DoubleBuffer params); + + @Dependent("OpenGL13") + @DeprecatedGL + void glMultiTexGenfEXT(@GLenum int texunit, @GLenum int coord, @GLenum int pname, float param); + + @Dependent("OpenGL13") + @StripPostfix("params") + @DeprecatedGL + void glMultiTexGenfvEXT(@GLenum int texunit, @GLenum int coord, @GLenum int pname, @Check("4") @Const FloatBuffer params); + + @Dependent("OpenGL13") + @DeprecatedGL + void glMultiTexGeniEXT(@GLenum int texunit, @GLenum int coord, @GLenum int pname, int param); + + @Dependent("OpenGL13") + @StripPostfix("params") + @DeprecatedGL + void glMultiTexGenivEXT(@GLenum int texunit, @GLenum int coord, @GLenum int pname, @Check("4") @Const IntBuffer params); + + @Dependent("OpenGL13") + @StripPostfix("params") + @DeprecatedGL + void glGetMultiTexEnvfvEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Check("4") @OutParameter FloatBuffer params); + + @Dependent("OpenGL13") + @StripPostfix("params") + @DeprecatedGL + void glGetMultiTexEnvivEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Check("4") @OutParameter IntBuffer params); + + @Dependent("OpenGL13") + @StripPostfix("params") + @DeprecatedGL + void glGetMultiTexGendvEXT(@GLenum int texunit, @GLenum int coord, @GLenum int pname, @Check("4") @OutParameter DoubleBuffer params); + + @Dependent("OpenGL13") + @StripPostfix("params") + @DeprecatedGL + void glGetMultiTexGenfvEXT(@GLenum int texunit, @GLenum int coord, @GLenum int pname, @Check("4") @OutParameter FloatBuffer params); + + @Dependent("OpenGL13") + @StripPostfix("params") + @DeprecatedGL + void glGetMultiTexGenivEXT(@GLenum int texunit, @GLenum int coord, @GLenum int pname, @Check("4") @OutParameter IntBuffer params); + + @Dependent("OpenGL13") + void glMultiTexParameteriEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, int param); + + @Dependent("OpenGL13") + @StripPostfix("param") + void glMultiTexParameterivEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Check("4") @Const IntBuffer param); + + @Dependent("OpenGL13") + void glMultiTexParameterfEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, float param); + + @Dependent("OpenGL13") + @StripPostfix("param") + void glMultiTexParameterfvEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Check("4") @Const FloatBuffer param); + + @Dependent("OpenGL13") + void glMultiTexImage1DEXT(@GLenum int texunit, @GLenum int target, int level, + int internalformat, @GLsizei int width, int border, @GLenum int format, @GLenum int type, + @BufferObject(BufferKind.UnpackPBO) + @Check(value = "GLChecks.calculateTexImage1DStorage(pixels, format, type, width)", canBeNull = true) + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer pixels); + + @Dependent("OpenGL13") + void glMultiTexImage2DEXT(@GLenum int texunit, @GLenum int target, int level, + int internalformat, @GLsizei int width, @GLsizei int height, int border, @GLenum int format, @GLenum int type, + @BufferObject(BufferKind.UnpackPBO) + @Check(value = "GLChecks.calculateTexImage2DStorage(pixels, format, type, width, height)", canBeNull = true) + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer pixels); + + @Dependent("OpenGL13") + void glMultiTexSubImage1DEXT(@GLenum int texunit, @GLenum int target, int level, + int xoffset, @GLsizei int width, @GLenum int format, @GLenum int type, + @BufferObject(BufferKind.UnpackPBO) + @Check("GLChecks.calculateImageStorage(pixels, format, type, width, 1, 1)") + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer pixels); + + @Dependent("OpenGL13") + void glMultiTexSubImage2DEXT(@GLenum int texunit, @GLenum int target, int level, + int xoffset, int yoffset, @GLsizei int width, @GLsizei int height, @GLenum int format, @GLenum int type, + @BufferObject(BufferKind.UnpackPBO) + @Check("GLChecks.calculateImageStorage(pixels, format, type, width, height, 1)") + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer pixels); + + @Dependent("OpenGL13") + void glCopyMultiTexImage1DEXT(@GLenum int texunit, @GLenum int target, int level, @GLenum int internalformat, int x, int y, @GLsizei int width, int border); + + @Dependent("OpenGL13") + void glCopyMultiTexImage2DEXT(@GLenum int texunit, @GLenum int target, int level, @GLenum int internalformat, int x, int y, @GLsizei int width, @GLsizei int height, int border); + + @Dependent("OpenGL13") + void glCopyMultiTexSubImage1DEXT(@GLenum int texunit, @GLenum int target, int level, int xoffset, int x, int y, @GLsizei int width); + + @Dependent("OpenGL13") + void glCopyMultiTexSubImage2DEXT(@GLenum int texunit, @GLenum int target, int level, int xoffset, int yoffset, int x, int y, @GLsizei int width, @GLsizei int height); + + @Dependent("OpenGL13") + void glGetMultiTexImageEXT(@GLenum int texunit, @GLenum int target, int level, @GLenum int format, @GLenum int type, + @OutParameter + @BufferObject(BufferKind.PackPBO) + @Check("GLChecks.calculateImageStorage(pixels, format, type, 1, 1, 1)") + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer pixels); + + @Dependent("OpenGL13") + @StripPostfix("params") + void glGetMultiTexParameterfvEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Check("4") @OutParameter FloatBuffer params); + + @Dependent("OpenGL13") + @StripPostfix("params") + void glGetMultiTexParameterivEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Check("4") @OutParameter IntBuffer params); + + @Dependent("OpenGL13") + @StripPostfix("params") + void glGetMultiTexLevelParameterfvEXT(@GLenum int texunit, @GLenum int target, int level, @GLenum int pname, @Check("4") @OutParameter FloatBuffer params); + + @Dependent("OpenGL13") + @StripPostfix("params") + void glGetMultiTexLevelParameterivEXT(@GLenum int texunit, @GLenum int target, int level, @GLenum int pname, @Check("4") @OutParameter IntBuffer params); + + @Dependent("OpenGL13") + void glMultiTexImage3DEXT(@GLenum int texunit, @GLenum int target, int level, + int internalformat, @GLsizei int width, @GLsizei int height, @GLsizei int depth, int border, @GLenum int format, @GLenum int type, + @BufferObject(BufferKind.UnpackPBO) + @Check(value = "GLChecks.calculateTexImage3DStorage(pixels, format, type, width, height, depth)", canBeNull = true) + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer pixels); + + @Dependent("OpenGL13") + void glMultiTexSubImage3DEXT(@GLenum int texunit, @GLenum int target, int level, + int xoffset, int yoffset, int zoffset, @GLsizei int width, @GLsizei int height, @GLsizei int depth, @GLenum int format, @GLenum int type, + @BufferObject(BufferKind.UnpackPBO) + @Check("GLChecks.calculateImageStorage(pixels, format, type, width, height, depth)") + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer pixels); + + @Dependent("OpenGL13") + void glCopyMultiTexSubImage3DEXT(@GLenum int texunit, @GLenum int target, int level, int xoffset, int yoffset, int zoffset, int x, int y, @GLsizei int width, @GLsizei int height); + + /* + OpenGL 1.2.1: New indexed texture commands and queries append + "Indexed" to name and add "uint index" parameter (to identify the + texture unit index) after state name parameters (if any) and before + state value parameters + */ + + @Dependent("OpenGL13") + @DeprecatedGL + void glEnableClientStateIndexedEXT(@GLenum int array, @GLuint int index); + + @Dependent("OpenGL13") + @DeprecatedGL + void glDisableClientStateIndexedEXT(@GLenum int array, @GLuint int index); + + /* + OpenGL 1.2.1: New indexed generic queries (added for indexed texture + state) append "Indexed" to name and add "uint index" parameter + (to identify the texture unit) after state name parameters (if any) + and before state value parameters + */ + + @Dependent("OpenGL13") + @StripPostfix("params") + void glGetFloatIndexedvEXT(@GLenum int pname, @GLuint int index, @OutParameter @Check("16")FloatBuffer params); + + @Dependent("OpenGL13") + @StripPostfix("params") + void glGetDoubleIndexedvEXT(@GLenum int pname, @GLuint int index, @OutParameter @Check("16")DoubleBuffer params); + + @Dependent("OpenGL13") + @StripPostfix("params") + void glGetPointerIndexedvEXT(@GLenum int pname, @GLuint int index, @Result @GLvoid ByteBuffer params); + + /* + OpenGL 1.2.1: Extend the functionality of these EXT_draw_buffers2 + commands and queries for multitexture + TODO: Why 1.2.1 and not EXT_draw_buffers2? + */ + + @Dependent("GL_EXT_draw_buffers2") + void glEnableIndexedEXT(@GLenum int cap, @GLuint int index); + + @Dependent("GL_EXT_draw_buffers2") + void glDisableIndexedEXT(@GLenum int cap, @GLuint int index); + + @Dependent("GL_EXT_draw_buffers2") + boolean glIsEnabledIndexedEXT(@GLenum int cap, @GLuint int index); + + @Dependent("GL_EXT_draw_buffers2") + @StripPostfix("params") + void glGetIntegerIndexedvEXT(@GLenum int pname, @GLuint int index, @OutParameter @Check("16")IntBuffer params); + + @Dependent("GL_EXT_draw_buffers2") + @StripPostfix("params") + void glGetBooleanIndexedvEXT(@GLenum int pname, @GLuint int index, @OutParameter @Check("16") @GLboolean ByteBuffer params); + + /* + ARB_vertex_program: New program commands and queries add "Named" + prefix to name and adds initial "uint program" parameter + */ + + @Dependent("GL_ARB_vertex_program") + void glNamedProgramStringEXT(@GLuint int program, @GLenum int target, @GLenum int format, @AutoSize("string") @GLsizei int len, @Const @GLvoid Buffer string); + + @Dependent("GL_ARB_vertex_program") + void glNamedProgramLocalParameter4dEXT(@GLuint int program, @GLenum int target, @GLuint int index, double x, double y, double z, double w); + + @Dependent("GL_ARB_vertex_program") + @StripPostfix("params") + void glNamedProgramLocalParameter4dvEXT(@GLuint int program, @GLenum int target, @GLuint int index, @Const @Check("4")DoubleBuffer params); + + @Dependent("GL_ARB_vertex_program") + void glNamedProgramLocalParameter4fEXT(@GLuint int program, @GLenum int target, @GLuint int index, float x, float y, float z, float w); + + @Dependent("GL_ARB_vertex_program") + @StripPostfix("params") + void glNamedProgramLocalParameter4fvEXT(@GLuint int program, @GLenum int target, @GLuint int index, @Const @Check("4")FloatBuffer params); + + @Dependent("GL_ARB_vertex_program") + @StripPostfix("params") + void glGetNamedProgramLocalParameterdvEXT(@GLuint int program, @GLenum int target, @GLuint int index, @OutParameter @Check("4")DoubleBuffer params); + + @Dependent("GL_ARB_vertex_program") + @StripPostfix("params") + void glGetNamedProgramLocalParameterfvEXT(@GLuint int program, @GLenum int target, @GLuint int index, @OutParameter @Check("4")FloatBuffer params); + + @Dependent("GL_ARB_vertex_program") + @StripPostfix("params") + void glGetNamedProgramivEXT(@GLuint int program, @GLenum int target, @GLenum int pname, @OutParameter @Check("4")IntBuffer params); + + @Dependent("GL_ARB_vertex_program") + void glGetNamedProgramStringEXT(@GLuint int program, @GLenum int target, @GLenum int pname, @OutParameter @Check @GLvoid ByteBuffer string); + + /* + OpenGL 1.3: New compressed texture object commands replace "Tex" + in name with "Texture" and add initial "uint texture" parameter + */ + + @Dependent("OpenGL13") + void glCompressedTextureImage3DEXT(@GLuint int texture, @GLenum int target, int level, + @GLenum int internalformat, @GLsizei int width, @GLsizei int height, @GLsizei int depth, int border, @AutoSize("data") @GLsizei int imageSize, + @BufferObject(BufferKind.UnpackPBO) + @Check + @Const + @GLvoid + ByteBuffer data); + + @Dependent("OpenGL13") + void glCompressedTextureImage2DEXT(@GLuint int texture, @GLenum int target, int level, + @GLenum int internalformat, @GLsizei int width, @GLsizei int height, int border, @AutoSize("data") @GLsizei int imageSize, + @BufferObject(BufferKind.UnpackPBO) + @Check + @Const + @GLvoid + ByteBuffer data); + + @Dependent("OpenGL13") + void glCompressedTextureImage1DEXT(@GLuint int texture, @GLenum int target, int level, + @GLenum int internalformat, @GLsizei int width, int border, @AutoSize("data") @GLsizei int imageSize, + @BufferObject(BufferKind.UnpackPBO) + @Check + @Const + @GLvoid + ByteBuffer data); + + @Dependent("OpenGL13") + void glCompressedTextureSubImage3DEXT(@GLuint int texture, @GLenum int target, int level, + int xoffset, int yoffset, int zoffset, @GLsizei int width, @GLsizei int height, @GLsizei int depth, + @GLenum int format, @AutoSize("data") @GLsizei int imageSize, + @BufferObject(BufferKind.UnpackPBO) + @Check + @Const + @GLvoid + ByteBuffer data); + + @Dependent("OpenGL13") + void glCompressedTextureSubImage2DEXT(@GLuint int texture, @GLenum int target, int level, + int xoffset, int yoffset, @GLsizei int width, @GLsizei int height, @GLenum int format, @AutoSize("data") @GLsizei int imageSize, + @BufferObject(BufferKind.UnpackPBO) + @Check + @Const + @GLvoid + ByteBuffer data); + + @Dependent("OpenGL13") + void glCompressedTextureSubImage1DEXT(@GLuint int texture, @GLenum int target, int level, + int xoffset, @GLsizei int width, @GLenum int format, @AutoSize("data") @GLsizei int imageSize, + @BufferObject(BufferKind.UnpackPBO) + @Check + @Const + @GLvoid + ByteBuffer data); + + @Dependent("OpenGL13") + void glGetCompressedTextureImageEXT(@GLuint int texture, @GLenum int target, int level, + @OutParameter + @BufferObject(BufferKind.PackPBO) + @Check + @GLbyte + @GLshort + @GLint Buffer img); + + /* + OpenGL 1.3: New multitexture compressed texture commands and queries + prefix "Multi" before "Tex" and add an initial "enum texunit" + parameter (to identify the texture unit) + */ + + @Dependent("OpenGL13") + void glCompressedMultiTexImage3DEXT(@GLenum int texunit, @GLenum int target, int level, + @GLenum int internalformat, @GLsizei int width, @GLsizei int height, @GLsizei int depth, int border, @AutoSize("data") @GLsizei int imageSize, + @BufferObject(BufferKind.UnpackPBO) + @Check + @Const + @GLvoid + ByteBuffer data); + + @Dependent("OpenGL13") + void glCompressedMultiTexImage2DEXT(@GLenum int texunit, @GLenum int target, int level, + @GLenum int internalformat, @GLsizei int width, @GLsizei int height, int border, @AutoSize("data") @GLsizei int imageSize, + @BufferObject(BufferKind.UnpackPBO) + @Check + @Const + @GLvoid + ByteBuffer data); + + @Dependent("OpenGL13") + void glCompressedMultiTexImage1DEXT(@GLenum int texunit, @GLenum int target, int level, + @GLenum int internalformat, @GLsizei int width, int border, @AutoSize("data") @GLsizei int imageSize, + @BufferObject(BufferKind.UnpackPBO) + @Check + @Const + @GLvoid + ByteBuffer data); + + @Dependent("OpenGL13") + void glCompressedMultiTexSubImage3DEXT(@GLenum int texunit, @GLenum int target, int level, + int xoffset, int yoffset, int zoffset, @GLsizei int width, @GLsizei int height, @GLsizei int depth, + @GLenum int format, @AutoSize("data") @GLsizei int imageSize, + @BufferObject(BufferKind.UnpackPBO) + @Check + @Const + @GLvoid + ByteBuffer data); + + @Dependent("OpenGL13") + void glCompressedMultiTexSubImage2DEXT(@GLenum int texunit, @GLenum int target, int level, + int xoffset, int yoffset, @GLsizei int width, @GLsizei int height, @GLenum int format, @AutoSize("data") @GLsizei int imageSize, + @BufferObject(BufferKind.UnpackPBO) + @Check + @Const + @GLvoid + ByteBuffer data); + + @Dependent("OpenGL13") + void glCompressedMultiTexSubImage1DEXT(@GLenum int texunit, @GLenum int target, int level, + int xoffset, @GLsizei int width, @GLenum int format, @AutoSize("data") @GLsizei int imageSize, + @BufferObject(BufferKind.UnpackPBO) + @Check + @Const + @GLvoid + ByteBuffer data); + + @Dependent("OpenGL13") + void glGetCompressedMultiTexImageEXT(@GLenum int texunit, @GLenum int target, int level, + @OutParameter + @BufferObject(BufferKind.PackPBO) + @Check + @GLbyte + @GLshort + @GLint Buffer img); + + void glGetCompressedTexImage(@GLenum int target, int lod, + @OutParameter + @BufferObject(BufferKind.PackPBO) + @Check + @GLbyte + @GLshort + @GLint Buffer img); + + /* + OpenGL 1.3: New transpose matrix commands add "Matrix" suffix + to name, drops "Matrix" suffix from name, and add initial "enum + matrixMode" parameter + */ + + @Dependent("OpenGL13") + @StripPostfix("m") + @DeprecatedGL + void glMatrixLoadTransposefEXT(@GLenum int matrixMode, @Check("16") @Const FloatBuffer m); + + @Dependent("OpenGL13") + @StripPostfix("m") + @DeprecatedGL + void glMatrixLoadTransposedEXT(@GLenum int matrixMode, @Check("16") @Const DoubleBuffer m); + + @Dependent("OpenGL13") + @StripPostfix("m") + @DeprecatedGL + void glMatrixMultTransposefEXT(@GLenum int matrixMode, @Check("16") @Const FloatBuffer m); + + @Dependent("OpenGL13") + @StripPostfix("m") + @DeprecatedGL + void glMatrixMultTransposedEXT(@GLenum int matrixMode, @Check("16") @Const DoubleBuffer m); + + /* + OpenGL 1.5: New buffer commands and queries replace "Buffer" with + "NamedBuffer" in name and replace "enum target" parameter with + "uint buffer" + */ + + @Dependent("OpenGL15") + void glNamedBufferDataEXT(@GLuint int buffer, @AutoSize("data") @GLsizeiptr long size, + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer data, @GLenum int usage); + + @Dependent("OpenGL15") + void glNamedBufferSubDataEXT(@GLuint int buffer, @GLintptr long offset, @AutoSize("data") @GLsizeiptr long size, + @Check + @Const + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer data); + + @Dependent("OpenGL15") + @CachedResult + @GLvoid + @AutoResultSize("GLChecks.getNamedBufferObjectSize(caps, buffer)") + ByteBuffer glMapNamedBufferEXT(@GLuint int buffer, @GLenum int access); + + @Dependent("OpenGL15") + boolean glUnmapNamedBufferEXT(@GLuint int buffer); + + @Dependent("OpenGL15") + @StripPostfix("params") + void glGetNamedBufferParameterivEXT(@GLuint int buffer, @GLenum int pname, @OutParameter @Check("4")IntBuffer params); + + @Dependent("OpenGL15") + @StripPostfix("params") + @AutoResultSize("GLChecks.getNamedBufferObjectSize(caps, buffer)") + void glGetNamedBufferPointervEXT(@GLuint int buffer, @GLenum int pname, @OutParameter @Result @GLvoid ByteBuffer params); + + @Dependent("OpenGL15") + void glGetNamedBufferSubDataEXT(@GLuint int buffer, @GLintptr long offset, @AutoSize("data") @GLsizeiptr long size, + @OutParameter + @Check + @GLbyte + @GLshort + @GLint + @GLfloat + @GLdouble Buffer data); + + /* + OpenGL 2.0: New uniform commands add "Program" prefix to name and + add initial "uint program" parameter + */ + + @Dependent("OpenGL20") + void glProgramUniform1fEXT(@GLuint int program, int location, float v0); + + @Dependent("OpenGL20") + void glProgramUniform2fEXT(@GLuint int program, int location, float v0, float v1); + + @Dependent("OpenGL20") + void glProgramUniform3fEXT(@GLuint int program, int location, float v0, float v1, float v2); + + @Dependent("OpenGL20") + void glProgramUniform4fEXT(@GLuint int program, int location, float v0, float v1, float v2, float v3); + + void glProgramUniform1iEXT(@GLuint int program, int location, int v0); + + @Dependent("OpenGL20") + void glProgramUniform2iEXT(@GLuint int program, int location, int v0, int v1); + + @Dependent("OpenGL20") + void glProgramUniform3iEXT(@GLuint int program, int location, int v0, int v1, int v2); + + @Dependent("OpenGL20") + void glProgramUniform4iEXT(@GLuint int program, int location, int v0, int v1, int v2, int v3); + + @Dependent("OpenGL20") + @StripPostfix("value") + void glProgramUniform1fvEXT(@GLuint int program, int location, @AutoSize(value = "value") @GLsizei int count, @Const FloatBuffer value); + + @Dependent("OpenGL20") + @StripPostfix("value") + void glProgramUniform2fvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const FloatBuffer value); + + @Dependent("OpenGL20") + @StripPostfix("value") + void glProgramUniform3fvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const FloatBuffer value); + + @Dependent("OpenGL20") + @StripPostfix("value") + void glProgramUniform4fvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const FloatBuffer value); + + @Dependent("OpenGL20") + @StripPostfix("value") + void glProgramUniform1ivEXT(@GLuint int program, int location, @AutoSize(value = "value") @GLsizei int count, @Const IntBuffer value); + + @Dependent("OpenGL20") + @StripPostfix("value") + void glProgramUniform2ivEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const IntBuffer value); + + @Dependent("OpenGL20") + @StripPostfix("value") + void glProgramUniform3ivEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const IntBuffer value); + + @Dependent("OpenGL20") + @StripPostfix("value") + void glProgramUniform4ivEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const IntBuffer value); + + @Dependent("OpenGL20") + @StripPostfix("value") + void glProgramUniformMatrix2fvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, boolean transpose, @Const FloatBuffer value); + + @Dependent("OpenGL20") + @StripPostfix("value") + void glProgramUniformMatrix3fvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " / (3 * 3)") @GLsizei int count, boolean transpose, @Const FloatBuffer value); + + @Dependent("OpenGL20") + @StripPostfix("value") + void glProgramUniformMatrix4fvEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 4") @GLsizei int count, boolean transpose, @Const FloatBuffer value); + + /* + OpenGL 2.1: New uniform matrix commands add "Program" prefix to + name and add initial "uint program" parameter + */ + + @Dependent("OpenGL21") + @StripPostfix("value") + void glProgramUniformMatrix2x3fvEXT(@GLuint int program, int location, + @AutoSize(value = "value", expression = " / (2 * 3)") @GLsizei int count, boolean transpose, @Const FloatBuffer value); + + @Dependent("OpenGL21") + @StripPostfix("value") + void glProgramUniformMatrix3x2fvEXT(@GLuint int program, int location, + @AutoSize(value = "value", expression = " / (3 * 2)") @GLsizei int count, boolean transpose, @Const FloatBuffer value); + + @Dependent("OpenGL21") + @StripPostfix("value") + void glProgramUniformMatrix2x4fvEXT(@GLuint int program, int location, + @AutoSize(value = "value", expression = " >> 3") @GLsizei int count, boolean transpose, @Const FloatBuffer value); + + @Dependent("OpenGL21") + @StripPostfix("value") + void glProgramUniformMatrix4x2fvEXT(@GLuint int program, int location, + @AutoSize(value = "value", expression = " >> 3") @GLsizei int count, boolean transpose, @Const FloatBuffer value); + + @Dependent("OpenGL21") + @StripPostfix("value") + void glProgramUniformMatrix3x4fvEXT(@GLuint int program, int location, + @AutoSize(value = "value", expression = " / (3 * 4)") @GLsizei int count, boolean transpose, @Const FloatBuffer value); + + @Dependent("OpenGL21") + @StripPostfix("value") + void glProgramUniformMatrix4x3fvEXT(@GLuint int program, int location, + @AutoSize(value = "value", expression = " / (4 * 3)") @GLsizei int count, boolean transpose, @Const FloatBuffer value); + + /* + EXT_texture_buffer_object: New texture buffer object command + replaces "Tex" in name with "Texture" and adds initial "uint texture" + parameter + */ + + @Dependent("GL_EXT_texture_buffer_object") + void glTextureBufferEXT(@GLuint int texture, @GLenum int target, @GLenum int internalformat, @GLuint int buffer); + + /* + EXT_texture_buffer_object: New multitexture texture buffer command + prefixes "Multi" before "Tex" and add an initial "enum texunit" + parameter (to identify the texture unit) + */ + + @Dependent("GL_EXT_texture_buffer_object") + void glMultiTexBufferEXT(@GLenum int texunit, @GLenum int target, @GLenum int internalformat, @GLuint int buffer); + + /* + EXT_texture_integer: New integer texture object commands and queries + replace "Tex" in name with "Texture" and add initial "uint texture" + parameter + */ + + @Dependent("GL_EXT_texture_integer") + @StripPostfix("params") + void glTextureParameterIivEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, @Check("4") @Const IntBuffer params); + + @Dependent("GL_EXT_texture_integer") + @StripPostfix("params") + void glTextureParameterIuivEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, @Check("4") @Const @GLuint IntBuffer params); + + @Dependent("GL_EXT_texture_integer") + @StripPostfix("params") + void glGetTextureParameterIivEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, @Check("4") @OutParameter IntBuffer params); + + @Dependent("GL_EXT_texture_integer") + @StripPostfix("params") + void glGetTextureParameterIuivEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, @Check("4") @OutParameter @GLuint IntBuffer params); + + /* + EXT_texture_integer: New multitexture integer texture commands and + queries prefix "Multi" before "Tex" and add an initial "enum texunit" + parameter (to identify the texture unit) + */ + + @Dependent("GL_EXT_texture_integer") + @StripPostfix("params") + void glMultiTexParameterIivEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Check("4") @Const IntBuffer params); + + @Dependent("GL_EXT_texture_integer") + @StripPostfix("params") + void glMultiTexParameterIuivEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Check("4") @Const @GLuint IntBuffer params); + + @Dependent("GL_EXT_texture_integer") + @StripPostfix("params") + void glGetMultiTexParameterIivEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Check("4") @OutParameter IntBuffer params); + + @Dependent("GL_EXT_texture_integer") + @StripPostfix("params") + void glGetMultiTexParameterIuivEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Check("4") @OutParameter @GLuint IntBuffer params); + + /* + EXT_gpu_shader4: New integer uniform commands add "Program" prefix + to name and add initial "uint program" parameter + */ + + @Dependent("GL_EXT_gpu_shader4") + void glProgramUniform1uiEXT(@GLuint int program, int location, @GLuint int v0); + + @Dependent("GL_EXT_gpu_shader4") + void glProgramUniform2uiEXT(@GLuint int program, int location, @GLuint int v0, @GLuint int v1); + + @Dependent("GL_EXT_gpu_shader4") + void glProgramUniform3uiEXT(@GLuint int program, int location, @GLuint int v0, @GLuint int v1, @GLuint int v2); + + @Dependent("GL_EXT_gpu_shader4") + void glProgramUniform4uiEXT(@GLuint int program, int location, @GLuint int v0, @GLuint int v1, @GLuint int v2, @GLuint int v3); + + @Dependent("GL_EXT_gpu_shader4") + @StripPostfix("value") + void glProgramUniform1uivEXT(@GLuint int program, int location, @AutoSize(value = "value") @GLsizei int count, @Const @GLuint IntBuffer value); + + @Dependent("GL_EXT_gpu_shader4") + @StripPostfix("value") + void glProgramUniform2uivEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const @GLuint IntBuffer value); + + @Dependent("GL_EXT_gpu_shader4") + @StripPostfix("value") + void glProgramUniform3uivEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const @GLuint IntBuffer value); + + @Dependent("GL_EXT_gpu_shader4") + @StripPostfix("value") + void glProgramUniform4uivEXT(@GLuint int program, int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const @GLuint IntBuffer value); + + /* + EXT_gpu_program_parameters: New program command adds "Named" prefix + to name and adds "uint program" parameter + */ + + @Dependent("GL_EXT_gpu_program_parameters") + @StripPostfix("params") + void glNamedProgramLocalParameters4fvEXT(@GLuint int program, @GLenum int target, @GLuint int index, + @AutoSize(value = "params", expression = " >> 2") @GLsizei int count, @Const FloatBuffer params); + + /* + NV_gpu_program4: New program commands and queries add "Named" + prefix to name and replace "enum target" with "uint program" + */ + + @Dependent("GL_NV_gpu_program4") + void glNamedProgramLocalParameterI4iEXT(@GLuint int program, @GLenum int target, @GLuint int index, int x, int y, int z, int w); + + @Dependent("GL_NV_gpu_program4") + @StripPostfix("params") + void glNamedProgramLocalParameterI4ivEXT(@GLuint int program, @GLenum int target, @GLuint int index, @Check("4") @Const IntBuffer params); + + @Dependent("GL_NV_gpu_program4") + @StripPostfix("params") + void glNamedProgramLocalParametersI4ivEXT(@GLuint int program, @GLenum int target, @GLuint int index, + @AutoSize(value = "params", expression = " >> 2") @GLsizei int count, @Const IntBuffer params); + + @Dependent("GL_NV_gpu_program4") + void glNamedProgramLocalParameterI4uiEXT(@GLuint int program, @GLenum int target, @GLuint int index, @GLuint int x, @GLuint int y, @GLuint int z, @GLuint int w); + + @Dependent("GL_NV_gpu_program4") + @StripPostfix("params") + void glNamedProgramLocalParameterI4uivEXT(@GLuint int program, @GLenum int target, @GLuint int index, @Check("4") @Const @GLuint IntBuffer params); + + @Dependent("GL_NV_gpu_program4") + @StripPostfix("params") + void glNamedProgramLocalParametersI4uivEXT(@GLuint int program, @GLenum int target, @GLuint int index, + @AutoSize(value = "params", expression = " >> 2") @GLsizei int count, @Const @GLuint IntBuffer params); + + @Dependent("GL_NV_gpu_program4") + @StripPostfix("params") + void glGetNamedProgramLocalParameterIivEXT(@GLuint int program, @GLenum int target, @GLuint int index, @Check("4") @OutParameter IntBuffer params); + + @Dependent("GL_NV_gpu_program4") + @StripPostfix("params") + void glGetNamedProgramLocalParameterIuivEXT(@GLuint int program, @GLenum int target, @GLuint int index, @Check("4") @OutParameter @GLuint IntBuffer params); + + /* + EXT_framebuffer_object: New renderbuffer commands add "Named" prefix + to name and replace "enum target" with "uint renderbuffer" + */ + + @Dependent("GL_EXT_framebuffer_object") + void glNamedRenderbufferStorageEXT(@GLuint int renderbuffer, @GLenum int internalformat, @GLsizei int width, @GLsizei int height); + + @Dependent("GL_EXT_framebuffer_object") + @StripPostfix("params") + void glGetNamedRenderbufferParameterivEXT(@GLuint int renderbuffer, @GLenum int pname, @Check("4") @OutParameter IntBuffer params); + + /* + EXT_framebuffer_multisample: New renderbuffer commands add "Named" + prefix to name and replace "enum target" with "uint renderbuffer" + */ + + @Dependent("GL_EXT_framebuffer_multisample") + void glNamedRenderbufferStorageMultisampleEXT(@GLuint int renderbuffer, @GLsizei int samples, @GLenum int internalformat, @GLsizei int width, @GLsizei int height); + + /* + NV_framebuffer_multisample_coverage: New renderbuffer commands + add "Named" prefix to name and replace "enum target" with "uint + renderbuffer" + */ + + @Dependent("GL_NV_framebuffer_multisample_coverage") + void glNamedRenderbufferStorageMultisampleCoverageEXT(@GLuint int renderbuffer, @GLsizei int coverageSamples, @GLsizei int colorSamples, @GLenum int internalformat, @GLsizei int width, @GLsizei int height); + + /* + EXT_framebuffer_object: New framebuffer commands add "Named" prefix + to name and replace "enum target" with "uint framebuffer" + */ + + @Dependent("GL_EXT_framebuffer_object") + @GLenum + int glCheckNamedFramebufferStatusEXT(@GLuint int framebuffer, @GLenum int target); + + @Dependent("GL_EXT_framebuffer_object") + void glNamedFramebufferTexture1DEXT(@GLuint int framebuffer, @GLenum int attachment, @GLenum int textarget, @GLuint int texture, int level); + + @Dependent("GL_EXT_framebuffer_object") + void glNamedFramebufferTexture2DEXT(@GLuint int framebuffer, @GLenum int attachment, @GLenum int textarget, @GLuint int texture, int level); + + @Dependent("GL_EXT_framebuffer_object") + void glNamedFramebufferTexture3DEXT(@GLuint int framebuffer, @GLenum int attachment, @GLenum int textarget, @GLuint int texture, int level, int zoffset); + + @Dependent("GL_EXT_framebuffer_object") + void glNamedFramebufferRenderbufferEXT(@GLuint int framebuffer, @GLenum int attachment, @GLenum int renderbuffertarget, @GLuint int renderbuffer); + + @Dependent("GL_EXT_framebuffer_object") + @StripPostfix("params") + void glGetNamedFramebufferAttachmentParameterivEXT(@GLuint int framebuffer, @GLenum int attachment, @GLenum int pname, @Check("4") @OutParameter IntBuffer params); + + /* + EXT_framebuffer_object: New texture commands add "Texture" within + name and replace "enum target" with "uint texture" + */ + + @Dependent("GL_EXT_framebuffer_object") + void glGenerateTextureMipmapEXT(@GLuint int texture, @GLenum int target); + + /* + EXT_framebuffer_object: New texture commands add "MultiTex" within + name and replace "enum target" with "enum texunit" + */ + + @Dependent("GL_EXT_framebuffer_object") + void glGenerateMultiTexMipmapEXT(@GLenum int texunit, @GLenum int target); + + /* + EXT_framebuffer_object: New framebuffer commands + */ + + @Dependent("GL_EXT_framebuffer_object") + void glFramebufferDrawBufferEXT(@GLuint int framebuffer, @GLenum int mode); + + @Dependent("GL_EXT_framebuffer_object") + void glFramebufferDrawBuffersEXT(@GLuint int framebuffer, @AutoSize("bufs") @GLsizei int n, @Const @GLenum IntBuffer bufs); + + @Dependent("GL_EXT_framebuffer_object") + void glFramebufferReadBufferEXT(@GLuint int framebuffer, @GLenum int mode); + + /* + EXT_framebuffer_object: New framebuffer query + */ + + @Dependent("GL_EXT_framebuffer_object") + @StripPostfix("param") + void glGetFramebufferParameterivEXT(@GLuint int framebuffer, @GLenum int pname, @Check("4") @OutParameter IntBuffer param); + + /* + EXT_geometry_shader4 or NV_gpu_program4: New framebuffer commands + add "Named" prefix to name and replace "enum target" with "uint + framebuffer" + */ + + @Dependent("GL_EXT_geometry_shader4") + void glNamedFramebufferTextureEXT(@GLuint int framebuffer, @GLenum int attachment, @GLuint int texture, int level); + + @Dependent("GL_EXT_geometry_shader4") + void glNamedFramebufferTextureLayerEXT(@GLuint int framebuffer, @GLenum int attachment, @GLuint int texture, int level, int layer); + + @Dependent("GL_EXT_geometry_shader4") + void glNamedFramebufferTextureFaceEXT(@GLuint int framebuffer, @GLenum int attachment, @GLuint int texture, int level, @GLenum int face); + + /* + NV_explicit_multisample: New texture renderbuffer object command + replaces "Tex" in name with "Texture" and add initial "uint texture" + parameter + */ + + @Dependent("GL_NV_explicit_multisample") + void glTextureRenderbufferEXT(@GLuint int texture, @GLenum int target, @GLuint int renderbuffer); + + /* + NV_explicit_multisample: New multitexture texture renderbuffer command + prefixes "Multi" before "Tex" and add an initial "enum texunit" + parameter (to identify the texture unit) + */ + + @Dependent("GL_NV_explicit_multisample") + void glMultiTexRenderbufferEXT(@GLenum int texunit, @GLenum int target, @GLuint int renderbuffer); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/EXT_secondary_color.java b/src/templates/org/lwjgl/opengl/EXT_secondary_color.java index 291fb2b7..10e55e40 100644 --- a/src/templates/org/lwjgl/opengl/EXT_secondary_color.java +++ b/src/templates/org/lwjgl/opengl/EXT_secondary_color.java @@ -33,9 +33,10 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; -import java.nio.*; +import java.nio.Buffer; public interface EXT_secondary_color { + int GL_COLOR_SUM_EXT = 0x8458; int GL_CURRENT_SECONDARY_COLOR_EXT = 0x8459; int GL_SECONDARY_COLOR_ARRAY_SIZE_EXT = 0x845A; diff --git a/src/templates/org/lwjgl/opengl/EXT_transform_feedback.java b/src/templates/org/lwjgl/opengl/EXT_transform_feedback.java index a72f215e..47439c2d 100644 --- a/src/templates/org/lwjgl/opengl/EXT_transform_feedback.java +++ b/src/templates/org/lwjgl/opengl/EXT_transform_feedback.java @@ -101,13 +101,13 @@ public interface EXT_transform_feedback { void glEndTransformFeedbackEXT(); - void glTransformFeedbackVaryingsEXT(@GLuint int program, @GLsizei int count, @Const @GLchar ByteBuffer varyings, @GLenum int bufferMode); + void glTransformFeedbackVaryingsEXT(@GLuint int program, @GLsizei int count, @Const @NullTerminated @GLchar ByteBuffer varyings, @GLenum int bufferMode); void glGetTransformFeedbackVaryingEXT(@GLuint int program, @GLuint int index, @AutoSize("name") @GLsizei int bufSize, @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length, @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer size, @OutParameter @Check(value = "1", canBeNull = true) @GLenum IntBuffer type, - @GLcharARB ByteBuffer name); + @GLchar ByteBuffer name); } \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/GL11.java b/src/templates/org/lwjgl/opengl/GL11.java index fe3279a8..73d4f65c 100644 --- a/src/templates/org/lwjgl/opengl/GL11.java +++ b/src/templates/org/lwjgl/opengl/GL11.java @@ -32,6 +32,7 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.DeprecatedGL; import java.nio.*; @@ -43,7 +44,7 @@ import java.nio.*; * @version $Revision$ * $Id$ */ - +@DeprecatedGL public interface GL11 { /* AccumOp */ int GL_ACCUM = 0x0100; @@ -714,26 +715,32 @@ public interface GL11 { int GL_LOGIC_OP = GL_INDEX_LOGIC_OP; int GL_TEXTURE_COMPONENTS = GL_TEXTURE_INTERNAL_FORMAT; + @DeprecatedGL void glAccum(@GLenum int op, float value); + @DeprecatedGL void glAlphaFunc(@GLenum int func, @GLclampf float ref); void glClearColor(@GLclampf float red, @GLclampf float green, @GLclampf float blue, @GLclampf float alpha); + @DeprecatedGL void glClearAccum(float red, float green, float blue, float alpha); void glClear(@GLbitfield int mask); + @DeprecatedGL void glCallLists(@AutoSize("lists") @GLsizei int n, @AutoType("lists") @GLenum int type, @Const @GLubyte @GLushort @GLuint Buffer lists); + @DeprecatedGL void glCallList(@GLuint int list); void glBlendFunc(@GLenum int sfactor, @GLenum int dfactor); + @DeprecatedGL void glBitmap(@GLsizei int width, @GLsizei int height, float xorig, float yorig, float xmove, float ymove, @BufferObject(BufferKind.UnpackPBO) @Check("(((width + 7)/8)*height)") @@ -742,6 +749,7 @@ public interface GL11 { void glBindTexture(@GLenum int target, @GLuint int texture); + @DeprecatedGL void glPrioritizeTextures(@AutoSize("textures") @GLsizei int n, @Const @GLuint IntBuffer textures, @@ -749,6 +757,7 @@ public interface GL11 { @Check("textures.remaining()") @GLclampf FloatBuffer priorities); + @DeprecatedGL boolean glAreTexturesResident(@AutoSize("textures") @GLsizei int n, @Const @GLuint IntBuffer textures, @@ -756,8 +765,10 @@ public interface GL11 { @GLboolean ByteBuffer residences); @NoErrorCheck + @DeprecatedGL void glBegin(@GLenum int mode); + @DeprecatedGL void glEnd(); @NoErrorCheck @@ -765,6 +776,7 @@ public interface GL11 { void glClearDepth(@GLclampd double depth); + @DeprecatedGL void glDeleteLists(@GLuint int list, @GLsizei int range); void glDeleteTextures(@AutoSize("textures") @GLsizei int n, @Const @GLuint IntBuffer textures); @@ -781,6 +793,7 @@ public interface GL11 { void glCopyPixels(int x, int y, int width, int height, int type); + @DeprecatedGL void glColorPointer(int size, @AutoType("pointer") @GLenum int type, @GLsizei int stride, @CachedReference @Check @@ -791,32 +804,41 @@ public interface GL11 { @GLubyte @GLbyte Buffer pointer); + @DeprecatedGL void glColorMaterial(@GLenum int face, @GLenum int mode); void glColorMask(boolean red, boolean green, boolean blue, boolean alpha); @NoErrorCheck + @DeprecatedGL void glColor3b(byte red, byte green, byte blue); @NoErrorCheck + @DeprecatedGL void glColor3f(float red, float green, float blue); @NoErrorCheck + @DeprecatedGL void glColor3d(double red, double green, double blue); @NoErrorCheck + @DeprecatedGL void glColor3ub(@GLubyte byte red, @GLubyte byte green, @GLubyte byte blue); @NoErrorCheck + @DeprecatedGL void glColor4b(byte red, byte green, byte blue, byte alpha); @NoErrorCheck + @DeprecatedGL void glColor4f(float red, float green, float blue, float alpha); @NoErrorCheck + @DeprecatedGL void glColor4d(double red, double green, double blue, double alpha); @NoErrorCheck + @DeprecatedGL void glColor4ub(@GLubyte byte red, @GLubyte byte green, @GLubyte byte blue, @GLubyte byte alpha); void glClipPlane(@GLenum int plane, @Check("4") @Const DoubleBuffer equation); @@ -824,31 +846,43 @@ public interface GL11 { void glClearStencil(int s); // This function is only used in indexed color mode -// void glClearIndex(float c); + // void glClearIndex(float c); + + @DeprecatedGL void glEvalPoint1(int i); + @DeprecatedGL void glEvalPoint2(int i, int j); + @DeprecatedGL void glEvalMesh1(@GLenum int mode, int i1, int i2); + @DeprecatedGL void glEvalMesh2(@GLenum int mode, int i1, int i2, int j1, int j2); + @DeprecatedGL void glEvalCoord1f(float u); + @DeprecatedGL void glEvalCoord1d(double u); + @DeprecatedGL void glEvalCoord2f(float u, float v); + @DeprecatedGL void glEvalCoord2d(double u, double v); + @DeprecatedGL void glEnableClientState(@GLenum int cap); + @DeprecatedGL void glDisableClientState(@GLenum int cap); void glEnable(@GLenum int cap); void glDisable(@GLenum int cap); + @DeprecatedGL void glEdgeFlagPointer(int stride, @CachedReference @BufferObject(BufferKind.ArrayVBO) @@ -856,8 +890,10 @@ public interface GL11 { @Const @GLbyte Buffer pointer); + @DeprecatedGL void glEdgeFlag(boolean flag); + @DeprecatedGL void glDrawPixels(@GLsizei int width, @GLsizei int height, @GLenum int format, @GLenum int type, @Check("GLChecks.calculateImageStorage(pixels, format, type, width, height, 1)") @BufferObject(BufferKind.UnpackPBO) @@ -883,36 +919,47 @@ public interface GL11 { void glDepthFunc(@GLenum int func); + @DeprecatedGL void glFeedbackBuffer(@AutoSize("buffer") @GLsizei int size, @GLenum int type, FloatBuffer buffer); @StripPostfix("values") + @DeprecatedGL void glGetPixelMapfv(@GLenum int map, @OutParameter @Check("256") @BufferObject(BufferKind.PackPBO) FloatBuffer values); @StripPostfix("values") + @DeprecatedGL void glGetPixelMapuiv(@GLenum int map, @OutParameter @Check("256") @BufferObject(BufferKind.PackPBO) @GLuint IntBuffer values); @StripPostfix("values") + @DeprecatedGL void glGetPixelMapusv(@GLenum int map, @OutParameter @Check("256") @BufferObject(BufferKind.PackPBO) @GLushort ShortBuffer values); @StripPostfix("params") + @DeprecatedGL void glGetMaterialfv(@GLenum int face, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); @StripPostfix("params") + @DeprecatedGL void glGetMaterialiv(@GLenum int face, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); @StripPostfix("v") + @DeprecatedGL void glGetMapfv(@GLenum int target, @GLenum int query, @OutParameter @Check("256") FloatBuffer v); @StripPostfix("v") + @DeprecatedGL void glGetMapdv(@GLenum int target, @GLenum int query, @OutParameter @Check("256") DoubleBuffer v); @StripPostfix("v") + @DeprecatedGL void glGetMapiv(@GLenum int target, @GLenum int query, @OutParameter @Check("256") IntBuffer v); @StripPostfix("params") + @DeprecatedGL void glGetLightfv(@GLenum int light, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); @StripPostfix("params") + @DeprecatedGL void glGetLightiv(@GLenum int light, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); @NoErrorCheck @@ -935,20 +982,26 @@ public interface GL11 { void glGenTextures(@AutoSize("textures") @GLsizei int n, @OutParameter @GLuint IntBuffer textures); @GLuint + @DeprecatedGL int glGenLists(@GLsizei int range); + @DeprecatedGL void glFrustum(double left, double right, double bottom, double top, double zNear, double zFar); void glFrontFace(@GLenum int mode); + @DeprecatedGL void glFogf(@GLenum int pname, float param); + @DeprecatedGL void glFogi(@GLenum int pname, int param); @StripPostfix("params") + @DeprecatedGL void glFogfv(@GLenum int pname, @Check("4") @Const FloatBuffer params); @StripPostfix("params") + @DeprecatedGL void glFogiv(@GLenum int pname, @Check("4") @Const IntBuffer params); void glFlush(); @@ -970,6 +1023,7 @@ public interface GL11 { @GLfloat @GLdouble Buffer pointer); + @DeprecatedGL void glInitNames(); void glHint(@GLenum int target, @GLenum int mode); @@ -997,97 +1051,132 @@ public interface GL11 { @GLdouble Buffer pixels); @StripPostfix("params") + @DeprecatedGL void glGetTexGeniv(@GLenum int coord, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); @StripPostfix("params") + @DeprecatedGL void glGetTexGenfv(@GLenum int coord, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); @StripPostfix("params") + @DeprecatedGL void glGetTexGendv(@GLenum int coord, @GLenum int pname, @OutParameter @Check("4") DoubleBuffer params); @StripPostfix("params") + @DeprecatedGL void glGetTexEnviv(@GLenum int coord, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); @StripPostfix("params") + @DeprecatedGL void glGetTexEnvfv(@GLenum int coord, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); @Const String glGetString(int name); + @DeprecatedGL void glGetPolygonStipple(@OutParameter @BufferObject(BufferKind.PackPBO) @Check("1024") @GLubyte ByteBuffer mask); + @DeprecatedGL boolean glIsList(@GLuint int list); + @DeprecatedGL void glMaterialf(@GLenum int face, @GLenum int pname, float param); + @DeprecatedGL void glMateriali(@GLenum int face, @GLenum int pname, int param); @StripPostfix("params") + @DeprecatedGL void glMaterialfv(@GLenum int face, @GLenum int pname, @Check("4") @Const FloatBuffer params); @StripPostfix("params") + @DeprecatedGL void glMaterialiv(@GLenum int face, @GLenum int pname, @Check("4") @Const IntBuffer params); + @DeprecatedGL void glMapGrid1f(int un, float u1, float u2); + @DeprecatedGL void glMapGrid1d(int un, double u1, double u2); + @DeprecatedGL void glMapGrid2f(int un, float u1, float u2, int vn, float v1, float v2); + @DeprecatedGL void glMapGrid2d(int un, double u1, double u2, int vn, double v1, double v2); // TODO: check buffer size valid + @DeprecatedGL void glMap2f(@GLenum int target, float u1, float u2, int ustride, int uorder, float v1, float v2, int vstride, int vorder, @Check @Const FloatBuffer points); + @DeprecatedGL void glMap2d(@GLenum int target, double u1, double u2, int ustride, int uorder, double v1, double v2, int vstride, int vorder, @Check @Const DoubleBuffer points); // TODO: check buffer size valid + @DeprecatedGL void glMap1f(@GLenum int target, float u1, float u2, int stride, int order, @Check @Const FloatBuffer points); + @DeprecatedGL void glMap1d(@GLenum int target, double u1, double u2, int stride, int order, @Check @Const DoubleBuffer points); void glLogicOp(@GLenum int opcode); + @DeprecatedGL void glLoadName(@GLuint int name); @StripPostfix("m") + @DeprecatedGL void glLoadMatrixf(@Check("16") @Const FloatBuffer m); @StripPostfix("m") + @DeprecatedGL void glLoadMatrixd(@Check("16") @Const DoubleBuffer m); + @DeprecatedGL void glLoadIdentity(); + @DeprecatedGL void glListBase(@GLuint int base); void glLineWidth(float width); + @DeprecatedGL void glLineStipple(int factor, @GLushort short pattern); + @DeprecatedGL void glLightModelf(@GLenum int pname, float param); + @DeprecatedGL void glLightModeli(@GLenum int pname, int param); @StripPostfix("params") + @DeprecatedGL void glLightModelfv(@GLenum int pname, @Check("4") @Const FloatBuffer params); @StripPostfix("params") + @DeprecatedGL void glLightModeliv(@GLenum int pname, @Check("4") @Const IntBuffer params); + @DeprecatedGL void glLightf(@GLenum int light, @GLenum int pname, float param); + @DeprecatedGL void glLighti(@GLenum int light, @GLenum int pname, int param); @StripPostfix("params") + @DeprecatedGL void glLightfv(@GLenum int light, @GLenum int pname, @Check("4") @Const FloatBuffer params); @StripPostfix("params") + @DeprecatedGL void glLightiv(@GLenum int light, @GLenum int pname, @Check("4") @Const IntBuffer params); boolean glIsTexture(@GLuint int texture); + @DeprecatedGL void glMatrixMode(@GLenum int mode); + @DeprecatedGL void glPolygonStipple(@BufferObject(BufferKind.UnpackPBO) @Check("1024") @Const @GLubyte ByteBuffer mask); void glPolygonOffset(float factor, float units); @@ -1096,10 +1185,13 @@ public interface GL11 { void glPointSize(float size); + @DeprecatedGL void glPixelZoom(float xfactor, float yfactor); + @DeprecatedGL void glPixelTransferf(@GLenum int pname, float param); + @DeprecatedGL void glPixelTransferi(@GLenum int pname, int param); void glPixelStoref(@GLenum int pname, float param); @@ -1107,18 +1199,24 @@ public interface GL11 { void glPixelStorei(@GLenum int pname, int param); @StripPostfix("values") + @DeprecatedGL void glPixelMapfv(@GLenum int map, @AutoSize("values") @GLsizei int mapsize, @BufferObject(BufferKind.UnpackPBO) @Const FloatBuffer values); @StripPostfix("values") + @DeprecatedGL void glPixelMapuiv(@GLenum int map, @AutoSize("values") @GLsizei int mapsize, @BufferObject(BufferKind.UnpackPBO) @Const @GLuint IntBuffer values); @StripPostfix("values") + @DeprecatedGL void glPixelMapusv(@GLenum int map, @AutoSize("values") @GLsizei int mapsize, @BufferObject(BufferKind.UnpackPBO) @Const @GLushort ShortBuffer values); + @DeprecatedGL void glPassThrough(float token); + @DeprecatedGL void glOrtho(double left, double right, double bottom, double top, double zNear, double zFar); + @DeprecatedGL void glNormalPointer(@AutoType("pointer") @GLenum int type, @GLsizei int stride, @CachedReference @BufferObject(BufferKind.ArrayVBO) @@ -1130,45 +1228,61 @@ public interface GL11 { @GLdouble Buffer pointer); @NoErrorCheck + @DeprecatedGL void glNormal3b(byte nx, byte ny, byte nz); @NoErrorCheck + @DeprecatedGL void glNormal3f(float nx, float ny, float nz); @NoErrorCheck + @DeprecatedGL void glNormal3d(double nx, double ny, double nz); @NoErrorCheck + @DeprecatedGL void glNormal3i(int nx, int ny, int nz); + @DeprecatedGL void glNewList(@GLuint int list, @GLenum int mode); + @DeprecatedGL void glEndList(); @StripPostfix("m") + @DeprecatedGL void glMultMatrixf(@Check("16") @Const FloatBuffer m); @StripPostfix("m") + @DeprecatedGL void glMultMatrixd(@Check("16") @Const DoubleBuffer m); void glShadeModel(@GLenum int mode); + @DeprecatedGL void glSelectBuffer(@AutoSize("buffer") @GLsizei int size, @CachedReference @GLuint IntBuffer buffer); void glScissor(int x, int y, @GLsizei int width, @GLsizei int height); + @DeprecatedGL void glScalef(float x, float y, float z); + @DeprecatedGL void glScaled(double x, double y, double z); + @DeprecatedGL void glRotatef(float angle, float x, float y, float z); + @DeprecatedGL int glRenderMode(@GLenum int mode); + @DeprecatedGL void glRectf(float x1, float y1, float x2, float y2); + @DeprecatedGL void glRectd(double x1, double y1, double x2, double y2); + @DeprecatedGL void glRecti(int x1, int y1, int x2, int y2); void glReadPixels(int x, int y, @GLsizei int width, @GLsizei int height, @GLenum int format, @GLenum int type, @@ -1182,44 +1296,62 @@ public interface GL11 { void glReadBuffer(@GLenum int mode); + @DeprecatedGL void glRasterPos2f(float x, float y); + @DeprecatedGL void glRasterPos2d(double x, double y); + @DeprecatedGL void glRasterPos2i(int x, int y); + @DeprecatedGL void glRasterPos3f(float x, float y, float z); + @DeprecatedGL void glRasterPos3d(double x, double y, double z); + @DeprecatedGL void glRasterPos3i(int x, int y, int z); + @DeprecatedGL void glRasterPos4f(float x, float y, float z, float w); + @DeprecatedGL void glRasterPos4d(double x, double y, double z, double w); + @DeprecatedGL void glRasterPos4i(int x, int y, int z, int w); + @DeprecatedGL void glPushName(@GLuint int name); + @DeprecatedGL void glPopName(); + @DeprecatedGL void glPushMatrix(); + @DeprecatedGL void glPopMatrix(); @Code(" StateTracker.pushAttrib(caps, mask);") + @DeprecatedGL void glPushClientAttrib(@GLbitfield int mask); @Code(" StateTracker.popAttrib(caps);") + @DeprecatedGL void glPopClientAttrib(); + @DeprecatedGL void glPushAttrib(@GLbitfield int mask); + @DeprecatedGL void glPopAttrib(); void glStencilFunc(@GLenum int func, int ref, @GLuint int mask); + @DeprecatedGL void glVertexPointer(int size, @AutoType("pointer") @GLenum int type, @GLsizei int stride, @CachedReference @BufferObject(BufferKind.ArrayVBO) @@ -1230,34 +1362,45 @@ public interface GL11 { @GLdouble Buffer pointer); @NoErrorCheck + @DeprecatedGL void glVertex2f(float x, float y); @NoErrorCheck + @DeprecatedGL void glVertex2d(double x, double y); @NoErrorCheck + @DeprecatedGL void glVertex2i(int x, int y); @NoErrorCheck + @DeprecatedGL void glVertex3f(float x, float y, float z); @NoErrorCheck + @DeprecatedGL void glVertex3d(double x, double y, double z); @NoErrorCheck + @DeprecatedGL void glVertex3i(int x, int y, int z); @NoErrorCheck + @DeprecatedGL void glVertex4f(float x, float y, float z, float w); @NoErrorCheck + @DeprecatedGL void glVertex4d(double x, double y, double z, double w); @NoErrorCheck + @DeprecatedGL void glVertex4i(int x, int y, int z, int w); + @DeprecatedGL void glTranslatef(float x, float y, float z); + @DeprecatedGL void glTranslated(double x, double y, double z); void glTexImage1D(@GLenum int target, int level, int internalformat, @GLsizei int width, int border, @GLenum int format, @GLenum int type, @@ -1310,31 +1453,42 @@ public interface GL11 { @StripPostfix("param") void glTexParameteriv(@GLenum int target, @GLenum int pname, @Check("4") @Const IntBuffer param); + @DeprecatedGL void glTexGenf(@GLenum int coord, @GLenum int pname, float param); + @DeprecatedGL void glTexGend(@GLenum int coord, @GLenum int pname, double param); @StripPostfix("params") + @DeprecatedGL void glTexGenfv(@GLenum int coord, @GLenum int pname, @Check("4") @Const FloatBuffer params); @StripPostfix("params") + @DeprecatedGL void glTexGendv(@GLenum int coord, @GLenum int pname, @Check("4") @Const DoubleBuffer params); + @DeprecatedGL void glTexGeni(@GLenum int coord, @GLenum int pname, int param); @StripPostfix("params") + @DeprecatedGL void glTexGeniv(@GLenum int coord, @GLenum int pname, @Check("4") @Const IntBuffer params); + @DeprecatedGL void glTexEnvf(@GLenum int target, @GLenum int pname, float param); + @DeprecatedGL void glTexEnvi(@GLenum int target, @GLenum int pname, int param); @StripPostfix("params") + @DeprecatedGL void glTexEnvfv(@GLenum int target, @GLenum int pname, @Check("4") @Const FloatBuffer params); @StripPostfix("params") + @DeprecatedGL void glTexEnviv(@GLenum int target, @GLenum int pname, @Check("4") @Const IntBuffer params); + @DeprecatedGL void glTexCoordPointer(int size, @AutoType("pointer") @GLenum int type, @GLsizei int stride, @CachedReference(index="GLChecks.getReferences(caps).glClientActiveTexture", name="glTexCoordPointer_buffer") @BufferObject(BufferKind.ArrayVBO) @@ -1344,27 +1498,35 @@ public interface GL11 { @GLdouble Buffer pointer); @NoErrorCheck + @DeprecatedGL void glTexCoord1f(float s); @NoErrorCheck + @DeprecatedGL void glTexCoord1d(double s); @NoErrorCheck + @DeprecatedGL void glTexCoord2f(float s, float t); @NoErrorCheck + @DeprecatedGL void glTexCoord2d(double s, double t); @NoErrorCheck + @DeprecatedGL void glTexCoord3f(float s, float t, float r); @NoErrorCheck + @DeprecatedGL void glTexCoord3d(double s, double t, double r); @NoErrorCheck + @DeprecatedGL void glTexCoord4f(float s, float t, float r, float q); @NoErrorCheck + @DeprecatedGL void glTexCoord4d(double s, double t, double r, double q); void glStencilOp(@GLenum int fail, @GLenum int zfail, @GLenum int zpass); diff --git a/src/templates/org/lwjgl/opengl/GL13.java b/src/templates/org/lwjgl/opengl/GL13.java index 293ed700..68b9b614 100644 --- a/src/templates/org/lwjgl/opengl/GL13.java +++ b/src/templates/org/lwjgl/opengl/GL13.java @@ -43,6 +43,7 @@ import java.nio.*; * @version $Revision$ * $Id$ */ +@DeprecatedGL public interface GL13 { int GL_TEXTURE0 = 0x84C0; int GL_TEXTURE1 = 0x84C1; @@ -148,7 +149,8 @@ public interface GL13 { void glActiveTexture(@GLenum int texture); - @Code("\t\tGLChecks.getReferences(caps).glClientActiveTexture = texture - GL_TEXTURE0;") + @Code("\t\tGLChecks.getReferences(caps).glClientActiveTexture = texture - GL_TEXTURE0;") + @DeprecatedGL void glClientActiveTexture(@GLenum int texture); void glCompressedTexImage1D(@GLenum int target, int level, @GLenum int internalformat, @GLsizei int width, int border, @AutoSize("data") @GLsizei int imageSize, @@ -203,39 +205,51 @@ public interface GL13 { @GLint Buffer img); @NoErrorCheck + @DeprecatedGL void glMultiTexCoord1f(@GLenum int target, float s); @NoErrorCheck + @DeprecatedGL void glMultiTexCoord1d(@GLenum int target, double s); @NoErrorCheck + @DeprecatedGL void glMultiTexCoord2f(@GLenum int target, float s, float t); @NoErrorCheck + @DeprecatedGL void glMultiTexCoord2d(@GLenum int target, double s, double t); @NoErrorCheck + @DeprecatedGL void glMultiTexCoord3f(@GLenum int target, float s, float t, float r); @NoErrorCheck + @DeprecatedGL void glMultiTexCoord3d(@GLenum int target, double s, double t, double r); @NoErrorCheck + @DeprecatedGL void glMultiTexCoord4f(@GLenum int target, float s, float t, float r, float q); @NoErrorCheck + @DeprecatedGL void glMultiTexCoord4d(@GLenum int target, double s, double t, double r, double q); @StripPostfix("m") + @DeprecatedGL void glLoadTransposeMatrixf(@Check("16") @Const FloatBuffer m); @StripPostfix("m") + @DeprecatedGL void glLoadTransposeMatrixd(@Check("16") @Const DoubleBuffer m); @StripPostfix("m") + @DeprecatedGL void glMultTransposeMatrixf(@Check("16") @Const FloatBuffer m); @StripPostfix("m") + @DeprecatedGL void glMultTransposeMatrixd(@Check("16") @Const DoubleBuffer m); void glSampleCoverage(@GLclampf float value, boolean invert); diff --git a/src/templates/org/lwjgl/opengl/GL14.java b/src/templates/org/lwjgl/opengl/GL14.java index c9e3a0eb..58cecd97 100644 --- a/src/templates/org/lwjgl/opengl/GL14.java +++ b/src/templates/org/lwjgl/opengl/GL14.java @@ -43,6 +43,7 @@ import java.nio.*; * @version $Revision$ * $Id$ */ +@DeprecatedGL public interface GL14 { int GL_GENERATE_MIPMAP = 0x8191; int GL_GENERATE_MIPMAP_HINT = 0x8192; @@ -88,10 +89,13 @@ public interface GL14 { void glBlendColor(@GLclampf float red, @GLclampf float green, @GLclampf float blue, @GLclampf float alpha); + @DeprecatedGL void glFogCoordf(float coord); + @DeprecatedGL void glFogCoordd(double coord); + @DeprecatedGL void glFogCoordPointer(@AutoType("data") @GLenum int type, @GLsizei int stride, @CachedReference @BufferObject(BufferKind.ArrayVBO) @@ -117,14 +121,19 @@ public interface GL14 { @StripPostfix("params") void glPointParameterfv(@GLenum int pname, @Check("4") @Const FloatBuffer params); + @DeprecatedGL void glSecondaryColor3b(byte red, byte green, byte blue); + @DeprecatedGL void glSecondaryColor3f(float red, float green, float blue); + @DeprecatedGL void glSecondaryColor3d(double red, double green, double blue); + @DeprecatedGL void glSecondaryColor3ub(@GLubyte byte red, @GLubyte byte green, @GLubyte byte blue); + @DeprecatedGL void glSecondaryColorPointer(int size, @AutoType("data") @GLenum int type, @GLsizei int stride, @BufferObject(BufferKind.ArrayVBO) @Check @@ -136,16 +145,22 @@ public interface GL14 { void glBlendFuncSeparate(@GLenum int sfactorRGB, @GLenum int dfactorRGB, @GLenum int sfactorAlpha, @GLenum int dfactorAlpha); + @DeprecatedGL void glWindowPos2f(float x, float y); + @DeprecatedGL void glWindowPos2d(double x, double y); + @DeprecatedGL void glWindowPos2i(int x, int y); + @DeprecatedGL void glWindowPos3f(float x, float y, float z); + @DeprecatedGL void glWindowPos3d(double x, double y, double z); + @DeprecatedGL void glWindowPos3i(int x, int y, int z); } diff --git a/src/templates/org/lwjgl/opengl/GL20.java b/src/templates/org/lwjgl/opengl/GL20.java index 2465b3d8..59af3bd5 100644 --- a/src/templates/org/lwjgl/opengl/GL20.java +++ b/src/templates/org/lwjgl/opengl/GL20.java @@ -37,7 +37,7 @@ import java.nio.*; public interface GL20 { // ------------------------------------------------------------------ - // ----------------------[ ARB_shading_language_100 ]---------------------- + // -------------------[ ARB_shading_language_100 ]------------------- // ------------------------------------------------------------------ /** diff --git a/src/templates/org/lwjgl/opengl/GL30.java b/src/templates/org/lwjgl/opengl/GL30.java new file mode 100644 index 00000000..54367907 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/GL30.java @@ -0,0 +1,912 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +import org.lwjgl.util.generator.*; + +import java.nio.*; + +public interface GL30 { + + // ---------------------------------------------------------- + // ----------------------[ OpenGL 3.0 ]---------------------- + // ---------------------------------------------------------- + + int GL_MAJOR_VERSION = 0x821B; + int GL_MINOR_VERSION = 0x821C; + int GL_NUM_EXTENSIONS = 0x821D; + + int GL_CONTEXT_FLAGS = 0x821E; + int GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT = 0x0001; + + int GL_DEPTH_BUFFER = 0x8223; + int GL_STENCIL_BUFFER = 0x8224; + + int GL_COMPRESSED_RED = 0x8225; + int GL_COMPRESSED_RG = 0x8226; + + int GL_COMPARE_REF_TO_TEXTURE = ARB_shadow.GL_COMPARE_R_TO_TEXTURE_ARB; + + int GL_CLIP_DISTANCE0 = GL11.GL_CLIP_PLANE0; + int GL_CLIP_DISTANCE1 = GL11.GL_CLIP_PLANE1; + int GL_CLIP_DISTANCE2 = GL11.GL_CLIP_PLANE2; + int GL_CLIP_DISTANCE3 = GL11.GL_CLIP_PLANE3; + int GL_CLIP_DISTANCE4 = GL11.GL_CLIP_PLANE4; + int GL_CLIP_DISTANCE5 = GL11.GL_CLIP_PLANE5; + + int GL_MAX_CLIP_DISTANCES = GL11.GL_MAX_CLIP_PLANES; + + int GL_MAX_VARYING_COMPONENTS = GL20.GL_MAX_VARYING_FLOATS; + + String glGetStringi(@GLenum int name, @GLuint int index); + + void glClearBufferfv(@GLenum int buffer, @Const @Check("4")FloatBuffer value); + void glClearBufferiv(@GLenum int buffer, @Const @Check("4")IntBuffer value); + void glClearBufferuiv(@GLenum int buffer, @Const @Check("4")IntBuffer value); + void glClearBufferfi(@GLenum int buffer, float depth, int stencil); + + // --------------------------------------------------------------- + // ----------------------[ EXT_gpu_shader4 ]---------------------- + // --------------------------------------------------------------- + + /** + * Accepted by the <pname> parameters of GetVertexAttribdv, + * GetVertexAttribfv, GetVertexAttribiv, GetVertexAttribIiv, and + * GetVertexAttribIuiv: + */ + int GL_VERTEX_ATTRIB_ARRAY_INTEGER = 0x88FD; + + /** Returned by the <type> parameter of GetActiveUniform: */ + + int GL_SAMPLER_BUFFER = 0x8DC2; + int GL_SAMPLER_CUBE_SHADOW = 0x8DC5; + int GL_UNSIGNED_INT_VEC2 = 0x8DC6; + int GL_UNSIGNED_INT_VEC3 = 0x8DC7; + int GL_UNSIGNED_INT_VEC4 = 0x8DC8; + int GL_INT_SAMPLER_1D = 0x8DC9; + int GL_INT_SAMPLER_2D = 0x8DCA; + int GL_INT_SAMPLER_3D = 0x8DCB; + int GL_INT_SAMPLER_CUBE = 0x8DCC; + int GL_INT_SAMPLER_2D_RECT = 0x8DCD; + int GL_INT_SAMPLER_1D_ARRAY = 0x8DCE; + int GL_INT_SAMPLER_2D_ARRAY = 0x8DCF; + int GL_INT_SAMPLER_BUFFER = 0x8DD0; + + int GL_UNSIGNED_INT_SAMPLER_1D = 0x8DD1; + int GL_UNSIGNED_INT_SAMPLER_2D = 0x8DD2; + int GL_UNSIGNED_INT_SAMPLER_3D = 0x8DD3; + int GL_UNSIGNED_INT_SAMPLER_CUBE = 0x8DD4; + int GL_UNSIGNED_INT_SAMPLER_2D_RECT = 0x8DD5; + int GL_UNSIGNED_INT_SAMPLER_1D_ARRAY = 0x8DD6; + int GL_UNSIGNED_INT_SAMPLER_2D_ARRAY = 0x8DD7; + int GL_UNSIGNED_INT_SAMPLER_BUFFER = 0x8DD8; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, + * and GetDoublev: + */ + int GL_MIN_PROGRAM_TEXEL_OFFSET = 0x8904; + int GL_MAX_PROGRAM_TEXEL_OFFSET = 0x8905; + + void glVertexAttribI1i(@GLuint int index, int x); + + void glVertexAttribI2i(@GLuint int index, int x, int y); + + void glVertexAttribI3i(@GLuint int index, int x, int y, int z); + + void glVertexAttribI4i(@GLuint int index, int x, int y, int z, int w); + + void glVertexAttribI1ui(@GLuint int index, @GLuint int x); + + void glVertexAttribI2ui(@GLuint int index, @GLuint int x, @GLuint int y); + + void glVertexAttribI3ui(@GLuint int index, @GLuint int x, @GLuint int y, @GLuint int z); + + void glVertexAttribI4ui(@GLuint int index, @GLuint int x, @GLuint int y, @GLuint int z, @GLuint int w); + + @StripPostfix("v") + void glVertexAttribI1iv(@GLuint int index, @Check("1") @Const IntBuffer v); + + @StripPostfix("v") + void glVertexAttribI2iv(@GLuint int index, @Check("2") @Const IntBuffer v); + + @StripPostfix("v") + void glVertexAttribI3iv(@GLuint int index, @Check("3") @Const IntBuffer v); + + @StripPostfix("v") + void glVertexAttribI4iv(@GLuint int index, @Check("4") @Const IntBuffer v); + + @StripPostfix("v") + void glVertexAttribI1uiv(@GLuint int index, @Check("1") @Const @GLuint IntBuffer v); + + @StripPostfix("v") + void glVertexAttribI2uiv(@GLuint int index, @Check("2") @Const @GLuint IntBuffer v); + + @StripPostfix("v") + void glVertexAttribI3uiv(@GLuint int index, @Check("3") @Const @GLuint IntBuffer v); + + @StripPostfix("v") + void glVertexAttribI4uiv(@GLuint int index, @Check("4") @Const @GLuint IntBuffer v); + + @StripPostfix("v") + void glVertexAttribI4bv(@GLuint int index, @Check("4") @Const ByteBuffer v); + + @StripPostfix("v") + void glVertexAttribI4sv(@GLuint int index, @Check("4") @Const ShortBuffer v); + + @StripPostfix("v") + void glVertexAttribI4ubv(@GLuint int index, @Check("4") @Const @GLubyte ByteBuffer v); + + @StripPostfix("v") + void glVertexAttribI4usv(@GLuint int index, @Check("4") @Const @GLushort ShortBuffer v); + + void glVertexAttribIPointer(@GLuint int index, int size, @GLenum int type, @GLsizei int stride, + @CachedReference + @BufferObject(BufferKind.ArrayVBO) + @Check + @Const + @GLbyte + @GLubyte + @GLshort + @GLushort + @GLint + @GLuint Buffer buffer); + + @StripPostfix("params") + void glGetVertexAttribIiv(@GLuint int index, @GLenum int pname, @OutParameter @Check("4")IntBuffer params); + + @StripPostfix("params") + void glGetVertexAttribIuiv(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") @GLuint IntBuffer params); + + void glUniform1ui(int location, @GLuint int v0); + + void glUniform2ui(int location, @GLuint int v0, @GLuint int v1); + + void glUniform3ui(int location, @GLuint int v0, @GLuint int v1, @GLuint int v2); + + void glUniform4ui(int location, @GLuint int v0, @GLuint int v1, @GLuint int v2, @GLuint int v3); + + @StripPostfix("value") + void glUniform1uiv(int location, @AutoSize("value") @GLsizei int count, @Const @GLuint IntBuffer value); + + @StripPostfix("value") + void glUniform2uiv(int location, @AutoSize(value = "value", expression = " >> 1") @GLsizei int count, @Const @GLuint IntBuffer value); + + @StripPostfix("value") + void glUniform3uiv(int location, @AutoSize(value = "value", expression = " / 3") @GLsizei int count, @Const @GLuint IntBuffer value); + + @StripPostfix("value") + void glUniform4uiv(int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const @GLuint IntBuffer value); + + @StripPostfix("params") + void glGetUniformuiv(@GLuint int program, int location, @OutParameter @Check @GLuint IntBuffer params); + + void glBindFragDataLocation(@GLuint int program, @GLuint int colorNumber, @NullTerminated @Const @GLchar ByteBuffer name); + + int glGetFragDataLocation(@GLuint int program, @NullTerminated @Const @GLchar ByteBuffer name); + + // --------------------------------------------------------------------- + // ----------------------[ NV_conditional_render ]---------------------- + // --------------------------------------------------------------------- + + /** Accepted by the <mode> parameter of BeginConditionalRender: */ + int GL_QUERY_WAIT = 0x8E13; + int GL_QUERY_NO_WAIT = 0x8E14; + int GL_QUERY_BY_REGION_WAIT = 0x8E15; + int GL_QUERY_BY_REGION_NO_WAIT = 0x8E16; + + void glBeginConditionalRender(@GLuint int id, @GLenum int mode); + + void glEndConditionalRender(); + + // -------------------------------------------------------------------- + // ----------------------[ ARB_map_buffer_range ]---------------------- + // -------------------------------------------------------------------- + + /** Accepted by the <access> parameter of MapBufferRange: */ + int GL_MAP_READ_BIT = 0x0001; + int GL_MAP_WRITE_BIT = 0x0002; + int GL_MAP_INVALIDATE_RANGE_BIT = 0x0004; + int GL_MAP_INVALIDATE_BUFFER_BIT = 0x0008; + int GL_MAP_FLUSH_EXPLICIT_BIT = 0x0010; + int GL_MAP_UNSYNCHRONIZED_BIT = 0x0020; + + @CachedResult + @GLvoid + ByteBuffer + glMapBufferRange(@GLenum int target, @GLintptr long offset, @GLsizeiptr long length, @GLbitfield int access); + + void glFlushMappedBufferRange(@GLenum int target, @GLintptr long offset, @GLsizeiptr long length); + + // ---------------------------------------------------------------------- + // ----------------------[ ARB_color_buffer_float ]---------------------- + // ---------------------------------------------------------------------- + + /** + * Accepted by the <target> parameter of ClampColor and the <pname> + * parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev. + */ + int GL_CLAMP_VERTEX_COLOR = 0x891A; + int GL_CLAMP_FRAGMENT_COLOR = 0x891B; + int GL_CLAMP_READ_COLOR = 0x891C; + + /** Accepted by the <clamp> parameter of ClampColor. */ + int GL_FIXED_ONLY = 0x891D; + + // TODO: ClampColor without the ARB postfix not present in NV driver atm. + void glClampColorARB(@GLenum int target, @GLenum int clamp); + + // ---------------------------------------------------------------------- + // ----------------------[ NV_depth_buffer_float ]---------------------- + // ---------------------------------------------------------------------- + + /** + * Accepted by the <internalformat> parameter of TexImage1D, TexImage2D, + * TexImage3D, CopyTexImage1D, CopyTexImage2D, and RenderbufferStorageEXT, + * and returned in the <data> parameter of GetTexLevelParameter and + * GetRenderbufferParameterivEXT: + */ + int GL_DEPTH_COMPONENT32F = 0x8DAB; + int GL_DEPTH32F_STENCIL8 = 0x8DAC; + + /** + * Accepted by the <type> parameter of DrawPixels, ReadPixels, TexImage1D, + * TexImage2D, TexImage3D, TexSubImage1D, TexSubImage2D, TexSubImage3D, and + * GetTexImage: + */ + int GL_FLOAT_32_UNSIGNED_INT_24_8_REV = 0x8DAD; + + // ----------------------------------------------------------------- + // ----------------------[ ARB_texture_float ]---------------------- + // ----------------------------------------------------------------- + + /** Accepted by the <value> parameter of GetTexLevelParameter: */ + int GL_TEXTURE_RED_TYPE = 0x8C10; + int GL_TEXTURE_GREEN_TYPE = 0x8C11; + int GL_TEXTURE_BLUE_TYPE = 0x8C12; + int GL_TEXTURE_ALPHA_TYPE = 0x8C13; + int GL_TEXTURE_LUMINANCE_TYPE = 0x8C14; + int GL_TEXTURE_INTENSITY_TYPE = 0x8C15; + int GL_TEXTURE_DEPTH_TYPE = 0x8C16; + + /** Returned by the <params> parameter of GetTexLevelParameter: */ + int GL_UNSIGNED_NORMALIZED = 0x8C17; + + /** + * Accepted by the <internalFormat> parameter of TexImage1D, + * TexImage2D, and TexImage3D: + */ + int GL_RGBA32F = 0x8814; + int GL_RGB32F = 0x8815; + int GL_ALPHA32F = 0x8816; + int GL_RGBA16F = 0x881A; + int GL_RGB16F = 0x881B; + int GL_ALPHA16F = 0x881C; + + // ---------------------------------------------------------------- + // ----------------------[ EXT_packed_float ]---------------------- + // ---------------------------------------------------------------- + + /** + * Accepted by the <internalformat> parameter of TexImage1D, + * TexImage2D, TexImage3D, CopyTexImage1D, CopyTexImage2D, and + * RenderbufferStorage: + */ + int GL_R11F_G11F_B10F = 0x8C3A; + + /** + * Accepted by the <type> parameter of DrawPixels, ReadPixels, + * TexImage1D, TexImage2D, GetTexImage, TexImage3D, TexSubImage1D, + * TexSubImage2D, TexSubImage3D, GetHistogram, GetMinmax, + * ConvolutionFilter1D, ConvolutionFilter2D, ConvolutionFilter3D, + * GetConvolutionFilter, SeparableFilter2D, GetSeparableFilter, + * ColorTable, ColorSubTable, and GetColorTable: + */ + int GL_UNSIGNED_INT_10F_11F_11F_REV = 0x8C3B; + + // --------------------------------------------------------------------------- + // ----------------------[ EXT_texture_shared_exponent ]---------------------- + // --------------------------------------------------------------------------- + + /** + * Accepted by the <internalformat> parameter of TexImage1D, + * TexImage2D, TexImage3D, CopyTexImage1D, CopyTexImage2D, and + * RenderbufferStorage: + */ + int GL_RGB9_E5 = 0x8C3D; + + /** + * Accepted by the <type> parameter of DrawPixels, ReadPixels, + * TexImage1D, TexImage2D, GetTexImage, TexImage3D, TexSubImage1D, + * TexSubImage2D, TexSubImage3D, GetHistogram, GetMinmax, + * ConvolutionFilter1D, ConvolutionFilter2D, ConvolutionFilter3D, + * GetConvolutionFilter, SeparableFilter2D, GetSeparableFilter, + * ColorTable, ColorSubTable, and GetColorTable: + */ + int GL_UNSIGNED_INT_5_9_9_9_REV = 0x8C3E; + + /** + * Accepted by the <pname> parameter of GetTexLevelParameterfv and + * GetTexLevelParameteriv: + */ + int GL_TEXTURE_SHARED_SIZE = 0x8C3F; + + // ---------------------------------------------------------------------- + // ----------------------[ EXT_framebuffer_object ]---------------------- + // ---------------------------------------------------------------------- + + /** + * Accepted by the <target> parameter of BindFramebuffer, + * CheckFramebufferStatus, FramebufferTexture{1D|2D|3D}, and + * FramebufferRenderbuffer: + */ + int GL_FRAMEBUFFER = 0x8D40; + + /** + * Accepted by the <target> parameter of BindRenderbuffer, + * RenderbufferStorage, and GetRenderbufferParameteriv, and + * returned by GetFramebufferAttachmentParameteriv: + */ + int GL_RENDERBUFFER = 0x8D41; + + /** + * Accepted by the <internalformat> parameter of + * RenderbufferStorage: + */ + int GL_STENCIL_INDEX1 = 0x8D46; + int GL_STENCIL_INDEX4 = 0x8D47; + int GL_STENCIL_INDEX8 = 0x8D48; + int GL_STENCIL_INDEX16 = 0x8D49; + + /** Accepted by the <pname> parameter of GetRenderbufferParameteriv: */ + int GL_RENDERBUFFER_WIDTH = 0x8D42; + int GL_RENDERBUFFER_HEIGHT = 0x8D43; + int GL_RENDERBUFFER_INTERNAL_FORMAT = 0x8D44; + int GL_RENDERBUFFER_RED_SIZE = 0x8D50; + int GL_RENDERBUFFER_GREEN_SIZE = 0x8D51; + int GL_RENDERBUFFER_BLUE_SIZE = 0x8D52; + int GL_RENDERBUFFER_ALPHA_SIZE = 0x8D53; + int GL_RENDERBUFFER_DEPTH_SIZE = 0x8D54; + int GL_RENDERBUFFER_STENCIL_SIZE = 0x8D55; + + /** + * Accepted by the <pname> parameter of + * GetFramebufferAttachmentParameteriv: + */ + int GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = 0x8CD0; + int GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = 0x8CD1; + int GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = 0x8CD2; + int GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = 0x8CD3; + int GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET = 0x8CD4; + + /** + * Accepted by the <attachment> parameter of + * FramebufferTexture{1D|2D|3D}, FramebufferRenderbuffer, and + * GetFramebufferAttachmentParameteriv + */ + int GL_COLOR_ATTACHMENT0 = 0x8CE0; + int GL_COLOR_ATTACHMENT1 = 0x8CE1; + int GL_COLOR_ATTACHMENT2 = 0x8CE2; + int GL_COLOR_ATTACHMENT3 = 0x8CE3; + int GL_COLOR_ATTACHMENT4 = 0x8CE4; + int GL_COLOR_ATTACHMENT5 = 0x8CE5; + int GL_COLOR_ATTACHMENT6 = 0x8CE6; + int GL_COLOR_ATTACHMENT7 = 0x8CE7; + int GL_COLOR_ATTACHMENT8 = 0x8CE8; + int GL_COLOR_ATTACHMENT9 = 0x8CE9; + int GL_COLOR_ATTACHMENT10 = 0x8CEA; + int GL_COLOR_ATTACHMENT11 = 0x8CEB; + int GL_COLOR_ATTACHMENT12 = 0x8CEC; + int GL_COLOR_ATTACHMENT13 = 0x8CED; + int GL_COLOR_ATTACHMENT14 = 0x8CEE; + int GL_COLOR_ATTACHMENT15 = 0x8CEF; + int GL_DEPTH_ATTACHMENT = 0x8D00; + int GL_STENCIL_ATTACHMENT = 0x8D20; + + /** Returned by CheckFramebufferStatus(): */ + int GL_FRAMEBUFFER_COMPLETE = 0x8CD5; + int GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT = 0x8CD6; + int GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = 0x8CD7; + int GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS = 0x8CD9; + int GL_FRAMEBUFFER_INCOMPLETE_FORMATS = 0x8CDA; + int GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER = 0x8CDB; + int GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER = 0x8CDC; + int GL_FRAMEBUFFER_UNSUPPORTED = 0x8CDD; + + /** Accepted by GetIntegerv(): */ + int GL_FRAMEBUFFER_BINDING = 0x8CA6; + int GL_RENDERBUFFER_BINDING = 0x8CA7; + int GL_MAX_COLOR_ATTACHMENTS = 0x8CDF; + int GL_MAX_RENDERBUFFER_SIZE = 0x84E8; + + /** Returned by GetError(): */ + int GL_INVALID_FRAMEBUFFER_OPERATION = 0x0506; + + boolean glIsRenderbuffer(@GLuint int renderbuffer); + + void glBindRenderbuffer(@GLenum int target, @GLuint int renderbuffer); + + void glDeleteRenderbuffers(@AutoSize("renderbuffers")int n, @Const @GLuint IntBuffer renderbuffers); + + void glGenRenderbuffers(@AutoSize("renderbuffers")int n, @OutParameter @GLuint IntBuffer renderbuffers); + + void glRenderbufferStorage(@GLenum int target, @GLenum int internalformat, @GLsizei int width, @GLsizei int height); + + @StripPostfix("params") + void glGetRenderbufferParameteriv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4")IntBuffer params); + + boolean glIsFramebuffer(@GLuint int framebuffer); + + void glBindFramebuffer(@GLenum int target, @GLuint int framebuffer); + + void glDeleteFramebuffers(@AutoSize("framebuffers")int n, @Const @GLuint IntBuffer framebuffers); + + void glGenFramebuffers(@AutoSize("framebuffers")int n, @OutParameter @GLuint IntBuffer framebuffers); + + @GLenum + int glCheckFramebufferStatus(@GLenum int target); + + void glFramebufferTexture1D(@GLenum int target, @GLenum int attachment, @GLenum int textarget, @GLuint int texture, int level); + + void glFramebufferTexture2D(@GLenum int target, @GLenum int attachment, @GLenum int textarget, @GLuint int texture, int level); + + void glFramebufferTexture3D(@GLenum int target, @GLenum int attachment, @GLenum int textarget, @GLuint int texture, int level, int zoffset); + + void glFramebufferRenderbuffer(@GLenum int target, @GLenum int attachment, @GLenum int renderbuffertarget, @GLuint int renderbuffer); + + @StripPostfix("params") + void glGetFramebufferAttachmentParameteriv(@GLenum int target, @GLenum int attachment, @GLenum int pname, @OutParameter @Check("4")IntBuffer params); + + void glGenerateMipmap(@GLenum int target); + + // -------------------------------------------------------------------------------------------- + // ----------------------[ ARB_half_float_vertex & ARB_half_float_pixel ]---------------------- + // -------------------------------------------------------------------------------------------- + + /** + * Accepted by the <type> parameter of DrawPixels, ReadPixels, + * TexImage1D, TexImage2D, TexImage3D, GetTexImage, TexSubImage1D, + * TexSubImage2D, TexSubImage3D, GetHistogram, GetMinmax, + * ConvolutionFilter1D, ConvolutionFilter2D, GetConvolutionFilter, + * SeparableFilter2D, GetSeparableFilter, ColorTable, ColorSubTable, + * and GetColorTable: + *

    + * Accepted by the <type> argument of VertexPointer, NormalPointer, + * ColorPointer, SecondaryColorPointer, FogCoordPointer, TexCoordPointer, + * and VertexAttribPointer: + */ + int GL_HALF_FLOAT = 0x140B; + + // --------------------------------------------------------------------------- + // ----------------------[ EXT_framebuffer_multisample ]---------------------- + // --------------------------------------------------------------------------- + + /** Accepted by the <pname> parameter of GetRenderbufferParameteriv. */ + int GL_RENDERBUFFER_SAMPLES = 0x8CAB; + + /** Returned by CheckFramebufferStatus. */ + int GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE = 0x8D56; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev. + */ + int GL_MAX_SAMPLES = 0x8D57; + + /** + * Establishes the data storage, format, dimensions, and number of + * samples of a renderbuffer object's image. + */ + void glRenderbufferStorageMultisample( + @GLenum int target, @GLsizei int samples, + @GLenum int internalformat, + @GLsizei int width, @GLsizei int height); + + // -------------------------------------------------------------------- + // ----------------------[ EXT_framebuffer_blit ]---------------------- + // -------------------------------------------------------------------- + + /** + * Accepted by the <target> parameter of BindFramebuffer, + * CheckFramebufferStatus, FramebufferTexture{1D|2D|3D}, + * FramebufferRenderbuffer, and + * GetFramebufferAttachmentParameteriv. + */ + int GL_READ_FRAMEBUFFER = 0x8CA8; + int GL_DRAW_FRAMEBUFFER = 0x8CA9; + + /** Accepted by the <pname> parameters of GetIntegerv, GetFloatv, and GetDoublev. */ + int GL_DRAW_FRAMEBUFFER_BINDING = 0x8CA6; // alias FRAMEBUFFER_BINDING + int GL_READ_FRAMEBUFFER_BINDING = 0x8CAA; + + /** + * Transfers a rectangle of pixel values from one + * region of the read framebuffer to another in the draw framebuffer. + * <mask> is the bitwise OR of a number of values indicating which + * buffers are to be copied. The values are COLOR_BUFFER_BIT, + * DEPTH_BUFFER_BIT, and STENCIL_BUFFER_BIT. + * The pixels corresponding to these buffers are + * copied from the source rectangle, bound by the locations (srcX0, + * srcY0) and (srcX1, srcY1) inclusive, to the destination rectangle, + * bound by the locations (dstX0, dstY0) and (dstX1, dstY1) + * inclusive. + * If the source and destination rectangle dimensions do not match, + * the source image is stretched to fit the destination + * rectangle. <filter> must be LINEAR or NEAREST and specifies the + * method of interpolation to be applied if the image is + * stretched. + */ + void glBlitFramebuffer( + @GLint int srcX0, @GLint int srcY0, @GLint int srcX1, @GLint int srcY1, + @GLint int dstX0, @GLint int dstY0, @GLint int dstX1, @GLint int dstY1, + @GLbitfield int mask, @GLenum int filter); + + // ------------------------------------------------------------------- + // ----------------------[ EXT_texture_integer ]---------------------- + // ------------------------------------------------------------------- + + /** + * Accepted by the <pname> parameters of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev: + */ + int GL_RGBA_INTEGER_MODE = 0x8D9E; + + /** + * Accepted by the <internalFormat> parameter of TexImage1D, + * TexImage2D, and TexImage3D: + */ + int GL_RGBA32UI = 0x8D70; + int GL_RGB32UI = 0x8D71; + int GL_ALPHA32UI = 0x8D72; + + int GL_RGBA16UI = 0x8D76; + int GL_RGB16UI = 0x8D77; + int GL_ALPHA16UI = 0x8D78; + + int GL_RGBA8UI = 0x8D7C; + int GL_RGB8UI = 0x8D7D; + int GL_ALPHA8UI = 0x8D7E; + + int GL_RGBA32I = 0x8D82; + int GL_RGB32I = 0x8D83; + int GL_ALPHA32I = 0x8D84; + + int GL_RGBA16I = 0x8D88; + int GL_RGB16I = 0x8D89; + int GL_ALPHA16I = 0x8D8A; + + int GL_RGBA8I = 0x8D8E; + int GL_RGB8I = 0x8D8F; + int GL_ALPHA8I = 0x8D90; + + /** + * Accepted by the <format> parameter of TexImage1D, TexImage2D, + * TexImage3D, TexSubImage1D, TexSubImage2D, TexSubImage3D, + * DrawPixels and ReadPixels: + */ + int GL_RED_INTEGER = 0x8D94; + int GL_GREEN_INTEGER = 0x8D95; + int GL_BLUE_INTEGER = 0x8D96; + int GL_ALPHA_INTEGER = 0x8D97; + int GL_RGB_INTEGER = 0x8D98; + int GL_RGBA_INTEGER = 0x8D99; + int GL_BGR_INTEGER = 0x8D9A; + int GL_BGRA_INTEGER = 0x8D9B; + + @StripPostfix("params") + void glTexParameterIiv(@GLenum int target, @GLenum int pname, @Check("4")IntBuffer params); + + @StripPostfix("params") + void glTexParameterIuiv(@GLenum int target, @GLenum int pname, @Check("4") @GLuint IntBuffer params); + + @StripPostfix("params") + void glGetTexParameterIiv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4")IntBuffer params); + + @StripPostfix("params") + void glGetTexParameterIuiv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") @GLuint IntBuffer params); + + // ----------------------------------------------------------------- + // ----------------------[ EXT_texture_array ]---------------------- + // ----------------------------------------------------------------- + + /** + * Accepted by the <target> parameter of TexParameteri, TexParameteriv, + * TexParameterf, TexParameterfv, and BindTexture: + */ + int GL_TEXTURE_1D_ARRAY = 0x8C18; + int GL_TEXTURE_2D_ARRAY = 0x8C1A; + + /** + * Accepted by the <target> parameter of TexImage3D, TexSubImage3D, + * CopyTexSubImage3D, CompressedTexImage3D, and CompressedTexSubImage3D: + */ + int GL_PROXY_TEXTURE_2D_ARRAY = 0x8C1B; + + /** + * Accepted by the <target> parameter of TexImage2D, TexSubImage2D, + * CopyTexImage2D, CopyTexSubImage2D, CompressedTexImage2D, and + * CompressedTexSubImage2D: + */ + int GL_PROXY_TEXTURE_1D_ARRAY = 0x8C19; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetDoublev, GetIntegerv + * and GetFloatv: + */ + int GL_TEXTURE_BINDING_1D_ARRAY = 0x8C1C; + int GL_TEXTURE_BINDING_2D_ARRAY = 0x8C1D; + int GL_MAX_ARRAY_TEXTURE_LAYERS = 0x88FF; + + /** + * Accepted by the <param> parameter of TexParameterf, TexParameteri, + * TexParameterfv, and TexParameteriv when the <pname> parameter is + * TEXTURE_COMPARE_MODE_ARB: + */ + int GL_COMPARE_REF_DEPTH_TO_TEXTURE = 0x884E; + + /** + * Accepted by the <pname> parameter of + * GetFramebufferAttachmentParameteriv: + */ + int GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER = 0x8CD4; + + /** Returned by the <type> parameter of GetActiveUniform: */ + int GL_SAMPLER_1D_ARRAY = 0x8DC0; + int GL_SAMPLER_2D_ARRAY = 0x8DC1; + int GL_SAMPLER_1D_ARRAY_SHADOW = 0x8DC3; + int GL_SAMPLER_2D_ARRAY_SHADOW = 0x8DC4; + + void glFramebufferTextureLayer(@GLenum int target, @GLenum int attachment, @GLuint int texture, int level, int layer); + + // ------------------------------------------------------------------------ + // ----------------------[ EXT_packed_depth_stencil ]---------------------- + // ------------------------------------------------------------------------ + + /** + * Accepted by the <format> parameter of DrawPixels, ReadPixels, + * TexImage1D, TexImage2D, TexImage3D, TexSubImage1D, TexSubImage2D, + * TexSubImage3D, and GetTexImage, by the <type> parameter of + * CopyPixels, by the <internalformat> parameter of TexImage1D, + * TexImage2D, TexImage3D, CopyTexImage1D, CopyTexImage2D, and + * RenderbufferStorage, and returned in the <data> parameter of + * GetTexLevelParameter and GetRenderbufferParameteriv. + */ + int GL_DEPTH_STENCIL = 0x84F9; + + /** + * Accepted by the <type> parameter of DrawPixels, ReadPixels, + * TexImage1D, TexImage2D, TexImage3D, TexSubImage1D, TexSubImage2D, + * TexSubImage3D, and GetTexImage. + */ + int GL_UNSIGNED_INT_24_8 = 0x84FA; + + /** + * Accepted by the <internalformat> parameter of TexImage1D, + * TexImage2D, TexImage3D, CopyTexImage1D, CopyTexImage2D, and + * RenderbufferStorage, and returned in the <data> parameter of + * GetTexLevelParameter and GetRenderbufferParameteriv. + */ + int GL_DEPTH24_STENCIL8 = 0x88F0; + + /** Accepted by the <value> parameter of GetTexLevelParameter. */ + int GL_TEXTURE_STENCIL_SIZE = 0x88F1; + + // ----------------------------------------------------------------- + // ----------------------[ EXT_draw_buffers2 ]---------------------- + // ----------------------------------------------------------------- + + void glColorMaski(@GLuint int buf, boolean r, boolean g, boolean b, boolean a); + + @StripPostfix("data") + void glGetBooleani_v(@GLenum int value, @GLuint int index, @OutParameter @Check("4") @GLboolean ByteBuffer data); + + @StripPostfix("data") + void glGetIntegeri_v(@GLenum int value, @GLuint int index, @OutParameter @Check("4")IntBuffer data); + + void glEnablei(@GLenum int target, @GLuint int index); + + void glDisablei(@GLenum int target, @GLuint int index); + + boolean glIsEnabledi(@GLenum int target, @GLuint int index); + + // ---------------------------------------------------------------------------- + // ----------------------[ ARB_texture_compression_rgtc ]---------------------- + // ---------------------------------------------------------------------------- + + /** + * Accepted by the <internalformat> parameter of TexImage2D, + * CopyTexImage2D, and CompressedTexImage2D and the <format> parameter + * of CompressedTexSubImage2D: + */ + int GL_COMPRESSED_RED_RGTC1 = 0x8DBB; + int GL_COMPRESSED_SIGNED_RED_RGTC1 = 0x8DBC; + int GL_COMPRESSED_RED_GREEN_RGTC2 = 0x8DBD; + int GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2 = 0x8DBE; + + // -------------------------------------------------------------- + // ----------------------[ ARB_texture_rg ]---------------------- + // -------------------------------------------------------------- + + /** + * Accepted by the <internalFormat> parameter of TexImage1D, TexImage2D, + * TexImage3D, CopyTexImage1D, and CopyTexImage2D: + */ + int GL_R8 = 0x8229; + int GL_R16 = 0x822A; + + int GL_RG8 = 0x822B; + int GL_RG16 = 0x822C; + + int GL_R16F = 0x822D; + int GL_R32F = 0x822E; + + int GL_RG16F = 0x822F; + int GL_RG32F = 0x8230; + + int GL_R8I = 0x8231; + int GL_R8UI = 0x8232; + int GL_R16I = 0x8233; + int GL_R16UI = 0x8234; + int GL_R32I = 0x8235; + int GL_R32UI = 0x8236; + + int GL_RG8I = 0x8237; + int GL_RG8UI = 0x8238; + int GL_RG16I = 0x8239; + int GL_RG16UI = 0x823A; + int GL_RG32I = 0x823B; + int GL_RG32UI = 0x823C; + + /** + * Accepted by the <format> parameter of TexImage3D, TexImage2D, + * TexImage3D, TexSubImage1D, TexSubImage2D, TexSubImage3D, + * DrawPixels and ReadPixels: + */ + int GL_RG = 0x8227; + int GL_RG_INTEGER = 0x8228; + + /** + * Accepted by the <param> parameter of the TexParameter{if}* + * functions when <pname> is DEPTH_TEXTURE_MODE: + */ + int GL_RED = 0x1903; + + // ---------------------------------------------------------------------- + // ----------------------[ EXT_transform_feedback ]---------------------- + // ---------------------------------------------------------------------- + + /** + * Accepted by the <target> parameters of BindBuffer, BufferData, + * BufferSubData, MapBuffer, UnmapBuffer, GetBufferSubData, + * GetBufferPointerv, BindBufferRange, BindBufferOffset and + * BindBufferBase: + */ + int GL_TRANSFORM_FEEDBACK_BUFFER = 0x8C8E; + + /** + * Accepted by the <param> parameter of GetIntegerIndexedv and + * GetBooleanIndexedv: + */ + int GL_TRANSFORM_FEEDBACK_BUFFER_START = 0x8C84; + int GL_TRANSFORM_FEEDBACK_BUFFER_SIZE = 0x8C85; + + /** + * Accepted by the <param> parameter of GetIntegerIndexedv and + * GetBooleanIndexedv, and by the <pname> parameter of GetBooleanv, + * GetDoublev, GetIntegerv, and GetFloatv: + */ + int GL_TRANSFORM_FEEDBACK_BUFFER_BINDING = 0x8C8F; + + /** Accepted by the <bufferMode> parameter of TransformFeedbackVaryings: */ + int GL_INTERLEAVED_ATTRIBS = 0x8C8C; + int GL_SEPARATE_ATTRIBS = 0x8C8D; + + /** + * Accepted by the <target> parameter of BeginQuery, EndQuery, and + * GetQueryiv: + */ + int GL_PRIMITIVES_GENERATED = 0x8C87; + int GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN = 0x8C88; + + /** + * Accepted by the <cap> parameter of Enable, Disable, and IsEnabled, and by + * the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, and + * GetDoublev: + */ + int GL_RASTERIZER_DISCARD = 0x8C89; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetDoublev, GetIntegerv, + * and GetFloatv: + */ + int GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS = 0x8C8A; + int GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS = 0x8C8B; + int GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS = 0x8C80; + + /** Accepted by the <pname> parameter of GetProgramiv: */ + int GL_TRANSFORM_FEEDBACK_VARYINGS = 0x8C83; + int GL_TRANSFORM_FEEDBACK_BUFFER_MODE = 0x8C7F; + int GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH = 0x8C76; + + void glBindBufferRange(@GLenum int target, @GLuint int index, @GLuint int buffer, @GLintptr long offset, @GLsizeiptr long size); + + void glBindBufferBase(@GLenum int target, @GLuint int index, @GLuint int buffer); + + void glBeginTransformFeedback(@GLenum int primitiveMode); + + void glEndTransformFeedback(); + + void glTransformFeedbackVaryings(@GLuint int program, @GLsizei int count, @Const @NullTerminated @GLchar ByteBuffer varyings, @GLenum int bufferMode); + + void glGetTransformFeedbackVarying(@GLuint int program, @GLuint int index, + @AutoSize("name") @GLsizei int bufSize, + @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length, + @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer size, + @OutParameter @Check(value = "1", canBeNull = true) @GLenum IntBuffer type, + @GLchar ByteBuffer name); + + // ----------------------------------------------------------------------- + // ----------------------[ ARB_vertex_array_object ]---------------------- + // ----------------------------------------------------------------------- + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev: + */ + int GL_VERTEX_ARRAY_BINDING = 0x85B5; + + void glBindVertexArray(@GLuint int array); + + void glDeleteVertexArrays(@AutoSize("arrays") @GLsizei int n, @Const @GLuint IntBuffer arrays); + + void glGenVertexArrays(@AutoSize("arrays") @GLsizei int n, @OutParameter @GLuint IntBuffer arrays); + + boolean glIsVertexArray(@GLuint int array); + + // -------------------------------------------------------------------- + // ----------------------[ ARB_framebuffer_sRGB ]---------------------- + // -------------------------------------------------------------------- + + /** + * Accepted by the <cap> parameter of Enable, Disable, and IsEnabled, + * and by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, + * and GetDoublev: + */ + int GL_FRAMEBUFFER_SRGB = 0x8DB9; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev: + */ + int GL_FRAMEBUFFER_SRGB_CAPABLE = 0x8DBA; + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/NV_conditional_render.java b/src/templates/org/lwjgl/opengl/NV_conditional_render.java index 22a353dd..61c13946 100644 --- a/src/templates/org/lwjgl/opengl/NV_conditional_render.java +++ b/src/templates/org/lwjgl/opengl/NV_conditional_render.java @@ -37,7 +37,7 @@ import org.lwjgl.util.generator.GLuint; public interface NV_conditional_render { /** - * Accepted by the parameter of BeginConditionalRenderNV: + * Accepted by the <mode> parameter of BeginConditionalRenderNV: */ int GL_QUERY_WAIT_NV = 0x8E13; int GL_QUERY_NO_WAIT_NV = 0x8E14;