You can subscribe to this list here.
| 2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(134) |
Sep
(52) |
Oct
(13) |
Nov
(342) |
Dec
(163) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(44) |
Feb
(62) |
Mar
(158) |
Apr
(38) |
May
(70) |
Jun
(58) |
Jul
(104) |
Aug
(207) |
Sep
(83) |
Oct
(122) |
Nov
(23) |
Dec
(49) |
| 2004 |
Jan
(119) |
Feb
(132) |
Mar
(192) |
Apr
(140) |
May
(77) |
Jun
(74) |
Jul
(201) |
Aug
(63) |
Sep
(102) |
Oct
(70) |
Nov
(173) |
Dec
(78) |
| 2005 |
Jan
(174) |
Feb
(197) |
Mar
(105) |
Apr
(59) |
May
(77) |
Jun
(43) |
Jul
(21) |
Aug
(18) |
Sep
(47) |
Oct
(37) |
Nov
(74) |
Dec
(50) |
| 2006 |
Jan
(44) |
Feb
(19) |
Mar
(32) |
Apr
(24) |
May
(31) |
Jun
(55) |
Jul
(138) |
Aug
(28) |
Sep
(12) |
Oct
(41) |
Nov
(58) |
Dec
(24) |
| 2007 |
Jan
(28) |
Feb
(14) |
Mar
(10) |
Apr
(68) |
May
(30) |
Jun
(26) |
Jul
(18) |
Aug
(63) |
Sep
(19) |
Oct
(29) |
Nov
(20) |
Dec
(10) |
| 2008 |
Jan
(38) |
Feb
(7) |
Mar
(37) |
Apr
(120) |
May
(41) |
Jun
(36) |
Jul
(39) |
Aug
(24) |
Sep
(28) |
Oct
(30) |
Nov
(36) |
Dec
(75) |
| 2009 |
Jan
(46) |
Feb
(22) |
Mar
(50) |
Apr
(70) |
May
(134) |
Jun
(105) |
Jul
(75) |
Aug
(34) |
Sep
(38) |
Oct
(34) |
Nov
(19) |
Dec
(20) |
| 2010 |
Jan
(11) |
Feb
(20) |
Mar
(65) |
Apr
(83) |
May
(104) |
Jun
(73) |
Jul
(78) |
Aug
(57) |
Sep
(43) |
Oct
(35) |
Nov
(9) |
Dec
(4) |
| 2011 |
Jan
(21) |
Feb
(11) |
Mar
(18) |
Apr
(10) |
May
(18) |
Jun
(15) |
Jul
(48) |
Aug
(25) |
Sep
(17) |
Oct
(45) |
Nov
(15) |
Dec
(12) |
| 2012 |
Jan
(21) |
Feb
(9) |
Mar
(12) |
Apr
(9) |
May
(9) |
Jun
(5) |
Jul
(1) |
Aug
(10) |
Sep
(12) |
Oct
(1) |
Nov
(28) |
Dec
(5) |
| 2013 |
Jan
(4) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2014 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
| 2015 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
|
| 2016 |
Jan
(2) |
Feb
(1) |
Mar
(1) |
Apr
(1) |
May
(2) |
Jun
|
Jul
(1) |
Aug
(2) |
Sep
|
Oct
|
Nov
(1) |
Dec
|
| 2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
|
|
1
|
2
(5) |
3
(1) |
4
(1) |
5
|
|
6
|
7
(6) |
8
(2) |
9
(11) |
10
|
11
(1) |
12
|
|
13
(1) |
14
(2) |
15
(30) |
16
(46) |
17
(13) |
18
(2) |
19
|
|
20
(26) |
21
(12) |
22
(9) |
23
(22) |
24
(5) |
25
(2) |
26
|
|
27
|
28
|
|
|
|
|
|
|
From: Brian M. <ma...@us...> - 2005-02-25 20:24:27
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31839/src/java/org/lwjgl/util Added Files: WaveData.java Log Message: moved WaveData to util --- NEW FILE: WaveData.java --- /* * 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.util; import java.io.BufferedInputStream; import java.io.ByteArrayInputStream; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.ShortBuffer; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; import org.lwjgl.openal.AL10; /** * $Id: WaveData.java,v 1.1 2005/02/25 20:24:11 matzon Exp $ * * Utitlity class for loading wavefiles. * * @author Brian Matzon <br...@ma...> * @version $Revision: 1.1 $ */ public class WaveData { /** actual wave data */ public final ByteBuffer data; /** format type of data */ public final int format; /** sample rate of data */ public final int samplerate; /** * Creates a new WaveData * * @param data actual wavedata * @param format format of wave data * @param samplerate sample rate of data */ private WaveData(ByteBuffer data, int format, int samplerate) { this.data = data; this.format = format; this.samplerate = samplerate; } /** * Disposes the wavedata */ public void dispose() { data.clear(); } /** * Creates a WaveData container from the specified filename * * @param filepath path to file (relative, and in classpath) * @return WaveData containing data, or null if a failure occured */ public static WaveData create(String filepath) { try { return create( AudioSystem.getAudioInputStream( new BufferedInputStream(WaveData.class.getClassLoader().getResourceAsStream(filepath)))); } catch (Exception e) { org.lwjgl.Sys.log("Unable to load file: " + filepath); e.printStackTrace(); return null; } } /** * Creates a WaveData container from the specified bytes * * @param buffer array of bytes containing the complete wave file * @return WaveData containing data, or null if a failure occured */ public static WaveData create(byte[] buffer) { try { return create( AudioSystem.getAudioInputStream( new BufferedInputStream(new ByteArrayInputStream(buffer)))); } catch (Exception e) { e.printStackTrace(); return null; } } /** * Creates a WaveData container from the specified stream * * @param ais AudioInputStream to read from * @return WaveData containing data, or null if a failure occured */ public static WaveData create(AudioInputStream ais) { //get format of data AudioFormat audioformat = ais.getFormat(); // get channels int channels = 0; if (audioformat.getChannels() == 1) { if (audioformat.getSampleSizeInBits() == 8) { channels = AL10.AL_FORMAT_MONO8; } else if (audioformat.getSampleSizeInBits() == 16) { channels = AL10.AL_FORMAT_MONO16; } else { assert false : "Illegal sample size"; } } else if (audioformat.getChannels() == 2) { if (audioformat.getSampleSizeInBits() == 8) { channels = AL10.AL_FORMAT_STEREO8; } else if (audioformat.getSampleSizeInBits() == 16) { channels = AL10.AL_FORMAT_STEREO16; } else { assert false : "Illegal sample size"; } } else { assert false : "Only mono or stereo is supported"; } //read data into buffer byte[] buf = new byte[audioformat.getChannels() * (int) ais.getFrameLength() * audioformat.getSampleSizeInBits() / 8]; int read = 0, total = 0; try { while ((read = ais.read(buf, total, buf.length - total)) != -1 && total < buf.length) { total += read; } } catch (IOException ioe) { return null; } //insert data into bytebuffer ByteBuffer buffer = convertAudioBytes(buf, audioformat.getSampleSizeInBits() == 16); /* ByteBuffer buffer = ByteBuffer.allocateDirect(buf.length); buffer.put(buf); buffer.rewind();*/ //create our result WaveData wavedata = new WaveData(buffer, channels, (int) audioformat.getSampleRate()); //close stream try { ais.close(); } catch (IOException ioe) { } return wavedata; } private static ByteBuffer convertAudioBytes(byte[] audio_bytes, boolean two_bytes_data) { ByteBuffer dest = ByteBuffer.allocateDirect(audio_bytes.length); dest.order(ByteOrder.nativeOrder()); ByteBuffer src = ByteBuffer.wrap(audio_bytes); src.order(ByteOrder.LITTLE_ENDIAN); if (two_bytes_data) { ShortBuffer dest_short = dest.asShortBuffer(); ShortBuffer src_short = src.asShortBuffer(); while (src_short.hasRemaining()) dest_short.put(src_short.get()); } else { while (src.hasRemaining()) dest.put(src.get()); } dest.rewind(); return dest; } } |
|
From: Brian M. <ma...@us...> - 2005-02-25 20:24:25
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/openal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31839/src/java/org/lwjgl/test/openal Modified Files: StressTest.java PositionTest.java MovingSoundTest.java PlayTest.java PlayTestMemory.java OpenALCreationTest.java Removed Files: WaveData.java Log Message: moved WaveData to util Index: PositionTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/openal/PositionTest.java,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- PositionTest.java 7 Dec 2004 22:01:15 -0000 1.24 +++ PositionTest.java 25 Feb 2005 20:24:10 -0000 1.25 @@ -43,6 +43,7 @@ import org.lwjgl.opengl.Display; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.glu.GLU; +import org.lwjgl.util.WaveData; /** * $Id$ --- WaveData.java DELETED --- Index: OpenALCreationTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/openal/OpenALCreationTest.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- OpenALCreationTest.java 12 Jun 2004 20:28:26 -0000 1.11 +++ OpenALCreationTest.java 25 Feb 2005 20:24:10 -0000 1.12 @@ -37,6 +37,7 @@ import org.lwjgl.openal.AL; import org.lwjgl.openal.AL10; +import org.lwjgl.util.WaveData; /** * $Id$ Index: PlayTestMemory.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/openal/PlayTestMemory.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- PlayTestMemory.java 22 Jul 2004 14:27:07 -0000 1.18 +++ PlayTestMemory.java 25 Feb 2005 20:24:10 -0000 1.19 @@ -39,6 +39,7 @@ import org.lwjgl.BufferUtils; import org.lwjgl.openal.AL10; +import org.lwjgl.util.WaveData; /** * $Id$ Index: StressTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/openal/StressTest.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- StressTest.java 22 Jul 2004 14:27:07 -0000 1.14 +++ StressTest.java 25 Feb 2005 20:24:10 -0000 1.15 @@ -35,6 +35,7 @@ import org.lwjgl.BufferUtils; import org.lwjgl.openal.AL10; +import org.lwjgl.util.WaveData; /** * $Id$ Index: MovingSoundTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/openal/MovingSoundTest.java,v retrieving revision 1.33 retrieving revision 1.34 diff -u -d -r1.33 -r1.34 --- MovingSoundTest.java 18 Jan 2005 15:22:50 -0000 1.33 +++ MovingSoundTest.java 25 Feb 2005 20:24:10 -0000 1.34 @@ -37,6 +37,7 @@ import org.lwjgl.input.Keyboard; import org.lwjgl.openal.AL10; import org.lwjgl.opengl.Display; +import org.lwjgl.util.WaveData; import org.lwjgl.util.vector.Vector3f; /** Index: PlayTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/openal/PlayTest.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- PlayTest.java 22 Jul 2004 14:27:07 -0000 1.17 +++ PlayTest.java 25 Feb 2005 20:24:10 -0000 1.18 @@ -39,6 +39,7 @@ import org.lwjgl.BufferUtils; import org.lwjgl.openal.AL10; +import org.lwjgl.util.WaveData; /** * $Id$ |
|
From: Elias N. <eli...@us...> - 2005-02-24 13:24:48
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19234/src/java/org/lwjgl/opengl Modified Files: Win32ContextImplementation.java Win32Display.java Log Message: Win32: Handle context-dependent wgl extensions Index: Win32Display.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/Win32Display.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- Win32Display.java 23 Feb 2005 11:45:25 -0000 1.14 +++ Win32Display.java 24 Feb 2005 13:24:08 -0000 1.15 @@ -124,7 +124,17 @@ } public native void destroyCursor(Object cursorHandle); - public native int getPbufferCapabilities(); + public int getPbufferCapabilities() { + try { + // Return the capabilities of a minimum pixel format + return nGetPbufferCapabilities(new PixelFormat(0, 0, 0, 0, 0, 0, 0, 0, false)); + } catch (LWJGLException e) { + Sys.log("Exception occurred while determining pbuffer capabilities: " + e); + return 0; + } + } + private native int nGetPbufferCapabilities(PixelFormat format) throws LWJGLException; + public boolean isBufferLost(PeerInfo handle) { return ((Win32PbufferPeerInfo)handle).isBufferLost(); } Index: Win32ContextImplementation.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/Win32ContextImplementation.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- Win32ContextImplementation.java 23 Feb 2005 12:12:47 -0000 1.3 +++ Win32ContextImplementation.java 24 Feb 2005 13:24:08 -0000 1.4 @@ -94,9 +94,14 @@ private static native boolean nIsCurrent(ByteBuffer context_handle) throws LWJGLException; public void setVSync(boolean enabled) { - nSetVSync(enabled); + Context current_context = Context.getCurrentContext(); + if (current_context == null) + throw new IllegalStateException("No context is current"); + synchronized (current_context) { + nSetVSync(current_context.getHandle(), enabled); + } } - private static native void nSetVSync(boolean enabled); + private static native void nSetVSync(ByteBuffer context_handle, boolean enabled); public void destroy(PeerInfo peer_info, ByteBuffer handle) throws LWJGLException { nDestroy(handle); |
Update of /cvsroot/java-game-lib/LWJGL/src/native/win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19234/src/native/win32 Modified Files: context.c context.h extgl_wgl.c extgl_wgl.h org_lwjgl_opengl_Pbuffer.c org_lwjgl_opengl_Win32ContextImplementation.c Log Message: Win32: Handle context-dependent wgl extensions Index: extgl_wgl.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/extgl_wgl.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- extgl_wgl.h 23 Feb 2005 15:34:42 -0000 1.4 +++ extgl_wgl.h 24 Feb 2005 13:24:08 -0000 1.5 @@ -40,40 +40,18 @@ #include "extgl.h" #include "common_tools.h" -typedef struct { - bool WGL_ARB_buffer_region; - bool WGL_ARB_extensions_string; - bool WGL_ARB_make_current_read; - bool WGL_ARB_multisample; - bool WGL_ARB_pbuffer; - bool WGL_ARB_pixel_format; - bool WGL_ARB_render_texture; - bool WGL_EXT_extensions_string; - bool WGL_EXT_swap_control; - bool WGL_NV_render_depth_texture; - bool WGL_NV_render_texture_rectangle; -} WGLExtensions; - -extern WGLExtensions extension_flags; - -extern void extgl_InitWGL(); - /*-------------------------------------------------------------------*/ /*------------WGL_EXT_EXTENSION_STRING-------------------------------*/ /*-------------------------------------------------------------------*/ typedef const char* (APIENTRY * wglGetExtensionsStringEXTPROC) (); -extern wglGetExtensionsStringEXTPROC wglGetExtensionsStringEXT; - /*-------------------------------------------------------------------*/ /*------------WGL_ARB_EXTENSION_STRING-------------------------------*/ /*-------------------------------------------------------------------*/ typedef const char* (APIENTRY * wglGetExtensionsStringARBPROC) (HDC hdc); -extern wglGetExtensionsStringARBPROC wglGetExtensionsStringARB; - /*-------------------------------------------------------------------*/ /*------------WGL_ARB_PBUFFER----------------------------------------*/ /*-------------------------------------------------------------------*/ @@ -96,12 +74,6 @@ typedef BOOL (APIENTRY * wglDestroyPbufferARBPROC) (HPBUFFERARB hPbuffer); typedef BOOL (APIENTRY * wglQueryPbufferARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue); -extern wglCreatePbufferARBPROC wglCreatePbufferARB; -extern wglGetPbufferDCARBPROC wglGetPbufferDCARB; -extern wglReleasePbufferDCARBPROC wglReleasePbufferDCARB; -extern wglDestroyPbufferARBPROC wglDestroyPbufferARB; -extern wglQueryPbufferARBPROC wglQueryPbufferARB; - /*-------------------------------------------------------------------*/ /*------------WGL_ARB_PIXEL_FORMAT-----------------------------------*/ /*-------------------------------------------------------------------*/ @@ -160,18 +132,10 @@ typedef BOOL (APIENTRY * wglGetPixelFormatAttribfvARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); typedef BOOL (APIENTRY * wglChoosePixelFormatARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); -extern wglGetPixelFormatAttribivARBPROC wglGetPixelFormatAttribivARB; -extern wglGetPixelFormatAttribfvARBPROC wglGetPixelFormatAttribfvARB; -extern wglChoosePixelFormatARBPROC wglChoosePixelFormatARB; - typedef BOOL (APIENTRY * wglBindTexImageARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); typedef BOOL (APIENTRY * wglReleaseTexImageARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); typedef BOOL (APIENTRY * wglSetPbufferAttribARBPROC) (HPBUFFERARB hPbuffer, const int *piAttribList); -extern wglBindTexImageARBPROC wglBindTexImageARB; -extern wglReleaseTexImageARBPROC wglReleaseTexImageARB; -extern wglSetPbufferAttribARBPROC wglSetPbufferAttribARB; - /*-------------------------------------------------------------------*/ /*------------WGL_EXT_SWAP_CONTROL-----------------------------------*/ /*-------------------------------------------------------------------*/ @@ -179,9 +143,6 @@ typedef BOOL (APIENTRY * wglSwapIntervalEXTPROC) (int interval); typedef int (APIENTRY * wglGetSwapIntervalEXTPROC) (void); -extern wglSwapIntervalEXTPROC wglSwapIntervalEXT; -extern wglGetSwapIntervalEXTPROC wglGetSwapIntervalEXT; - /*-------------------------------------------------------------------*/ /*------------WGL_ARB_MAKE_CURRENT_READ------------------------------*/ /*-------------------------------------------------------------------*/ @@ -192,9 +153,6 @@ typedef BOOL (APIENTRY * wglMakeContextCurrentARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); typedef HDC (APIENTRY * wglGetCurrentReadDCARBPROC) (void); -extern wglMakeContextCurrentARBPROC wglMakeContextCurrentARB; -extern wglGetCurrentReadDCARBPROC wglGetCurrentReadDCARB; - /*-------------------------------------------------------------------*/ /*------------WGL_ARB_MULTISAMPLE------------------------------------*/ /*-------------------------------------------------------------------*/ @@ -202,5 +160,44 @@ #define WGL_SAMPLE_BUFFERS_ARB 0x2041 #define WGL_SAMPLES_ARB 0x2042 +typedef struct { + bool WGL_ARB_buffer_region; + bool WGL_ARB_extensions_string; + bool WGL_ARB_make_current_read; + bool WGL_ARB_multisample; + bool WGL_ARB_pbuffer; + bool WGL_ARB_pixel_format; + bool WGL_ARB_render_texture; + bool WGL_EXT_extensions_string; + bool WGL_EXT_swap_control; + bool WGL_NV_render_depth_texture; + bool WGL_NV_render_texture_rectangle; + wglGetExtensionsStringEXTPROC wglGetExtensionsStringEXT; + + wglGetExtensionsStringARBPROC wglGetExtensionsStringARB; + + wglCreatePbufferARBPROC wglCreatePbufferARB; + wglGetPbufferDCARBPROC wglGetPbufferDCARB; + wglReleasePbufferDCARBPROC wglReleasePbufferDCARB; + wglDestroyPbufferARBPROC wglDestroyPbufferARB; + wglQueryPbufferARBPROC wglQueryPbufferARB; + + wglGetPixelFormatAttribivARBPROC wglGetPixelFormatAttribivARB; + wglGetPixelFormatAttribfvARBPROC wglGetPixelFormatAttribfvARB; + wglChoosePixelFormatARBPROC wglChoosePixelFormatARB; + + wglBindTexImageARBPROC wglBindTexImageARB; + wglReleaseTexImageARBPROC wglReleaseTexImageARB; + wglSetPbufferAttribARBPROC wglSetPbufferAttribARB; + + wglSwapIntervalEXTPROC wglSwapIntervalEXT; + wglGetSwapIntervalEXTPROC wglGetSwapIntervalEXT; + + wglMakeContextCurrentARBPROC wglMakeContextCurrentARB; + wglGetCurrentReadDCARBPROC wglGetCurrentReadDCARB; +} WGLExtensions; + +extern void extgl_InitWGL(WGLExtensions *extensions); + #endif Index: org_lwjgl_opengl_Win32ContextImplementation.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_opengl_Win32ContextImplementation.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- org_lwjgl_opengl_Win32ContextImplementation.c 21 Feb 2005 14:46:47 -0000 1.1 +++ org_lwjgl_opengl_Win32ContextImplementation.c 24 Feb 2005 13:24:08 -0000 1.2 @@ -43,6 +43,7 @@ #include "common_tools.h" typedef struct { + WGLExtensions extensions; HGLRC context; } Win32Context; @@ -53,6 +54,9 @@ Win32Context *context_info; HGLRC context; HGLRC shared_context = NULL; + HDC saved_hdc; + HGLRC saved_context; + WGLExtensions extensions; jobject context_handle = newJavaManagedByteBuffer(env, sizeof(Win32Context)); if (context_handle == NULL) { @@ -74,9 +78,21 @@ return NULL; } } + saved_hdc = wglGetCurrentDC(); + saved_context = wglGetCurrentContext(); + if (!wglMakeCurrent(peer_info->format_hdc, context)) { + wglMakeCurrent(saved_hdc, saved_context); + wglDeleteContext(context); + throwException(env, "Could not make context current"); + return NULL; + } + extgl_InitWGL(&extensions); + if (!wglMakeCurrent(saved_hdc, saved_context)) + printfDebug("Failed to restore current context\n"); context_info = (Win32Context *)(*env)->GetDirectBufferAddress(env, context_handle); context_info->context = context; - return context_handle; + context_info->extensions = extensions; + return context_handle; } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32ContextImplementation_nSwapBuffers @@ -105,12 +121,13 @@ } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32ContextImplementation_nSetVSync - (JNIEnv *env, jclass clazz, jboolean enable) { - if (extension_flags.WGL_EXT_swap_control) { + (JNIEnv *env, jclass clazz, jobject context_handle, jboolean enable) { + Win32Context *context_info = (Win32Context *)(*env)->GetDirectBufferAddress(env, context_handle); + if (context_info->extensions.WGL_EXT_swap_control) { if (enable == JNI_TRUE) { - wglSwapIntervalEXT(1); + context_info->extensions.wglSwapIntervalEXT(1); } else { - wglSwapIntervalEXT(0); + context_info->extensions.wglSwapIntervalEXT(0); } } } Index: context.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/context.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- context.h 21 Feb 2005 14:46:47 -0000 1.1 +++ context.h 24 Feb 2005 13:24:08 -0000 1.2 @@ -50,7 +50,12 @@ typedef struct { union { HWND format_hwnd; - HPBUFFERARB pbuffer; + struct { + HPBUFFERARB pbuffer; + // Contains the function pointers that + // created the pbuffer + WGLExtensions extensions; + } pbuffer; }; HDC format_hdc; HDC drawable_hdc; Index: extgl_wgl.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/extgl_wgl.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- extgl_wgl.c 23 Feb 2005 15:17:53 -0000 1.6 +++ extgl_wgl.c 24 Feb 2005 13:24:08 -0000 1.7 @@ -38,50 +38,9 @@ #include "extgl_wgl.h" #include "extgl.h" -WGLExtensions extension_flags; - -/* WGL_EXT_etxension_string */ - -wglGetExtensionsStringEXTPROC wglGetExtensionsStringEXT = NULL; - -/* WGL_ARB_extension_string */ - -wglGetExtensionsStringARBPROC wglGetExtensionsStringARB = NULL; - -/* WGL_ARB_pbuffer */ - -wglCreatePbufferARBPROC wglCreatePbufferARB = NULL; -wglGetPbufferDCARBPROC wglGetPbufferDCARB = NULL; -wglReleasePbufferDCARBPROC wglReleasePbufferDCARB = NULL; -wglDestroyPbufferARBPROC wglDestroyPbufferARB = NULL; -wglQueryPbufferARBPROC wglQueryPbufferARB = NULL; - -/* WGL_ARB_pixel_format */ - -wglGetPixelFormatAttribivARBPROC wglGetPixelFormatAttribivARB = NULL; -wglGetPixelFormatAttribfvARBPROC wglGetPixelFormatAttribfvARB = NULL; -wglChoosePixelFormatARBPROC wglChoosePixelFormatARB = NULL; - -/* WGL_ARB_render_texture */ - -wglBindTexImageARBPROC wglBindTexImageARB = NULL; -wglReleaseTexImageARBPROC wglReleaseTexImageARB = NULL; -wglSetPbufferAttribARBPROC wglSetPbufferAttribARB = NULL; - -/* WGL_EXT_swap_control */ - -wglSwapIntervalEXTPROC wglSwapIntervalEXT = NULL; -wglGetSwapIntervalEXTPROC wglGetSwapIntervalEXT = NULL; - -/* WGL_ARB_make_current_read */ - -wglMakeContextCurrentARBPROC wglMakeContextCurrentARB = NULL; -wglGetCurrentReadDCARBPROC wglGetCurrentReadDCARB = NULL; - static HMODULE lib_gl_handle = NULL; -void *extgl_GetProcAddress(const char *name) -{ +void *extgl_GetProcAddress(const char *name) { void *t = wglGetProcAddress(name); if (t == NULL) { @@ -94,8 +53,7 @@ return t; } -bool extgl_Open(JNIEnv *env) -{ +bool extgl_Open(JNIEnv *env) { if (lib_gl_handle != NULL) return true; // load the dynamic libraries for OpenGL @@ -107,104 +65,105 @@ return true; } -void extgl_Close(void) -{ +void extgl_Close(void) { FreeLibrary(lib_gl_handle); lib_gl_handle = NULL; } /** returns true if the extension is available */ -static bool WGLQueryExtension(const char *name) -{ - const GLubyte *extensions; +static bool WGLQueryExtension(WGLExtensions *extensions, const char *name) { + const GLubyte *extension_string; - if (wglGetExtensionsStringARB == NULL) - if (wglGetExtensionsStringEXT == NULL) + if (extensions->wglGetExtensionsStringARB == NULL) + if (extensions->wglGetExtensionsStringEXT == NULL) return false; else - extensions = (GLubyte*)wglGetExtensionsStringEXT(); + extension_string = (GLubyte*)extensions->wglGetExtensionsStringEXT(); else - extensions = (GLubyte*)wglGetExtensionsStringARB(wglGetCurrentDC()); - return extgl_QueryExtension(extensions, name); + extension_string = (GLubyte*)extensions->wglGetExtensionsStringARB(wglGetCurrentDC()); + return extgl_QueryExtension(extension_string, name); } -static void extgl_InitWGLARBPbuffer() -{ +static void extgl_InitWGLARBPbuffer(WGLExtensions *extensions) { ExtFunction functions[] = { - {"wglCreatePbufferARB", (void **)&wglCreatePbufferARB}, - {"wglGetPbufferDCARB", (void **)&wglGetPbufferDCARB}, - {"wglReleasePbufferDCARB", (void **)&wglReleasePbufferDCARB}, - {"wglDestroyPbufferARB", (void **)&wglDestroyPbufferARB}, - {"wglQueryPbufferARB", (void **)&wglQueryPbufferARB}}; - if (extension_flags.WGL_ARB_pbuffer) - extension_flags.WGL_ARB_pbuffer = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); + {"wglCreatePbufferARB", (void **)&extensions->wglCreatePbufferARB}, + {"wglGetPbufferDCARB", (void **)&extensions->wglGetPbufferDCARB}, + {"wglReleasePbufferDCARB", (void **)&extensions->wglReleasePbufferDCARB}, + {"wglDestroyPbufferARB", (void **)&extensions->wglDestroyPbufferARB}, + {"wglQueryPbufferARB", (void **)&extensions->wglQueryPbufferARB}}; + if (extensions->WGL_ARB_pbuffer) + extensions->WGL_ARB_pbuffer = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); } -static void extgl_InitWGLARBPixelFormat() -{ +static void extgl_InitWGLARBPixelFormat(WGLExtensions *extensions) { ExtFunction functions[] = { - {"wglGetPixelFormatAttribivARB", (void **)&wglGetPixelFormatAttribivARB}, - {"wglGetPixelFormatAttribfvARB", (void **)&wglGetPixelFormatAttribfvARB}, - {"wglChoosePixelFormatARB", (void **)&wglChoosePixelFormatARB}}; - if (extension_flags.WGL_ARB_pixel_format) - extension_flags.WGL_ARB_pixel_format = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); + {"wglGetPixelFormatAttribivARB", (void **)&extensions->wglGetPixelFormatAttribivARB}, + {"wglGetPixelFormatAttribfvARB", (void **)&extensions->wglGetPixelFormatAttribfvARB}, + {"wglChoosePixelFormatARB", (void **)&extensions->wglChoosePixelFormatARB}}; + if (extensions->WGL_ARB_pixel_format) + extensions->WGL_ARB_pixel_format = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); } -static void extgl_InitWGLARBRenderTexture() -{ +static void extgl_InitWGLARBRenderTexture(WGLExtensions *extensions) { ExtFunction functions[] = { - {"wglBindTexImageARB", (void **)&wglBindTexImageARB}, - {"wglReleaseTexImageARB", (void **)&wglReleaseTexImageARB}, - {"wglSetPbufferAttribARB", (void **)&wglSetPbufferAttribARB}}; - if (extension_flags.WGL_ARB_render_texture) - extension_flags.WGL_ARB_render_texture = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); + {"wglBindTexImageARB", (void **)&extensions->wglBindTexImageARB}, + {"wglReleaseTexImageARB", (void **)&extensions->wglReleaseTexImageARB}, + {"wglSetPbufferAttribARB", (void **)&extensions->wglSetPbufferAttribARB}}; + if (extensions->WGL_ARB_render_texture) + extensions->WGL_ARB_render_texture = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); } -static void extgl_InitWGLEXTSwapControl() -{ +static void extgl_InitWGLEXTSwapControl(WGLExtensions *extensions) { ExtFunction functions[] = { - {"wglSwapIntervalEXT", (void **)&wglSwapIntervalEXT}, - {"wglGetSwapIntervalEXT", (void **)&wglGetSwapIntervalEXT}}; - if (extension_flags.WGL_EXT_swap_control) - extension_flags.WGL_EXT_swap_control = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); + {"wglSwapIntervalEXT", (void **)&extensions->wglSwapIntervalEXT}, + {"wglGetSwapIntervalEXT", (void **)&extensions->wglGetSwapIntervalEXT}}; + if (extensions->WGL_EXT_swap_control) + extensions->WGL_EXT_swap_control = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); } -static void extgl_InitWGLARBMakeCurrentRead() -{ +static void extgl_InitWGLARBMakeCurrentRead(WGLExtensions *extensions) { ExtFunction functions[] = { - {"wglMakeContextCurrentARB", (void **)&wglMakeContextCurrentARB}, - {"wglGetCurrentReadDCARB", (void **)&wglGetCurrentReadDCARB}}; - if (extension_flags.WGL_ARB_make_current_read) - extension_flags.WGL_ARB_make_current_read = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); + {"wglMakeContextCurrentARB", (void **)&extensions->wglMakeContextCurrentARB}, + {"wglGetCurrentReadDCARB", (void **)&extensions->wglGetCurrentReadDCARB}}; + if (extensions->WGL_ARB_make_current_read) + extensions->WGL_ARB_make_current_read = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); } -static void extgl_InitSupportedWGLExtensions() -{ - extension_flags.WGL_ARB_buffer_region = WGLQueryExtension("WGL_ARB_buffer_region"); - extension_flags.WGL_ARB_make_current_read = WGLQueryExtension("WGL_ARB_make_current_read"); - extension_flags.WGL_ARB_multisample = WGLQueryExtension("WGL_ARB_multisample"); - extension_flags.WGL_ARB_pbuffer = WGLQueryExtension("WGL_ARB_pbuffer"); - extension_flags.WGL_ARB_pixel_format = WGLQueryExtension("WGL_ARB_pixel_format"); - extension_flags.WGL_ARB_render_texture = WGLQueryExtension("WGL_ARB_render_texture"); - extension_flags.WGL_EXT_swap_control = WGLQueryExtension("WGL_EXT_swap_control"); - extension_flags.WGL_NV_render_depth_texture = WGLQueryExtension("WGL_NV_render_depth_texture"); - extension_flags.WGL_NV_render_texture_rectangle = WGLQueryExtension("WGL_NV_render_texture_rectangle"); +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"); + extensions->WGL_ARB_multisample = WGLQueryExtension(extensions, "WGL_ARB_multisample"); + extensions->WGL_ARB_pbuffer = WGLQueryExtension(extensions, "WGL_ARB_pbuffer"); + extensions->WGL_ARB_pixel_format = WGLQueryExtension(extensions, "WGL_ARB_pixel_format"); + extensions->WGL_ARB_render_texture = WGLQueryExtension(extensions, "WGL_ARB_render_texture"); + 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"); } -void extgl_InitWGL() -{ +static void extgl_InitWGLEXTExtensionsString(WGLExtensions *extensions) { ExtFunction functions[] = { - {"wglGetExtensionsStringARB", (void **)&wglGetExtensionsStringARB}, - {"wglGetExtensionsStringEXT", (void **)&wglGetExtensionsStringEXT}}; - extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); - extension_flags.WGL_ARB_extensions_string = wglGetExtensionsStringARB != NULL; - extension_flags.WGL_EXT_extensions_string = wglGetExtensionsStringEXT != NULL; + {"wglGetExtensionsStringEXT", (void **)&extensions->wglGetExtensionsStringEXT} + }; + extensions->WGL_EXT_extensions_string = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); +} - extgl_InitSupportedWGLExtensions(); +static void extgl_InitWGLARBExtensionsString(WGLExtensions *extensions) { + ExtFunction functions[] = { + {"wglGetExtensionsStringARB", (void **)&extensions->wglGetExtensionsStringARB} + }; + extensions->WGL_ARB_extensions_string = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); +} - extgl_InitWGLARBMakeCurrentRead(); - extgl_InitWGLEXTSwapControl(); - extgl_InitWGLARBRenderTexture(); - extgl_InitWGLARBPixelFormat(); - extgl_InitWGLARBPbuffer(); +void extgl_InitWGL(WGLExtensions *extensions) { + extgl_InitWGLARBExtensionsString(extensions); + extgl_InitWGLEXTExtensionsString(extensions); + + extgl_InitSupportedWGLExtensions(extensions); + + extgl_InitWGLARBMakeCurrentRead(extensions); + extgl_InitWGLEXTSwapControl(extensions); + extgl_InitWGLARBRenderTexture(extensions); + extgl_InitWGLARBPixelFormat(extensions); + extgl_InitWGLARBPbuffer(extensions); } Index: org_lwjgl_opengl_Pbuffer.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_opengl_Pbuffer.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- org_lwjgl_opengl_Pbuffer.c 23 Feb 2005 11:42:04 -0000 1.11 +++ org_lwjgl_opengl_Pbuffer.c 24 Feb 2005 13:24:08 -0000 1.12 @@ -49,31 +49,68 @@ #include "common_tools.h" -typedef struct _PbufferInfo { - HGLRC Pbuffer_context; - HPBUFFERARB Pbuffer; - HDC Pbuffer_dc; -} PbufferInfo; - -static bool isPbuffersSupported() { - return extension_flags.WGL_ARB_pixel_format && extension_flags.WGL_ARB_pbuffer; +static bool isPbufferSupported(WGLExtensions *extensions) { + return extensions->WGL_ARB_pixel_format && extensions->WGL_ARB_pbuffer; } -JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Win32Display_getPbufferCapabilities - (JNIEnv *env, jobject self) +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Win32Display_nGetPbufferCapabilities + (JNIEnv *env, jobject self, jobject pixel_format) { int caps = 0; - if (isPbuffersSupported()) + int origin_x = 0; int origin_y = 0; + HWND dummy_hwnd; + HDC dummy_hdc; + HGLRC dummy_context; + HDC saved_hdc; + HGLRC saved_context; + int pixel_format_id; + WGLExtensions extensions; + + pixel_format_id = findPixelFormat(env, origin_x, origin_y, pixel_format, NULL, false, false, true, false); + if (pixel_format_id == -1) + return 0; + dummy_hwnd = createDummyWindow(origin_x, origin_y); + if (dummy_hwnd == NULL) { + throwException(env, "Could not create dummy window"); + return 0; + } + dummy_hdc = GetDC(dummy_hwnd); + if (!applyPixelFormat(dummy_hdc, pixel_format_id)) { + closeWindow(&dummy_hwnd, &dummy_hdc); + throwException(env, "Could not apply pixel format"); + return 0; + } + dummy_context = wglCreateContext(dummy_hdc); + if (dummy_context == NULL) { + closeWindow(&dummy_hwnd, &dummy_hdc); + throwException(env, "Could not create dummy context"); + return 0; + } + saved_hdc = wglGetCurrentDC(); + saved_context = wglGetCurrentContext(); + if (!wglMakeCurrent(dummy_hdc, dummy_context)) { + wglMakeCurrent(saved_hdc, saved_context); + closeWindow(&dummy_hwnd, &dummy_hdc); + wglDeleteContext(dummy_context); + throwException(env, "Could not create dummy context"); + return 0; + } + extgl_InitWGL(&extensions); + if (isPbufferSupported(&extensions)) caps |= org_lwjgl_opengl_Pbuffer_PBUFFER_SUPPORTED; - if (extension_flags.WGL_ARB_render_texture) + if (extensions.WGL_ARB_render_texture) caps |= org_lwjgl_opengl_Pbuffer_RENDER_TEXTURE_SUPPORTED; - if (extension_flags.WGL_NV_render_texture_rectangle) + if (extensions.WGL_NV_render_texture_rectangle) caps |= org_lwjgl_opengl_Pbuffer_RENDER_TEXTURE_RECTANGLE_SUPPORTED; - if (extension_flags.WGL_NV_render_depth_texture) + if (extensions.WGL_NV_render_depth_texture) caps |= org_lwjgl_opengl_Pbuffer_RENDER_DEPTH_TEXTURE_SUPPORTED; + if (!wglMakeCurrent(saved_hdc, saved_context)) + printfDebug("ERROR: Could not restore current context\n"); + closeWindow(&dummy_hwnd, &dummy_hdc); + wglDeleteContext(dummy_context); return caps; } @@ -86,8 +123,12 @@ int origin_x = 0; int origin_y = 0; HWND dummy_hwnd; HDC dummy_hdc; + HGLRC dummy_context; HPBUFFERARB Pbuffer; HDC Pbuffer_dc; + HDC saved_hdc; + HGLRC saved_context; + WGLExtensions extensions; const int *pBufferAttribs_ptr; Win32PeerInfo *peer_info = (Win32PeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); int pixel_format_id; @@ -98,7 +139,8 @@ pBufferAttribs_ptr = NULL; } pixel_format_id = findPixelFormat(env, origin_x, origin_y, pixel_format, pixelFormatCaps, false, false, true, false); - + if (pixel_format_id == -1) + return; dummy_hwnd = createDummyWindow(origin_x, origin_y); if (dummy_hwnd == NULL) { throwException(env, "Could not create dummy window"); @@ -110,36 +152,59 @@ throwException(env, "Could not apply pixel format"); return; } - Pbuffer = wglCreatePbufferARB(dummy_hdc, pixel_format_id, width, height, pBufferAttribs_ptr); + dummy_context = wglCreateContext(dummy_hdc); + if (dummy_context == NULL) { + closeWindow(&dummy_hwnd, &dummy_hdc); + throwException(env, "Could not create dummy context"); + return; + } + saved_hdc = wglGetCurrentDC(); + saved_context = wglGetCurrentContext(); + if (!wglMakeCurrent(dummy_hdc, dummy_context)) { + wglMakeCurrent(saved_hdc, saved_context); + wglDeleteContext(dummy_context); + closeWindow(&dummy_hwnd, &dummy_hdc); + throwException(env, "Could not make context current"); + return; + } + extgl_InitWGL(&extensions); + wglMakeCurrent(saved_hdc, saved_context); + wglDeleteContext(dummy_context); + closeWindow(&dummy_hwnd, &dummy_hdc); + if (!isPbufferSupported(&extensions)) { + throwException(env, "Pbuffers are not supported"); + return; + } + Pbuffer = extensions.wglCreatePbufferARB(dummy_hdc, pixel_format_id, width, height, pBufferAttribs_ptr); closeWindow(&dummy_hwnd, &dummy_hdc); if (Pbuffer == NULL) { throwException(env, "Could not create Pbuffer"); return; } - Pbuffer_dc = wglGetPbufferDCARB(Pbuffer); + Pbuffer_dc = extensions.wglGetPbufferDCARB(Pbuffer); if (Pbuffer_dc == NULL) { - wglDestroyPbufferARB(Pbuffer); + extensions.wglDestroyPbufferARB(Pbuffer); throwException(env, "Could not get Pbuffer DC"); return; } peer_info->format_hdc = Pbuffer_dc; - peer_info->pbuffer = Pbuffer; + peer_info->pbuffer.extensions = extensions; + peer_info->pbuffer.pbuffer = Pbuffer; peer_info->drawable_hdc = Pbuffer_dc; - } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32PbufferPeerInfo_nDestroy (JNIEnv *env, jclass clazz, jobject peer_info_handle) { Win32PeerInfo *peer_info = (Win32PeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); - wglReleasePbufferDCARB(peer_info->pbuffer, peer_info->drawable_hdc); - wglDestroyPbufferARB(peer_info->pbuffer); + peer_info->pbuffer.extensions.wglReleasePbufferDCARB(peer_info->pbuffer.pbuffer, peer_info->drawable_hdc); + peer_info->pbuffer.extensions.wglDestroyPbufferARB(peer_info->pbuffer.pbuffer); } JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Win32PbufferPeerInfo_nIsBufferLost (JNIEnv *env, jclass clazz, jobject peer_info_handle) { Win32PeerInfo *peer_info = (Win32PeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); BOOL buffer_lost; - wglQueryPbufferARB(peer_info->pbuffer, WGL_PBUFFER_LOST_ARB, &buffer_lost); + peer_info->pbuffer.extensions.wglQueryPbufferARB(peer_info->pbuffer.pbuffer, WGL_PBUFFER_LOST_ARB, &buffer_lost); return buffer_lost ? JNI_TRUE : JNI_FALSE; } @@ -152,17 +217,17 @@ attribs[1] = value; attribs[2] = 0; - wglSetPbufferAttribARB(peer_info->pbuffer, attribs); + peer_info->pbuffer.extensions.wglSetPbufferAttribARB(peer_info->pbuffer.pbuffer, attribs); } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32PbufferPeerInfo_nBindTexImageToPbuffer (JNIEnv *env, jclass clazz, jobject peer_info_handle, jint buffer) { Win32PeerInfo *peer_info = (Win32PeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); - wglBindTexImageARB(peer_info->pbuffer, buffer); + peer_info->pbuffer.extensions.wglBindTexImageARB(peer_info->pbuffer.pbuffer, buffer); } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32PbufferPeerInfo_nReleaseTexImageFromPbuffer (JNIEnv *env, jclass clazz, jobject peer_info_handle, jint buffer) { Win32PeerInfo *peer_info = (Win32PeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); - wglReleaseTexImageARB(peer_info->pbuffer, buffer); + peer_info->pbuffer.extensions.wglReleaseTexImageARB(peer_info->pbuffer.pbuffer, buffer); } Index: context.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/context.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- context.c 23 Feb 2005 15:19:21 -0000 1.2 +++ context.c 24 Feb 2005 13:24:08 -0000 1.3 @@ -161,7 +161,7 @@ return new_hwnd; } -static int findPixelFormatARBFromBPP(JNIEnv *env, HDC hdc, jobject pixel_format, jobject pixelFormatCaps, int bpp, bool window, bool pbuffer, bool double_buffer) { +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")); @@ -195,7 +195,8 @@ putAttrib(&attrib_list, WGL_ALPHA_BITS_ARB); putAttrib(&attrib_list, alpha); putAttrib(&attrib_list, WGL_DEPTH_BITS_ARB); putAttrib(&attrib_list, depth); putAttrib(&attrib_list, WGL_STENCIL_BITS_ARB); putAttrib(&attrib_list, stencil); - if (samples > 0 && extension_flags.WGL_ARB_multisample) { + // Assume caller checked extension availability + if (samples > 0) { putAttrib(&attrib_list, WGL_SAMPLE_BUFFERS_ARB); putAttrib(&attrib_list, 1); putAttrib(&attrib_list, WGL_SAMPLES_ARB); putAttrib(&attrib_list, samples); } @@ -203,11 +204,8 @@ 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); + // Assume caller checked extension availability if ( pixelFormatCaps != NULL ) { - if ( !extension_flags.WGL_ARB_render_texture ) { - return -1; - } - pixelFormatCaps_ptr = (GLuint *)(*env)->GetDirectBufferAddress(env, pixelFormatCaps); pixelFormatCapsSize = (*env)->GetDirectBufferCapacity(env, pixelFormatCaps); @@ -215,7 +213,7 @@ putAttrib(&attrib_list, pixelFormatCaps_ptr[i]); } putAttrib(&attrib_list, 0); putAttrib(&attrib_list, 0); - result = wglChoosePixelFormatARB(hdc, attrib_list.attribs, NULL, 1, &iPixelFormat, &num_formats_returned); + result = extensions->wglChoosePixelFormatARB(hdc, attrib_list.attribs, NULL, 1, &iPixelFormat, &num_formats_returned); if (result == FALSE || num_formats_returned < 1) { return -1; @@ -223,20 +221,20 @@ return iPixelFormat; } -static int findPixelFormatARB(JNIEnv *env, HDC hdc, jobject pixel_format, jobject pixelFormatCaps, bool use_hdc_bpp, bool window, bool pbuffer, bool double_buffer) { +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; jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format); if (use_hdc_bpp) { bpp = GetDeviceCaps(hdc, BITSPIXEL); - iPixelFormat = findPixelFormatARBFromBPP(env, hdc, pixel_format, pixelFormatCaps, bpp, window, pbuffer, double_buffer); + iPixelFormat = findPixelFormatARBFromBPP(env, hdc, extensions, pixel_format, pixelFormatCaps, bpp, window, pbuffer, double_buffer); if (iPixelFormat == -1) bpp = 16; else return iPixelFormat; } else bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "bpp", "I")); - return findPixelFormatARBFromBPP(env, hdc, pixel_format, pixelFormatCaps, bpp, window, pbuffer, double_buffer); + return findPixelFormatARBFromBPP(env, hdc, extensions, pixel_format, pixelFormatCaps, bpp, window, pbuffer, double_buffer); } /* @@ -345,6 +343,7 @@ HGLRC dummy_hglrc; HDC saved_current_hdc; HGLRC saved_current_hglrc; + WGLExtensions extensions; 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")); @@ -364,17 +363,32 @@ saved_current_hdc = wglGetCurrentDC(); saved_current_hglrc = wglGetCurrentContext(); if (!wglMakeCurrent(hdc, dummy_hglrc)) { + wglMakeCurrent(saved_current_hdc, saved_current_hglrc); wglDeleteContext(dummy_hglrc); throwException(env, "Could not bind context to dummy window"); return -1; } - extgl_InitWGL(); + extgl_InitWGL(&extensions); - if (!extension_flags.WGL_ARB_pixel_format) { + if (!extensions.WGL_ARB_pixel_format) { + wglMakeCurrent(saved_current_hdc, saved_current_hglrc); + wglDeleteContext(dummy_hglrc); throwException(env, "No support for WGL_ARB_pixel_format"); return -1; } - pixel_format_id = findPixelFormatARB(env, hdc, pixel_format, pixelFormatCaps, use_hdc_bpp, window, pbuffer, double_buffer); + if (samples > 0 && !extensions.WGL_ARB_multisample) { + wglMakeCurrent(saved_current_hdc, saved_current_hglrc); + wglDeleteContext(dummy_hglrc); + throwException(env, "No support for WGL_ARB_multisample"); + return -1; + } + if (pixelFormatCaps != NULL && !extensions.WGL_ARB_render_texture) { + wglMakeCurrent(saved_current_hdc, saved_current_hglrc); + wglDeleteContext(dummy_hglrc); + throwException(env, "No support for WGL_ARB_multisample"); + return -1; + } + 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); } |
|
From: Elias N. <eli...@us...> - 2005-02-24 11:09:27
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16020/src/java/org/lwjgl/opengl Modified Files: MacOSXDisplay.java Log Message: Mac OS X: getPbufferCapabilities no longer requires a current context Index: MacOSXDisplay.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- MacOSXDisplay.java 23 Feb 2005 11:45:25 -0000 1.24 +++ MacOSXDisplay.java 24 Feb 2005 11:09:16 -0000 1.25 @@ -53,9 +53,11 @@ import java.nio.IntBuffer; import java.util.ArrayList; import java.util.List; +import java.util.StringTokenizer; import org.lwjgl.LWJGLException; import org.lwjgl.BufferUtils; +import org.lwjgl.Sys; import org.lwjgl.input.Keyboard; final class MacOSXDisplay implements DisplayImplementation { @@ -364,7 +366,19 @@ } public int getPbufferCapabilities() { - return GL11.glGetString(GL11.GL_EXTENSIONS).indexOf("GL_APPLE_pixel_buffer") != -1 ? Pbuffer.PBUFFER_SUPPORTED : 0; + int major_version; + int minor_version; + String os_version = System.getProperty("os.version"); + StringTokenizer tokenizer = new StringTokenizer(os_version, "."); + try { + major_version = Integer.parseInt(tokenizer.nextToken()); + minor_version = Integer.parseInt(tokenizer.nextToken()); + if (major_version > 10 || (major_version == 10 && minor_version >= 3)) + return Pbuffer.PBUFFER_SUPPORTED; + } catch (Exception e) { + Sys.log("Exception occurred when trying to determine OS version: " + e); + } + return 0; } /** |
|
From: Elias N. <eli...@us...> - 2005-02-24 10:44:49
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10183/src/native/linux Modified Files: context.c extgl_glx.c extgl_glx.h org_lwjgl_opengl_Display.c org_lwjgl_opengl_LinuxCanvasImplementation.c org_lwjgl_opengl_LinuxContextImplementation.c org_lwjgl_opengl_Pbuffer.c Log Message: Linux: Handle different GLX capabilities on different screens Index: context.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/context.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- context.c 23 Feb 2005 15:17:49 -0000 1.3 +++ context.c 24 Feb 2005 10:44:33 -0000 1.4 @@ -70,7 +70,7 @@ GLXFBConfig *configs = getFBConfigFromPeerInfo(env, peer_info); if (configs == NULL) return NULL; - vis_info = glXGetVisualFromFBConfig(peer_info->display, configs[0]); + vis_info = _glXGetVisualFromFBConfig(peer_info->display, configs[0]); if (vis_info == NULL) throwException(env, "Could not get VisualInfo from GLX 1.3 config"); XFree(configs); @@ -81,7 +81,7 @@ GLXFBConfig *getFBConfigFromPeerInfo(JNIEnv *env, X11PeerInfo *peer_info) { int attribs[] = {GLX_FBCONFIG_ID, peer_info->config.glx13_config.config_id, None, None}; int num_elements; - GLXFBConfig *configs = glXChooseFBConfig(peer_info->display, peer_info->screen, attribs, &num_elements); + GLXFBConfig *configs = _glXChooseFBConfig(peer_info->display, peer_info->screen, attribs, &num_elements); if (configs == NULL) { throwException(env, "Could not find GLX 1.3 config from peer info"); return NULL; @@ -140,13 +140,14 @@ putAttrib(&attrib_list, GLX_ACCUM_BLUE_SIZE); putAttrib(&attrib_list, accum_bpe); putAttrib(&attrib_list, GLX_ACCUM_ALPHA_SIZE); putAttrib(&attrib_list, accum_alpha); putAttrib(&attrib_list, GLX_STEREO); putAttrib(&attrib_list, stereo ? True : False); - if (samples > 0 && extension_flags.GLX_ARB_multisample) { + // Assume the caller has checked support for multisample + if (samples > 0) { putAttrib(&attrib_list, GLX_SAMPLE_BUFFERS_ARB); putAttrib(&attrib_list, 1); putAttrib(&attrib_list, GLX_SAMPLES_ARB); putAttrib(&attrib_list, samples); } putAttrib(&attrib_list, None); putAttrib(&attrib_list, None); int num_formats = 0; - GLXFBConfig* configs = glXChooseFBConfig(disp, screen, attrib_list.attribs, &num_formats); + GLXFBConfig* configs = _glXChooseFBConfig(disp, screen, attrib_list.attribs, &num_formats); if (num_formats > 0) { return configs; } else { @@ -201,12 +202,13 @@ putAttrib(&attrib_list, GLX_ACCUM_ALPHA_SIZE); putAttrib(&attrib_list, accum_alpha); if (stereo) putAttrib(&attrib_list, GLX_STEREO); - if (samples > 0 && extension_flags.GLX_ARB_multisample) { + // Assume the caller has checked support for multisample + if (samples > 0) { putAttrib(&attrib_list, GLX_SAMPLE_BUFFERS_ARB); putAttrib(&attrib_list, 1); putAttrib(&attrib_list, GLX_SAMPLES_ARB); putAttrib(&attrib_list, samples); } putAttrib(&attrib_list, None); - return glXChooseVisual(disp, screen, attrib_list.attribs); + return _glXChooseVisual(disp, screen, attrib_list.attribs); } XVisualInfo *chooseVisualGLX(JNIEnv *env, Display *disp, int screen, jobject pixel_format, bool use_display_bpp, bool double_buffer) { @@ -224,19 +226,19 @@ return chooseVisualGLXFromBPP(env, disp, screen, pixel_format, bpp, double_buffer); } -static void dumpVisualInfo(JNIEnv *env, Display *display, XVisualInfo *vis_info) { +static void dumpVisualInfo(JNIEnv *env, Display *display, GLXExtensions *extension_flags, XVisualInfo *vis_info) { int alpha, depth, stencil, r, g, b; int sample_buffers = 0; int samples = 0; - glXGetConfig(display, vis_info, GLX_RED_SIZE, &r); - glXGetConfig(display, vis_info, GLX_GREEN_SIZE, &g); - glXGetConfig(display, vis_info, GLX_BLUE_SIZE, &b); - glXGetConfig(display, vis_info, GLX_ALPHA_SIZE, &alpha); - glXGetConfig(display, vis_info, GLX_DEPTH_SIZE, &depth); - glXGetConfig(display, vis_info, GLX_STENCIL_SIZE, &stencil); - if (extension_flags.GLX_ARB_multisample) { - glXGetConfig(display, vis_info, GLX_SAMPLE_BUFFERS_ARB, &sample_buffers); - glXGetConfig(display, vis_info, GLX_SAMPLES_ARB, &samples); + _glXGetConfig(display, vis_info, GLX_RED_SIZE, &r); + _glXGetConfig(display, vis_info, GLX_GREEN_SIZE, &g); + _glXGetConfig(display, vis_info, GLX_BLUE_SIZE, &b); + _glXGetConfig(display, vis_info, GLX_ALPHA_SIZE, &alpha); + _glXGetConfig(display, vis_info, GLX_DEPTH_SIZE, &depth); + _glXGetConfig(display, vis_info, GLX_STENCIL_SIZE, &stencil); + if (extension_flags->GLX_ARB_multisample) { + _glXGetConfig(display, vis_info, GLX_SAMPLE_BUFFERS_ARB, &sample_buffers); + _glXGetConfig(display, vis_info, GLX_SAMPLES_ARB, &samples); } printfDebugJava(env, "Pixel format info: r = %d, g = %d, b = %d, a = %d, depth = %d, stencil = %d, sample buffers = %d, samples = %d", r, g, b, alpha, depth, stencil, sample_buffers, samples); } @@ -247,7 +249,8 @@ return false; } X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle); - if (!extgl_InitGLX(display, screen)) { + GLXExtensions extension_flags; + if (!extgl_InitGLX(display, screen, &extension_flags)) { throwException(env, "Could not init GLX"); return false; } @@ -255,18 +258,24 @@ throwException(env, "GLX13 is required, but is not available"); return false; } + 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")); + if (samples > 0 && !extension_flags.GLX_ARB_multisample) { + throwException(env, "Samples > 0 specified but there's no support for GLX_ARB_multisample"); + 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); if (isDebugEnabled()) { - XVisualInfo *vis_info = glXGetVisualFromFBConfig(display, configs[0]); + XVisualInfo *vis_info = _glXGetVisualFromFBConfig(display, configs[0]); if (vis_info != NULL) { - dumpVisualInfo(env, display, vis_info); + dumpVisualInfo(env, display, &extension_flags, vis_info); XFree(vis_info); } } int config_id; - int result = glXGetFBConfigAttrib(display, configs[0], GLX_FBCONFIG_ID, &config_id); + int result = _glXGetFBConfigAttrib(display, configs[0], GLX_FBCONFIG_ID, &config_id); XFree(configs); if (result != Success) { throwException(env, "Could not choose GLX13 config"); @@ -283,7 +292,7 @@ peer_info->config.glx_config.depth = vis_info->depth; peer_info->screen = vis_info->screen; if (isDebugEnabled()) - dumpVisualInfo(env, display, vis_info); + dumpVisualInfo(env, display, &extension_flags, vis_info); XFree(vis_info); } peer_info->display = display; Index: extgl_glx.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/extgl_glx.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- extgl_glx.c 23 Feb 2005 15:17:50 -0000 1.5 +++ extgl_glx.c 24 Feb 2005 10:44:34 -0000 1.6 @@ -32,185 +32,180 @@ #include <dlfcn.h> #include "extgl_glx.h" -GLXExtensions extension_flags; - -glXGetFBConfigsPROC glXGetFBConfigs = NULL; -glXChooseFBConfigPROC glXChooseFBConfig = NULL; -glXGetFBConfigAttribPROC glXGetFBConfigAttrib = NULL; -glXGetVisualFromFBConfigPROC glXGetVisualFromFBConfig = NULL; -glXCreateWindowPROC glXCreateWindow = NULL; -glXDestroyWindowPROC glXDestroyWindow = NULL; -glXCreatePixmapPROC glXCreatePixmap = NULL; -glXDestroyPixmapPROC glXDestroyPixmap = NULL; -glXCreatePbufferPROC glXCreatePbuffer = NULL; -glXDestroyPbufferPROC glXDestroyPbuffer = NULL; -glXQueryDrawablePROC glXQueryDrawable = NULL; -glXCreateNewContextPROC glXCreateNewContext = NULL; -glXMakeContextCurrentPROC glXMakeContextCurrent = NULL; -glXGetCurrentReadDrawablePROC glXGetCurrentReadDrawable = NULL; -glXGetCurrentDisplayPROC glXGetCurrentDisplay = NULL; -glXQueryContextPROC glXQueryContext = NULL; -glXSelectEventPROC glXSelectEvent = NULL; -glXGetSelectedEventPROC glXGetSelectedEvent = NULL; -glXChooseVisualPROC glXChooseVisual = NULL; -glXCopyContextPROC glXCopyContext = NULL; -glXCreateContextPROC glXCreateContext = NULL; -glXCreateGLXPixmapPROC glXCreateGLXPixmap = NULL; -glXDestroyContextPROC glXDestroyContext = NULL; -glXDestroyGLXPixmapPROC glXDestroyGLXPixmap = NULL; -glXGetConfigPROC glXGetConfig = NULL; -glXGetCurrentContextPROC glXGetCurrentContext = NULL; -glXGetCurrentDrawablePROC glXGetCurrentDrawable = NULL; -glXIsDirectPROC glXIsDirect = NULL; -glXMakeCurrentPROC glXMakeCurrent = NULL; -glXQueryExtensionPROC glXQueryExtension = NULL; -glXQueryVersionPROC glXQueryVersion = NULL; -glXSwapBuffersPROC glXSwapBuffers = NULL; -glXUseXFontPROC glXUseXFont = NULL; -glXWaitGLPROC glXWaitGL = NULL; -glXWaitXPROC glXWaitX = NULL; -glXGetClientStringPROC glXGetClientString = NULL; -glXQueryServerStringPROC glXQueryServerString = NULL; -glXQueryExtensionsStringPROC glXQueryExtensionsString = NULL; +glXGetFBConfigsPROC _glXGetFBConfigs = NULL; +glXChooseFBConfigPROC _glXChooseFBConfig = NULL; +glXGetFBConfigAttribPROC _glXGetFBConfigAttrib = NULL; +glXGetVisualFromFBConfigPROC _glXGetVisualFromFBConfig = NULL; +glXCreateWindowPROC _glXCreateWindow = NULL; +glXDestroyWindowPROC _glXDestroyWindow = NULL; +glXCreatePixmapPROC _glXCreatePixmap = NULL; +glXDestroyPixmapPROC _glXDestroyPixmap = NULL; +glXCreatePbufferPROC _glXCreatePbuffer = NULL; +glXDestroyPbufferPROC _glXDestroyPbuffer = NULL; +glXQueryDrawablePROC _glXQueryDrawable = NULL; +glXCreateNewContextPROC _glXCreateNewContext = NULL; +glXMakeContextCurrentPROC _glXMakeContextCurrent = NULL; +glXGetCurrentReadDrawablePROC _glXGetCurrentReadDrawable = NULL; +glXGetCurrentDisplayPROC _glXGetCurrentDisplay = NULL; +glXQueryContextPROC _glXQueryContext = NULL; +glXSelectEventPROC _glXSelectEvent = NULL; +glXGetSelectedEventPROC _glXGetSelectedEvent = NULL; +glXChooseVisualPROC _glXChooseVisual = NULL; +glXCopyContextPROC _glXCopyContext = NULL; +glXCreateContextPROC _glXCreateContext = NULL; +glXCreateGLXPixmapPROC _glXCreateGLXPixmap = NULL; +glXDestroyContextPROC _glXDestroyContext = NULL; +glXDestroyGLXPixmapPROC _glXDestroyGLXPixmap = NULL; +glXGetConfigPROC _glXGetConfig = NULL; +glXGetCurrentContextPROC _glXGetCurrentContext = NULL; +glXGetCurrentDrawablePROC _glXGetCurrentDrawable = NULL; +glXIsDirectPROC _glXIsDirect = NULL; +glXMakeCurrentPROC _glXMakeCurrent = NULL; +glXQueryExtensionPROC _glXQueryExtension = NULL; +glXQueryVersionPROC _glXQueryVersion = NULL; +glXSwapBuffersPROC _glXSwapBuffers = NULL; +glXUseXFontPROC _glXUseXFont = NULL; +glXWaitGLPROC _glXWaitGL = NULL; +glXWaitXPROC _glXWaitX = NULL; +glXGetClientStringPROC _glXGetClientString = NULL; +glXQueryServerStringPROC _glXQueryServerString = NULL; +glXQueryExtensionsStringPROC _glXQueryExtensionsString = NULL; /* GLX_SGI_swap_control */ -glXSwapIntervalSGIPROC glXSwapIntervalSGI = NULL; +glXSwapIntervalSGIPROC _glXSwapIntervalSGI = NULL; static void * lib_gl_handle = NULL; typedef void * (APIENTRY * glXGetProcAddressARBPROC) (const GLubyte *procName); -static glXGetProcAddressARBPROC glXGetProcAddressARB; +static glXGetProcAddressARBPROC _glXGetProcAddressARB; -bool extgl_Open(JNIEnv *env) -{ +static GLXExtensions symbols_flags; + +/** returns true if the extention is available */ +static bool GLXQueryExtension(Display *disp, int screen, const char *name) { + const GLubyte *exts = (const GLubyte *)_glXQueryExtensionsString(disp, screen); + return extgl_QueryExtension(exts, name); +} + +static void extgl_InitGLX13() { + ExtFunction functions[] = { + {"glXGetFBConfigs", (void*)&_glXGetFBConfigs}, + {"glXChooseFBConfig", (void*)&_glXChooseFBConfig}, + {"glXGetFBConfigAttrib", (void*)&_glXGetFBConfigAttrib}, + {"glXGetVisualFromFBConfig", (void*)&_glXGetVisualFromFBConfig}, + {"glXCreateWindow", (void*)&_glXCreateWindow}, + {"glXDestroyWindow", (void*)&_glXDestroyWindow}, + {"glXCreatePixmap", (void*)&_glXCreatePixmap}, + {"glXDestroyPixmap", (void*)&_glXDestroyPixmap}, + {"glXCreatePbuffer", (void*)&_glXCreatePbuffer}, + {"glXDestroyPbuffer", (void*)&_glXDestroyPbuffer}, + {"glXQueryDrawable", (void*)&_glXQueryDrawable}, + {"glXCreateNewContext", (void*)&_glXCreateNewContext}, + {"glXMakeContextCurrent", (void*)&_glXMakeContextCurrent}, + {"glXGetCurrentReadDrawable", (void*)&_glXGetCurrentReadDrawable}, + {"glXGetCurrentDisplay", (void*)&_glXGetCurrentDisplay}, + {"glXQueryContext", (void*)&_glXQueryContext}, + {"glXSelectEvent", (void*)&_glXSelectEvent}, + {"glXGetSelectedEvent", (void*)&_glXGetSelectedEvent}}; + symbols_flags.GLX13 = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); +} + +static void extgl_InitGLX12(void) { + ExtFunction functions[] = { + {"glXChooseVisual", (void*)&_glXChooseVisual}, + {"glXCopyContext", (void*)&_glXCopyContext}, + {"glXCreateContext", (void*)&_glXCreateContext}, + {"glXCreateGLXPixmap", (void*)&_glXCreateGLXPixmap}, + {"glXDestroyContext", (void*)&_glXDestroyContext}, + {"glXDestroyGLXPixmap", (void*)&_glXDestroyGLXPixmap}, + {"glXGetConfig", (void*)&_glXGetConfig}, + {"glXGetCurrentContext", (void*)&_glXGetCurrentContext}, + {"glXGetCurrentDrawable", (void*)&_glXGetCurrentDrawable}, + {"glXIsDirect", (void*)&_glXIsDirect}, + {"glXMakeCurrent", (void*)&_glXMakeCurrent}, + {"glXQueryExtension", (void*)&_glXQueryExtension}, + {"glXQueryVersion", (void*)&_glXQueryVersion}, + {"glXSwapBuffers", (void*)&_glXSwapBuffers}, + {"glXUseXFont", (void*)&_glXUseXFont}, + {"glXWaitGL", (void*)&_glXWaitGL}, + {"glXWaitX", (void*)&_glXWaitX}, + {"glXGetClientString", (void*)&_glXGetClientString}, + {"glXQueryServerString", (void*)&_glXQueryServerString}, + {"glXQueryExtensionsString", (void*)&_glXQueryExtensionsString}}; + symbols_flags.GLX12 = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); +} + +static void extgl_InitGLXSGISwapControl() { + ExtFunction functions[] = { + {"glXSwapIntervalSGI", (void*)&_glXSwapIntervalSGI}}; + symbols_flags.GLX_SGI_swap_control = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); +} + +static void extgl_InitGLXSupportedExtensions(Display *disp, int screen, GLXExtensions *extension_flags) { +/* extension_flags.GLX_EXT_visual_info = GLXQueryExtension(disp, screen, "GLX_EXT_visual_info"); + extension_flags.GLX_EXT_visual_rating = GLXQueryExtension(disp, screen, "GLX_EXT_visual_rating");*/ + 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"); +} + +bool extgl_Open(JNIEnv *env) { #define BUFFER_SIZE 2000 static char buffer[BUFFER_SIZE]; if (lib_gl_handle != NULL) return true; - lib_gl_handle = dlopen("libGL.so.1", RTLD_LAZY | RTLD_GLOBAL); + lib_gl_handle = dlopen("libGL.so.1", RTLD_LAZY); if (lib_gl_handle == NULL) { snprintf(buffer, BUFFER_SIZE, "Error loading libGL.so.1: %s", dlerror()); buffer[BUFFER_SIZE - 1] = '\0'; throwException(env, buffer); return false; } - glXGetProcAddressARB = (glXGetProcAddressARBPROC)dlsym(lib_gl_handle, "glXGetProcAddressARB"); - if (glXGetProcAddressARB == NULL) { + _glXGetProcAddressARB = (glXGetProcAddressARBPROC)dlsym(lib_gl_handle, "glXGetProcAddressARB"); + if (_glXGetProcAddressARB == NULL) { extgl_Close(); throwException(env, "Could not get address of glXGetProcAddressARB"); return false; } + /* Unlike Windows, GLX function addresses are context-independent + * so we only have to initialize the addresses once at load + */ + extgl_InitGLX12(); + extgl_InitGLX13(); + extgl_InitGLXSGISwapControl(); return true; } -void *extgl_GetProcAddress(const char *name) -{ - void *t = (void*)glXGetProcAddressARB((const GLubyte*)name); - if (t == NULL) - { +void *extgl_GetProcAddress(const char *name) { + void *t = (void*)_glXGetProcAddressARB((const GLubyte*)name); + if (t == NULL) { t = dlsym(lib_gl_handle, name); - if (t == NULL) - { + if (t == NULL) { printfDebug("Could not locate symbol %s\n", name); } } return t; } -void extgl_Close(void) -{ +void extgl_Close(void) { dlclose(lib_gl_handle); lib_gl_handle = NULL; } -/** returns true if the extention is available */ -static bool GLXQueryExtension(Display *disp, int screen, const char *name) -{ - const GLubyte *exts = (const GLubyte *)glXQueryExtensionsString(disp, screen); - return extgl_QueryExtension(exts, name); -} - -static void extgl_InitGLX13() -{ - ExtFunction functions[] = { - {"glXGetFBConfigs", (void*)&glXGetFBConfigs}, - {"glXChooseFBConfig", (void*)&glXChooseFBConfig}, - {"glXGetFBConfigAttrib", (void*)&glXGetFBConfigAttrib}, - {"glXGetVisualFromFBConfig", (void*)&glXGetVisualFromFBConfig}, - {"glXCreateWindow", (void*)&glXCreateWindow}, - {"glXDestroyWindow", (void*)&glXDestroyWindow}, - {"glXCreatePixmap", (void*)&glXCreatePixmap}, - {"glXDestroyPixmap", (void*)&glXDestroyPixmap}, - {"glXCreatePbuffer", (void*)&glXCreatePbuffer}, - {"glXDestroyPbuffer", (void*)&glXDestroyPbuffer}, - {"glXQueryDrawable", (void*)&glXQueryDrawable}, - {"glXCreateNewContext", (void*)&glXCreateNewContext}, - {"glXMakeContextCurrent", (void*)&glXMakeContextCurrent}, - {"glXGetCurrentReadDrawable", (void*)&glXGetCurrentReadDrawable}, - {"glXGetCurrentDisplay", (void*)&glXGetCurrentDisplay}, - {"glXQueryContext", (void*)&glXQueryContext}, - {"glXSelectEvent", (void*)&glXSelectEvent}, - {"glXGetSelectedEvent", (void*)&glXGetSelectedEvent}}; - if (extension_flags.GLX13) - extension_flags.GLX13 = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); -} - -static bool extgl_InitGLX12(void) -{ - ExtFunction functions[] = { - {"glXChooseVisual", (void*)&glXChooseVisual}, - {"glXCopyContext", (void*)&glXCopyContext}, - {"glXCreateContext", (void*)&glXCreateContext}, - {"glXCreateGLXPixmap", (void*)&glXCreateGLXPixmap}, - {"glXDestroyContext", (void*)&glXDestroyContext}, - {"glXDestroyGLXPixmap", (void*)&glXDestroyGLXPixmap}, - {"glXGetConfig", (void*)&glXGetConfig}, - {"glXGetCurrentContext", (void*)&glXGetCurrentContext}, - {"glXGetCurrentDrawable", (void*)&glXGetCurrentDrawable}, - {"glXIsDirect", (void*)&glXIsDirect}, - {"glXMakeCurrent", (void*)&glXMakeCurrent}, - {"glXQueryExtension", (void*)&glXQueryExtension}, - {"glXQueryVersion", (void*)&glXQueryVersion}, - {"glXSwapBuffers", (void*)&glXSwapBuffers}, - {"glXUseXFont", (void*)&glXUseXFont}, - {"glXWaitGL", (void*)&glXWaitGL}, - {"glXWaitX", (void*)&glXWaitX}, - {"glXGetClientString", (void*)&glXGetClientString}, - {"glXQueryServerString", (void*)&glXQueryServerString}, - {"glXQueryExtensionsString", (void*)&glXQueryExtensionsString}}; - return extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); -} - -static void extgl_InitGLXSupportedExtensions(Display *disp, int screen) -{ - extension_flags.GLX_EXT_visual_info = GLXQueryExtension(disp, screen, "GLX_EXT_visual_info"); - extension_flags.GLX_EXT_visual_rating = GLXQueryExtension(disp, screen, "GLX_EXT_visual_rating"); - extension_flags.GLX_SGI_swap_control = GLXQueryExtension(disp, screen, "GLX_SGI_swap_control"); - extension_flags.GLX_ARB_multisample = GLXQueryExtension(disp, screen, "GLX_ARB_multisample"); -} - -static void extgl_InitGLXSGISwapControl() -{ - ExtFunction functions[] = { - {"glXSwapIntervalSGI", (void*)&glXSwapIntervalSGI}}; - if (extension_flags.GLX_SGI_swap_control) - extension_flags.GLX_SGI_swap_control = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); -} - -bool extgl_InitGLX(Display *disp, int screen) -{ +bool extgl_InitGLX(Display *disp, int screen, GLXExtensions *extension_flags) { int major, minor; /* Assume glx ver >= 1.2 */ - if (!extgl_InitGLX12()) + // Check GLX 1.2 symbols available + if (!symbols_flags.GLX12) return false; - extension_flags.GLX12 = true; - if (glXQueryVersion(disp, &major, &minor) != True) + if (_glXQueryVersion(disp, &major, &minor) != True) return false; - if (major > 1 || (major == 1 && minor >= 3)) - extension_flags.GLX13 = true; - extgl_InitGLX13(); - extgl_InitGLXSupportedExtensions(disp, screen); - extgl_InitGLXSGISwapControl(); + bool glx12 = major > 1 || (major == 1 && minor >= 2); + // Check GLX 1.2 version + if (!glx12) + return false; + extension_flags->GLX12 = glx12; + extension_flags->GLX13 = major > 1 || (major == 1 && minor >= 3); + extgl_InitGLXSupportedExtensions(disp, screen, extension_flags); return true; } Index: org_lwjgl_opengl_LinuxCanvasImplementation.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxCanvasImplementation.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- org_lwjgl_opengl_LinuxCanvasImplementation.c 23 Feb 2005 15:17:52 -0000 1.2 +++ org_lwjgl_opengl_LinuxCanvasImplementation.c 24 Feb 2005 10:44:34 -0000 1.3 @@ -48,7 +48,8 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxCanvasImplementation_nFindVisualIDFromFormat (JNIEnv *env, jclass clazz, jint screen, jobject pixel_format) { - if (!extgl_InitGLX(getDisplay(), screen)) { + GLXExtensions extension_flags; + if (!extgl_InitGLX(getDisplay(), screen, &extension_flags)) { throwException(env, "Could not initialize GLX"); return -1; } Index: org_lwjgl_opengl_Pbuffer.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_opengl_Pbuffer.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- org_lwjgl_opengl_Pbuffer.c 23 Feb 2005 15:17:52 -0000 1.14 +++ org_lwjgl_opengl_Pbuffer.c 24 Feb 2005 10:44:34 -0000 1.15 @@ -47,20 +47,20 @@ #include "Window.h" #include "common_tools.h" -static bool isPbuffersSupported() { - // Only support the GLX 1.3 Pbuffers and ignore the GLX_SGIX_pbuffer extension - return extension_flags.GLX13 ? org_lwjgl_opengl_Pbuffer_PBUFFER_SUPPORTED : 0; -} - JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetPbufferCapabilities (JNIEnv *env, jclass clazz) { - return isPbuffersSupported() ? org_lwjgl_opengl_Pbuffer_PBUFFER_SUPPORTED : 0; + GLXExtensions extension_flags; + if (!extgl_InitGLX(getDisplay(), getCurrentScreen(), &extension_flags)) + return 0; + // Only support the GLX 1.3 Pbuffers and ignore the GLX_SGIX_pbuffer extension + return extension_flags.GLX13 ? org_lwjgl_opengl_Pbuffer_PBUFFER_SUPPORTED : 0; } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxPbufferPeerInfo_nInitHandle (JNIEnv *env, jclass clazz, jobject peer_info_handle, jint width, jint height, jobject pixel_format) { - if (!extgl_InitGLX(getDisplay(), getCurrentScreen()) || !isPbuffersSupported()) { + GLXExtensions extension_flags; + if (!extgl_InitGLX(getDisplay(), getCurrentScreen(), &extension_flags) || !extension_flags.GLX13) { throwException(env, "No Pbuffer support"); return; } @@ -75,7 +75,7 @@ X11PeerInfo *peer_info = (X11PeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); GLXFBConfig *config = getFBConfigFromPeerInfo(env, peer_info); - GLXPbuffer buffer = glXCreatePbuffer(peer_info->display, *config, buffer_attribs); + GLXPbuffer buffer = _glXCreatePbuffer(peer_info->display, *config, buffer_attribs); XFree(config); peer_info->drawable = buffer; } @@ -83,5 +83,5 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxPbufferPeerInfo_nDestroy (JNIEnv *env, jclass clazz, jobject peer_info_handle) { X11PeerInfo *peer_info = (X11PeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); - glXDestroyPbuffer(peer_info->display, peer_info->drawable); + _glXDestroyPbuffer(peer_info->display, peer_info->drawable); } Index: org_lwjgl_opengl_LinuxContextImplementation.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxContextImplementation.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- org_lwjgl_opengl_LinuxContextImplementation.c 23 Feb 2005 15:17:52 -0000 1.3 +++ org_lwjgl_opengl_LinuxContextImplementation.c 24 Feb 2005 10:44:34 -0000 1.4 @@ -48,7 +48,7 @@ #include "Window.h" typedef struct { - bool glx13; + GLXExtensions extension_flags; GLXContext context; } X11Context; @@ -58,8 +58,8 @@ return false; } jboolean allow_software_acceleration = getBooleanProperty(env, "org.lwjgl.opengl.Display.allowSoftwareOpenGL"); - if (!allow_software_acceleration && glXIsDirect(display, context) == False) { - glXDestroyContext(display, context); + if (!allow_software_acceleration && _glXIsDirect(display, context) == False) { + _glXDestroyContext(display, context); throwException(env, "Could not create a direct GLX context"); return false; } @@ -70,11 +70,10 @@ GLXFBConfig *config = getFBConfigFromPeerInfo(env, peer_info); if (config == NULL) return; - GLXContext context = glXCreateNewContext(peer_info->display, *config, GLX_RGBA_TYPE, shared_context, True); + GLXContext context = _glXCreateNewContext(peer_info->display, *config, GLX_RGBA_TYPE, shared_context, True); XFree(config); if (!checkContext(env, peer_info->display, context)) return; - context_info->glx13 = true; context_info->context = context; } @@ -82,20 +81,20 @@ XVisualInfo *vis_info = getVisualInfoFromPeerInfo(env, peer_info); if (vis_info == NULL) return; - GLXContext context = glXCreateContext(peer_info->display, vis_info, shared_context, True); + GLXContext context = _glXCreateContext(peer_info->display, vis_info, shared_context, True); XFree(vis_info); if (!checkContext(env, peer_info->display, context)) return; - context_info->glx13 = false; context_info->context = context; } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nSetVSync - (JNIEnv *env, jclass clazz, jboolean sync) + (JNIEnv *env, jclass clazz, jobject context_handle, jboolean sync) { - if (extension_flags.GLX_SGI_swap_control) { + X11Context *context_info = (*env)->GetDirectBufferAddress(env, context_handle); + if (context_info->extension_flags.GLX_SGI_swap_control) { int interval = sync == JNI_TRUE ? 1 : 0; - glXSwapIntervalSGI(interval); + _glXSwapIntervalSGI(interval); } } @@ -108,8 +107,8 @@ } X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_handle); X11Context *context_info = (*env)->GetDirectBufferAddress(env, context_handle); - - if (!extgl_InitGLX(peer_info->display, peer_info->screen)) { + GLXExtensions extension_flags; + if (!extgl_InitGLX(peer_info->display, peer_info->screen, &extension_flags)) { throwException(env, "Could not initialize GLX"); return NULL; } @@ -123,6 +122,7 @@ } else { createContextGLX(env, peer_info, context_info, shared_context); } + context_info->extension_flags = extension_flags; return context_handle; } @@ -130,17 +130,17 @@ (JNIEnv *env, jclass clazz, jobject peer_handle, jobject context_handle) { X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_handle); X11Context *context_info = (*env)->GetDirectBufferAddress(env, context_handle); - glXDestroyContext(peer_info->display, context_info->context); + _glXDestroyContext(peer_info->display, context_info->context); } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nReleaseCurrentContext (JNIEnv *env , jclass clazz, jobject peer_info_handle) { X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle); Bool result; - if (extension_flags.GLX13) { - result = glXMakeContextCurrent(peer_info->display, None, None, NULL); + if (peer_info->glx13) { + result = _glXMakeContextCurrent(peer_info->display, None, None, NULL); } else { - result = glXMakeCurrent(peer_info->display, None, NULL); + result = _glXMakeCurrent(peer_info->display, None, NULL); } if (!result) throwException(env, "Could not release current context"); @@ -151,10 +151,10 @@ X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle); X11Context *context_info = (*env)->GetDirectBufferAddress(env, context_handle); Bool result; - if (context_info->glx13) { - result = glXMakeContextCurrent(peer_info->display, peer_info->drawable, peer_info->drawable, context_info->context); + if (peer_info->glx13) { + result = _glXMakeContextCurrent(peer_info->display, peer_info->drawable, peer_info->drawable, context_info->context); } else { - result = glXMakeCurrent(peer_info->display, peer_info->drawable, context_info->context); + result = _glXMakeCurrent(peer_info->display, peer_info->drawable, context_info->context); } if (!result) throwException(env, "Could not make context current"); @@ -163,11 +163,11 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nIsCurrent (JNIEnv *env, jclass clazz, jobject context_handle) { X11Context *context_info = (*env)->GetDirectBufferAddress(env, context_handle); - return context_info->context == glXGetCurrentContext(); + return context_info->context == _glXGetCurrentContext(); } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nSwapBuffers (JNIEnv *env, jclass clazz, jobject peer_info_handle) { X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle); - glXSwapBuffers(peer_info->display, peer_info->drawable); + _glXSwapBuffers(peer_info->display, peer_info->drawable); } Index: org_lwjgl_opengl_Display.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- org_lwjgl_opengl_Display.c 23 Feb 2005 11:38:24 -0000 1.25 +++ org_lwjgl_opengl_Display.c 24 Feb 2005 10:44:34 -0000 1.26 @@ -337,7 +337,7 @@ static void destroyWindow(JNIEnv *env) { if (glx_window != None) { - glXDestroyWindow(getDisplay(), glx_window); + _glXDestroyWindow(getDisplay(), glx_window); glx_window = None; } XDestroyWindow(getDisplay(), current_win); @@ -513,11 +513,11 @@ return; } if (peer_info->glx13) { - glx_window = glXCreateWindow(getDisplay(), *fb_config, getCurrentWindow(), NULL); + glx_window = _glXCreateWindow(getDisplay(), *fb_config, getCurrentWindow(), NULL); XFree(fb_config); } if (!checkXError(env, getDisplay())) { - glXDestroyWindow(getDisplay(), glx_window); + _glXDestroyWindow(getDisplay(), glx_window); destroyWindow(env); } } Index: extgl_glx.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/extgl_glx.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- extgl_glx.h 23 Feb 2005 15:17:51 -0000 1.4 +++ extgl_glx.h 24 Feb 2005 10:44:34 -0000 1.5 @@ -37,7 +37,7 @@ #include "extgl.h" /* - * Names for attributes to glXGetConfig. + * Names for attributes to _glXGetConfig. */ #define GLX_USE_GL 1 /* support GLX rendering */ #define GLX_BUFFER_SIZE 2 /* depth of the color buffer */ @@ -91,7 +91,7 @@ #define GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX 0x801A /* - * Error return values from glXGetConfig. Success is indicated by + * Error return values from _glXGetConfig. Success is indicated by * a value of 0. */ #define GLX_BAD_SCREEN 1 /* screen # is bad */ @@ -106,7 +106,7 @@ /* FBConfig attribute values */ /* - * Generic "don't care" value for glX ChooseFBConfig attributes (except + * Generic "don't care" value for _glX ChooseFBConfig attributes (except * GLX_LEVEL). */ #define GLX_DONT_CARE 0xFFFFFFFF @@ -143,7 +143,7 @@ #define GLX_TRANSPARENT_RGB 0x8008 #define GLX_TRANSPARENT_INDEX 0x8009 -/* glXCreateGLXPbuffer attributes */ +/* _glXCreateGLXPbuffer attributes */ #define GLX_PRESERVED_CONTENTS 0x801B #define GLX_LARGEST_PBUFFER 0x801C #define GLX_PBUFFER_HEIGHT 0x8040 /* New for GLX 1.3 */ @@ -151,7 +151,7 @@ #define GLX_PRESERVED_CONTENTS_SGIX GLX_PRESERVED_CONTENTS #define GLX_LARGEST_PBUFFER_SGIX GLX_LARGEST_PBUFFER -/* glXQueryGLXPBuffer attributes */ +/* _glXQueryGLXPBuffer attributes */ #define GLX_WIDTH 0x801D #define GLX_HEIGHT 0x801E #define GLX_EVENT_MASK 0x801F @@ -159,18 +159,18 @@ #define GLX_HEIGHT_SGIX GLX_HEIGHT #define GLX_EVENT_MASK_SGIX GLX_EVENT_MASK -/* glXCreateNewContext render_type attribute values */ +/* _glXCreateNewContext render_type attribute values */ #define GLX_RGBA_TYPE 0x8014 #define GLX_COLOR_INDEX_TYPE 0x8015 #define GLX_RGBA_TYPE_SGIX GLX_RGBA_TYPE #define GLX_COLOR_INDEX_TYPE_SGIX GLX_COLOR_INDEX_TYPE -/* glXQueryContext attributes */ +/* _glXQueryContext attributes */ /* #define GLX_FBCONFIG_ID 0x8013 */ /* #define GLX_RENDER_TYPE 0x8011 */ #define GLX_SCREEN 0x800C -/* glXSelectEvent event mask bits */ +/* _glXSelectEvent event mask bits */ #define GLX_PBUFFER_CLOBBER_MASK 0x08000000 #define GLX_PBUFFER_CLOBBER_MASK_SGIX GLX_PBUFFER_CLOBBER_MASK @@ -205,8 +205,8 @@ #define GLX_ACCUM_BUFFER_BIT_SGIX GLX_ACCUM_BUFFER_BIT /* - * Extension return values from glXGetConfig. These are also - * accepted as parameter values for glXChooseVisual. + * Extension return values from _glXGetConfig. These are also + * accepted as parameter values for _glXChooseVisual. */ #define GLX_X_VISUAL_TYPE_EXT 0x22 /* visual_info extension type */ @@ -236,14 +236,14 @@ #define GLX_NON_CONFORMANT_VISUAL_EXT 0x800D /* - * Names for attributes to glXGetClientString. + * Names for attributes to _glXGetClientString. */ #define GLX_VENDOR 0x1 #define GLX_VERSION 0x2 #define GLX_EXTENSIONS 0x3 /* - * Names for attributes to glXQueryContextInfoEXT. + * Names for attributes to _glXQueryContextInfoEXT. */ #define GLX_SHARE_CONTEXT_EXT 0x800A /* id of share context */ #define GLX_VISUAL_ID_EXT 0x800B /* id of context's visual */ @@ -315,56 +315,55 @@ typedef struct { bool GLX12; bool GLX13; - bool GLX_EXT_visual_info; - bool GLX_EXT_visual_rating; +/* bool GLX_EXT_visual_info; + bool GLX_EXT_visual_rating;*/ bool GLX_SGI_swap_control; bool GLX_ARB_multisample; } GLXExtensions; -extern GLXExtensions extension_flags; - -extern glXGetFBConfigsPROC glXGetFBConfigs; -extern glXChooseFBConfigPROC glXChooseFBConfig; -extern glXGetFBConfigAttribPROC glXGetFBConfigAttrib; -extern glXGetVisualFromFBConfigPROC glXGetVisualFromFBConfig; -extern glXCreateWindowPROC glXCreateWindow; -extern glXDestroyWindowPROC glXDestroyWindow; -extern glXCreatePixmapPROC glXCreatePixmap; -extern glXDestroyPixmapPROC glXDestroyPixmap; -extern glXCreatePbufferPROC glXCreatePbuffer; -extern glXDestroyPbufferPROC glXDestroyPbuffer; -extern glXQueryDrawablePROC glXQueryDrawable; -extern glXCreateNewContextPROC glXCreateNewContext; -extern glXMakeContextCurrentPROC glXMakeContextCurrent; -extern glXGetCurrentReadDrawablePROC glXGetCurrentReadDrawable; -extern glXGetCurrentDisplayPROC glXGetCurrentDisplay; -extern glXQueryContextPROC glXQueryContext; -extern glXSelectEventPROC glXSelectEvent; -extern glXGetSelectedEventPROC glXGetSelectedEvent; +/* Add _ to global symbols to avoid symbol clash with the OpenGL library */ +extern glXGetFBConfigsPROC _glXGetFBConfigs; +extern glXChooseFBConfigPROC _glXChooseFBConfig; +extern glXGetFBConfigAttribPROC _glXGetFBConfigAttrib; +extern glXGetVisualFromFBConfigPROC _glXGetVisualFromFBConfig; +extern glXCreateWindowPROC _glXCreateWindow; +extern glXDestroyWindowPROC _glXDestroyWindow; +extern glXCreatePixmapPROC _glXCreatePixmap; +extern glXDestroyPixmapPROC _glXDestroyPixmap; +extern glXCreatePbufferPROC _glXCreatePbuffer; +extern glXDestroyPbufferPROC _glXDestroyPbuffer; +extern glXQueryDrawablePROC _glXQueryDrawable; +extern glXCreateNewContextPROC _glXCreateNewContext; +extern glXMakeContextCurrentPROC _glXMakeContextCurrent; +extern glXGetCurrentReadDrawablePROC _glXGetCurrentReadDrawable; +extern glXGetCurrentDisplayPROC _glXGetCurrentDisplay; +extern glXQueryContextPROC _glXQueryContext; +extern glXSelectEventPROC _glXSelectEvent; +extern glXGetSelectedEventPROC _glXGetSelectedEvent; -extern glXChooseVisualPROC glXChooseVisual; -extern glXCopyContextPROC glXCopyContext; -extern glXCreateContextPROC glXCreateContext; -extern glXCreateGLXPixmapPROC glXCreateGLXPixmap; -extern glXDestroyContextPROC glXDestroyContext; -extern glXDestroyGLXPixmapPROC glXDestroyGLXPixmap; -extern glXGetConfigPROC glXGetConfig; -extern glXGetCurrentContextPROC glXGetCurrentContext; -extern glXGetCurrentDrawablePROC glXGetCurrentDrawable; -extern glXIsDirectPROC glXIsDirect; -extern glXMakeCurrentPROC glXMakeCurrent; -extern glXQueryExtensionPROC glXQueryExtension; -extern glXQueryVersionPROC glXQueryVersion; -extern glXSwapBuffersPROC glXSwapBuffers; -extern glXUseXFontPROC glXUseXFont; -extern glXWaitGLPROC glXWaitGL; -extern glXWaitXPROC glXWaitX; -extern glXGetClientStringPROC glXGetClientString; -extern glXQueryServerStringPROC glXQueryServerString; -extern glXQueryExtensionsStringPROC glXQueryExtensionsString; +extern glXChooseVisualPROC _glXChooseVisual; +extern glXCopyContextPROC _glXCopyContext; +extern glXCreateContextPROC _glXCreateContext; +extern glXCreateGLXPixmapPROC _glXCreateGLXPixmap; +extern glXDestroyContextPROC _glXDestroyContext; +extern glXDestroyGLXPixmapPROC _glXDestroyGLXPixmap; +extern glXGetConfigPROC _glXGetConfig; +extern glXGetCurrentContextPROC _glXGetCurrentContext; +extern glXGetCurrentDrawablePROC _glXGetCurrentDrawable; +extern glXIsDirectPROC _glXIsDirect; +extern glXMakeCurrentPROC _glXMakeCurrent; +extern glXQueryExtensionPROC _glXQueryExtension; +extern glXQueryVersionPROC _glXQueryVersion; +extern glXSwapBuffersPROC _glXSwapBuffers; +extern glXUseXFontPROC _glXUseXFont; +extern glXWaitGLPROC _glXWaitGL; +extern glXWaitXPROC _glXWaitX; +extern glXGetClientStringPROC _glXGetClientString; +extern glXQueryServerStringPROC _glXQueryServerString; +extern glXQueryExtensionsStringPROC _glXQueryExtensionsString; -extern glXSwapIntervalSGIPROC glXSwapIntervalSGI; +extern glXSwapIntervalSGIPROC _glXSwapIntervalSGI; -extern bool extgl_InitGLX(Display *disp, int screen); +extern bool extgl_InitGLX(Display *disp, int screen, GLXExtensions *extension_flags); #endif |
|
From: Elias N. <eli...@us...> - 2005-02-24 10:44:48
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10183/src/java/org/lwjgl/opengl Modified Files: LinuxContextImplementation.java LinuxDisplay.java Log Message: Linux: Handle different GLX capabilities on different screens Index: LinuxContextImplementation.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/LinuxContextImplementation.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- LinuxContextImplementation.java 23 Feb 2005 12:12:47 -0000 1.4 +++ LinuxContextImplementation.java 24 Feb 2005 10:44:33 -0000 1.5 @@ -35,6 +35,7 @@ import org.lwjgl.LWJGLException; import org.lwjgl.BufferUtils; +import org.lwjgl.Sys; /** * $Id$ @@ -131,11 +132,16 @@ private static native boolean nIsCurrent(ByteBuffer context_handle) throws LWJGLException; public void setVSync(boolean enabled) { - LinuxDisplay.lockAWT(); - nSetVSync(enabled); - LinuxDisplay.unlockAWT(); + Context current_context = Context.getCurrentContext(); + if (current_context == null) + throw new IllegalStateException("No context is current"); + synchronized (current_context) { + LinuxDisplay.lockAWT(); + nSetVSync(current_context.getHandle(), enabled); + LinuxDisplay.unlockAWT(); + } } - private static native void nSetVSync(boolean enabled); + private static native void nSetVSync(ByteBuffer context_handle, boolean enabled); public void destroy(PeerInfo peer_info, ByteBuffer handle) throws LWJGLException { LinuxDisplay.lockAWT(); Index: LinuxDisplay.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- LinuxDisplay.java 23 Feb 2005 11:45:24 -0000 1.19 +++ LinuxDisplay.java 24 Feb 2005 10:44:33 -0000 1.20 @@ -359,9 +359,17 @@ public int getPbufferCapabilities() { lockAWT(); - int caps = nGetPbufferCapabilities(); - unlockAWT(); - return caps; + try { + incDisplay(); + int caps = nGetPbufferCapabilities(); + decDisplay(); + return caps; + } catch (LWJGLException e) { + Sys.log("Exception occurred in getPbufferCapabilities: " + e); + return 0; + } finally { + unlockAWT(); + } } private static native int nGetPbufferCapabilities(); |
|
From: Elias N. <eli...@us...> - 2005-02-23 15:35:02
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30422/src/native/win32 Modified Files: extgl_wgl.h Log Message: Win32: Compile fix Index: extgl_wgl.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/extgl_wgl.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- extgl_wgl.h 21 Feb 2005 14:46:47 -0000 1.3 +++ extgl_wgl.h 23 Feb 2005 15:34:42 -0000 1.4 @@ -56,7 +56,7 @@ extern WGLExtensions extension_flags; -extern void extgl_InitWGL(JNIEnv *env); +extern void extgl_InitWGL(); /*-------------------------------------------------------------------*/ /*------------WGL_EXT_EXTENSION_STRING-------------------------------*/ |
|
From: Elias N. <eli...@us...> - 2005-02-23 15:19:33
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25270/win32 Modified Files: context.c Log Message: Removed unsued JNIEnv parameter from extgl_QueryExtension Index: context.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/context.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- context.c 21 Feb 2005 14:46:47 -0000 1.1 +++ context.c 23 Feb 2005 15:19:21 -0000 1.2 @@ -368,7 +368,7 @@ throwException(env, "Could not bind context to dummy window"); return -1; } - extgl_InitWGL(env); + extgl_InitWGL(); if (!extension_flags.WGL_ARB_pixel_format) { throwException(env, "No support for WGL_ARB_pixel_format"); |
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24393/linux Modified Files: context.c extgl_glx.c extgl_glx.h org_lwjgl_opengl_LinuxCanvasImplementation.c org_lwjgl_opengl_LinuxContextImplementation.c org_lwjgl_opengl_Pbuffer.c Log Message: Removed unsued JNIEnv parameter from extgl_QueryExtension Index: extgl_glx.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/extgl_glx.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- extgl_glx.c 23 Feb 2005 14:16:57 -0000 1.4 +++ extgl_glx.c 23 Feb 2005 15:17:50 -0000 1.5 @@ -125,13 +125,13 @@ } /** returns true if the extention is available */ -static bool GLXQueryExtension(JNIEnv* env, Display *disp, int screen, const char *name) +static bool GLXQueryExtension(Display *disp, int screen, const char *name) { const GLubyte *exts = (const GLubyte *)glXQueryExtensionsString(disp, screen); - return extgl_QueryExtension(env, exts, name); + return extgl_QueryExtension(exts, name); } -static void extgl_InitGLX13(JNIEnv *env) +static void extgl_InitGLX13() { ExtFunction functions[] = { {"glXGetFBConfigs", (void*)&glXGetFBConfigs}, @@ -182,15 +182,15 @@ return extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); } -static void extgl_InitGLXSupportedExtensions(JNIEnv *env, Display *disp, int screen) +static void extgl_InitGLXSupportedExtensions(Display *disp, int screen) { - extension_flags.GLX_EXT_visual_info = GLXQueryExtension(env, disp, screen, "GLX_EXT_visual_info"); - extension_flags.GLX_EXT_visual_rating = GLXQueryExtension(env, disp, screen, "GLX_EXT_visual_rating"); - extension_flags.GLX_SGI_swap_control = GLXQueryExtension(env, disp, screen, "GLX_SGI_swap_control"); - extension_flags.GLX_ARB_multisample = GLXQueryExtension(env, disp, screen, "GLX_ARB_multisample"); + extension_flags.GLX_EXT_visual_info = GLXQueryExtension(disp, screen, "GLX_EXT_visual_info"); + extension_flags.GLX_EXT_visual_rating = GLXQueryExtension(disp, screen, "GLX_EXT_visual_rating"); + extension_flags.GLX_SGI_swap_control = GLXQueryExtension(disp, screen, "GLX_SGI_swap_control"); + extension_flags.GLX_ARB_multisample = GLXQueryExtension(disp, screen, "GLX_ARB_multisample"); } -static void extgl_InitGLXSGISwapControl(JNIEnv *env) +static void extgl_InitGLXSGISwapControl() { ExtFunction functions[] = { {"glXSwapIntervalSGI", (void*)&glXSwapIntervalSGI}}; @@ -198,7 +198,7 @@ extension_flags.GLX_SGI_swap_control = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); } -bool extgl_InitGLX(JNIEnv *env, Display *disp, int screen) +bool extgl_InitGLX(Display *disp, int screen) { int major, minor; /* Assume glx ver >= 1.2 */ @@ -209,8 +209,8 @@ return false; if (major > 1 || (major == 1 && minor >= 3)) extension_flags.GLX13 = true; - extgl_InitGLX13(env); - extgl_InitGLXSupportedExtensions(env, disp, screen); - extgl_InitGLXSGISwapControl(env); + extgl_InitGLX13(); + extgl_InitGLXSupportedExtensions(disp, screen); + extgl_InitGLXSGISwapControl(); return true; } Index: org_lwjgl_opengl_LinuxCanvasImplementation.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxCanvasImplementation.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- org_lwjgl_opengl_LinuxCanvasImplementation.c 20 Feb 2005 11:24:22 -0000 1.1 +++ org_lwjgl_opengl_LinuxCanvasImplementation.c 23 Feb 2005 15:17:52 -0000 1.2 @@ -48,7 +48,7 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxCanvasImplementation_nFindVisualIDFromFormat (JNIEnv *env, jclass clazz, jint screen, jobject pixel_format) { - if (!extgl_InitGLX(env, getDisplay(), screen)) { + if (!extgl_InitGLX(getDisplay(), screen)) { throwException(env, "Could not initialize GLX"); return -1; } Index: org_lwjgl_opengl_Pbuffer.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_opengl_Pbuffer.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- org_lwjgl_opengl_Pbuffer.c 23 Feb 2005 11:38:24 -0000 1.13 +++ org_lwjgl_opengl_Pbuffer.c 23 Feb 2005 15:17:52 -0000 1.14 @@ -60,7 +60,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxPbufferPeerInfo_nInitHandle (JNIEnv *env, jclass clazz, jobject peer_info_handle, jint width, jint height, jobject pixel_format) { - if (!extgl_InitGLX(env, getDisplay(), getCurrentScreen()) || !isPbuffersSupported()) { + if (!extgl_InitGLX(getDisplay(), getCurrentScreen()) || !isPbuffersSupported()) { throwException(env, "No Pbuffer support"); return; } Index: org_lwjgl_opengl_LinuxContextImplementation.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxContextImplementation.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- org_lwjgl_opengl_LinuxContextImplementation.c 22 Feb 2005 13:59:32 -0000 1.2 +++ org_lwjgl_opengl_LinuxContextImplementation.c 23 Feb 2005 15:17:52 -0000 1.3 @@ -109,7 +109,7 @@ X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_handle); X11Context *context_info = (*env)->GetDirectBufferAddress(env, context_handle); - if (!extgl_InitGLX(env, peer_info->display, peer_info->screen)) { + if (!extgl_InitGLX(peer_info->display, peer_info->screen)) { throwException(env, "Could not initialize GLX"); return NULL; } Index: context.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/context.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- context.c 21 Feb 2005 15:35:09 -0000 1.2 +++ context.c 23 Feb 2005 15:17:49 -0000 1.3 @@ -247,7 +247,7 @@ return false; } X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle); - if (!extgl_InitGLX(env, display, screen)) { + if (!extgl_InitGLX(display, screen)) { throwException(env, "Could not init GLX"); return false; } Index: extgl_glx.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/extgl_glx.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- extgl_glx.h 17 Feb 2005 12:39:32 -0000 1.3 +++ extgl_glx.h 23 Feb 2005 15:17:51 -0000 1.4 @@ -365,6 +365,6 @@ extern glXSwapIntervalSGIPROC glXSwapIntervalSGI; -extern bool extgl_InitGLX(JNIEnv *env, Display *disp, int screen); +extern bool extgl_InitGLX(Display *disp, int screen); #endif |
|
From: Elias N. <eli...@us...> - 2005-02-23 15:18:52
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24393/win32 Modified Files: extgl_wgl.c Log Message: Removed unsued JNIEnv parameter from extgl_QueryExtension Index: extgl_wgl.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/extgl_wgl.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- extgl_wgl.c 23 Feb 2005 13:22:44 -0000 1.5 +++ extgl_wgl.c 23 Feb 2005 15:17:53 -0000 1.6 @@ -114,7 +114,7 @@ } /** returns true if the extension is available */ -static bool WGLQueryExtension(JNIEnv *env, const char *name) +static bool WGLQueryExtension(const char *name) { const GLubyte *extensions; @@ -125,10 +125,10 @@ extensions = (GLubyte*)wglGetExtensionsStringEXT(); else extensions = (GLubyte*)wglGetExtensionsStringARB(wglGetCurrentDC()); - return extgl_QueryExtension(env, extensions, name); + return extgl_QueryExtension(extensions, name); } -static void extgl_InitWGLARBPbuffer(JNIEnv *env) +static void extgl_InitWGLARBPbuffer() { ExtFunction functions[] = { {"wglCreatePbufferARB", (void **)&wglCreatePbufferARB}, @@ -140,7 +140,7 @@ extension_flags.WGL_ARB_pbuffer = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); } -static void extgl_InitWGLARBPixelFormat(JNIEnv *env) +static void extgl_InitWGLARBPixelFormat() { ExtFunction functions[] = { {"wglGetPixelFormatAttribivARB", (void **)&wglGetPixelFormatAttribivARB}, @@ -150,7 +150,7 @@ extension_flags.WGL_ARB_pixel_format = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); } -static void extgl_InitWGLARBRenderTexture(JNIEnv *env) +static void extgl_InitWGLARBRenderTexture() { ExtFunction functions[] = { {"wglBindTexImageARB", (void **)&wglBindTexImageARB}, @@ -160,7 +160,7 @@ extension_flags.WGL_ARB_render_texture = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); } -static void extgl_InitWGLEXTSwapControl(JNIEnv *env) +static void extgl_InitWGLEXTSwapControl() { ExtFunction functions[] = { {"wglSwapIntervalEXT", (void **)&wglSwapIntervalEXT}, @@ -169,7 +169,7 @@ extension_flags.WGL_EXT_swap_control = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); } -static void extgl_InitWGLARBMakeCurrentRead(JNIEnv *env) +static void extgl_InitWGLARBMakeCurrentRead() { ExtFunction functions[] = { {"wglMakeContextCurrentARB", (void **)&wglMakeContextCurrentARB}, @@ -178,20 +178,20 @@ extension_flags.WGL_ARB_make_current_read = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); } -static void extgl_InitSupportedWGLExtensions(JNIEnv *env) +static void extgl_InitSupportedWGLExtensions() { - extension_flags.WGL_ARB_buffer_region = WGLQueryExtension(env, "WGL_ARB_buffer_region"); - extension_flags.WGL_ARB_make_current_read = WGLQueryExtension(env, "WGL_ARB_make_current_read"); - extension_flags.WGL_ARB_multisample = WGLQueryExtension(env, "WGL_ARB_multisample"); - extension_flags.WGL_ARB_pbuffer = WGLQueryExtension(env, "WGL_ARB_pbuffer"); - extension_flags.WGL_ARB_pixel_format = WGLQueryExtension(env, "WGL_ARB_pixel_format"); - extension_flags.WGL_ARB_render_texture = WGLQueryExtension(env, "WGL_ARB_render_texture"); - extension_flags.WGL_EXT_swap_control = WGLQueryExtension(env, "WGL_EXT_swap_control"); - extension_flags.WGL_NV_render_depth_texture = WGLQueryExtension(env, "WGL_NV_render_depth_texture"); - extension_flags.WGL_NV_render_texture_rectangle = WGLQueryExtension(env, "WGL_NV_render_texture_rectangle"); + extension_flags.WGL_ARB_buffer_region = WGLQueryExtension("WGL_ARB_buffer_region"); + extension_flags.WGL_ARB_make_current_read = WGLQueryExtension("WGL_ARB_make_current_read"); + extension_flags.WGL_ARB_multisample = WGLQueryExtension("WGL_ARB_multisample"); + extension_flags.WGL_ARB_pbuffer = WGLQueryExtension("WGL_ARB_pbuffer"); + extension_flags.WGL_ARB_pixel_format = WGLQueryExtension("WGL_ARB_pixel_format"); + extension_flags.WGL_ARB_render_texture = WGLQueryExtension("WGL_ARB_render_texture"); + extension_flags.WGL_EXT_swap_control = WGLQueryExtension("WGL_EXT_swap_control"); + extension_flags.WGL_NV_render_depth_texture = WGLQueryExtension("WGL_NV_render_depth_texture"); + extension_flags.WGL_NV_render_texture_rectangle = WGLQueryExtension("WGL_NV_render_texture_rectangle"); } -void extgl_InitWGL(JNIEnv *env) +void extgl_InitWGL() { ExtFunction functions[] = { {"wglGetExtensionsStringARB", (void **)&wglGetExtensionsStringARB}, @@ -200,12 +200,11 @@ extension_flags.WGL_ARB_extensions_string = wglGetExtensionsStringARB != NULL; extension_flags.WGL_EXT_extensions_string = wglGetExtensionsStringEXT != NULL; - extgl_InitSupportedWGLExtensions(env); + extgl_InitSupportedWGLExtensions(); - extgl_InitWGLARBMakeCurrentRead(env); - extgl_InitWGLEXTSwapControl(env); - extgl_InitWGLARBRenderTexture(env); - extgl_InitWGLARBPixelFormat(env); - extgl_InitWGLARBPbuffer(env); - //extgl_InitWGLARBBufferRegion(env); + extgl_InitWGLARBMakeCurrentRead(); + extgl_InitWGLEXTSwapControl(); + extgl_InitWGLARBRenderTexture(); + extgl_InitWGLARBPixelFormat(); + extgl_InitWGLARBPbuffer(); } |
|
From: Elias N. <eli...@us...> - 2005-02-23 15:18:42
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/common In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24393/common Modified Files: extgl.c extgl.h Log Message: Removed unsued JNIEnv parameter from extgl_QueryExtension Index: extgl.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/extgl.h,v retrieving revision 1.53 retrieving revision 1.54 diff -u -d -r1.53 -r1.54 --- extgl.h 21 Feb 2005 14:46:43 -0000 1.53 +++ extgl.h 23 Feb 2005 15:17:17 -0000 1.54 @@ -72,7 +72,6 @@ #include <jni.h> - /*-----------------------------------------*/ /*-----------------------------------------*/ @@ -162,7 +161,7 @@ extern void extgl_Close(void); extern void extgl_InitializeClass(JNIEnv *env, jclass clazz, int num_functions, JavaMethodAndExtFunction *functions); extern bool extgl_InitializeFunctions(int num_functions, ExtFunction *functions); -extern bool extgl_QueryExtension(JNIEnv *env, const GLubyte*extensions, const char *name); +extern bool extgl_QueryExtension(const GLubyte*extensions, const char *name); extern void *extgl_GetProcAddress(const char *name); #ifdef __cplusplus Index: extgl.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/extgl.c,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- extgl.c 23 Feb 2005 13:22:42 -0000 1.34 +++ extgl.c 23 Feb 2005 15:16:59 -0000 1.35 @@ -46,7 +46,7 @@ return ext_InitializeFunctions(&extgl_GetProcAddress, num_functions, functions); } -bool extgl_QueryExtension(JNIEnv *env, const GLubyte*extensions, const char *name) +bool extgl_QueryExtension(const GLubyte*extensions, const char *name) { const GLubyte *start; GLubyte *where, *terminator; |
|
From: Elias N. <eli...@us...> - 2005-02-23 14:17:06
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4430 Modified Files: extgl_glx.c Log Message: Linux: Fixed glx Index: extgl_glx.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/extgl_glx.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- extgl_glx.c 23 Feb 2005 13:22:43 -0000 1.3 +++ extgl_glx.c 23 Feb 2005 14:16:57 -0000 1.4 @@ -205,12 +205,12 @@ if (!extgl_InitGLX12()) return false; extension_flags.GLX12 = true; + if (glXQueryVersion(disp, &major, &minor) != True) + return false; if (major > 1 || (major == 1 && minor >= 3)) extension_flags.GLX13 = true; extgl_InitGLX13(env); extgl_InitGLXSupportedExtensions(env, disp, screen); - if (glXQueryVersion(disp, &major, &minor) != True) - return false; extgl_InitGLXSGISwapControl(env); return true; } |
|
From: Elias N. <eli...@us...> - 2005-02-23 13:22:58
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21131/win32 Modified Files: extgl_wgl.c Log Message: Moved platform specific stuff from extgl.c into platform directories Index: extgl_wgl.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/extgl_wgl.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- extgl_wgl.c 23 Feb 2005 12:38:39 -0000 1.4 +++ extgl_wgl.c 23 Feb 2005 13:22:44 -0000 1.5 @@ -78,6 +78,41 @@ wglMakeContextCurrentARBPROC wglMakeContextCurrentARB = NULL; wglGetCurrentReadDCARBPROC wglGetCurrentReadDCARB = NULL; +static HMODULE lib_gl_handle = NULL; + +void *extgl_GetProcAddress(const char *name) +{ + void *t = wglGetProcAddress(name); + if (t == NULL) + { + t = GetProcAddress(lib_gl_handle, name); + if (t == NULL) + { + printfDebug("Could not locate symbol %s\n", name); + } + } + return t; +} + +bool extgl_Open(JNIEnv *env) +{ + if (lib_gl_handle != NULL) + return true; + // load the dynamic libraries for OpenGL + lib_gl_handle = LoadLibrary("opengl32.dll"); + if (lib_gl_handle == NULL) { + throwException(env, "Could not load OpenGL library"); + return false; + } + return true; +} + +void extgl_Close(void) +{ + FreeLibrary(lib_gl_handle); + lib_gl_handle = NULL; +} + /** returns true if the extension is available */ static bool WGLQueryExtension(JNIEnv *env, const char *name) { |
|
From: Elias N. <eli...@us...> - 2005-02-23 13:22:57
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/common In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21131/common Modified Files: extgl.c Log Message: Moved platform specific stuff from extgl.c into platform directories Index: extgl.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/extgl.c,v retrieving revision 1.33 retrieving revision 1.34 diff -u -d -r1.33 -r1.34 --- extgl.c 17 Feb 2005 12:39:31 -0000 1.33 +++ extgl.c 23 Feb 2005 13:22:42 -0000 1.34 @@ -38,80 +38,6 @@ #include "extgl.h" #include "common_tools.h" -/* turn off the warning for the borland compiler*/ -#ifdef __BORLANDC__ -#pragma warn -8064 -#pragma warn -8065 -#endif /* __BORLANDC__ */ - -#ifdef _X11 - -#include <dlfcn.h> -#endif - -#ifdef _WIN32 -HMODULE lib_gl_handle = NULL; -#endif - -#ifdef _X11 -void * lib_gl_handle = NULL; - -typedef void * (APIENTRY * glXGetProcAddressARBPROC) (const GLubyte *procName); - -static glXGetProcAddressARBPROC glXGetProcAddressARB; -#endif - -#ifdef _MACOSX -#include <mach-o/dyld.h> -static const struct mach_header *opengl_lib_handle = NULL; -#endif - -/* getProcAddress */ - -void *extgl_GetProcAddress(const char *name) -{ -#ifdef _WIN32 - void *t = wglGetProcAddress(name); - if (t == NULL) - { - t = GetProcAddress(lib_gl_handle, name); - if (t == NULL) - { - printfDebug("Could not locate symbol %s\n", name); - } - } - return t; -#endif - -#ifdef _X11 - void *t = (void*)glXGetProcAddressARB((const GLubyte*)name); - if (t == NULL) - { - t = dlsym(lib_gl_handle, name); - if (t == NULL) - { - printfDebug("Could not locate symbol %s\n", name); - } - } - return t; -#endif - -#ifdef _MACOSX - #define BUFFER_SIZE 1024 - char mach_name[BUFFER_SIZE] = "_"; - strncat(mach_name, name, BUFFER_SIZE - 1); - - if (NSIsSymbolNameDefinedInImage(opengl_lib_handle, mach_name)) { - NSSymbol sym = NSLookupSymbolInImage(opengl_lib_handle, mach_name, NSLOOKUPSYMBOLINIMAGE_OPTION_BIND | NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR); - void *address = NSAddressOfSymbol(sym); - return address; - } else { - printfDebug("Could not locate symbol %s\n", name); - return NULL; - } -#endif -} - void extgl_InitializeClass(JNIEnv *env, jclass clazz, int num_functions, JavaMethodAndExtFunction *functions) { ext_InitializeClass(env, clazz, &extgl_GetProcAddress, num_functions, functions); } @@ -120,12 +46,6 @@ return ext_InitializeFunctions(&extgl_GetProcAddress, num_functions, functions); } -#ifdef _MACOSX -static const struct mach_header *loadImage(const char *lib_name) { - return NSAddImage(lib_name, NSADDIMAGE_OPTION_RETURN_ON_ERROR); -} -#endif - bool extgl_QueryExtension(JNIEnv *env, const GLubyte*extensions, const char *name) { const GLubyte *start; @@ -161,82 +81,3 @@ } -/*-----------------------------------------------------*/ -/* AGL stuff END*/ -/*-----------------------------------------------------*/ - -#ifdef _MACOSX -bool extgl_Open(JNIEnv *env) { - if (opengl_lib_handle != NULL) - return true; - opengl_lib_handle = loadImage("/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib"); - if (opengl_lib_handle != NULL) { - return true; - } else { - throwException(env, "Could not load OpenGL library"); - return false; - } -} -#endif - -#ifdef _X11 -bool extgl_Open(JNIEnv *env) -{ -#define BUFFER_SIZE 2000 - static char buffer[BUFFER_SIZE]; - if (lib_gl_handle != NULL) - return true; - lib_gl_handle = dlopen("libGL.so.1", RTLD_LAZY | RTLD_GLOBAL); - if (lib_gl_handle == NULL) { - snprintf(buffer, BUFFER_SIZE, "Error loading libGL.so.1: %s", dlerror()); - buffer[BUFFER_SIZE - 1] = '\0'; - throwException(env, buffer); - return false; - } - glXGetProcAddressARB = (glXGetProcAddressARBPROC)dlsym(lib_gl_handle, "glXGetProcAddressARB"); - if (glXGetProcAddressARB == NULL) { - extgl_Close(); - throwException(env, "Could not get address of glXGetProcAddressARB"); - return false; - } - return true; -} - -#endif /* X11 */ - -#ifdef _WIN32 -bool extgl_Open(JNIEnv *env) -{ - if (lib_gl_handle != NULL) - return true; - // load the dynamic libraries for OpenGL - lib_gl_handle = LoadLibrary("opengl32.dll"); - if (lib_gl_handle == NULL) { - throwException(env, "Could not load OpenGL library"); - return false; - } - return true; -} -#endif /* WIN32 */ - -void extgl_Close(void) -{ -#ifdef _X11 - dlclose(lib_gl_handle); - lib_gl_handle = NULL; -#endif -#ifdef _WIN32 - FreeLibrary(lib_gl_handle); - lib_gl_handle = NULL; -#endif -#ifdef _MACOSX - opengl_lib_handle = NULL; -#endif -} - -/* turn on the warning for the borland compiler*/ -#ifdef __BORLANDC__ -#pragma warn .8064 -#pragma warn .8065 -#endif /* __BORLANDC__ */ - |
|
From: Elias N. <eli...@us...> - 2005-02-23 13:22:57
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/macosx In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21131/macosx Modified Files: context.m Log Message: Moved platform specific stuff from extgl.c into platform directories Index: context.m =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/context.m,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- context.m 23 Feb 2005 11:11:07 -0000 1.1 +++ context.m 23 Feb 2005 13:22:43 -0000 1.2 @@ -42,6 +42,46 @@ #import <Cocoa/Cocoa.h> #import <Carbon/Carbon.h> +#include <mach-o/dyld.h> +static const struct mach_header *opengl_lib_handle = NULL; + +void *extgl_GetProcAddress(const char *name) +{ + #define BUFFER_SIZE 1024 + char mach_name[BUFFER_SIZE] = "_"; + strncat(mach_name, name, BUFFER_SIZE - 1); + + if (NSIsSymbolNameDefinedInImage(opengl_lib_handle, mach_name)) { + NSSymbol sym = NSLookupSymbolInImage(opengl_lib_handle, mach_name, NSLOOKUPSYMBOLINIMAGE_OPTION_BIND | NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR); + void *address = NSAddressOfSymbol(sym); + return address; + } else { + printfDebug("Could not locate symbol %s\n", name); + return NULL; + } +} + +static const struct mach_header *loadImage(const char *lib_name) { + return NSAddImage(lib_name, NSADDIMAGE_OPTION_RETURN_ON_ERROR); +} + +bool extgl_Open(JNIEnv *env) { + if (opengl_lib_handle != NULL) + return true; + opengl_lib_handle = loadImage("/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib"); + if (opengl_lib_handle != NULL) { + return true; + } else { + throwException(env, "Could not load OpenGL library"); + return false; + } +} + +void extgl_Close(void) +{ + opengl_lib_handle = NULL; +} + NSOpenGLPixelFormat *choosePixelFormat(JNIEnv *env, jobject pixel_format, bool use_display_bpp, bool support_window, bool support_pbuffer, bool double_buffered) { int bpp; jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format); |
|
From: Elias N. <eli...@us...> - 2005-02-23 13:22:57
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21131/linux Modified Files: extgl_glx.c Log Message: Moved platform specific stuff from extgl.c into platform directories Index: extgl_glx.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/extgl_glx.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- extgl_glx.c 17 Feb 2005 12:39:32 -0000 1.2 +++ extgl_glx.c 23 Feb 2005 13:22:43 -0000 1.3 @@ -29,6 +29,7 @@ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include <dlfcn.h> #include "extgl_glx.h" GLXExtensions extension_flags; @@ -75,6 +76,54 @@ /* GLX_SGI_swap_control */ glXSwapIntervalSGIPROC glXSwapIntervalSGI = NULL; +static void * lib_gl_handle = NULL; + +typedef void * (APIENTRY * glXGetProcAddressARBPROC) (const GLubyte *procName); + +static glXGetProcAddressARBPROC glXGetProcAddressARB; + +bool extgl_Open(JNIEnv *env) +{ +#define BUFFER_SIZE 2000 + static char buffer[BUFFER_SIZE]; + if (lib_gl_handle != NULL) + return true; + lib_gl_handle = dlopen("libGL.so.1", RTLD_LAZY | RTLD_GLOBAL); + if (lib_gl_handle == NULL) { + snprintf(buffer, BUFFER_SIZE, "Error loading libGL.so.1: %s", dlerror()); + buffer[BUFFER_SIZE - 1] = '\0'; + throwException(env, buffer); + return false; + } + glXGetProcAddressARB = (glXGetProcAddressARBPROC)dlsym(lib_gl_handle, "glXGetProcAddressARB"); + if (glXGetProcAddressARB == NULL) { + extgl_Close(); + throwException(env, "Could not get address of glXGetProcAddressARB"); + return false; + } + return true; +} + +void *extgl_GetProcAddress(const char *name) +{ + void *t = (void*)glXGetProcAddressARB((const GLubyte*)name); + if (t == NULL) + { + t = dlsym(lib_gl_handle, name); + if (t == NULL) + { + printfDebug("Could not locate symbol %s\n", name); + } + } + return t; +} + +void extgl_Close(void) +{ + dlclose(lib_gl_handle); + lib_gl_handle = NULL; +} + /** returns true if the extention is available */ static bool GLXQueryExtension(JNIEnv* env, Display *disp, int screen, const char *name) { @@ -153,15 +202,15 @@ { int major, minor; /* Assume glx ver >= 1.2 */ - extension_flags.GLX12 = true; if (!extgl_InitGLX12()) return false; - extgl_InitGLXSupportedExtensions(env, disp, screen); - if (glXQueryVersion(disp, &major, &minor) != True) - return false; + extension_flags.GLX12 = true; if (major > 1 || (major == 1 && minor >= 3)) extension_flags.GLX13 = true; extgl_InitGLX13(env); + extgl_InitGLXSupportedExtensions(env, disp, screen); + if (glXQueryVersion(disp, &major, &minor) != True) + return false; extgl_InitGLXSGISwapControl(env); return true; } |
|
From: Elias N. <eli...@us...> - 2005-02-23 12:38:49
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10353/win32 Modified Files: extgl_wgl.c Log Message: Typo fix Index: extgl_wgl.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/extgl_wgl.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- extgl_wgl.c 21 Feb 2005 14:46:47 -0000 1.3 +++ extgl_wgl.c 23 Feb 2005 12:38:39 -0000 1.4 @@ -78,7 +78,7 @@ wglMakeContextCurrentARBPROC wglMakeContextCurrentARB = NULL; wglGetCurrentReadDCARBPROC wglGetCurrentReadDCARB = NULL; -/** returns true if the extention is available */ +/** returns true if the extension is available */ static bool WGLQueryExtension(JNIEnv *env, const char *name) { const GLubyte *extensions; |
|
From: Elias N. <eli...@us...> - 2005-02-23 12:12:56
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2428/src/java/org/lwjgl/opengl Modified Files: Context.java LinuxContextImplementation.java MacOSXContextImplementation.java Win32ContextImplementation.java Log Message: Made Context.setVSync static. Added synchronization. Index: Context.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/Context.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Context.java 23 Feb 2005 11:11:06 -0000 1.2 +++ Context.java 23 Feb 2005 12:12:46 -0000 1.3 @@ -208,7 +208,7 @@ * the monitor vertical refresh synchronization of the context, and is not guaranteed to be successful. * @param sync true to synchronize; false to ignore synchronization */ - public synchronized void setVSync(boolean enable) { + public static void setVSync(boolean enable) { implementation.setVSync(enable); } Index: MacOSXContextImplementation.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/MacOSXContextImplementation.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- MacOSXContextImplementation.java 23 Feb 2005 11:47:47 -0000 1.2 +++ MacOSXContextImplementation.java 23 Feb 2005 12:12:47 -0000 1.3 @@ -43,10 +43,6 @@ * @version $Revision$ */ final class MacOSXContextImplementation 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 { @@ -59,7 +55,11 @@ public void swapBuffers() throws LWJGLException { Context current_context = Context.getCurrentContext(); - nSwapBuffers(current_context.getHandle()); + if (current_context == null) + throw new IllegalStateException("No context is current"); + synchronized (current_context) { + nSwapBuffers(current_context.getHandle()); + } } private static native void nSwapBuffers(ByteBuffer context_handle) throws LWJGLException; @@ -70,8 +70,11 @@ public void releaseCurrentContext() throws LWJGLException { Context current_context = Context.getCurrentContext(); - if (current_context != null) - clearDrawable(current_context.getHandle()); + if (current_context != null) { + synchronized (current_context) { + clearDrawable(current_context.getHandle()); + } + } nReleaseCurrentContext(); } private static native void nReleaseCurrentContext() throws LWJGLException; @@ -97,7 +100,10 @@ private static native boolean nIsCurrent(ByteBuffer context_handle) throws LWJGLException; public void setVSync(boolean enabled) { - nSetVSync(Context.getCurrentContext().getHandle(), enabled); + Context current_context = Context.getCurrentContext(); + synchronized (current_context) { + nSetVSync(current_context.getHandle(), enabled); + } } private static native void nSetVSync(ByteBuffer context_handle, boolean enabled); Index: Win32ContextImplementation.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/Win32ContextImplementation.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Win32ContextImplementation.java 23 Feb 2005 11:11:07 -0000 1.2 +++ Win32ContextImplementation.java 23 Feb 2005 12:12:47 -0000 1.3 @@ -43,10 +43,6 @@ * @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 { @@ -58,14 +54,17 @@ 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) + Context current_context = Context.getCurrentContext(); + if (current_context == null) throw new IllegalStateException("No context is current"); - ByteBuffer peer_handle = current_peer_info.lockAndGetHandle(); - try { - nSwapBuffers(peer_handle); - } finally { - current_peer_info.unlock(); + synchronized (current_context) { + PeerInfo current_peer_info = current_context.getPeerInfo(); + 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; Index: LinuxContextImplementation.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/LinuxContextImplementation.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- LinuxContextImplementation.java 23 Feb 2005 11:11:07 -0000 1.3 +++ LinuxContextImplementation.java 23 Feb 2005 12:12:47 -0000 1.4 @@ -43,10 +43,6 @@ * @version $Revision$ */ final class LinuxContextImplementation implements ContextImplementation { - private static PeerInfo getCurrentPeerInfo() { - return Context.getCurrentContext().getPeerInfo(); - } - public ByteBuffer create(PeerInfo peer_info, ByteBuffer shared_context_handle) throws LWJGLException { LinuxDisplay.lockAWT(); try { @@ -64,37 +60,43 @@ 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) + Context current_context = Context.getCurrentContext(); + if (current_context == null) throw new IllegalStateException("No context is current"); - LinuxDisplay.lockAWT(); - try { - ByteBuffer peer_handle = current_peer_info.lockAndGetHandle(); + synchronized (current_context) { + PeerInfo current_peer_info = current_context.getPeerInfo(); + LinuxDisplay.lockAWT(); try { - nSwapBuffers(peer_handle); + ByteBuffer peer_handle = current_peer_info.lockAndGetHandle(); + try { + nSwapBuffers(peer_handle); + } finally { + current_peer_info.unlock(); + } } finally { - current_peer_info.unlock(); + LinuxDisplay.unlockAWT(); } - } finally { - LinuxDisplay.unlockAWT(); } } private static native void nSwapBuffers(ByteBuffer peer_info_handle) throws LWJGLException; public void releaseCurrentContext() throws LWJGLException { - PeerInfo current_peer_info = getCurrentPeerInfo(); - if (current_peer_info == null) - return; // No context is current - LinuxDisplay.lockAWT(); - try { - ByteBuffer peer_handle = current_peer_info.lockAndGetHandle(); + Context current_context = Context.getCurrentContext(); + if (current_context == null) + throw new IllegalStateException("No context is current"); + synchronized (current_context) { + PeerInfo current_peer_info = current_context.getPeerInfo(); + LinuxDisplay.lockAWT(); try { - nReleaseCurrentContext(peer_handle); + ByteBuffer peer_handle = current_peer_info.lockAndGetHandle(); + try { + nReleaseCurrentContext(peer_handle); + } finally { + current_peer_info.unlock(); + } } finally { - current_peer_info.unlock(); + LinuxDisplay.unlockAWT(); } - } finally { - LinuxDisplay.unlockAWT(); } } private static native void nReleaseCurrentContext(ByteBuffer peer_info_handle) throws LWJGLException; |
|
From: Elias N. <eli...@us...> - 2005-02-23 11:47:55
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28215/src/java/org/lwjgl/opengl Modified Files: MacOSXContextImplementation.java Log Message: Removed debug Index: MacOSXContextImplementation.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/MacOSXContextImplementation.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- MacOSXContextImplementation.java 23 Feb 2005 11:11:07 -0000 1.1 +++ MacOSXContextImplementation.java 23 Feb 2005 11:47:47 -0000 1.2 @@ -64,7 +64,6 @@ private static native void nSwapBuffers(ByteBuffer context_handle) throws LWJGLException; public void update(ByteBuffer context_handle) { -System.out.println("context_handle = " + context_handle); nUpdate(context_handle); } private static native void nUpdate(ByteBuffer context_handle); |
|
From: Elias N. <eli...@us...> - 2005-02-23 11:45:35
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27610 Modified Files: LinuxDisplay.java MacOSXDisplay.java Win32Display.java Log Message: Clean up java code Index: Win32Display.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/Win32Display.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- Win32Display.java 23 Feb 2005 11:11:07 -0000 1.13 +++ Win32Display.java 23 Feb 2005 11:45:25 -0000 1.14 @@ -48,8 +48,6 @@ import org.lwjgl.input.Cursor; final class Win32Display implements DisplayImplementation { -// private static final int PBUFFER_HANDLE_SIZE = 24; - private static Win32DisplayPeerInfo peer_info; public void createWindow(DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException { @@ -70,14 +68,10 @@ public native boolean isVisible(); public native boolean isActive(); public native boolean isDirty(); -// public native void swapBuffers(); -// public native void makeCurrent() throws LWJGLException; public PeerInfo createPeerInfo(PixelFormat pixel_format) throws LWJGLException { peer_info = new Win32DisplayPeerInfo(pixel_format); return peer_info; } -// public native void createContext(PixelFormat pixel_format) throws LWJGLException; -// public native void destroyContext(); public void update() { nUpdate(); if (didMaximize()) { @@ -97,7 +91,6 @@ 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; @@ -136,29 +129,12 @@ 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 { return new Win32PbufferPeerInfo(width, height, pixel_format, pixelFormatCaps, pBufferAttribs); } -/* public ByteBuffer createPbuffer(int width, int height, PixelFormat pixel_format, - IntBuffer pixelFormatCaps, - IntBuffer pBufferAttribs, ByteBuffer shared_pbuffer_handle) throws LWJGLException { - ByteBuffer handle = BufferUtils.createByteBuffer(PBUFFER_HANDLE_SIZE); - nCreatePbuffer(handle, width, height, pixel_format, pixelFormatCaps, pBufferAttribs, shared_pbuffer_handle); - return handle; - } - - private native void nCreatePbuffer(ByteBuffer handle, int width, int height, PixelFormat pixel_format, - IntBuffer pixelFormatCaps, - IntBuffer pBufferAttribs, ByteBuffer shared_pbuffer_handle) throws LWJGLException; -*/ -// public native void destroyPbuffer(ByteBuffer handle); - public void setPbufferAttrib(PeerInfo handle, int attrib, int value) { ((Win32PbufferPeerInfo)handle).setPbufferAttrib(attrib, value); } @@ -170,7 +146,4 @@ 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);*/ } Index: MacOSXDisplay.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- MacOSXDisplay.java 23 Feb 2005 11:11:07 -0000 1.23 +++ MacOSXDisplay.java 23 Feb 2005 11:45:25 -0000 1.24 @@ -201,19 +201,9 @@ return frame.getCanvas().syncIsDirty(); } -// public native void setView(MacOSXGLCanvas canvas); - -// public native void swapBuffers(); - -// public native void makeCurrent() throws LWJGLException; - public PeerInfo createPeerInfo(PixelFormat pixel_format) throws LWJGLException { return new MacOSXDisplayPeerInfo(pixel_format); } -// public native void createContext(PixelFormat pixel_format) throws LWJGLException; - -// public native void destroyPeerInfo(); -// public native void destroyContext(); public void update() { if (frame.getCanvas().syncShouldUpdateContext()) { @@ -246,8 +236,6 @@ private native void updateContext(); -// public native void setVSyncEnabled(boolean sync); - public void reshape(int x, int y, int width, int height) { frame.resize(x, y, width, height); } @@ -423,28 +411,12 @@ return false; } -// public native void makePbufferCurrent(ByteBuffer handle) throws LWJGLException; - public PeerInfo createPbuffer(int width, int height, PixelFormat pixel_format, IntBuffer pixelFormatCaps, IntBuffer pBufferAttribs) throws LWJGLException { return new MacOSXPbufferPeerInfo(width, height, pixel_format); } -/* public ByteBuffer createPbuffer(int width, int height, PixelFormat pixel_format, - IntBuffer pixelFormatCaps, - IntBuffer pBufferAttribs, ByteBuffer shared_pbuffer_handle) throws LWJGLException { - ByteBuffer handle = BufferUtils.createByteBuffer(PBUFFER_HANDLE_SIZE); - nCreatePbuffer(handle, width, height, pixel_format, pixelFormatCaps, pBufferAttribs, shared_pbuffer_handle); - return handle; - } - - private native void nCreatePbuffer(ByteBuffer handle, int width, int height, PixelFormat pixel_format, - IntBuffer pixelFormatCaps, - IntBuffer pBufferAttribs, ByteBuffer shared_pbuffer_handle) throws LWJGLException; -*/ -// public native void destroyPbuffer(ByteBuffer handle); - public void setPbufferAttrib(PeerInfo handle, int attrib, int value) { throw new UnsupportedOperationException(); } Index: LinuxDisplay.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- LinuxDisplay.java 23 Feb 2005 11:11:07 -0000 1.18 +++ LinuxDisplay.java 23 Feb 2005 11:45:24 -0000 1.19 @@ -48,7 +48,6 @@ import org.lwjgl.input.Keyboard; final class LinuxDisplay implements DisplayImplementation { -// private static final int PBUFFER_HANDLE_SIZE = 24; private static final int NUM_BUTTONS = 3; private static PeerInfo peer_info; @@ -370,40 +369,6 @@ return false; } -/* public void makePbufferCurrent(ByteBuffer handle) throws LWJGLException { - lockAWT(); - try { - nMakePbufferCurrent(handle); - } finally { - unlockAWT(); - } - } - - private static native void nMakePbufferCurrent(ByteBuffer handle) throws LWJGLException; -*/ -/* public ByteBuffer createPbuffer(int width, int height, PixelFormat pixel_format, - IntBuffer pixelFormatCaps, - IntBuffer pBufferAttribs, ByteBuffer shared_pbuffer_handle) throws LWJGLException { - lockAWT(); - try { - ByteBuffer handle = BufferUtils.createByteBuffer(PBUFFER_HANDLE_SIZE); - incDisplay(); - try { - nCreatePbuffer(handle, width, height, pixel_format, pixelFormatCaps, pBufferAttribs, shared_pbuffer_handle); - return handle; - } catch (LWJGLException e) { - decDisplay(); - throw e; - } - } finally { - unlockAWT(); - } - } - - private static native void nCreatePbuffer(ByteBuffer handle, int width, int height, PixelFormat pixel_format, - IntBuffer pixelFormatCaps, - IntBuffer pBufferAttribs, ByteBuffer shared_pbuffer_handle) throws LWJGLException; -*/ public PeerInfo createPbuffer(int width, int height, PixelFormat pixel_format, IntBuffer pixelFormatCaps, IntBuffer pBufferAttribs) throws LWJGLException { |
|
From: Elias N. <eli...@us...> - 2005-02-23 11:42:14
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26806/win32 Modified Files: Window.h org_lwjgl_opengl_Display.c org_lwjgl_opengl_Pbuffer.c Log Message: Clean out commented code Index: org_lwjgl_opengl_Pbuffer.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_opengl_Pbuffer.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- org_lwjgl_opengl_Pbuffer.c 21 Feb 2005 14:46:47 -0000 1.10 +++ org_lwjgl_opengl_Pbuffer.c 23 Feb 2005 11:42:04 -0000 1.11 @@ -78,78 +78,6 @@ return caps; } -/*static HPBUFFERARB createPbuffer(JNIEnv *env, int width, int height, jobject pixel_format, jobject pixelFormatCaps, const int *pBufferAttribs_ptr) { - HWND dummy_hwnd = createWindow(0, 0, 1, 1, false, false); - HDC dummy_hdc; - int iPixelFormat; - HGLRC dummy_hglrc; - BOOL result; - HPBUFFERARB Pbuffer; - bool pbuffers_supported; - - if (dummy_hwnd == NULL) { - throwException(env, "Could not create dummy window"); - return NULL; - } - dummy_hdc = GetDC(dummy_hwnd); - iPixelFormat = findPixelFormat(env, dummy_hdc, pixel_format); - if (iPixelFormat == -1) { - return NULL; - } - if (!applyPixelFormat(dummy_hdc, iPixelFormat)) { - closeWindow(&dummy_hwnd, &dummy_hdc); - throwException(env, "Could not apply pixel format to window"); - return NULL; - } - - dummy_hglrc = wglCreateContext(dummy_hdc); - if (dummy_hglrc == NULL) { - closeWindow(&dummy_hwnd, &dummy_hdc); - throwException(env, "Failed to create OpenGL rendering context"); - return NULL; - } - result = wglMakeCurrent(dummy_hdc, dummy_hglrc); - if (!result) { - wglDeleteContext(dummy_hglrc); - closeWindow(&dummy_hwnd, &dummy_hdc); - throwException(env, "Could not bind context to dummy window"); - return NULL; - } - extgl_InitWGL(env); - pbuffers_supported = isPbuffersSupported(); - iPixelFormat = findPixelFormatARB(env, dummy_hdc, pixel_format, pixelFormatCaps, false, false, true, false); - if (iPixelFormat == -1) - iPixelFormat = findPixelFormatARB(env, dummy_hdc, pixel_format, pixelFormatCaps, false, false, true, true); - wglDeleteContext(dummy_hglrc); - if (!pbuffers_supported) { - closeWindow(&dummy_hwnd, &dummy_hdc); - throwException(env, "No Pbuffer support."); - return NULL; - } - if (iPixelFormat == -1) { - closeWindow(&dummy_hwnd, &dummy_hdc); - throwException(env, "Could not find suitable pixel format."); - return NULL; - } - Pbuffer = wglCreatePbufferARB(dummy_hdc, iPixelFormat, width, height, pBufferAttribs_ptr); - closeWindow(&dummy_hwnd, &dummy_hdc); - return Pbuffer; -} - -static HGLRC createPbufferContext(JNIEnv *env, HDC Pbuffer_dc, HGLRC shared_context) { - HGLRC Pbuffer_context = wglCreateContext(Pbuffer_dc); - if (Pbuffer_context == NULL) { - throwException(env, "Failed to create Pbuffer rendering context"); - return NULL; - } - if (shared_context != NULL && !wglShareLists(shared_context, Pbuffer_context)) { - wglDeleteContext(Pbuffer_context); - throwException(env, "Could not share buffer context."); - return NULL; - } - return Pbuffer_context; -} -*/ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32PbufferPeerInfo_nCreate (JNIEnv *env, jobject self, jobject peer_info_handle, jint width, jint height, jobject pixel_format, @@ -214,71 +142,6 @@ wglQueryPbufferARB(peer_info->pbuffer, WGL_PBUFFER_LOST_ARB, &buffer_lost); return buffer_lost ? JNI_TRUE : JNI_FALSE; } -/* HDC Pbuffer_dc; - HGLRC Pbuffer_context; - HGLRC shared_context; - PbufferInfo *Pbuffer_info; - if ((*env)->GetDirectBufferCapacity(env, buffer_handle) < sizeof(PbufferInfo)) { - throwException(env, "Buffer handle not large enough"); - return; - } - Pbuffer = createPbuffer(env, width, height, pixel_format, pixelFormatCaps, pBufferAttribs_ptr); - - if (Pbuffer == NULL) { - throwException(env, "Could not create Pbuffer."); - return; - } - - Pbuffer_dc = wglGetPbufferDCARB(Pbuffer); - if (Pbuffer_dc == NULL) { - wglDestroyPbufferARB(Pbuffer); - throwException(env, "Could not get Pbuffer dc."); - return; - } - shared_context = getCurrentContext(); - if (shared_context_handle_buffer != NULL) { - Pbuffer_info = (PbufferInfo *)(*env)->GetDirectBufferAddress(env, shared_context_handle_buffer); - shared_context = Pbuffer_info->Pbuffer_context; - } - Pbuffer_context = createPbufferContext(env, Pbuffer_dc, shared_context); - if (Pbuffer_context == NULL) { - wglReleasePbufferDCARB(Pbuffer, Pbuffer_dc); - wglDestroyPbufferARB(Pbuffer); - return; - } - Pbuffer_info = (PbufferInfo *)(*env)->GetDirectBufferAddress(env, buffer_handle); - Pbuffer_info->Pbuffer = Pbuffer; - Pbuffer_info->Pbuffer_context = Pbuffer_context; - Pbuffer_info->Pbuffer_dc = Pbuffer_dc; -} - -JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Win32Display_isBufferLost - (JNIEnv *env, jobject self, jobject buffer_handle) -{ - PbufferInfo *Pbuffer_info = (PbufferInfo *)(*env)->GetDirectBufferAddress(env, buffer_handle); - BOOL buffer_lost; - wglQueryPbufferARB(Pbuffer_info->Pbuffer, WGL_PBUFFER_LOST_ARB, &buffer_lost); - return buffer_lost ? JNI_TRUE : JNI_FALSE; -} - -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_makePbufferCurrent - (JNIEnv *env, jobject self, jobject buffer_handle) -{ - PbufferInfo *Pbuffer_info = (PbufferInfo *)(*env)->GetDirectBufferAddress(env, buffer_handle); -// PbufferInfo *Pbuffer_info = (PbufferInfo *)handle; - if (!wglMakeCurrent(Pbuffer_info->Pbuffer_dc, Pbuffer_info->Pbuffer_context)) - throwException(env, "Could not make pbuffer context current"); -} - -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_destroyPbuffer - (JNIEnv *env, jobject self, jobject buffer_handle) -{ - PbufferInfo *Pbuffer_info = (PbufferInfo *)(*env)->GetDirectBufferAddress(env, buffer_handle); - wglDeleteContext(Pbuffer_info->Pbuffer_context); - wglReleasePbufferDCARB(Pbuffer_info->Pbuffer, Pbuffer_info->Pbuffer_dc); - wglDestroyPbufferARB(Pbuffer_info->Pbuffer); -} -*/ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32PbufferPeerInfo_nSetPbufferAttrib (JNIEnv *env, jclass clazz, jobject peer_info_handle, jint attrib, jint value) { @@ -303,31 +166,3 @@ Win32PeerInfo *peer_info = (Win32PeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); wglReleaseTexImageARB(peer_info->pbuffer, buffer); } -/* -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_setPbufferAttrib - (JNIEnv *env, jobject self, jobject buffer_handle, jint attrib, jint value) -{ - PbufferInfo *Pbuffer_info = (PbufferInfo *)(*env)->GetDirectBufferAddress(env, buffer_handle); - - int attribs[3]; - - attribs[0] = attrib; - attribs[1] = value; - attribs[2] = 0; - - wglSetPbufferAttribARB(Pbuffer_info->Pbuffer, attribs); -} - -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_bindTexImageToPbuffer - (JNIEnv *env, jobject self, jobject buffer_handle, jint buffer) -{ - PbufferInfo *Pbuffer_info = (PbufferInfo *)(*env)->GetDirectBufferAddress(env, buffer_handle); - wglBindTexImageARB(Pbuffer_info->Pbuffer, buffer); -} - -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_releaseTexImageFromPbuffer - (JNIEnv *env, jobject self, jobject buffer_handle, jint buffer) -{ - PbufferInfo *Pbuffer_info = (PbufferInfo *)(*env)->GetDirectBufferAddress(env, buffer_handle); - wglReleaseTexImageARB(Pbuffer_info->Pbuffer, buffer); -}*/ Index: org_lwjgl_opengl_Display.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_opengl_Display.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- org_lwjgl_opengl_Display.c 21 Feb 2005 14:46:47 -0000 1.16 +++ org_lwjgl_opengl_Display.c 23 Feb 2005 11:42:04 -0000 1.17 @@ -51,7 +51,6 @@ static HWND display_hwnd = NULL; // Handle to the window static HDC display_hdc = NULL; // Device context -//static HGLRC display_hglrc = NULL; // OpenGL context static bool isFullScreen = false; // Whether we're fullscreen or not static bool isMinimized = false; // Whether we're minimized or not static bool isFocused = false; // whether we're focused or not @@ -61,24 +60,9 @@ // has recovered from minimized static bool closerequested; -//static int pixel_format_index; #define WINDOWCLASSNAME "LWJGL" -/*bool applyPixelFormat(HDC hdc, int iPixelFormat) { - PIXELFORMATDESCRIPTOR desc; - if (DescribePixelFormat(hdc, iPixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &desc) == 0) { - return false; - } - - // make that the pixel format of the device context - if (SetPixelFormat(hdc, iPixelFormat, &desc) == FALSE) { - return false; - } - return true; -} -*/ - HDC getCurrentHDC() { return display_hdc; } @@ -87,185 +71,6 @@ return display_hwnd; } -/*HGLRC getCurrentContext() { - return display_hglrc; -} - -static int findPixelFormatARBFromBPP(JNIEnv *env, HDC hdc, 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")); - int stencil = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stencil", "I")); - int samples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "samples", "I")); - 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 iPixelFormat; - unsigned int num_formats_returned; - attrib_list_t attrib_list; - GLuint *pixelFormatCaps_ptr; - jlong pixelFormatCapsSize; - BOOL result; - jlong i; - - initAttribList(&attrib_list); - if (window) { - putAttrib(&attrib_list, WGL_DRAW_TO_WINDOW_ARB); putAttrib(&attrib_list, TRUE); - } - if (pbuffer) { - putAttrib(&attrib_list, WGL_DRAW_TO_PBUFFER_ARB); putAttrib(&attrib_list, TRUE); - } - putAttrib(&attrib_list, WGL_ACCELERATION_ARB); putAttrib(&attrib_list, WGL_FULL_ACCELERATION_ARB); - putAttrib(&attrib_list, WGL_PIXEL_TYPE_ARB); putAttrib(&attrib_list, WGL_TYPE_RGBA_ARB); - putAttrib(&attrib_list, WGL_DOUBLE_BUFFER_ARB); putAttrib(&attrib_list, double_buffer ? TRUE : FALSE); - putAttrib(&attrib_list, WGL_SUPPORT_OPENGL_ARB); putAttrib(&attrib_list, TRUE); - putAttrib(&attrib_list, WGL_COLOR_BITS_ARB); putAttrib(&attrib_list, bpp); - putAttrib(&attrib_list, WGL_ALPHA_BITS_ARB); putAttrib(&attrib_list, alpha); - putAttrib(&attrib_list, WGL_DEPTH_BITS_ARB); putAttrib(&attrib_list, depth); - putAttrib(&attrib_list, WGL_STENCIL_BITS_ARB); putAttrib(&attrib_list, stencil); - if (samples > 0 && extension_flags.WGL_ARB_multisample) { - putAttrib(&attrib_list, WGL_SAMPLE_BUFFERS_ARB); putAttrib(&attrib_list, 1); - putAttrib(&attrib_list, WGL_SAMPLES_ARB); putAttrib(&attrib_list, samples); - } - putAttrib(&attrib_list, WGL_ACCUM_BITS_ARB); putAttrib(&attrib_list, accum_bpp); - 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); - if ( pixelFormatCaps != NULL ) { - if ( !extension_flags.WGL_ARB_render_texture ) { - return -1; - } - - pixelFormatCaps_ptr = (GLuint *)(*env)->GetDirectBufferAddress(env, pixelFormatCaps); - pixelFormatCapsSize = (*env)->GetDirectBufferCapacity(env, pixelFormatCaps); - - for (i = 0; i < pixelFormatCapsSize; i++) - putAttrib(&attrib_list, pixelFormatCaps_ptr[i]); - } - putAttrib(&attrib_list, 0); putAttrib(&attrib_list, 0); - result = wglChoosePixelFormatARB(hdc, attrib_list.attribs, NULL, 1, &iPixelFormat, &num_formats_returned); - - if (result == FALSE || num_formats_returned < 1) { - return -1; - } - return iPixelFormat; -} - -int findPixelFormatARB(JNIEnv *env, HDC hdc, jobject pixel_format, jobject pixelFormatCaps, bool use_hdc_bpp, bool window, bool pbuffer, bool double_buffer) { - int bpp; - int iPixelFormat; - jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format); - if (use_hdc_bpp) { - bpp = GetDeviceCaps(hdc, BITSPIXEL); - iPixelFormat = findPixelFormatARBFromBPP(env, hdc, pixel_format, pixelFormatCaps, bpp, window, pbuffer, double_buffer); - if (iPixelFormat == -1) - bpp = 16; - else - return iPixelFormat; - } else - bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "bpp", "I")); - return findPixelFormatARBFromBPP(env, hdc, pixel_format, pixelFormatCaps, bpp, window, pbuffer, double_buffer); -} -*/ -/* - * Find an appropriate pixel format - */ -/* -static int findPixelFormatFromBPP(JNIEnv *env, HDC hdc, jobject pixel_format, int bpp) -{ - 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")); - int stencil = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stencil", "I")); - int samples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "samples", "I")); - 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")); - unsigned int flags = PFD_DRAW_TO_WINDOW | // support window - PFD_SUPPORT_OPENGL | - PFD_DOUBLEBUFFER | - (stereo ? PFD_STEREO : 0); - PIXELFORMATDESCRIPTOR desc; - int iPixelFormat; - PIXELFORMATDESCRIPTOR pfd = { - sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd - 1, // version number - flags, // RGBA type - PFD_TYPE_RGBA, - (BYTE)bpp, - 0, 0, 0, 0, 0, 0, // color bits ignored - (BYTE)alpha, - 0, // shift bit ignored - accum_bpp + accum_alpha, // no accumulation buffer - 0, 0, 0, 0, // accum bits ignored - (BYTE)depth, - (BYTE)stencil, - num_aux_buffers, - PFD_MAIN_PLANE, // main layer - 0, // reserved - 0, 0, 0 // layer masks ignored - }; - // get the best available match of pixel format for the device context - iPixelFormat = ChoosePixelFormat(hdc, &pfd); - if (iPixelFormat == 0) { - printfDebugJava(env, "Failed to choose pixel format"); - return -1; - } - - if (DescribePixelFormat(hdc, iPixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &desc) == 0) { - printfDebugJava(env, "Could not describe pixel format"); - return -1; - } - - if (desc.cColorBits < bpp) { - printfDebugJava(env, "Insufficient color precision"); - return -1; - } - - if (desc.cAlphaBits < alpha) { - printfDebugJava(env, "Insufficient alpha precision"); - return -1; - } - - if (desc.cStencilBits < stencil) { - printfDebugJava(env, "Insufficient stencil precision"); - return -1; - } - - if (desc.cDepthBits < depth) { - printfDebugJava(env, "Insufficient depth buffer precision"); - return -1; - } - - if ((desc.dwFlags & PFD_GENERIC_FORMAT) != 0 || (desc.dwFlags & PFD_GENERIC_ACCELERATED) != 0) { - jboolean allowSoftwareOpenGL = getBooleanProperty(env, "org.lwjgl.opengl.Display.allowSoftwareOpenGL"); - // secondary check for software override - if(!allowSoftwareOpenGL) { - printfDebugJava(env, "Pixel format not accelerated"); - return -1; - } - } - - if ((desc.dwFlags & flags) != flags) { - printfDebugJava(env, "Capabilities not supported"); - return -1; - } - - return iPixelFormat; -} - -int findPixelFormat(JNIEnv *env, HDC hdc, jobject pixel_format) { - int bpp = GetDeviceCaps(hdc, BITSPIXEL); - int iPixelFormat; - iPixelFormat = findPixelFormatFromBPP(env, hdc, pixel_format, bpp); - if (iPixelFormat == -1) { - return findPixelFormatFromBPP(env, hdc, pixel_format, 16); - } else - return iPixelFormat; -} -*/ /* * Called when the application is alt-tabbed to or from */ @@ -408,36 +213,6 @@ } /* - * Register the LWJGL window class. - * Returns true for success, or false for failure - */ -/*static bool registerWindow() -{ - WNDCLASS windowClass; - if (!oneShotInitialised) { - windowClass.style = CS_OWNDC; - windowClass.lpfnWndProc = lwjglWindowProc; - windowClass.cbClsExtra = 0; - windowClass.cbWndExtra = 0; - windowClass.hInstance = dll_handle; - windowClass.hIcon = LoadIcon(NULL, IDI_APPLICATION); - windowClass.hCursor = LoadCursor(NULL, IDC_ARROW); - windowClass.hbrBackground = NULL; - windowClass.lpszMenuName = NULL; - windowClass.lpszClassName = WINDOWCLASSNAME; - - if (RegisterClass(&windowClass) == 0) { - printfDebug("Failed to register window class\n"); - return false; - } - printfDebug("Window registered\n"); - oneShotInitialised = true; - } - - return true; -} -*/ -/* * Handle native Win32 messages */ void handleMessages(void) @@ -473,11 +248,6 @@ free(title); } -/* - * Class: org_lwjgl_Window - * Method: update - * Signature: ()V - */ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_nUpdate (JNIEnv * env, jobject self) { @@ -485,23 +255,6 @@ } -/* - * Class: org_lwjgl_Window - * Method: swapBuffers - * Signature: ()V - */ -/*JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_swapBuffers - (JNIEnv * env, jobject self) -{ - isDirty = false; - SwapBuffers(display_hdc); -} -*/ -/* - * Class: org_lwjgl_opengl_Window - * Method: nIsDirty - * Signature: ()Z - */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Win32Display_isDirty (JNIEnv *env, jobject self) { bool result = isDirty; @@ -509,21 +262,11 @@ return result ? JNI_TRUE : JNI_FALSE; } -/* - * Class: org_lwjgl_opengl_Window - * Method: nIsVisible - * Signature: ()Z - */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Win32Display_isVisible (JNIEnv *env, jobject self) { return isMinimized ? JNI_FALSE : JNI_TRUE; } -/* - * Class: org_lwjgl_opengl_Window - * Method: nIsCloseRequested - * Signature: ()Z - */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Win32Display_isCloseRequested (JNIEnv *env, jobject self) { bool saved = closerequested; @@ -531,41 +274,11 @@ return saved; } -/* - * Class: org_lwjgl_opengl_Window - * Method: nIsActive - * Signature: ()Z - */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Win32Display_isActive (JNIEnv *env, jobject self) { return isFocused; } -/* - * Class: org_lwjgl_opengl_Window - * Method: nSetVSyncEnabled - * Signature: (Z)Z - */ -/*JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_setVSyncEnabled - (JNIEnv * env, jobject self, jboolean sync) -{ - if (extension_flags.WGL_EXT_swap_control) { - if (sync == JNI_TRUE) { - wglSwapIntervalEXT(1); - } else { - wglSwapIntervalEXT(0); - } - } -} - -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_makeCurrent - (JNIEnv *env, jobject self) -{ - BOOL result = wglMakeCurrent(display_hdc, display_hglrc); - if (!result) - throwException(env, "Could not make display context current"); -} -*/ JNIEXPORT jobjectArray JNICALL Java_org_lwjgl_opengl_Win32Display_getAvailableDisplayModes(JNIEnv *env, jobject self) { return getAvailableDisplayModes(env); } @@ -598,12 +311,6 @@ return; } display_hdc = GetDC(display_hwnd); -/* if (!applyPixelFormat(display_hdc, pixel_format_index)) { - closeWindow(&display_hwnd, &display_hdc); - throwException(env, "Could not apply pixel format to window"); - return; - } -*/ ShowWindow(display_hwnd, SW_SHOWDEFAULT); UpdateWindow(display_hwnd); SetForegroundWindow(display_hwnd); @@ -642,119 +349,6 @@ return initDisplay(env); } -/*bool createARBContextAndPixelFormat(JNIEnv *env, HDC hdc, jobject pixel_format, int *pixel_format_index_return, HGLRC *context_return) { - int pixel_format_index; - HWND arb_hwnd; - HDC arb_hdc; - HGLRC arb_context; - - // Some crazy strangeness here so we can use ARB_pixel_format to specify the number - // of multisamples we want. If the extension is present we'll delete the existing - // rendering context and start over, using the ARB extension instead to pick the context. - if (!extension_flags.WGL_ARB_pixel_format) - return false; - pixel_format_index = findPixelFormatARB(env, hdc, pixel_format, NULL, true, true, true, true); - if (pixel_format_index == -1) { - pixel_format_index = findPixelFormatARB(env, hdc, pixel_format, NULL, true, true, false, true); - if ( pixel_format_index == -1) - return false; - } - - arb_hwnd = createWindow(0, 0, 1, 1, false, false); - if (arb_hwnd == NULL) - return false; - - arb_hdc = GetDC(arb_hwnd); - if (!applyPixelFormat(arb_hdc, pixel_format_index)) { - closeWindow(&arb_hwnd, &arb_hdc); - return false; - } - - arb_context = wglCreateContext(arb_hdc); - if (arb_context == NULL) { - closeWindow(&arb_hwnd, &arb_hdc); - return false; - } - if (!wglMakeCurrent(arb_hdc, arb_context)) { - wglDeleteContext(arb_context); - closeWindow(&arb_hwnd, &arb_hdc); - return false; - } - - extgl_InitWGL(env); - wglMakeCurrent(NULL, NULL); - closeWindow(&arb_hwnd, &arb_hdc); - *pixel_format_index_return = pixel_format_index; - *context_return = arb_context; - - return true; -} -*/ -/*JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_createContext(JNIEnv *env, jobject self, jobject pixel_format) { - HWND dummy_hwnd; - HDC dummy_hdc; - BOOL result; - jclass cls_pixel_format; - int samples; - int pixel_format_index_arb; - HGLRC context_arb; - bool arb_success; - dummy_hwnd = createWindow(0, 0, 1, 1, false, false); - if (dummy_hwnd == NULL) { - throwException(env, "Failed to create the window."); - return; - } - dummy_hdc = GetDC(dummy_hwnd); - pixel_format_index = findPixelFormat(env, dummy_hdc, pixel_format); - if (pixel_format_index == -1) { - return; - } - if (!applyPixelFormat(dummy_hdc, pixel_format_index)) { - closeWindow(&dummy_hwnd, &dummy_hdc); - throwException(env, "Could not apply pixel format to window"); - return; - } - display_hglrc = wglCreateContext(dummy_hdc); - if (display_hglrc == NULL) { - closeWindow(&dummy_hwnd, &dummy_hdc); - throwException(env, "Failed to create OpenGL rendering context"); - return; - } - result = wglMakeCurrent(dummy_hdc, display_hglrc); - if (!result) { - throwException(env, "Could not bind context to dummy window"); - wglDeleteContext(display_hglrc); - closeWindow(&dummy_hwnd, &dummy_hdc); - return; - } - extgl_InitWGL(env); - cls_pixel_format = (*env)->GetObjectClass(env, pixel_format); - samples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "samples", "I")); - if (samples > 0) { - arb_success = createARBContextAndPixelFormat(env, dummy_hdc, pixel_format, &pixel_format_index_arb, &context_arb); - closeWindow(&dummy_hwnd, &dummy_hdc); - wglDeleteContext(display_hglrc); - if (!arb_success) { - throwException(env, "Samples > 0 but could not find a suitable ARB pixel format"); - return; - } - display_hglrc = context_arb; - pixel_format_index = pixel_format_index_arb; - } else - closeWindow(&dummy_hwnd, &dummy_hdc); -} - -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_destroyContext(JNIEnv *env, jobject self) { - wglMakeCurrent(NULL, NULL); - - // Delete the rendering context - if (display_hglrc != NULL) { - printfDebug("Deleting GL context\n"); - wglDeleteContext(display_hglrc); - display_hglrc = NULL; - } -} -*/ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_reshape(JNIEnv *env, jobject self, jint x, jint y, jint width, jint height) { int exstyle, windowflags; RECT clientSize; Index: Window.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/Window.h,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- Window.h 21 Feb 2005 14:46:47 -0000 1.23 +++ Window.h 23 Feb 2005 11:42:04 -0000 1.24 @@ -64,12 +64,6 @@ WINDOW_H_API HDC getCurrentHDC(); -// WINDOW_H_API HGLRC getCurrentContext(); - -// WINDOW_H_API bool applyPixelFormat(HDC hdc, int iPixelFormat); - -// WINDOW_H_API void closeWindow(HWND *hwnd, HDC *hdc); - WINDOW_H_API void handleMouseMoved(int x, int y); WINDOW_H_API void handleMouseScrolled(int dwheel); @@ -79,17 +73,6 @@ WINDOW_H_API void handleMessages(void); /* - * Find a suitable pixel format - */ -// WINDOW_H_API int findPixelFormat(JNIEnv *env, HDC hdc, jobject pixel_format); - - /* - * Find a suitable pixel format using the WGL_ARB_pixel_format extension - */ -// WINDOW_H_API int findPixelFormatARB(JNIEnv *env, HDC hdc, jobject pixel_format, jobject pixelFormatCaps, bool use_hdc_bpp, bool window, bool pbuffer, bool double_buffer); - - - /* * Handle native Win32 messages */ WINDOW_H_API void handleMessage(JNIEnv * env, jobject obj); |
|
From: Elias N. <eli...@us...> - 2005-02-23 11:42:13
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/macosx In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26806/macosx Modified Files: org_lwjgl_opengl_Display.m Log Message: Clean out commented code Index: org_lwjgl_opengl_Display.m =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_opengl_Display.m,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- org_lwjgl_opengl_Display.m 23 Feb 2005 11:11:07 -0000 1.8 +++ org_lwjgl_opengl_Display.m 23 Feb 2005 11:42:03 -0000 1.9 @@ -49,131 +49,6 @@ #define WAIT_DELAY 100 -/*static NSOpenGLContext *gl_context; - -NSOpenGLContext *createContext(JNIEnv *env, jobject pixel_format, bool double_buffered, bool use_display_bpp, long drawable_type, NSOpenGLContext *share_context) { - int bpp; - jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format); - if (use_display_bpp) - bpp = CGDisplayBitsPerPixel(kCGDirectMainDisplay); - else - bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "bpp", "I")); - - 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")); - int stencil = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stencil", "I")); - int samples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "samples", "I")); - 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")); - - attrib_list_t attribs; - jboolean allow_software_acceleration = getBooleanProperty(env, "org.lwjgl.opengl.Display.allowSoftwareOpenGL"); - initAttribList(&attribs); - if (!allow_software_acceleration) - putAttrib(&attribs, NSOpenGLPFAAccelerated); - if (double_buffered) - putAttrib(&attribs, NSOpenGLPFADoubleBuffer); - putAttrib(&attribs, NSOpenGLPFAColorSize); putAttrib(&attribs, bpp); - putAttrib(&attribs, NSOpenGLPFAAlphaSize); putAttrib(&attribs, alpha); - putAttrib(&attribs, NSOpenGLPFADepthSize); putAttrib(&attribs, depth); - putAttrib(&attribs, NSOpenGLPFAStencilSize); putAttrib(&attribs, stencil); - putAttrib(&attribs, NSOpenGLPFAAccumSize); putAttrib(&attribs, accum_bpp + accum_alpha); - putAttrib(&attribs, NSOpenGLPFASampleBuffers); putAttrib(&attribs, samples > 0 ? 1 : 0); - putAttrib(&attribs, NSOpenGLPFASamples); putAttrib(&attribs, samples); - putAttrib(&attribs, NSOpenGLPFAAuxBuffers); putAttrib(&attribs, num_aux_buffers); - putAttrib(&attribs, drawable_type); - if (stereo) - putAttrib(&attribs, NSOpenGLPFAStereo); - putAttrib(&attribs, 0); - NSOpenGLPixelFormat* fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:(NSOpenGLPixelFormatAttribute *)attribs.attribs]; - - if (fmt == nil) { - throwException(env, "Could not create pixel format"); - return NULL; - } - - NSOpenGLContext *context = [[NSOpenGLContext alloc] initWithFormat:fmt shareContext:share_context]; - - [fmt release]; - if (context == nil) - throwException(env, "Could not create context"); - return context; -} - -NSOpenGLContext *getDisplayContext() { - return gl_context; -} - -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_createContext(JNIEnv *env, jobject this, jobject pixel_format) { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - gl_context = createContext(env, pixel_format, true, true, NSOpenGLPFAWindow, nil); - [pool release]; -} - -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_updateContext(JNIEnv *env, jobject this) { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - [gl_context update]; - [pool release]; -} - -static void setView(JNIEnv *env, jobject canvas) { - JAWT awt; - JAWT_DrawingSurface* ds; - JAWT_DrawingSurfaceInfo* dsi; - JAWT_MacOSXDrawingSurfaceInfo* dsi_mac; - jboolean result = JNI_FALSE; - jint lock = 0; - - // get the AWT - awt.version = JAWT_VERSION_1_4; - NSView *view; - while (true) { - result = JAWT_GetAWT(env, &awt); - if (result == JNI_FALSE) { - throwException(env, "Could not get the JAWT interface"); - return; - } - - ds = awt.GetDrawingSurface(env, canvas); - if (ds == NULL) { - throwException(env, "Could not get the drawing surface"); - return; - } - - lock = ds->Lock(ds); - if((lock & JAWT_LOCK_ERROR) != 0) { - awt.FreeDrawingSurface(ds); - throwException(env, "Could not lock the drawing surface"); - return; - } - - dsi = ds->GetDrawingSurfaceInfo(ds); - if (dsi != NULL) { - dsi_mac = (JAWT_MacOSXDrawingSurfaceInfo*)dsi->platformInfo; - view = dsi_mac->cocoaViewRef; - if ([view lockFocusIfCanDraw] == YES) - break; - view = NULL; - ds->FreeDrawingSurfaceInfo(dsi); - } - - printfDebug("Could not get drawing surface info, retrying... \n"); - ds->Unlock(ds); - awt.FreeDrawingSurface(ds); - usleep(WAIT_DELAY); - } - - [gl_context setView:view]; - - [view unlockFocus]; - - ds->FreeDrawingSurfaceInfo(dsi); - ds->Unlock(ds); - awt.FreeDrawingSurface(ds); -} -*/ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_restoreGamma(JNIEnv *env, jobject this) { CGDisplayRestoreColorSyncSettings(); } @@ -194,43 +69,3 @@ SetSystemUIMode(kUIModeNormal, 0); } } -/* -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_setVSyncEnabled(JNIEnv *env, jobject this, jboolean vsync) { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - long vsync_value = vsync == JNI_TRUE ? 1 : 0; - [gl_context setValues:&vsync_value forParameter:NSOpenGLCPSwapInterval]; - [pool release]; -} - -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_swapBuffers(JNIEnv *env, jobject this) { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - [gl_context flushBuffer]; - [pool release]; -} - -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_setView(JNIEnv *env, jobject this, jobject canvas) { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - if (canvas != NULL) { - setView(env, canvas); - } else { - [gl_context clearDrawable]; - } - [pool release]; -} - -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_makeCurrent(JNIEnv *env, jobject this) { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - [gl_context makeCurrentContext]; - [pool release]; -} - -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_destroyContext(JNIEnv *env, jobject this) { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - if (gl_context != nil) { - [gl_context clearDrawable]; - [gl_context release]; - gl_context = nil; - } - [pool release]; -} -*/ |
|
From: Elias N. <eli...@us...> - 2005-02-23 11:38:34
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25828 Modified Files: org_lwjgl_opengl_Display.c org_lwjgl_opengl_Pbuffer.c Log Message: Clean out commented code Index: org_lwjgl_opengl_Pbuffer.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_opengl_Pbuffer.c,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- org_lwjgl_opengl_Pbuffer.c 20 Feb 2005 11:24:22 -0000 1.12 +++ org_lwjgl_opengl_Pbuffer.c 23 Feb 2005 11:38:24 -0000 1.13 @@ -46,12 +46,7 @@ #include "context.h" #include "Window.h" #include "common_tools.h" -/* -typedef struct _PbufferInfo { - GLXPbuffer buffer; - GLXContext context; -} PbufferInfo; -*/ + static bool isPbuffersSupported() { // Only support the GLX 1.3 Pbuffers and ignore the GLX_SGIX_pbuffer extension return extension_flags.GLX13 ? org_lwjgl_opengl_Pbuffer_PBUFFER_SUPPORTED : 0; @@ -63,67 +58,6 @@ return isPbuffersSupported() ? org_lwjgl_opengl_Pbuffer_PBUFFER_SUPPORTED : 0; } -/*static void destroyPbuffer(PbufferInfo *buffer_info) { - GLXPbuffer buffer = buffer_info->buffer; - GLXContext context = buffer_info->context; - glXDestroyPbuffer(getDisplay(), buffer); - releaseContext(context); - glXDestroyContext(getDisplay(), context); -} -*/ -/*static bool checkPbufferCaps(JNIEnv *env, GLXFBConfig config, int width, int height) { - int max; - int result = glXGetFBConfigAttrib(getDisplay(), config, GLX_MAX_PBUFFER_WIDTH, &max); - if (result != Success) { - throwException(env, "Could not get GLX_MAX_PBUFFER_WIDTH from configuration"); - return false; - } - if (max < width) { - throwException(env, "Width too large"); - return false; - } - result = glXGetFBConfigAttrib(getDisplay(), config, GLX_MAX_PBUFFER_HEIGHT, &max); - if (result != Success) { - throwException(env, "Could not get GLX_MAX_PBUFFER_WIDTH from configuration"); - return false; - } - if (max < height) { - throwException(env, "Height too large"); - return false; - } - return true; -} - -static bool createPbufferUsingUniqueContext(JNIEnv *env, PbufferInfo *pbuffer_info, jobject pixel_format, int width, int height, const int *buffer_attribs, GLXContext shared_context) { - GLXFBConfig *configs = chooseVisualGLX13(env, getDisplay(), getCurrentScreen(), pixel_format, false, GLX_PBUFFER_BIT, false); - if (configs == NULL) { - throwException(env, "No matching pixel format"); - return false; - } - if (!checkPbufferCaps(env, configs[0], width, height)) { - XFree(configs); - return false; - } - GLXContext context = glXCreateNewContext(getDisplay(), configs[0], GLX_RGBA_TYPE, shared_context, True); - if (context == NULL) { - XFree(configs); - throwException(env, "Could not create a GLX context"); - return false; - } - jboolean allow_software_acceleration = getBooleanProperty(env, "org.lwjgl.opengl.Display.allowSoftwareOpenGL"); - if (!allow_software_acceleration && glXIsDirect(getDisplay(), context) == False) { - glXDestroyContext(getDisplay(), context); - XFree(configs); - throwException(env, "Could not create a direct GLX context"); - return false; - } - GLXPbuffer buffer = glXCreatePbuffer(getDisplay(), configs[0], buffer_attribs); - XFree(configs); - pbuffer_info->context = context; - pbuffer_info->buffer = buffer; - return true; -} -*/ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxPbufferPeerInfo_nInitHandle (JNIEnv *env, jclass clazz, jobject peer_info_handle, jint width, jint height, jobject pixel_format) { if (!extgl_InitGLX(env, getDisplay(), getCurrentScreen()) || !isPbuffersSupported()) { @@ -151,55 +85,3 @@ X11PeerInfo *peer_info = (X11PeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); glXDestroyPbuffer(peer_info->display, peer_info->drawable); } -/* -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreatePbuffer(JNIEnv *env, jclass clazz, jobject handle_buffer, jint width, jint height, jobject pixel_format, jobject pixelFormatCaps, jobject pBufferAttribs, jobject shared_context_handle_buffer) -{ - if ((*env)->GetDirectBufferCapacity(env, handle_buffer) < sizeof(PbufferInfo)) { - throwException(env, "Handle buffer not large enough"); - return; - } - int current_screen = getCurrentScreen(); - if (!extgl_InitGLX(env, getDisplay(), current_screen) || !isPbuffersSupported()) { - throwException(env, "No Pbuffer support"); - return; - } - - const int buffer_attribs[] = {GLX_PBUFFER_WIDTH, width, - GLX_PBUFFER_HEIGHT, height, - GLX_PRESERVED_CONTENTS, True, - GLX_LARGEST_PBUFFER, False, - None, None}; - - GLXContext shared_context = getDisplayContext(); - if (shared_context_handle_buffer != NULL) { - PbufferInfo *shared_buffer_info = (PbufferInfo *)(*env)->GetDirectBufferAddress(env, shared_context_handle_buffer); - shared_context = shared_buffer_info->context; - } - PbufferInfo *buffer_info = (PbufferInfo *)(*env)->GetDirectBufferAddress(env, handle_buffer); - bool result; - result = createPbufferUsingUniqueContext(env, buffer_info, pixel_format, width, height, buffer_attribs, shared_context); - if (!result) - return; - if (!checkXError(env, getDisplay())) { - destroyPbuffer(buffer_info); - return; - } -} - -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nMakePbufferCurrent - (JNIEnv *env, jclass clazz, jobject handle_buffer) -{ - PbufferInfo *buffer_info = (PbufferInfo *)(*env)->GetDirectBufferAddress(env, handle_buffer); - GLXPbuffer buffer = buffer_info->buffer; - GLXContext context = buffer_info->context; - if (glXMakeContextCurrent(getDisplay(), buffer, buffer, context) == False) { - throwException(env, "Could not make pbuffer context current"); - } -} - -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nDestroyPbuffer - (JNIEnv *env, jclass clazz, jobject handle_buffer) -{ - PbufferInfo *buffer_info = (PbufferInfo *)(*env)->GetDirectBufferAddress(env, handle_buffer); - destroyPbuffer(buffer_info); -}*/ Index: org_lwjgl_opengl_Display.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- org_lwjgl_opengl_Display.c 20 Feb 2005 11:24:22 -0000 1.24 +++ org_lwjgl_opengl_Display.c 23 Feb 2005 11:38:24 -0000 1.25 @@ -56,7 +56,6 @@ #include "org_lwjgl_opengl_LinuxDisplay.h" #include "org_lwjgl_opengl_LinuxDisplayPeerInfo.h" -//#define USEGLX13 extension_flags.GLX13 #define ERR_MSG_SIZE 1024 typedef struct { @@ -71,10 +70,7 @@ typedef enum {FULLSCREEN_LEGACY, FULLSCREEN_NETWM, WINDOWED} window_mode; -//static GLXContext display_context = NULL; // OpenGL rendering context -//static GLXFBConfig *configs = NULL; static GLXWindow glx_window = None; -//static XVisualInfo *vis_info = NULL; static Atom delete_atom; static Colormap cmap; @@ -99,10 +95,6 @@ static char error_message[ERR_MSG_SIZE]; static Atom warp_atom; -/*GLXContext getDisplayContext(void) { - return display_context; -} -*/ int getCurrentScreen(void) { return current_screen; } @@ -468,103 +460,6 @@ handleMessages(env); } -/*bool releaseContext(GLXContext context) { - if (glXGetCurrentContext() != context) - return true; - if (USEGLX13) - return glXMakeContextCurrent(getDisplay(), None, None, NULL) == True; - else - return glXMakeCurrent(getDisplay(), None, NULL) == True; -} - -static bool makeCurrent(void) { - if (USEGLX13) - return glXMakeContextCurrent(getDisplay(), glx_window, glx_window, display_context) == True; - else - return glXMakeCurrent(getDisplay(), getCurrentWindow(), display_context) == True; -} - -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nMakeCurrent - (JNIEnv *env, jclass clazz) -{ - if (!makeCurrent()) - throwException(env, "Could not make display context current"); -} -*/ -/*static void destroyContext(void) { - if (USEGLX13) { - XFree(configs); - configs = NULL; - } - XFree(vis_info); - vis_info = NULL; - releaseContext(display_context); - glXDestroyContext(getDisplay(), display_context); - display_context = NULL; -} -*/ -/*static bool initWindowGLX13(JNIEnv *env, jobject pixel_format) { - configs = chooseVisualGLX13(env, getDisplay(), getCurrentScreen(), pixel_format, true, GLX_WINDOW_BIT, true); - if (configs == NULL) { - throwException(env, "Could not find a matching pixel format"); - return false; - } - display_context = glXCreateNewContext(getDisplay(), configs[0], GLX_RGBA_TYPE, NULL, True); - if (display_context == NULL) { - XFree(configs); - throwException(env, "Could not create a GLX context"); - return false; - } - jboolean allow_software_acceleration = getBooleanProperty(env, "org.lwjgl.opengl.Display.allowSoftwareOpenGL"); - if (!allow_software_acceleration && (glXIsDirect(getDisplay(), display_context) == False)) { - glXDestroyContext(getDisplay(), display_context); - XFree(configs); - throwException(env, "Could not create a direct GLX context"); - return false; - } - vis_info = glXGetVisualFromFBConfig(getDisplay(), configs[0]); - if (vis_info == NULL) { - glXDestroyContext(getDisplay(), display_context); - XFree(configs); - throwException(env, "Could not get visual from FB config"); - return false; - } - if (!checkXError(env, getDisplay())) { - glXDestroyContext(getDisplay(), display_context); - XFree(configs); - XFree(vis_info); - return false; - } - return true; -} - -static bool initWindowGLX(JNIEnv *env, jobject pixel_format) { - vis_info = chooseVisualGLX(env, getDisplay(), getCurrentScreen(), pixel_format, true, true); - if (vis_info == NULL) { - throwException(env, "Could not find a matching pixel format"); - return false; - } - display_context = glXCreateContext(getDisplay(), vis_info, NULL, True); - if (display_context == NULL) { - XFree(vis_info); - throwException(env, "Could not create a GLX context"); - return false; - } - jboolean allow_software_acceleration = getBooleanProperty(env, "org.lwjgl.opengl.Display.allowSoftwareOpenGL"); - if (!allow_software_acceleration && glXIsDirect(getDisplay(), display_context) == False) { - glXDestroyContext(getDisplay(), display_context); - XFree(vis_info); - throwException(env, "Could not create a direct GLX context"); - return false; - } - if (!checkXError(env, getDisplay())) { - glXDestroyContext(getDisplay(), display_context); - XFree(vis_info); - return false; - } - return true; -} -*/ JNIEXPORT jobjectArray JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetAvailableDisplayModes(JNIEnv *env, jclass clazz) { return getAvailableDisplayModes(env, getCurrentScreen()); } @@ -589,33 +484,6 @@ return initDisplay(env, getCurrentScreen()); } -/*JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateContext(JNIEnv *env, jclass clazz, jobject pixel_format) { - Display *disp = incDisplay(env); - if (disp == NULL) { - return; - } - current_screen = XDefaultScreen(disp); - if (!extgl_InitGLX(env, disp, current_screen)) { - decDisplay(); - throwException(env, "Could not init GLX"); - return; - } - - bool result; - if (USEGLX13) { - result = initWindowGLX13(env, pixel_format); - } else { - result = initWindowGLX(env, pixel_format); - } - if (!result) - decDisplay(); -} -*/ -/*JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nDestroyContext(JNIEnv *env, jclass clazz) { - destroyContext(); - decDisplay(); -} -*/ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateWindow(JNIEnv *env, jclass clazz, jobject peer_info_handle, jobject mode, jboolean fullscreen, jint x, jint y) { bool current_fullscreen = fullscreen == JNI_TRUE; if (current_fullscreen) { @@ -658,15 +526,6 @@ destroyWindow(env); } -/*JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSwapBuffers(JNIEnv * env, jclass clazz) -{ - dirty = false; - if (USEGLX13) - glXSwapBuffers(getDisplay(), glx_window); - else - glXSwapBuffers(getDisplay(), getCurrentWindow()); -} -*/ JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nIsDirty (JNIEnv *env, jclass clazz) { bool result = dirty; @@ -691,19 +550,6 @@ return focused || isLegacyFullscreen() ? JNI_TRUE : JNI_FALSE; } -/*JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetVSyncEnabled - (JNIEnv *env, jclass clazz, jboolean sync) -{ - if (extension_flags.GLX_SGI_swap_control) { - bool vsync = sync == JNI_TRUE ? true : false; - if (vsync != vsync_enabled) { - int interval = vsync ? 1 : 0; - glXSwapIntervalSGI(interval); - vsync_enabled = vsync; - } - } -} -*/ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_lockAWT(JNIEnv *env, jclass clazz) { JAWT jawt; jawt.version = JAWT_VERSION_1_4; |
|
From: Elias N. <eli...@us...> - 2005-02-23 11:22:24
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22284/src/java/org/lwjgl Modified Files: LinuxSysImplementation.java Sys.java Log Message: Linux: Make sure libjawt.so can be loaded Index: LinuxSysImplementation.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/LinuxSysImplementation.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- LinuxSysImplementation.java 3 Feb 2005 13:51:45 -0000 1.3 +++ LinuxSysImplementation.java 23 Feb 2005 11:22:14 -0000 1.4 @@ -40,6 +40,10 @@ * @version $Revision$ */ class LinuxSysImplementation extends J2SESysImplementation { + static { + java.awt.Toolkit.getDefaultToolkit(); // This will make sure libjawt.so is loaded + } + public boolean openURL(String url) { // Linux may as well resort to pure Java hackery, as there's no Linux native way of doing it // right anyway. Index: Sys.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/Sys.java,v retrieving revision 1.78 retrieving revision 1.79 diff -u -d -r1.78 -r1.79 --- Sys.java 21 Feb 2005 15:58:24 -0000 1.78 +++ Sys.java 23 Feb 2005 11:22:14 -0000 1.79 @@ -63,8 +63,8 @@ private final static SysImplementation implementation; static { - System.loadLibrary(LIBRARY_NAME); implementation = createImplementation(); + System.loadLibrary(LIBRARY_NAME); String native_version = implementation.getNativeLibraryVersion(); if (!native_version.equals(VERSION)) throw new LinkageError("Version mismatch: jar version is '" + VERSION + |