Win32 part of refactor and AWTGLCanvas

This commit is contained in:
Elias Naur 2005-02-21 14:46:47 +00:00
parent 50d3a7fbf3
commit 62e561cddf
37 changed files with 1644 additions and 670 deletions

View file

@ -63,6 +63,8 @@ public final class Sys {
private final static SysImplementation implementation;
static {
System.loadLibrary("awt");
System.loadLibrary("jawt");
System.loadLibrary(LIBRARY_NAME);
implementation = createImplementation();
String native_version = implementation.getNativeLibraryVersion();

View file

@ -48,7 +48,7 @@ interface AWTCanvasImplementation {
/**
* Return an opaque handle to the canvas peer information required to create a context from it.
*/
public PeerInfo createPeerInfo(AWTGLCanvas canvas) throws LWJGLException;
public PeerInfo createPeerInfo(AWTGLCanvas canvas, PixelFormat pixel_format) throws LWJGLException;
/**
* Find a proper GraphicsConfiguration from the given GraphicsDevice and PixelFormat.

View file

@ -51,14 +51,13 @@ public class AWTGLCanvas extends Canvas implements Drawable {
private final static AWTCanvasImplementation implementation;
static {
System.loadLibrary("jawt");
Sys.initialize();
String class_name;
String OS_NAME = System.getProperty("os.name");
if (OS_NAME.startsWith("Linux")) {
class_name = "org.lwjgl.opengl.LinuxCanvasImplementation";
} else if (OS_NAME.startsWith("Windows")) {
class_name = "org.lwjgl.opengl.DefaultCanvasImplementation";
class_name = "org.lwjgl.opengl.Win32CanvasImplementation";
} else if (OS_NAME.startsWith("Mac")) {
class_name = "org.lwjgl.opengl.DefaultCanvasImplementation";
} else
@ -127,7 +126,7 @@ public class AWTGLCanvas extends Canvas implements Drawable {
*/
public AWTGLCanvas(GraphicsDevice device, PixelFormat pixel_format, Drawable drawable) throws LWJGLException {
super(implementation.findConfiguration(device, pixel_format));
this.peer_info = implementation.createPeerInfo(this);
this.peer_info = implementation.createPeerInfo(this, pixel_format);
this.drawable = drawable;
}

View file

@ -46,8 +46,12 @@ import java.awt.Canvas;
* @version $Revision$
*/
final class AWTSurfaceLock {
private final static int LOCK_HANDLE_SIZE = 64;
private final ByteBuffer lock_buffer = BufferUtils.createByteBuffer(LOCK_HANDLE_SIZE);
private final ByteBuffer lock_buffer;
public AWTSurfaceLock() {
lock_buffer = createHandle();
}
private static native ByteBuffer createHandle();
public ByteBuffer lockAndGetHandle(Canvas canvas) throws LWJGLException {
lockAndInitHandle(lock_buffer, canvas);

View file

@ -111,6 +111,8 @@ public final class GLContext {
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();

View file

@ -44,8 +44,6 @@ import org.lwjgl.Sys;
* @version $Revision$
*/
final class LinuxAWTGLCanvasPeerInfo extends LinuxPeerInfo {
private final static int LOCK_HANDLE_SIZE = 64;
private final ByteBuffer lock_buffer = BufferUtils.createByteBuffer(LOCK_HANDLE_SIZE);
private final AWTGLCanvas canvas;
private final AWTSurfaceLock awt_surface = new AWTSurfaceLock();

View file

@ -68,7 +68,7 @@ final class LinuxCanvasImplementation implements AWTCanvasImplementation {
}
}
public PeerInfo createPeerInfo(AWTGLCanvas canvas) throws LWJGLException {
public PeerInfo createPeerInfo(AWTGLCanvas canvas, PixelFormat pixel_format) throws LWJGLException {
return new LinuxAWTGLCanvasPeerInfo(canvas);
}

View file

@ -49,7 +49,7 @@ import org.lwjgl.input.Keyboard;
final class LinuxDisplay implements DisplayImplementation {
private static final int CURSOR_HANDLE_SIZE = 8;
private static final int PBUFFER_HANDLE_SIZE = 24;
// private static final int PBUFFER_HANDLE_SIZE = 24;
private static final int NUM_BUTTONS = 3;
private static PeerInfo peer_info;

View file

@ -46,15 +46,21 @@ import org.lwjgl.Sys;
final class LinuxDisplayPeerInfo extends LinuxPeerInfo {
public LinuxDisplayPeerInfo(PixelFormat pixel_format) throws LWJGLException {
LinuxDisplay.lockAWT();
initDefaultPeerInfo(getHandle(), pixel_format);
LinuxDisplay.unlockAWT();
try {
initDefaultPeerInfo(getHandle(), pixel_format);
} finally {
LinuxDisplay.unlockAWT();
}
}
private static native void initDefaultPeerInfo(ByteBuffer peer_info_handle, PixelFormat pixel_format) throws LWJGLException;
protected void doLockAndInitHandle() throws LWJGLException {
LinuxDisplay.lockAWT();
initDrawable(getHandle());
LinuxDisplay.unlockAWT();
try {
initDrawable(getHandle());
} finally {
LinuxDisplay.unlockAWT();
}
}
private static native void initDrawable(ByteBuffer peer_info_handle);

View file

@ -0,0 +1,70 @@
/*
* Copyright (c) 2002-2004 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 java.nio.ByteBuffer;
import org.lwjgl.BufferUtils;
import org.lwjgl.LWJGLException;
import org.lwjgl.Sys;
/**
* $Id$
*
* @author elias_naur <elias_naur@users.sourceforge.net>
* @version $Revision$
*/
final class Win32AWTGLCanvasPeerInfo extends Win32PeerInfo {
private final AWTGLCanvas canvas;
private final AWTSurfaceLock awt_surface = new AWTSurfaceLock();
private final PixelFormat pixel_format;
private boolean has_pixel_format= false;
public Win32AWTGLCanvasPeerInfo(AWTGLCanvas canvas, PixelFormat pixel_format) {
this.canvas = canvas;
this.pixel_format = pixel_format;
}
protected void doLockAndInitHandle() throws LWJGLException {
nInitHandle(awt_surface.lockAndGetHandle(canvas), getHandle());
if (!has_pixel_format) {
// If we haven't applied a pixel format yet, do it now
choosePixelFormat(canvas.getX(), canvas.getY(), pixel_format, null, true, true, false, true);
has_pixel_format = true;
}
}
private static native void nInitHandle(ByteBuffer surface_buffer, ByteBuffer peer_info_handle) throws LWJGLException;
protected void doUnlock() throws LWJGLException {
awt_surface.unlock();
}
}

View file

@ -0,0 +1,68 @@
/*
* Copyright (c) 2002-2004 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 java.nio.ByteBuffer;
import org.lwjgl.LWJGLException;
import org.lwjgl.BufferUtils;
import java.awt.GraphicsDevice;
import java.awt.GraphicsConfiguration;
import java.awt.Rectangle;
import java.lang.reflect.Method;
/**
* $Id$
*
* @author elias_naur <elias_naur@users.sourceforge.net>
* @version $Revision$
*/
final class Win32CanvasImplementation implements AWTCanvasImplementation {
public PeerInfo createPeerInfo(AWTGLCanvas canvas, PixelFormat pixel_format) throws LWJGLException {
return new Win32AWTGLCanvasPeerInfo(canvas, pixel_format);
}
/**
* Find a proper GraphicsConfiguration from the given GraphicsDevice and PixelFormat.
*
* @return The GraphicsConfiguration corresponding to a visual that matches the pixel format.
*/
public GraphicsConfiguration findConfiguration(GraphicsDevice device, PixelFormat pixel_format) throws LWJGLException {
/*
* It seems like the best way is to simply return null and let
* use SetPixelFormat in JNI later.
*/
return null;
}
}

View file

@ -0,0 +1,103 @@
/*
* Copyright (c) 2002-2004 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 java.nio.ByteBuffer;
import org.lwjgl.LWJGLException;
import org.lwjgl.BufferUtils;
/**
* $Id$
*
* @author elias_naur <elias_naur@users.sourceforge.net>
* @version $Revision$
*/
final class Win32ContextImplementation implements ContextImplementation {
private static PeerInfo getCurrentPeerInfo() {
return Context.getCurrentContext().getPeerInfo();
}
public ByteBuffer create(PeerInfo peer_info, ByteBuffer shared_context_handle) throws LWJGLException {
ByteBuffer peer_handle = peer_info.lockAndGetHandle();
try {
return nCreate(peer_handle, shared_context_handle);
} finally {
peer_info.unlock();
}
}
private static native ByteBuffer nCreate(ByteBuffer peer_handle, ByteBuffer shared_context_handle) throws LWJGLException;
public void swapBuffers() throws LWJGLException {
PeerInfo current_peer_info = getCurrentPeerInfo();
if (current_peer_info == null)
throw new IllegalStateException("No context is current");
ByteBuffer peer_handle = current_peer_info.lockAndGetHandle();
try {
nSwapBuffers(peer_handle);
} finally {
current_peer_info.unlock();
}
}
private static native void nSwapBuffers(ByteBuffer peer_info_handle) throws LWJGLException;
public void releaseCurrentContext() throws LWJGLException {
nReleaseCurrentContext();
}
private static native void nReleaseCurrentContext() throws LWJGLException;
public void makeCurrent(PeerInfo peer_info, ByteBuffer handle) throws LWJGLException {
ByteBuffer peer_handle = peer_info.lockAndGetHandle();
try {
nMakeCurrent(peer_handle, handle);
} finally {
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 setVSync(boolean enabled) {
nSetVSync(enabled);
}
private static native void nSetVSync(boolean enabled);
public void destroy(PeerInfo peer_info, ByteBuffer handle) throws LWJGLException {
nDestroy(handle);
}
private static native void nDestroy(ByteBuffer context_handle) throws LWJGLException;
}

View file

@ -42,15 +42,21 @@ import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import org.lwjgl.Sys;
import org.lwjgl.BufferUtils;
import org.lwjgl.LWJGLException;
import org.lwjgl.input.Cursor;
final class Win32Display implements DisplayImplementation {
private static final int CURSOR_HANDLE_SIZE = 8;
private static final int PBUFFER_HANDLE_SIZE = 24;
// private static final int PBUFFER_HANDLE_SIZE = 24;
public native void createWindow(DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException;
private static Win32DisplayPeerInfo peer_info;
public void createWindow(DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException {
nCreateWindow(mode, fullscreen, x, y);
peer_info.initDC();
}
private native void nCreateWindow(DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException;
public native void destroyWindow();
public native void switchDisplayMode(DisplayMode mode) throws LWJGLException;
public native void resetDisplayMode();
@ -67,13 +73,41 @@ final class Win32Display implements DisplayImplementation {
// public native void swapBuffers();
// public native void makeCurrent() throws LWJGLException;
public PeerInfo createPeerInfo(PixelFormat pixel_format) throws LWJGLException {
throw new RuntimeException("Not supported yet");
GLContext.loadOpenGLLibrary();
try {
peer_info = new Win32DisplayPeerInfo(pixel_format);
return peer_info;
} catch (LWJGLException e) {
GLContext.unloadOpenGLLibrary();
throw e;
}
}
// public native void createContext(PixelFormat pixel_format) throws LWJGLException;
// public native void destroyContext();
public native void destroyPeerInfo();
public native void update();
public native void setVSyncEnabled(boolean sync);
public void destroyPeerInfo() {
peer_info.destroy();
GLContext.unloadOpenGLLibrary();
}
public void update() {
nUpdate();
if (didMaximize()) {
/**
* WORKAROUND:
* Making the context current (redundantly) when the window
* is maximized helps some gfx recover from fullscreen
*/
try {
if (Display.getContext().isCurrent())
Display.getContext().makeCurrent();
} catch (LWJGLException e) {
Sys.log("Exception occurred while trying to make context current: " + e);
}
}
}
private native void nUpdate();
private native boolean didMaximize();
// public native void setVSyncEnabled(boolean sync);
public native void reshape(int x, int y, int width, int height);
public native DisplayMode[] getAvailableDisplayModes() throws LWJGLException;
@ -100,24 +134,25 @@ final class Win32Display implements DisplayImplementation {
public native int readKeyboard(IntBuffer buffer, int buffer_position);
public native int isStateKeySet(int key);
public native void nCreateCursor(ByteBuffer handle, int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, int images_offset, IntBuffer delays, int delays_offset) throws LWJGLException;
public native ByteBuffer nCreateCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, int images_offset, IntBuffer delays, int delays_offset) throws LWJGLException;
public Object createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException {
ByteBuffer handle = BufferUtils.createByteBuffer(CURSOR_HANDLE_SIZE);
nCreateCursor(handle, width, height, xHotspot, yHotspot, numImages, images, images.position(), delays, delays != null ? delays.position() : -1);
return handle;
return nCreateCursor(width, height, xHotspot, yHotspot, numImages, images, images.position(), delays, delays != null ? delays.position() : -1);
}
public native void destroyCursor(Object cursorHandle);
public native int getPbufferCapabilities();
public native boolean isBufferLost(PeerInfo handle);
public boolean isBufferLost(PeerInfo handle) {
return ((Win32PbufferPeerInfo)handle).isBufferLost();
}
// public native boolean isBufferLost(ByteBuffer handle);
// public native void makePbufferCurrent(ByteBuffer handle) throws LWJGLException;
public PeerInfo createPbuffer(int width, int height, PixelFormat pixel_format,
IntBuffer pixelFormatCaps,
IntBuffer pBufferAttribs) throws LWJGLException {
throw new RuntimeException("Not yet supported");
return new Win32PbufferPeerInfo(width, height, pixel_format, pixelFormatCaps, pBufferAttribs);
}
/* public ByteBuffer createPbuffer(int width, int height, PixelFormat pixel_format,
@ -132,12 +167,22 @@ final class Win32Display implements DisplayImplementation {
IntBuffer pixelFormatCaps,
IntBuffer pBufferAttribs, ByteBuffer shared_pbuffer_handle) throws LWJGLException;
*/
public native void destroyPbuffer(PeerInfo handle);
public void destroyPbuffer(PeerInfo handle) {
((Win32PbufferPeerInfo)handle).destroy();
}
// public native void destroyPbuffer(ByteBuffer handle);
public native void setPbufferAttrib(PeerInfo handle, int attrib, int value);
public native void bindTexImageToPbuffer(PeerInfo handle, int buffer);
public native void releaseTexImageFromPbuffer(PeerInfo handle, int buffer);
public void setPbufferAttrib(PeerInfo handle, int attrib, int value) {
((Win32PbufferPeerInfo)handle).setPbufferAttrib(attrib, value);
}
public void bindTexImageToPbuffer(PeerInfo handle, int buffer) {
((Win32PbufferPeerInfo)handle).bindTexImageToPbuffer(buffer);
}
public void releaseTexImageFromPbuffer(PeerInfo handle, int buffer) {
((Win32PbufferPeerInfo)handle).releaseTexImageFromPbuffer(buffer);
}
/* public native void setPbufferAttrib(ByteBuffer handle, int attrib, int value);
public native void bindTexImageToPbuffer(ByteBuffer handle, int buffer);
public native void releaseTexImageFromPbuffer(ByteBuffer handle, int buffer);*/

View file

@ -0,0 +1,78 @@
/*
* Copyright (c) 2002-2004 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 java.nio.ByteBuffer;
import org.lwjgl.BufferUtils;
import org.lwjgl.LWJGLException;
import org.lwjgl.Sys;
/**
* $Id$
*
* @author elias_naur <elias_naur@users.sourceforge.net>
* @version $Revision$
*/
final class Win32DisplayPeerInfo extends Win32PeerInfo {
public Win32DisplayPeerInfo(PixelFormat pixel_format) throws LWJGLException {
createDummyDC(getHandle());
try {
choosePixelFormat(0, 0, pixel_format, null, true, true, false, true);
} catch (LWJGLException e) {
destroy();
throw e;
}
}
private static native void createDummyDC(ByteBuffer peer_info_handle) throws LWJGLException;
void initDC() {
nInitDC(getHandle());
}
private static native void nInitDC(ByteBuffer peer_info_handle);
void destroy() {
nDestroy(getHandle());
}
private static native void nDestroy(ByteBuffer peer_info_handle);
protected void doLockAndInitHandle() throws LWJGLException {
// NO-OP
}
private static native void setPixelFormat(ByteBuffer peer_info_handle);
protected void doUnlock() throws LWJGLException {
// NO-OP
}
}

View file

@ -0,0 +1,85 @@
/*
* Copyright (c) 2002-2004 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 java.nio.ByteBuffer;
import java.nio.IntBuffer;
import org.lwjgl.BufferUtils;
import org.lwjgl.LWJGLException;
import org.lwjgl.Sys;
/**
* $Id$
*
* @author elias_naur <elias_naur@users.sourceforge.net>
* @version $Revision$
*/
final class Win32PbufferPeerInfo extends Win32PeerInfo {
public Win32PbufferPeerInfo(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;
public boolean isBufferLost() {
return nIsBufferLost(getHandle());
}
private static native boolean nIsBufferLost(ByteBuffer handle);
public void setPbufferAttrib(int attrib, int value) {
nSetPbufferAttrib(getHandle(), attrib, value);
}
private static native void nSetPbufferAttrib(ByteBuffer handle, int attrib, int value);
public void bindTexImageToPbuffer(int buffer) {
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());
}
private static native void nDestroy(ByteBuffer handle);
protected void doLockAndInitHandle() throws LWJGLException {
// NO-OP
}
protected void doUnlock() throws LWJGLException {
// NO-OP
}
}

View file

@ -0,0 +1,58 @@
/*
* Copyright (c) 2002-2004 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 java.nio.ByteBuffer;
import org.lwjgl.BufferUtils;
import org.lwjgl.LWJGLException;
import org.lwjgl.Sys;
import java.nio.IntBuffer;
/**
* $Id$
*
* @author elias_naur <elias_naur@users.sourceforge.net>
* @version $Revision$
*/
abstract class Win32PeerInfo extends PeerInfo {
public Win32PeerInfo() {
super(createHandle());
}
private static native ByteBuffer createHandle();
protected void choosePixelFormat(int origin_x, int origin_y, PixelFormat pixel_format, IntBuffer pixel_format_caps, boolean use_hdc_bpp, boolean support_window, boolean support_pbuffer, boolean double_buffered) throws LWJGLException {
nChoosePixelFormat(getHandle(), origin_x, origin_y, pixel_format, pixel_format_caps, use_hdc_bpp, support_window, support_pbuffer, double_buffered);
}
private static native void nChoosePixelFormat(ByteBuffer peer_info_handle, int origin_x, int origin_y, PixelFormat pixel_format, IntBuffer pixel_format_caps, boolean use_hdc_bpp, boolean support_window, boolean support_pbuffer, boolean double_buffered) throws LWJGLException;
}