From: <sp...@us...> - 2011-05-21 10:48:14
|
Revision: 3537 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3537&view=rev Author: spasi Date: 2011-05-21 10:48:05 +0000 (Sat, 21 May 2011) Log Message: ----------- Added support for NV_present_video and NV_video_capture. Re-designed WindowsPeerInfo so that we can more easily use WGL extensions in the future. Modified Paths: -------------- branches/opengles/LWJGL/build.xml branches/opengles/LWJGL/src/native/common/opengl/extgl.h branches/opengles/LWJGL/src/native/linux/opengl/extgl_glx.c branches/opengles/LWJGL/src/native/linux/opengl/extgl_glx.h branches/opengles/LWJGL/src/native/windows/opengl/context.h branches/opengles/LWJGL/src/native/windows/opengl/extgl_wgl.c branches/opengles/LWJGL/src/native/windows/opengl/extgl_wgl.h branches/opengles/LWJGL/src/native/windows/opengl/org_lwjgl_opengl_Pbuffer.c branches/opengles/LWJGL/src/native/windows/opengl/org_lwjgl_opengl_WindowsContextImplementation.c branches/opengles/LWJGL/src/native/windows/opengles/context.h Added Paths: ----------- branches/opengles/LWJGL/src/java/org/lwjgl/opengl/NVPresentVideoUtil.java branches/opengles/LWJGL/src/java/org/lwjgl/opengl/NVVideoCaptureUtil.java branches/opengles/LWJGL/src/native/common/opengl/org_lwjgl_opengl_NVPresentVideoUtil.c branches/opengles/LWJGL/src/native/common/opengl/org_lwjgl_opengl_NVVideoCaptureUtil.c branches/opengles/LWJGL/src/native/linux/opengl/GLX.c branches/opengles/LWJGL/src/native/linux/opengl/GLX.h branches/opengles/LWJGL/src/native/windows/opengl/WGL.c branches/opengles/LWJGL/src/native/windows/opengl/WGL.h branches/opengles/LWJGL/src/templates/org/lwjgl/opengl/NV_present_video.java branches/opengles/LWJGL/src/templates/org/lwjgl/opengl/NV_video_capture.java Modified: branches/opengles/LWJGL/build.xml =================================================================== --- branches/opengles/LWJGL/build.xml 2011-05-17 17:26:33 UTC (rev 3536) +++ branches/opengles/LWJGL/build.xml 2011-05-21 10:48:05 UTC (rev 3537) @@ -49,6 +49,7 @@ <!-- Useful when we need to force native recompilation --> <target name="clean-native" description="Cleans native files generated by this ant script" depends="clean-generated-native"> <delete dir="${lwjgl.bin}/lwjgl" quiet="true" failonerror="false" taskname="cleaning native bin folder" /> + <delete dir="${lwjgl.bin}/lwjgles" quiet="true" failonerror="false" taskname="cleaning native OpenGL ES bin folder"/> </target> <!-- Creates a distribution of LWJGL --> @@ -305,6 +306,8 @@ <class name="org.lwjgl.opengl.GLContext"/> <class name="org.lwjgl.opengl.Pbuffer"/> <class name="org.lwjgl.opengl.CallbackUtil"/> + <class name="org.lwjgl.opengl.NVPresentVideoUtil"/> + <class name="org.lwjgl.opengl.NVVideoCaptureUtil"/> </javah> <javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.headers}/opengles" force="yes"> Added: branches/opengles/LWJGL/src/java/org/lwjgl/opengl/NVPresentVideoUtil.java =================================================================== --- branches/opengles/LWJGL/src/java/org/lwjgl/opengl/NVPresentVideoUtil.java (rev 0) +++ branches/opengles/LWJGL/src/java/org/lwjgl/opengl/NVPresentVideoUtil.java 2011-05-21 10:48:05 UTC (rev 3537) @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2002-2011 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.lwjgl.opengl; + +import org.lwjgl.BufferChecks; +import org.lwjgl.LWJGLUtil; + +import java.nio.ByteBuffer; +import java.nio.IntBuffer; +import java.nio.LongBuffer; + +/** + * This class exposes the platform specific functionality present in the + * NV_present_video extension. + * + * @author Spasi + * @since 20/5/2011 + */ +public final class NVPresentVideoUtil { + + private NVPresentVideoUtil() {} + + private static void checkExtension() { + if ( LWJGLUtil.CHECKS && !GLContext.getCapabilities().GL_NV_present_video ) + throw new IllegalStateException("NV_present_video is not supported"); + } + + private static ByteBuffer getPeerInfo() { + return ContextGL.getCurrentContext().getPeerInfo().getHandle(); + } + + /** + * Enumerate the available video output devices. This method is the cross-platform + * equivalent of glXEnumerateVideoDevicesNV and wglEnumerateVideoDevicesNV. Since they are + * not really compatible, this method works like the WGL version. That is, you first + * call it with a null devices buffer, get the number of devices, then call it again + * with an appropriately sized buffer. + * + * @param devices the buffer to store devices in + * + * @return the number of available video output devices + */ + public static int glEnumerateVideoDevicesNV(LongBuffer devices) { + checkExtension(); + + if ( devices != null ) + BufferChecks.checkBuffer(devices, 1); + return nglEnumerateVideoDevicesNV(getPeerInfo(), devices, devices == null ? 0 : devices.position()); + } + + private static native int nglEnumerateVideoDevicesNV(ByteBuffer peer_info, LongBuffer devices, int devices_position); + + /** + * Binds the video output device specified to one of the context's available video output slots. + * This method is the cross-platform equivalent of glXBindVideoDeviceNV and wglBindVideoDeviceNV. + * To release a video device without binding another device to the same slot, call it with + * video_device set to 0 (will use INVALID_HANDLE_VALUE on WGL). + * + * @param video_slot the video slot + * @param video_device the video device + * @param attrib_list the attributes to use + * + * @return true if the binding was successful + */ + public static boolean glBindVideoDeviceNV(int video_slot, long video_device, IntBuffer attrib_list) { + checkExtension(); + + if ( attrib_list != null ) + BufferChecks.checkNullTerminated(attrib_list); + return nglBindVideoDeviceNV(getPeerInfo(), video_slot, video_device, attrib_list, attrib_list == null ? 0 : attrib_list.position()); + } + + private static native boolean nglBindVideoDeviceNV(ByteBuffer peer_info, int video_slot, long video_device, IntBuffer attrib_list, int attrib_list_position); + + /** + * Queries an attribute associated with the current context. This method is the cross-platform + * equivalent of glXQueryContext and wglQueryCurrentContextNV. + * + * @param attrib the attribute to query + * @param value the buffer to store the value in + */ + public static boolean glQueryContextNV(int attrib, IntBuffer value) { + checkExtension(); + + BufferChecks.checkBuffer(value, 1); + ContextGL ctx = ContextGL.getCurrentContext(); + return nglQueryContextNV(ctx.getPeerInfo().getHandle(), ctx.getHandle(), attrib, value, value.position()); + } + + private static native boolean nglQueryContextNV(ByteBuffer peer_info, ByteBuffer context_handle, int attrib, IntBuffer value, int value_position); + +} Added: branches/opengles/LWJGL/src/java/org/lwjgl/opengl/NVVideoCaptureUtil.java =================================================================== --- branches/opengles/LWJGL/src/java/org/lwjgl/opengl/NVVideoCaptureUtil.java (rev 0) +++ branches/opengles/LWJGL/src/java/org/lwjgl/opengl/NVVideoCaptureUtil.java 2011-05-21 10:48:05 UTC (rev 3537) @@ -0,0 +1,153 @@ +/* + * Copyright (c) 2002-2011 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.lwjgl.opengl; + +import org.lwjgl.BufferChecks; +import org.lwjgl.LWJGLUtil; + +import java.nio.ByteBuffer; +import java.nio.IntBuffer; +import java.nio.LongBuffer; + +/** + * This class exposes the platform specific functionality present in the + * NV_video_capture extension. + * + * @author Spasi + * @since 20/5/2011 + */ +public final class NVVideoCaptureUtil { + + private NVVideoCaptureUtil() {} + + private static void checkExtension() { + if ( LWJGLUtil.CHECKS && !GLContext.getCapabilities().GL_NV_video_capture ) + throw new IllegalStateException("NV_video_capture is not supported"); + } + + private static ByteBuffer getPeerInfo() { + return ContextGL.getCurrentContext().getPeerInfo().getHandle(); + } + + /** + * After successfully locking a video capture device, use this method to bind it + * to the capture slot specified in the current context. This method is the cross- + * platform equivalent of glXBindVideoCaptureDeviceNV and wglBindVideoCaptureDeviceNV. + * + * @param video_slot the video slot + * @param device the video capture device + * + * @return true if the binding was successful + */ + public static boolean glBindVideoCaptureDeviceNV(int video_slot, long device) { + checkExtension(); + return nglBindVideoCaptureDeviceNV(getPeerInfo(), video_slot, device); + } + + private static native boolean nglBindVideoCaptureDeviceNV(ByteBuffer peer_info, int video_slot, long device); + + /** + * Enumerate the available video capture devices. This method is the cross-platform + * equivalent of glXEnumerateVideoCaptureDevicesNV and wglEnumerateVideoCaptureDevicesNV. + * Since they are not really compatible, this method works like the WGL version. That is, + * you first call it with a null devices buffer, get the number of devices, then call it + * again with an appropriately sized buffer. + * + * @param devices the buffer to store devices in + * + * @return the number of available video capture devices + */ + public static int glEnumerateVideoCaptureDevicesNV(LongBuffer devices) { + checkExtension(); + + if ( devices != null ) + BufferChecks.checkBuffer(devices, 1); + return nglEnumerateVideoCaptureDevicesNV(getPeerInfo(), devices, devices == null ? 0 : devices.position()); + } + + private static native int nglEnumerateVideoCaptureDevicesNV(ByteBuffer peer_info, LongBuffer devices, int devices_position); + + /** + * To lock a video capture device to a display connection, use this method. + * Before using a video capture device, it must be locked. Once a + * video capture device is locked by a process, no other process can + * lock a video capture device with the same unique ID until the lock + * is released or the process ends. + * + * @param device the device to lock + * + * @return true if the lock was successful + */ + public static boolean glLockVideoCaptureDeviceNV(long device) { + checkExtension(); + return nglLockVideoCaptureDeviceNV(getPeerInfo(), device); + } + + private static native boolean nglLockVideoCaptureDeviceNV(ByteBuffer peer_info, long device); + + /** + * Use this method to query the unique ID of the physical device backing a + * video capture device handle. + * + * @param device the device + * @param attribute the attribute to query + * @param value the buffer to store the value in + * + * @return true if the query was successful + */ + public static boolean glQueryVideoCaptureDeviceNV(long device, int attribute, IntBuffer value) { + checkExtension(); + + BufferChecks.checkBuffer(value, 1); + return nglQueryVideoCaptureDeviceNV(getPeerInfo(), device, attribute, value, value.position()); + } + + private static native boolean nglQueryVideoCaptureDeviceNV(ByteBuffer peer_info, long device, int attribute, IntBuffer value, int value_position); + + /** + * Use this method when finished capturing data on a locked video capture device + * to unlock it. + * + * @param device the device + * + * @return true if the device was unlocked successfully + */ + public static boolean glReleaseVideoCaptureDeviceNV(long device) { + checkExtension(); + return nglReleaseVideoCaptureDeviceNV(getPeerInfo(), device); + } + + private static native boolean nglReleaseVideoCaptureDeviceNV(ByteBuffer peer_info, long device); + +} + Modified: branches/opengles/LWJGL/src/native/common/opengl/extgl.h =================================================================== --- branches/opengles/LWJGL/src/native/common/opengl/extgl.h 2011-05-17 17:26:33 UTC (rev 3536) +++ branches/opengles/LWJGL/src/native/common/opengl/extgl.h 2011-05-21 10:48:05 UTC (rev 3537) @@ -103,4 +103,19 @@ extern bool extgl_QueryExtension(const GLubyte*extensions, const char *name); extern void *extgl_GetProcAddress(const char *name); + +#ifndef __APPLE__ + /* NV_present_video functions (GLX & WGL only) */ + extern jint extgl_EnumerateVideoDevicesNV(JNIEnv *env, jobject peer_info_handle, jobject devices, jint devices_position); + extern jboolean extgl_BindVideoDeviceNV(JNIEnv *env, jobject peer_info_handle, jint video_slot, jlong video_device, jobject attrib_list, jint attrib_list_position); + extern jboolean extgl_QueryContextNV(JNIEnv *env, jobject peer_info_handle, jobject context_handle, jint attrib, jobject value, jint value_position); + + /* NV_video_capture functions (GLX & WGL only) */ + extern jboolean extgl_BindVideoCaptureDeviceNV(JNIEnv *env, jobject peer_info_handle, jint video_slot, jlong device); + extern jint extgl_EnumerateVideoCaptureDevicesNV(JNIEnv *env, jobject peer_info_handle, jobject devices, jint devices_position); + extern jboolean extgl_LockVideoCaptureDeviceNV(JNIEnv *env, jobject peer_info_handle, jlong device); + extern jboolean extgl_QueryVideoCaptureDeviceNV(JNIEnv *env, jobject peer_info_handle, jlong device, jint attribute, jobject value, jint value_position); + extern jboolean extgl_ReleaseVideoCaptureDeviceNV(JNIEnv *env, jobject peer_info_handle, jlong device); +#endif + #endif /* __EXTGL_H__ */ Added: branches/opengles/LWJGL/src/native/common/opengl/org_lwjgl_opengl_NVPresentVideoUtil.c =================================================================== --- branches/opengles/LWJGL/src/native/common/opengl/org_lwjgl_opengl_NVPresentVideoUtil.c (rev 0) +++ branches/opengles/LWJGL/src/native/common/opengl/org_lwjgl_opengl_NVPresentVideoUtil.c 2011-05-21 10:48:05 UTC (rev 3537) @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2002-2011 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. + */ + +/** + * JNI implementation of the NVPresentVideoUtil class (GLX & WGL only). + * + * @author Spasi + */ + +#include <jni.h> +#include "common_tools.h" +#include "extgl.h" +#include "org_lwjgl_opengl_NVPresentVideoUtil.h" + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_NVPresentVideoUtil_nglEnumerateVideoDevicesNV( + JNIEnv *env, jclass clazz, jobject peer_info, jobject devices, jint devices_position +) { + #ifdef __APPLE__ + return 0; + #else + return extgl_EnumerateVideoDevicesNV(env, peer_info, devices, devices_position); + #endif +} + +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_NVPresentVideoUtil_nglBindVideoDeviceNV( + JNIEnv *env, jclass clazz, jobject peer_info, jint video_slot, jlong video_device, jobject attrib_list, jint attrib_list_position +) { + #ifdef __APPLE__ + return false; + #else + return extgl_BindVideoDeviceNV(env, peer_info, video_slot, video_device, attrib_list, attrib_list_position); + #endif +} + +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_NVPresentVideoUtil_nglQueryContextNV(JNIEnv *env, jclass clazz, jobject peer_info, jobject context_handle, jint attrib, jobject value, jint value_position) { + #ifdef __APPLE__ + return false; + #else + return extgl_QueryContextNV(env, peer_info, context_handle, attrib, value, value_position); + #endif +} Added: branches/opengles/LWJGL/src/native/common/opengl/org_lwjgl_opengl_NVVideoCaptureUtil.c =================================================================== --- branches/opengles/LWJGL/src/native/common/opengl/org_lwjgl_opengl_NVVideoCaptureUtil.c (rev 0) +++ branches/opengles/LWJGL/src/native/common/opengl/org_lwjgl_opengl_NVVideoCaptureUtil.c 2011-05-21 10:48:05 UTC (rev 3537) @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2002-2011 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. + */ + +/** + * JNI implementation of the NVVideoCaptureUtil class (GLX & WGL only). + * + * @author Spasi + */ + +#include <jni.h> +#include "common_tools.h" +#include "extgl.h" +#include "org_lwjgl_opengl_NVVideoCaptureUtil.h" + +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_NVVideoCaptureUtil_nglBindVideoCaptureDeviceNV(JNIEnv *env, jclass clazz, jobject peer_info, jint video_slot, jlong device) { + #ifdef __APPLE__ + return false; + #else + return extgl_BindVideoCaptureDeviceNV(env, peer_info, video_slot, device); + #endif +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_NVVideoCaptureUtil_nglEnumerateVideoCaptureDevicesNV(JNIEnv *env, jclass clazz, jobject peer_info, jobject devices, jint devices_position) { + #ifdef __APPLE__ + return 0; + #else + return extgl_EnumerateVideoCaptureDevicesNV(env, peer_info, devices, devices_position); + #endif +} + +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_NVVideoCaptureUtil_nglLockVideoCaptureDeviceNV(JNIEnv *env, jclass clazz, jobject peer_info, jlong device) { + #ifdef __APPLE__ + return false; + #else + return extgl_LockVideoCaptureDeviceNV(env, peer_info, device); + #endif +} + +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_NVVideoCaptureUtil_nglQueryVideoCaptureDeviceNV(JNIEnv *env, jclass clazz, jobject peer_info, jlong device, jint attribute, jobject value, jint value_position) { + #ifdef __APPLE__ + return false; + #else + return extgl_QueryVideoCaptureDeviceNV(env, peer_info, device, attribute, value, value_position); + #endif +} + +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_NVVideoCaptureUtil_nglReleaseVideoCaptureDeviceNV(JNIEnv *env, jclass clazz, jobject peer_info, jlong device) { + #ifdef __APPLE__ + return false; + #else + return extgl_ReleaseVideoCaptureDeviceNV(env, peer_info, device); + #endif +} \ No newline at end of file Added: branches/opengles/LWJGL/src/native/linux/opengl/GLX.c =================================================================== --- branches/opengles/LWJGL/src/native/linux/opengl/GLX.c (rev 0) +++ branches/opengles/LWJGL/src/native/linux/opengl/GLX.c 2011-05-21 10:48:05 UTC (rev 3537) @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2002-2011 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. + */ + +/** + * GLX extension implementations. + * + * @author Spasi + */ +#include "GLX.h" + +/* NV_present_video functions */ + +typedef struct { + GLXExtensions extension_flags; + GLXContext context; +} X11Context; + +jint extgl_EnumerateVideoDevicesNV(JNIEnv *env, jobject peer_info_handle, jobject devices, jint devices_position) { + X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle); + jlong *devices_address = ((jlong *)safeGetBufferAddress(env, devices)) + devices_position; + unsigned int *result; + int i, elements; + + result = lwjgl_glXEnumerateVideoDevicesNV(peer_info->display, peer_info->screen, &elements); + if ( devices_address != NULL ) { + for ( i = 0; i < elements; i++ ) + devices_address[i] = (jlong)result[i]; + } + XFree(result); + + return elements; +} + +jboolean extgl_BindVideoDeviceNV(JNIEnv *env, jobject peer_info_handle, jint video_slot, jlong video_device, jobject attrib_list, jint attrib_list_position) { + X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle); + const int *attrib_list_address = ((const int *)safeGetBufferAddress(env, attrib_list)) + attrib_list_position; + + return lwjgl_glXBindVideoDeviceNV(peer_info->display, video_slot, (unsigned int)video_device, attrib_list_address); +} + +jboolean extgl_QueryContextNV(JNIEnv *env, jobject peer_info_handle, jobject context_handle, jint attrib, jobject value, jint value_position) { + X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle); + X11Context *context_info = (*env)->GetDirectBufferAddress(env, context_handle); + int *value_address = ((int *)(*env)->GetDirectBufferAddress(env, value)) + value_position; + + return lwjgl_glXQueryContext(peer_info->display, context_info->context, attrib, value_address) == GLX_BAD_ATTRIBUTE ? 0 : 1; +} + +/* NV_video_capture functions */ + +jboolean extgl_BindVideoCaptureDeviceNV(JNIEnv *env, jobject peer_info_handle, jint video_slot, jlong device) { + X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle); + + return lwjgl_glXBindVideoCaptureDeviceNV(peer_info->display, video_slot, (GLXVideoCaptureDeviceNV)device); +} + +jint extgl_EnumerateVideoCaptureDevicesNV(JNIEnv *env, jobject peer_info_handle, jobject devices, jint devices_position) { + X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle); + jlong *devices_address = ((jlong *)safeGetBufferAddress(env, devices)) + devices_position; + GLXVideoCaptureDeviceNV *result; + int i, elements; + + result = lwjgl_glXEnumerateVideoCaptureDevicesNV(peer_info->display, peer_info->screen, &elements); + if ( devices_address != NULL ) { + for ( i = 0; i < elements; i++ ) + devices_address[i] = (jlong)result[i]; + } + XFree(devices); + + return elements; +} + +jboolean extgl_LockVideoCaptureDeviceNV(JNIEnv *env, jobject peer_info_handle, jlong device) { + X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle); + + lwjgl_glXLockVideoCaptureDeviceNV(peer_info->display, (GLXVideoCaptureDeviceNV)device); + return true; +} + +jboolean extgl_QueryVideoCaptureDeviceNV(JNIEnv *env, jobject peer_info_handle, jlong device, jint attribute, jobject value, jint value_position) { + X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle); + int *value_address = ((int *)(*env)->GetDirectBufferAddress(env, value)) + value_position; + + return lwjgl_glXQueryVideoCaptureDeviceNV(peer_info->display, (GLXVideoCaptureDeviceNV)device, attribute, value_address); +} + +jboolean extgl_ReleaseVideoCaptureDeviceNV(JNIEnv *env, jobject peer_info_handle, jlong device) { + X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle); + + lwjgl_glXReleaseVideoCaptureDeviceNV(peer_info->display, (GLXVideoCaptureDeviceNV)device); + return true; +} Added: branches/opengles/LWJGL/src/native/linux/opengl/GLX.h =================================================================== --- branches/opengles/LWJGL/src/native/linux/opengl/GLX.h (rev 0) +++ branches/opengles/LWJGL/src/native/linux/opengl/GLX.h 2011-05-21 10:48:05 UTC (rev 3537) @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2002-2011 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. + */ + +/** + * GLX extension implementations. + * + * @author Spasi + */ +#ifndef __LWJGL_GLX_H +#define __LWJGL_GLX_H + +#include <jni.h> +#include "common_tools.h" +#include "context.h" + +#include "extgl.h" +#include "extgl_glx.h" + +/* NV_present_video functions */ +extern jint extgl_EnumerateVideoDevicesNV(JNIEnv *env, jobject peer_info_handle, jobject devices, jint devices_position); +extern jboolean extgl_BindVideoDeviceNV(JNIEnv *env, jobject peer_info_handle, jint video_slot, jlong video_device, jobject attrib_list, jint attrib_list_position); +extern jboolean extgl_QueryContextNV(JNIEnv *env, jobject peer_info_handle, jobject context_handle, jint attrib, jobject value, jint value_position); + +/* NV_video_capture functions */ +extern jboolean extgl_BindVideoCaptureDeviceNV(JNIEnv *env, jobject peer_info_handle, jint video_slot, jlong device); +extern jint extgl_EnumerateVideoCaptureDevicesNV(JNIEnv *env, jobject peer_info_handle, jobject devices, jint devices_position); +extern jboolean extgl_LockVideoCaptureDeviceNV(JNIEnv *env, jobject peer_info_handle, jlong device); +extern jboolean extgl_QueryVideoCaptureDeviceNV(JNIEnv *env, jobject peer_info_handle, jlong device, jint attribute, jobject value, jint value_position); +extern jboolean extgl_ReleaseVideoCaptureDeviceNV(JNIEnv *env, jobject peer_info_handle, jlong device); + +#endif Modified: branches/opengles/LWJGL/src/native/linux/opengl/extgl_glx.c =================================================================== --- branches/opengles/LWJGL/src/native/linux/opengl/extgl_glx.c 2011-05-17 17:26:33 UTC (rev 3536) +++ branches/opengles/LWJGL/src/native/linux/opengl/extgl_glx.c 2011-05-21 10:48:05 UTC (rev 3537) @@ -77,6 +77,17 @@ /* GLX_ARB_create_context */ glXCreateContextAttribsARBPROC lwjgl_glXCreateContextAttribsARB = NULL; +/* GLX_NV_present_video */ +glXEnumerateVideoDevicesNVPROC lwjgl_glXEnumerateVideoDevicesNV = NULL; +glXBindVideoDeviceNVPROC lwjgl_glXBindVideoDeviceNV = NULL; + +/* GLX_NV_video_capture */ +glXBindVideoCaptureDeviceNVPROC lwjgl_glXBindVideoCaptureDeviceNV = NULL; +glXEnumerateVideoCaptureDevicesNVPROC lwjgl_glXEnumerateVideoCaptureDevicesNV = NULL; +glXLockVideoCaptureDeviceNVPROC lwjgl_glXLockVideoCaptureDeviceNV = NULL; +glXQueryVideoCaptureDeviceNVPROC lwjgl_glXQueryVideoCaptureDeviceNV = NULL; +glXReleaseVideoCaptureDeviceNVPROC lwjgl_glXReleaseVideoCaptureDeviceNV = NULL; + static void * lib_gl_handle = NULL; typedef void * (APIENTRY * glXGetProcAddressARBPROC) (const GLubyte *procName); @@ -151,6 +162,27 @@ symbols_flags.GLX_ARB_create_context = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); } +static void extgl_InitGLXNVPresentVideo() { + ExtFunction functions[] = { + { "glXEnumerateVideoDevicesNV", (void*)&lwjgl_glXEnumerateVideoDevicesNV }, + { "glXBindVideoDeviceNV", (void*)&lwjgl_glXBindVideoDeviceNV } + }; + + symbols_flags.GLX_NV_present_video = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); +} + +static void extgl_InitGLXNVVideoCapture() { + ExtFunction functions[] = { + { "glXBindVideoCaptureDeviceNV", (void*)&lwjgl_glXBindVideoCaptureDeviceNV }, + { "glXEnumerateVideoCaptureDevicesNV", (void*)&lwjgl_glXEnumerateVideoCaptureDevicesNV }, + { "glXLockVideoCaptureDeviceNV", (void*)&lwjgl_glXLockVideoCaptureDeviceNV }, + { "glXQueryVideoCaptureDeviceNV", (void*)&lwjgl_glXQueryVideoCaptureDeviceNV }, + { "glXReleaseVideoCaptureDeviceNV", (void*)&lwjgl_glXReleaseVideoCaptureDeviceNV } + }; + + symbols_flags.GLX_NV_video_capture = 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");*/ @@ -161,6 +193,8 @@ extension_flags->GLX_ARB_framebuffer_sRGB = GLXQueryExtension(disp, screen, "GLX_ARB_framebuffer_sRGB") || GLXQueryExtension(disp, screen, "GLX_EXT_framebuffer_sRGB"); extension_flags->GLX_ARB_create_context = GLXQueryExtension(disp, screen, "GLX_ARB_create_context"); extension_flags->GLX_NV_multisample_coverage = GLXQueryExtension(disp, screen, "GLX_NV_multisample_coverage"); + extension_flags->GLX_NV_present_video = GLXQueryExtension(disp, screen, "GLX_NV_present_video"); + extension_flags->GLX_NV_video_capture = GLXQueryExtension(disp, screen, "GLX_NV_video_capture"); } bool extgl_Open(JNIEnv *env) { @@ -193,6 +227,8 @@ extgl_InitGLX13(); extgl_InitGLXSGISwapControl(); extgl_InitGLXARBCreateContext(); + extgl_InitGLXNVPresentVideo(); + extgl_InitGLXNVVideoCapture(); return true; } Modified: branches/opengles/LWJGL/src/native/linux/opengl/extgl_glx.h =================================================================== --- branches/opengles/LWJGL/src/native/linux/opengl/extgl_glx.h 2011-05-17 17:26:33 UTC (rev 3536) +++ branches/opengles/LWJGL/src/native/linux/opengl/extgl_glx.h 2011-05-21 10:48:05 UTC (rev 3537) @@ -272,10 +272,17 @@ #define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002 /* GLX_NV_multisample_coverage */ -#define GLX_COVERAGE_SAMPLES_NV 100001 -#define GLX_COLOR_SAMPLES_NV 0x20B3 +#define GLX_COVERAGE_SAMPLES_NV 100001 +#define GLX_COLOR_SAMPLES_NV 0x20B3 +/* GLX_NV_present_video */ +#define GLX_NUM_VIDEO_SLOTS_NV 0x20F0 +/* GLX_NV_video_capture */ +#define GLX_DEVICE_ID_NV 0x20CD +#define GLX_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF +#define GLX_UNIQUE_ID_NV 0x20CE + typedef XID GLXContextID; typedef XID GLXPixmap; typedef XID GLXDrawable; @@ -339,6 +346,18 @@ /* GLX_ARB_create_context */ typedef GLXContext (APIENTRY * glXCreateContextAttribsARBPROC) (Display *dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list); +/* GLX_NV_present_video */ +typedef unsigned int * (APIENTRY * glXEnumerateVideoDevicesNVPROC) (Display *dpy, int screen, int *nelements); +typedef int (APIENTRY * glXBindVideoDeviceNVPROC) (Display *dpy, unsigned int video_slot, unsigned int video_device, const int *attrib_list); + +/* GLX_NV_video_capture */ +typedef XID GLXVideoCaptureDeviceNV; +typedef int (APIENTRY * glXBindVideoCaptureDeviceNVPROC) (Display *dpy, unsigned int video_capture_slot, GLXVideoCaptureDeviceNV device); +typedef GLXVideoCaptureDeviceNV * (APIENTRY * glXEnumerateVideoCaptureDevicesNVPROC) (Display *dpy, int screen, int *nelements); +typedef void (APIENTRY * glXLockVideoCaptureDeviceNVPROC) (Display *dpy, GLXVideoCaptureDeviceNV device); +typedef int (APIENTRY * glXQueryVideoCaptureDeviceNVPROC) (Display *dpy, GLXVideoCaptureDeviceNV device, int attribute, int *value); +typedef void (APIENTRY * glXReleaseVideoCaptureDeviceNVPROC) (Display *dpy, GLXVideoCaptureDeviceNV device); + typedef struct { bool GLX12; bool GLX13; @@ -352,6 +371,8 @@ bool GLX_ARB_framebuffer_sRGB; bool GLX_ARB_create_context; bool GLX_NV_multisample_coverage; + bool GLX_NV_present_video; + bool GLX_NV_video_capture; } GLXExtensions; /* Add _ to global symbols to avoid symbol clash with the OpenGL library */ @@ -399,6 +420,17 @@ extern glXCreateContextAttribsARBPROC lwjgl_glXCreateContextAttribsARB; +/* GLX_NV_present_video */ +extern glXEnumerateVideoDevicesNVPROC lwjgl_glXEnumerateVideoDevicesNV; +extern glXBindVideoDeviceNVPROC lwjgl_glXBindVideoDeviceNV; + +/* GLX_NV_video_capture */ +extern glXBindVideoCaptureDeviceNVPROC lwjgl_glXBindVideoCaptureDeviceNV; +extern glXEnumerateVideoCaptureDevicesNVPROC lwjgl_glXEnumerateVideoCaptureDevicesNV; +extern glXLockVideoCaptureDeviceNVPROC lwjgl_glXLockVideoCaptureDeviceNV; +extern glXQueryVideoCaptureDeviceNVPROC lwjgl_glXQueryVideoCaptureDeviceNV; +extern glXReleaseVideoCaptureDeviceNVPROC lwjgl_glXReleaseVideoCaptureDeviceNV; + extern bool extgl_InitGLX(Display *disp, int screen, GLXExtensions *extension_flags); #endif Added: branches/opengles/LWJGL/src/native/windows/opengl/WGL.c =================================================================== --- branches/opengles/LWJGL/src/native/windows/opengl/WGL.c (rev 0) +++ branches/opengles/LWJGL/src/native/windows/opengl/WGL.c 2011-05-21 10:48:05 UTC (rev 3537) @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2002-2011 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. + */ + +/** + * WGL extension implementations. + * + * @author Spasi + */ +#include "WGL.h" + +/* NV_present_video functions */ + +jint extgl_EnumerateVideoDevicesNV(JNIEnv *env, jobject peer_info_handle, jobject devices, jint devices_position) { + WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); + HVIDEOOUTPUTDEVICENV *devices_address = ((HVIDEOOUTPUTDEVICENV *)safeGetBufferAddress(env, devices)) + devices_position; + + return peer_info->extensions.wglEnumerateVideoDevicesNV(peer_info->drawable_hdc, devices_address); +} + +jboolean extgl_BindVideoDeviceNV(JNIEnv *env, jobject peer_info_handle, jint video_slot, jlong video_device, jobject attrib_list, jint attrib_list_position) { + WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); + const int *attrib_list_address = ((const int *)safeGetBufferAddress(env, attrib_list)) + attrib_list_position; + + return peer_info->extensions.wglBindVideoDeviceNV(peer_info->drawable_hdc, video_slot, video_device == 0 ? INVALID_HANDLE_VALUE : (HVIDEOOUTPUTDEVICENV)(intptr_t)video_device, attrib_list_address); +} + +jboolean extgl_QueryContextNV(JNIEnv *env, jobject peer_info_handle, jobject context_handle, jint attrib, jobject value, jint value_position) { + WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); + int *value_address = ((int *)(*env)->GetDirectBufferAddress(env, value)) + value_position; + + return peer_info->extensions.wglQueryCurrentContextNV(attrib, value_address); +} + +/* NV_video_capture functions */ + +jboolean extgl_BindVideoCaptureDeviceNV(JNIEnv *env, jobject peer_info_handle, jint video_slot, jlong device) { + WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); + + return peer_info->extensions.wglBindVideoCaptureDeviceNV(video_slot, (HVIDEOINPUTDEVICENV)(intptr_t)device); +} + +jint extgl_EnumerateVideoCaptureDevicesNV(JNIEnv *env, jobject peer_info_handle, jobject devices, jint devices_position) { + WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); + HVIDEOINPUTDEVICENV *devices_address = ((HVIDEOINPUTDEVICENV *)safeGetBufferAddress(env, devices)) + devices_position; + + return peer_info->extensions.wglEnumerateVideoCaptureDevicesNV(peer_info->drawable_hdc, devices_address); +} + +jboolean extgl_LockVideoCaptureDeviceNV(JNIEnv *env, jobject peer_info_handle, jlong device) { + WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); + + return peer_info->extensions.wglLockVideoCaptureDeviceNV(peer_info->drawable_hdc, (HVIDEOINPUTDEVICENV)(intptr_t)device); +} + +jboolean extgl_QueryVideoCaptureDeviceNV(JNIEnv *env, jobject peer_info_handle, jlong device, jint attribute, jobject value, jint value_position) { + WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); + int *value_address = ((int *)(*env)->GetDirectBufferAddress(env, value)) + value_position; + + return peer_info->extensions.wglQueryVideoCaptureDeviceNV(peer_info->drawable_hdc, (HVIDEOINPUTDEVICENV)(intptr_t)device, attribute, value_address); +} + +jboolean extgl_ReleaseVideoCaptureDeviceNV(JNIEnv *env, jobject peer_info_handle, jlong device) { + WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); + + return peer_info->extensions.wglReleaseVideoCaptureDeviceNV(peer_info->drawable_hdc, (HVIDEOINPUTDEVICENV)(intptr_t)device); +} \ No newline at end of file Added: branches/opengles/LWJGL/src/native/windows/opengl/WGL.h =================================================================== --- branches/opengles/LWJGL/src/native/windows/opengl/WGL.h (rev 0) +++ branches/opengles/LWJGL/src/native/windows/opengl/WGL.h 2011-05-21 10:48:05 UTC (rev 3537) @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2002-2011 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. + */ + +/** + * WGL extension implementations. + * + * @author Spasi + */ +#ifndef __LWJGL_WGL_H +#define __LWJGL_WGL_H + +#include <jni.h> +#include "common_tools.h" +#include "context.h" + +#include "extgl.h" +#include "extgl_wgl.h" + +/* NV_present_video functions */ +extern jint extgl_EnumerateVideoDevicesNV(JNIEnv *env, jobject peer_info_handle, jobject devices, jint devices_position); +extern jboolean extgl_BindVideoDeviceNV(JNIEnv *env, jobject peer_info_handle, jint video_slot, jlong video_device, jobject attrib_list, jint attrib_list_position); +extern jboolean extgl_QueryContextNV(JNIEnv *env, jobject peer_info_handle, jobject context_handle, jint attrib, jobject value, jint value_position); + +/* NV_video_capture functions */ +extern jboolean extgl_BindVideoCaptureDeviceNV(JNIEnv *env, jobject peer_info_handle, jint video_slot, jlong device); +extern jint extgl_EnumerateVideoCaptureDevicesNV(JNIEnv *env, jobject peer_info_handle, jobject devices, jint devices_position); +extern jboolean extgl_LockVideoCaptureDeviceNV(JNIEnv *env, jobject peer_info_handle, jlong device); +extern jboolean extgl_QueryVideoCaptureDeviceNV(JNIEnv *env, jobject peer_info_handle, jlong device, jint attribute, jobject value, jint value_position); +extern jboolean extgl_ReleaseVideoCaptureDeviceNV(JNIEnv *env, jobject peer_info_handle, jlong device); + +#endif \ No newline at end of file Modified: branches/opengles/LWJGL/src/native/windows/opengl/context.h =================================================================== --- branches/opengles/LWJGL/src/native/windows/opengl/context.h 2011-05-17 17:26:33 UTC (rev 3536) +++ branches/opengles/LWJGL/src/native/windows/opengl/context.h 2011-05-21 10:48:05 UTC (rev 3537) @@ -1,31 +1,31 @@ -/* +/* * Copyright (c) 2002-2008 LWJGL Project * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are + * modification, are permitted provided that the following conditions are * met: - * - * * Redistributions of source code must retain the above copyright + * + * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ @@ -49,14 +49,10 @@ typedef struct { union { HWND hwnd; - struct { - HPBUFFERARB pbuffer; - // Contains the function pointers that - // created the pbuffer - WGLExtensions extensions; - } pbuffer; + HPBUFFERARB pbuffer; } u; HDC drawable_hdc; + WGLExtensions extensions; } WindowsPeerInfo; /* @@ -86,7 +82,7 @@ * Create a window with the specified position, size, and * fullscreen attribute. The window will have DirectInput associated * with it. - * + * * Returns true for success, or false for failure */ extern HWND createWindow(LPCTSTR window_class_name, int x, int y, int width, int height, bool undecorated, bool child_window, HWND parent); Modified: branches/opengles/LWJGL/src/native/windows/opengl/extgl_wgl.c =================================================================== --- branches/opengles/LWJGL/src/native/windows/opengl/extgl_wgl.c 2011-05-17 17:26:33 UTC (rev 3536) +++ branches/opengles/LWJGL/src/native/windows/opengl/extgl_wgl.c 2011-05-21 10:48:05 UTC (rev 3537) @@ -84,6 +84,8 @@ return extgl_QueryExtension(extension_string, name); } +/*---------------------------------------------------------------------*/ + static void extgl_InitWGLARBPbuffer(WGLExtensions *extensions) { ExtFunction functions[] = { {"wglCreatePbufferARB", (void *)&extensions->wglCreatePbufferARB}, @@ -137,6 +139,32 @@ extensions->WGL_ARB_create_context = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); } +static void extgl_InitWGLNVPresentVideo(WGLExtensions *extensions) { + ExtFunction functions[] = { + {"wglEnumerateVideoDevicesNV", (void *)&extensions->wglEnumerateVideoDevicesNV}, + {"wglBindVideoDeviceNV", (void *)&extensions->wglBindVideoDeviceNV}, + {"wglQueryCurrentContextNV", (void *)&extensions->wglQueryCurrentContextNV} + }; + + if (extensions->WGL_NV_present_video) + extensions->WGL_NV_present_video = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); +} + +static void extgl_InitWGLNVVideoCapture(WGLExtensions *extensions) { + ExtFunction functions[] = { + {"wglBindVideoCaptureDeviceNV", (void *)&extensions->wglBindVideoCaptureDeviceNV}, + {"wglEnumerateVideoCaptureDevicesNV", (void *)&extensions->wglEnumerateVideoCaptureDevicesNV}, + {"wglLockVideoCaptureDeviceNV", (void *)&extensions->wglLockVideoCaptureDeviceNV}, + {"wglQueryVideoCaptureDeviceNV", (void *)&extensions->wglQueryVideoCaptureDeviceNV}, + {"wglReleaseVideoCaptureDeviceNV", (void *)&extensions->wglReleaseVideoCaptureDeviceNV} + }; + + if (extensions->WGL_NV_video_capture) + extensions->WGL_NV_video_capture = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); +} + +/*---------------------------------------------------------------------*/ + static void extgl_InitSupportedWGLExtensions(WGLExtensions *extensions) { extensions->WGL_ARB_buffer_region = WGLQueryExtension(extensions, "WGL_ARB_buffer_region"); extensions->WGL_ARB_make_current_read = WGLQueryExtension(extensions, "WGL_ARB_make_current_read"); @@ -153,6 +181,8 @@ extensions->WGL_EXT_pixel_format_packed_float = WGLQueryExtension(extensions, "WGL_EXT_pixel_format_packed_float"); extensions->WGL_ARB_create_context = WGLQueryExtension(extensions, "WGL_ARB_create_context"); extensions->WGL_NV_multisample_coverage = WGLQueryExtension(extensions, "WGL_NV_multisample_coverage"); + extensions->WGL_NV_present_video = WGLQueryExtension(extensions, "WGL_NV_present_video"); + extensions->WGL_NV_video_capture = WGLQueryExtension(extensions, "WGL_NV_video_capture"); } static void extgl_InitWGLEXTExtensionsString(WGLExtensions *extensions) { @@ -181,4 +211,6 @@ extgl_InitWGLARBPixelFormat(extensions); extgl_InitWGLARBPbuffer(extensions); extgl_InitWGLARBCreateContext(extensions); + extgl_InitWGLNVPresentVideo(extensions); + extgl_InitWGLNVVideoCapture(extensions); } Modified: branches/opengles/LWJGL/src/native/windows/opengl/extgl_wgl.h =================================================================== --- branches/opengles/LWJGL/src/native/windows/opengl/extgl_wgl.h 2011-05-17 17:26:33 UTC (rev 3536) +++ branches/opengles/LWJGL/src/native/windows/opengl/extgl_wgl.h 2011-05-21 10:48:05 UTC (rev 3537) @@ -207,6 +207,32 @@ #define WGL_COVERAGE_SAMPLES_NV 0x2042 #define WGL_COLOR_SAMPLES_NV 0x20B9 +/*--------------------------------------------------------------*/ +/*------------ WGL_NV_present_video ----------------------------*/ +/*--------------------------------------------------------------*/ + +DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV); + +#define WGL_NUM_VIDEO_SLOTS_NV 0x20F0 + +typedef int (APIENTRY * wglEnumerateVideoDevicesNVPROC) (HDC hDc, HVIDEOOUTPUTDEVICENV *phDeviceList); +typedef BOOL (APIENTRY * wglBindVideoDeviceNVPROC) (HDC hDc, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList); +typedef BOOL (APIENTRY * wglQueryCurrentContextNVPROC) (int iAttribute, int *piValue); + +/*--------------------------------------------------------------*/ +/*------------ WGL_NV_video_capture ----------------------------*/ +/*--------------------------------------------------------------*/ + +DECLARE_HANDLE(HVIDEOINPUTDEVICENV); + +#define WGL_NUM_VIDEO_SLOTS_NV 0x20F0 + +typedef BOOL (APIENTRY * wglBindVideoCaptureDeviceNVPROC) (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice); +typedef UINT (APIENTRY * wglEnumerateVideoCaptureDevicesNVPROC) (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList); +typedef BOOL (APIENTRY * wglLockVideoCaptureDeviceNVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice); +typedef BOOL (APIENTRY * wglQueryVideoCaptureDeviceNVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue); +typedef BOOL (APIENTRY * wglReleaseVideoCaptureDeviceNVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice); + /*---------------------------------------------------------------------*/ typedef struct { @@ -227,6 +253,8 @@ bool WGL_EXT_pixel_format_packed_float; bool WGL_ARB_create_context; bool WGL_NV_multisample_coverage; + bool WGL_NV_present_video; + bool WGL_NV_video_capture; wglGetExtensionsStringEXTPROC wglGetExtensionsStringEXT; @@ -253,6 +281,16 @@ wglGetCurrentReadDCARBPROC wglGetCurrentReadDCARB; wglCreateContextAttribsARBPROC wglCreateContextAttribsARB; + + wglEnumerateVideoDevicesNVPROC wglEnumerateVideoDevicesNV; + wglBindVideoDeviceNVPROC wglBindVideoDeviceNV; + wglQueryCurrentContextNVPROC wglQueryCurrentContextNV; + + wglBindVideoCaptureDeviceNVPROC wglBindVideoCaptureDeviceNV; + wglEnumerateVideoCaptureDevicesNVPROC wglEnumerateVideoCaptureDevicesNV; + wglLockVideoCaptureDeviceNVPROC wglLockVideoCaptureDeviceNV; + wglQueryVideoCaptureDeviceNVPROC wglQueryVideoCaptureDeviceNV; + wglReleaseVideoCaptureDeviceNVPROC wglReleaseVideoCaptureDeviceNV; } WGLExtensions; extern void extgl_InitWGL(WGLExtensions *extensions); Modified: branches/opengles/LWJGL/src/native/windows/opengl/org_lwjgl_opengl_Pbuffer.c =================================================================== --- branches/opengles/LWJGL/src/native/windows/opengl/org_lwjgl_opengl_Pbuffer.c 2011-05-17 17:26:33 UTC (rev 3536) +++ branches/opengles/LWJGL/src/native/windows/opengl/org_lwjgl_opengl_Pbuffer.c 2011-05-21 10:48:05 UTC (rev 3537) @@ -167,23 +167,23 @@ throwException(env, "Could not get Pbuffer DC"); return; } - peer_info->u.pbuffer.extensions = extensions; - peer_info->u.pbuffer.pbuffer = Pbuffer; + peer_info->extensions = extensions; + peer_info->u.pbuffer = Pbuffer; peer_info->drawable_hdc = Pbuffer_dc; } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsPbufferPeerInfo_nDestroy (JNIEnv *env, jclass clazz, jobject peer_info_handle) { WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); - peer_info->u.pbuffer.extensions.wglReleasePbufferDCARB(peer_info->u.pbuffer.pbuffer, peer_info->drawable_hdc); - peer_info->u.pbuffer.extensions.wglDestroyPbufferARB(peer_info->u.pbuffer.pbuffer); + peer_info->extensions.wglReleasePbufferDCARB(peer_info->u.pbuffer, peer_info->drawable_hdc); + peer_info->extensions.wglDestroyPbufferARB(peer_info->u.pbuffer); } JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_WindowsPbufferPeerInfo_nIsBufferLost (JNIEnv *env, jclass clazz, jobject peer_info_handle) { WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); BOOL buffer_lost; - peer_info->u.pbuffer.extensions.wglQueryPbufferARB(peer_info->u.pbuffer.pbuffer, WGL_PBUFFER_LOST_ARB, &buffer_lost); + peer_info->extensions.wglQueryPbufferARB(peer_info->u.pbuffer, WGL_PBUFFER_LOST_ARB, &buffer_lost); return buffer_lost ? JNI_TRUE : JNI_FALSE; } @@ -196,17 +196,17 @@ attribs[1] = value; attribs[2] = 0; - peer_info->u.pbuffer.extensions.wglSetPbufferAttribARB(peer_info->u.pbuffer.pbuffer, attribs); + peer_info->extensions.wglSetPbufferAttribARB(peer_info->u.pbuffer, attribs); } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsPbufferPeerInfo_nBindTexImageToPbuffer (JNIEnv *env, jclass clazz, jobject peer_info_handle, jint buffer) { WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); - peer_info->u.pbuffer.extensions.wglBindTexImageARB(peer_info->u.pbuffer.pbuffer, buffer); + peer_info->extensions.wglBindTexImageARB(peer_info->u.pbuffer, buffer); } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsPbufferPeerInfo_nReleaseTexImageFromPbuffer (JNIEnv *env, jclass clazz, jobject peer_info_handle, jint buffer) { WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); - peer_info->u.pbuffer.extensions.w... [truncated message content] |