From eff8493ef666ce39ff1355b814952fdfdaf35201 Mon Sep 17 00:00:00 2001 From: Ioannis Tsakpinis Date: Sat, 21 May 2011 10:48:05 +0000 Subject: [PATCH] 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. --- build.xml | 3 + .../org/lwjgl/opengl/NVPresentVideoUtil.java | 122 +++++++++++ .../org/lwjgl/opengl/NVVideoCaptureUtil.java | 153 +++++++++++++ src/native/common/opengl/extgl.h | 15 ++ .../org_lwjgl_opengl_NVPresentVideoUtil.c | 70 ++++++ .../org_lwjgl_opengl_NVVideoCaptureUtil.c | 82 +++++++ src/native/linux/opengl/GLX.c | 121 +++++++++++ src/native/linux/opengl/GLX.h | 60 ++++++ src/native/linux/opengl/extgl_glx.c | 36 ++++ src/native/linux/opengl/extgl_glx.h | 36 +++- src/native/windows/opengl/WGL.c | 95 +++++++++ src/native/windows/opengl/WGL.h | 60 ++++++ src/native/windows/opengl/context.h | 36 ++-- src/native/windows/opengl/extgl_wgl.c | 32 +++ src/native/windows/opengl/extgl_wgl.h | 38 ++++ .../windows/opengl/org_lwjgl_opengl_Pbuffer.c | 16 +- ...wjgl_opengl_WindowsContextImplementation.c | 3 +- src/native/windows/opengles/context.h | 9 - .../org/lwjgl/opengl/NV_present_video.java | 116 ++++++++++ .../org/lwjgl/opengl/NV_video_capture.java | 201 ++++++++++++++++++ 20 files changed, 1264 insertions(+), 40 deletions(-) create mode 100644 src/java/org/lwjgl/opengl/NVPresentVideoUtil.java create mode 100644 src/java/org/lwjgl/opengl/NVVideoCaptureUtil.java create mode 100644 src/native/common/opengl/org_lwjgl_opengl_NVPresentVideoUtil.c create mode 100644 src/native/common/opengl/org_lwjgl_opengl_NVVideoCaptureUtil.c create mode 100644 src/native/linux/opengl/GLX.c create mode 100644 src/native/linux/opengl/GLX.h create mode 100644 src/native/windows/opengl/WGL.c create mode 100644 src/native/windows/opengl/WGL.h create mode 100644 src/templates/org/lwjgl/opengl/NV_present_video.java create mode 100644 src/templates/org/lwjgl/opengl/NV_video_capture.java diff --git a/build.xml b/build.xml index f9cbbad6..50aedfbe 100644 --- a/build.xml +++ b/build.xml @@ -49,6 +49,7 @@ + @@ -305,6 +306,8 @@ + + diff --git a/src/java/org/lwjgl/opengl/NVPresentVideoUtil.java b/src/java/org/lwjgl/opengl/NVPresentVideoUtil.java new file mode 100644 index 00000000..a79f281d --- /dev/null +++ b/src/java/org/lwjgl/opengl/NVPresentVideoUtil.java @@ -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); + +} diff --git a/src/java/org/lwjgl/opengl/NVVideoCaptureUtil.java b/src/java/org/lwjgl/opengl/NVVideoCaptureUtil.java new file mode 100644 index 00000000..f6409e87 --- /dev/null +++ b/src/java/org/lwjgl/opengl/NVVideoCaptureUtil.java @@ -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); + +} + diff --git a/src/native/common/opengl/extgl.h b/src/native/common/opengl/extgl.h index c2b242a6..fc767aeb 100644 --- a/src/native/common/opengl/extgl.h +++ b/src/native/common/opengl/extgl.h @@ -103,4 +103,19 @@ extern bool extgl_InitializeFunctions(int num_functions, ExtFunction *functions) 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__ */ diff --git a/src/native/common/opengl/org_lwjgl_opengl_NVPresentVideoUtil.c b/src/native/common/opengl/org_lwjgl_opengl_NVPresentVideoUtil.c new file mode 100644 index 00000000..3e842877 --- /dev/null +++ b/src/native/common/opengl/org_lwjgl_opengl_NVPresentVideoUtil.c @@ -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 +#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 +} diff --git a/src/native/common/opengl/org_lwjgl_opengl_NVVideoCaptureUtil.c b/src/native/common/opengl/org_lwjgl_opengl_NVVideoCaptureUtil.c new file mode 100644 index 00000000..ce663de2 --- /dev/null +++ b/src/native/common/opengl/org_lwjgl_opengl_NVVideoCaptureUtil.c @@ -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 +#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 diff --git a/src/native/linux/opengl/GLX.c b/src/native/linux/opengl/GLX.c new file mode 100644 index 00000000..7da252ee --- /dev/null +++ b/src/native/linux/opengl/GLX.c @@ -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; +} diff --git a/src/native/linux/opengl/GLX.h b/src/native/linux/opengl/GLX.h new file mode 100644 index 00000000..1a6b8fd5 --- /dev/null +++ b/src/native/linux/opengl/GLX.h @@ -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 +#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 diff --git a/src/native/linux/opengl/extgl_glx.c b/src/native/linux/opengl/extgl_glx.c index 7e07d485..df8c577a 100644 --- a/src/native/linux/opengl/extgl_glx.c +++ b/src/native/linux/opengl/extgl_glx.c @@ -77,6 +77,17 @@ glXSwapIntervalSGIPROC lwjgl_glXSwapIntervalSGI = NULL; /* 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 @@ static void extgl_InitGLXARBCreateContext() { 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 @@ static void extgl_InitGLXSupportedExtensions(Display *disp, int screen, GLXExten 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 @@ bool extgl_Open(JNIEnv *env) { extgl_InitGLX13(); extgl_InitGLXSGISwapControl(); extgl_InitGLXARBCreateContext(); + extgl_InitGLXNVPresentVideo(); + extgl_InitGLXNVVideoCapture(); return true; } diff --git a/src/native/linux/opengl/extgl_glx.h b/src/native/linux/opengl/extgl_glx.h index 0ee85d83..ed72520a 100644 --- a/src/native/linux/opengl/extgl_glx.h +++ b/src/native/linux/opengl/extgl_glx.h @@ -272,9 +272,16 @@ #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; @@ -339,6 +346,18 @@ typedef void (APIENTRY * glXSwapIntervalSGIPROC)(int interval); /* 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 @@ typedef struct { 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 glXSwapIntervalSGIPROC lwjgl_glXSwapIntervalSGI; 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 diff --git a/src/native/windows/opengl/WGL.c b/src/native/windows/opengl/WGL.c new file mode 100644 index 00000000..b5d338ab --- /dev/null +++ b/src/native/windows/opengl/WGL.c @@ -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 diff --git a/src/native/windows/opengl/WGL.h b/src/native/windows/opengl/WGL.h new file mode 100644 index 00000000..6a00e2d6 --- /dev/null +++ b/src/native/windows/opengl/WGL.h @@ -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 +#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 diff --git a/src/native/windows/opengl/context.h b/src/native/windows/opengl/context.h index 75baa396..ee9eb13e 100644 --- a/src/native/windows/opengl/context.h +++ b/src/native/windows/opengl/context.h @@ -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 @@ extern void getWindowFlags(DWORD *windowflags_return, DWORD *exstyle_return, boo * 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); diff --git a/src/native/windows/opengl/extgl_wgl.c b/src/native/windows/opengl/extgl_wgl.c index b8432b4c..5111481f 100644 --- a/src/native/windows/opengl/extgl_wgl.c +++ b/src/native/windows/opengl/extgl_wgl.c @@ -84,6 +84,8 @@ static bool WGLQueryExtension(WGLExtensions *extensions, const char *name) { return extgl_QueryExtension(extension_string, name); } +/*---------------------------------------------------------------------*/ + static void extgl_InitWGLARBPbuffer(WGLExtensions *extensions) { ExtFunction functions[] = { {"wglCreatePbufferARB", (void *)&extensions->wglCreatePbufferARB}, @@ -137,6 +139,32 @@ static void extgl_InitWGLARBCreateContext(WGLExtensions *extensions) { 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 @@ static void extgl_InitSupportedWGLExtensions(WGLExtensions *extensions) { 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 @@ void extgl_InitWGL(WGLExtensions *extensions) { extgl_InitWGLARBPixelFormat(extensions); extgl_InitWGLARBPbuffer(extensions); extgl_InitWGLARBCreateContext(extensions); + extgl_InitWGLNVPresentVideo(extensions); + extgl_InitWGLNVVideoCapture(extensions); } diff --git a/src/native/windows/opengl/extgl_wgl.h b/src/native/windows/opengl/extgl_wgl.h index e0ca55be..8c4826b0 100644 --- a/src/native/windows/opengl/extgl_wgl.h +++ b/src/native/windows/opengl/extgl_wgl.h @@ -207,6 +207,32 @@ typedef HGLRC (APIENTRY * wglCreateContextAttribsARBPROC) (HDC hDC, HGLRC hShare #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 @@ typedef struct { 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 @@ typedef struct { 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); diff --git a/src/native/windows/opengl/org_lwjgl_opengl_Pbuffer.c b/src/native/windows/opengl/org_lwjgl_opengl_Pbuffer.c index 260e13e9..9bd78ad8 100644 --- a/src/native/windows/opengl/org_lwjgl_opengl_Pbuffer.c +++ b/src/native/windows/opengl/org_lwjgl_opengl_Pbuffer.c @@ -167,23 +167,23 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsPbufferPeerInfo_nCreate 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 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsPbufferPeerInfo_nSetPbufferA 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.wglReleaseTexImageARB(peer_info->u.pbuffer.pbuffer, buffer); + peer_info->extensions.wglReleaseTexImageARB(peer_info->u.pbuffer, buffer); } diff --git a/src/native/windows/opengl/org_lwjgl_opengl_WindowsContextImplementation.c b/src/native/windows/opengl/org_lwjgl_opengl_WindowsContextImplementation.c index 894caff2..48d934a9 100644 --- a/src/native/windows/opengl/org_lwjgl_opengl_WindowsContextImplementation.c +++ b/src/native/windows/opengl/org_lwjgl_opengl_WindowsContextImplementation.c @@ -90,6 +90,7 @@ JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nCr return NULL; } extgl_InitWGL(&extensions); + peer_info->extensions = extensions; // Restore previous context wglMakeCurrent(saved_current_hdc, saved_current_hglrc); @@ -127,7 +128,7 @@ JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_getHG JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_getHDC(JNIEnv *env, jclass clazz, jobject peer_info_handle) { WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); - return (intptr_t)peer_info->drawable_hdc; + return (intptr_t)peer_info->drawable_hdc; } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nSwapBuffers diff --git a/src/native/windows/opengles/context.h b/src/native/windows/opengles/context.h index 5370bbdf..17d72466 100644 --- a/src/native/windows/opengles/context.h +++ b/src/native/windows/opengles/context.h @@ -44,19 +44,10 @@ #include #include "common_tools.h" #include "extgl.h" -/*#include "extgl_wgl.h"*/ typedef struct { union { HWND hwnd; - /* - struct { - HPBUFFERARB pbuffer; - // Contains the function pointers that - // created the pbuffer - WGLExtensions extensions; - } pbuffer; - */ } u; HDC drawable_hdc; } WindowsPeerInfo; diff --git a/src/templates/org/lwjgl/opengl/NV_present_video.java b/src/templates/org/lwjgl/opengl/NV_present_video.java new file mode 100644 index 00000000..3c1d0d1e --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_present_video.java @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +import org.lwjgl.util.generator.Alternate; +import org.lwjgl.util.generator.Check; +import org.lwjgl.util.generator.OutParameter; +import org.lwjgl.util.generator.StripPostfix; +import org.lwjgl.util.generator.opengl.*; + +import java.nio.IntBuffer; +import java.nio.LongBuffer; + +public interface NV_present_video { + + /** + * Accepted by the <type> parameter of PresentFrameKeyedNV and + * PresentFrameDualFillNV: + */ + int GL_FRAME_NV = 0x8E26, + FIELDS_NV = 0x8E27; + + /** + * Accepted by the <pname> parameter of GetVideoivNV, GetVideouivNV, + * GetVideoi64vNV, GetVideoui64vNV: + */ + int GL_CURRENT_TIME_NV = 0x8E28, + GL_NUM_FILL_STREAMS_NV = 0x8E29; + + /** Accepted by the <target> parameter of GetQueryiv: */ + int GL_PRESENT_TIME_NV = 0x8E2A, + GL_PRESENT_DURATION_NV = 0x8E2B; + + /** Accepted by the <attribute> parameter of NVPresentVideoUtil.glQueryContextNV: */ + int GL_NUM_VIDEO_SLOTS_NV = 0x20F0; // GLX_NUM_VIDEO_SLOTS_NV & WGL_NUM_VIDEO_SLOTS_NV + + void glPresentFrameKeyedNV(@GLuint int video_slot, + @GLuint64EXT long minPresentTime, + @GLuint int beginPresentTimeId, + @GLuint int presentDurationId, + @GLenum int type, + @GLenum int target0, @GLuint int fill0, @GLuint int key0, + @GLenum int target1, @GLuint int fill1, @GLuint int key1); + + void glPresentFrameDualFillNV(@GLuint int video_slot, + @GLuint64EXT long minPresentTime, + @GLuint int beginPresentTimeId, + @GLuint int presentDurationId, + @GLenum int type, + @GLenum int target0, @GLuint int fill0, + @GLenum int target1, @GLuint int fill1, + @GLenum int target2, @GLuint int fill2, + @GLenum int target3, @GLuint int fill3); + + @StripPostfix("params") + void glGetVideoivNV(@GLuint int video_slot, @GLenum int pname, @OutParameter @Check("1") IntBuffer params); + + @Alternate("glGetVideoivNV") + @GLreturn("params") + @StripPostfix("params") + void glGetVideoivNV2(@GLuint int video_slot, @GLenum int pname, @OutParameter IntBuffer params); + + @StripPostfix("params") + void glGetVideouivNV(@GLuint int video_slot, @GLenum int pname, @OutParameter @Check("1") @GLuint IntBuffer params); + + @Alternate("glGetVideouivNV") + @GLreturn("params") + @StripPostfix("params") + void glGetVideouivNV2(@GLuint int video_slot, @GLenum int pname, @OutParameter @GLuint IntBuffer params); + + @StripPostfix("params") + void glGetVideoi64vNV(@GLuint int video_slot, @GLenum int pname, @OutParameter @Check("1") @GLint64EXT LongBuffer params); + + @Alternate("glGetVideoi64vNV") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "v") + void glGetVideoi64vNV2(@GLuint int video_slot, @GLenum int pname, @OutParameter @GLint64EXT LongBuffer params); + + @StripPostfix("params") + void glGetVideoui64vNV(@GLuint int video_slot, @GLenum int pname, @OutParameter @Check("1") @GLuint64EXT LongBuffer params); + + @Alternate("glGetVideoui64vNV") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "v") + void glGetVideoui64vNV2(@GLuint int video_slot, @GLenum int pname, @OutParameter @GLuint64EXT LongBuffer params); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/NV_video_capture.java b/src/templates/org/lwjgl/opengl/NV_video_capture.java new file mode 100644 index 00000000..0ecb7c8d --- /dev/null +++ b/src/templates/org/lwjgl/opengl/NV_video_capture.java @@ -0,0 +1,201 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opengl.*; + +import java.nio.DoubleBuffer; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; +import java.nio.LongBuffer; + +public interface NV_video_capture { + + /** + * Accepted by the <target> parameters of BindBufferARB, BufferDataARB, + * BufferSubDataARB, MapBufferARB, UnmapBufferARB, GetBufferSubDataARB, + * GetBufferParameterivARB, and GetBufferPointervARB: + */ + int GL_VIDEO_BUFFER_NV = 0x9020; + + /** + * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, + * GetFloatv, and GetDoublev: + */ + int GL_VIDEO_BUFFER_BINDING_NV = 0x9021; + + /** + * Accepted by the <frame_region> parameter of + * BindVideoCaptureStreamBufferNV, and BindVideoCaptureStreamTextureNV: + */ + int GL_FIELD_UPPER_NV = 0x9022, + GL_FIELD_LOWER_NV = 0x9023; + + /** Accepted by the <pname> parameter of GetVideoCaptureivNV: */ + int GL_NUM_VIDEO_CAPTURE_STREAMS_NV = 0x9024, + GL_NEXT_VIDEO_CAPTURE_BUFFER_STATUS_NV = 0x9025; + + /** + * Accepted by the <pname> parameter of + * GetVideoCaptureStream{i,f,d}vNV: + */ + int GL_LAST_VIDEO_CAPTURE_STATUS_NV = 0x9027, + GL_VIDEO_BUFFER_PITCH_NV = 0x9028, + GL_VIDEO_CAPTURE_FRAME_WIDTH_NV = 0x9038, + GL_VIDEO_CAPTURE_FRAME_HEIGHT_NV = 0x9039, + GL_VIDEO_CAPTURE_FIELD_UPPER_HEIGHT_NV = 0x903A, + GL_VIDEO_CAPTURE_FIELD_LOWER_HEIGHT_NV = 0x903B, + GL_VIDEO_CAPTURE_TO_422_SUPPORTED_NV = 0x9026; + + /** + * Accepted by the <pname> parameter of + * GetVideoCaptureStream{i,f,d}vNV and as the <pname> parameter of + * VideoCaptureStreamParameter{i,f,d}vNV: + */ + int GL_VIDEO_COLOR_CONVERSION_MATRIX_NV = 0x9029, + GL_VIDEO_COLOR_CONVERSION_MAX_NV = 0x902A, + GL_VIDEO_COLOR_CONVERSION_MIN_NV = 0x902B, + GL_VIDEO_COLOR_CONVERSION_OFFSET_NV = 0x902C, + GL_VIDEO_BUFFER_INTERNAL_FORMAT_NV = 0x902D, + GL_VIDEO_CAPTURE_SURFACE_ORIGIN_NV = 0x903C; + /** Returned by VideoCaptureNV: */ + int GL_PARTIAL_SUCCESS_NV = 0x902E; + + /** + * Returned by VideoCaptureNV and GetVideoCaptureStream{i,f,d}vNV + * when <pname> is LAST_VIDEO_CAPTURE_STATUS_NV: + */ + int GL_SUCCESS_NV = 0x902F, + GL_FAILURE_NV = 0x9030; + + /** + * Accepted in the <params> parameter of + * VideoCaptureStreamParameter{i,f,d}vNV when <pname> is + * VIDEO_BUFFER_INTERNAL_FORMAT_NV and returned by + * GetVideoCaptureStream{i,f,d}vNV when <pname> is + * VIDEO_BUFFER_INTERNAL_FORMAT_NV: + */ + int GL_YCBYCR8_422_NV = 0x9031, + GL_YCBAYCR8A_4224_NV = 0x9032, + GL_Z6Y10Z6CB10Z6Y10Z6CR10_422_NV = 0x9033, + GL_Z6Y10Z6CB10Z6A10Z6Y10Z6CR10Z6A10_4224_NV = 0x9034, + GL_Z4Y12Z4CB12Z4Y12Z4CR12_422_NV = 0x9035, + GL_Z4Y12Z4CB12Z4A12Z4Y12Z4CR12Z4A12_4224_NV = 0x9036, + GL_Z4Y12Z4CB12Z4CR12_444_NV = 0x9037; + + /* + * Accepted in the attribute list of the GLX reply to the + * glXEnumerateVideoCaptureDevicesNV command: + */ + /*int GLX_DEVICE_ID_NV = 0x20CD;*/ + + /** Accepted by the <attribute> parameter of NVPresentVideoUtil.glQueryContextNV: */ + int GL_NUM_VIDEO_CAPTURE_SLOTS_NV = 0x20CF; + + /** + * Accepted by the <attribute> parameter of + * glQueryVideoCaptureDeviceNV: + */ + int GL_UNIQUE_ID_NV = 0x20CE; + + void glBeginVideoCaptureNV(@GLuint int video_capture_slot); + + void glBindVideoCaptureStreamBufferNV(@GLuint int video_capture_slot, + @GLuint int stream, @GLenum int frame_region, + @GLintptrARB long offset); + + void glBindVideoCaptureStreamTextureNV(@GLuint int video_capture_slot, + @GLuint int stream, @GLenum int frame_region, + @GLenum int target, @GLuint int texture); + + void glEndVideoCaptureNV(@GLuint int video_capture_slot); + + @StripPostfix("params") + void glGetVideoCaptureivNV(@GLuint int video_capture_slot, @GLenum int pname, @OutParameter @Check("1") IntBuffer params); + + @Alternate("glGetVideoCaptureivNV") + @GLreturn("params") + @StripPostfix("params") + void glGetVideoCaptureivNV2(@GLuint int video_capture_slot, @GLenum int pname, @OutParameter IntBuffer params); + + @StripPostfix("params") + void glGetVideoCaptureStreamivNV(@GLuint int video_capture_slot, + @GLuint int stream, @GLenum int pname, + @OutParameter @Check("1") IntBuffer params); + + @Alternate("glGetVideoCaptureStreamivNV") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "v") + void glGetVideoCaptureStreamivNV2(@GLuint int video_capture_slot, + @GLuint int stream, @GLenum int pname, + @OutParameter IntBuffer params); + + @StripPostfix("params") + void glGetVideoCaptureStreamfvNV(@GLuint int video_capture_slot, + @GLuint int stream, @GLenum int pname, + @OutParameter @Check("1") FloatBuffer params); + + @Alternate("glGetVideoCaptureStreamfvNV") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "v") + void glGetVideoCaptureStreamfvNV2(@GLuint int video_capture_slot, + @GLuint int stream, @GLenum int pname, + @OutParameter FloatBuffer params); + + @StripPostfix("params") + void glGetVideoCaptureStreamdvNV(@GLuint int video_capture_slot, + @GLuint int stream, @GLenum int pname, + @OutParameter @Check("1") DoubleBuffer params); + + @Alternate("glGetVideoCaptureStreamdvNV") + @GLreturn("params") + @StripPostfix(value = "params", postfix = "v") + void glGetVideoCaptureStreamdvNV2(@GLuint int video_capture_slot, + @GLuint int stream, @GLenum int pname, + @OutParameter DoubleBuffer params); + + @GLenum + int glVideoCaptureNV(@GLuint int video_capture_slot, + @OutParameter @Check("1") @GLuint IntBuffer sequence_num, + @OutParameter @Check("1") @GLuint64EXT LongBuffer capture_time); + + @StripPostfix("params") + void glVideoCaptureStreamParameterivNV(@GLuint int video_capture_slot, @GLuint int stream, @GLenum int pname, @Const @Check("16") IntBuffer params); + + @StripPostfix("params") + void glVideoCaptureStreamParameterfvNV(@GLuint int video_capture_slot, @GLuint int stream, @GLenum int pname, @Const @Check("16") FloatBuffer params); + + @StripPostfix("params") + void glVideoCaptureStreamParameterdvNV(@GLuint int video_capture_slot, @GLuint int stream, @GLenum int pname, @Const @Check("16") DoubleBuffer params); + +} \ No newline at end of file