Skip to content

Commit

Permalink
Bug 1021: Enhance OVR GlueGen Mapping / Adapt to GlueGen commit 9ee44…
Browse files Browse the repository at this point in the history
…e1a289ecbac024662dd5a2ffc42e8add023 (Bug 1025)
  • Loading branch information
sgothel committed Jun 25, 2014
1 parent e1dc632 commit a515faf
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 24 deletions.
8 changes: 5 additions & 3 deletions make/build-oculusvr.xml
Expand Up @@ -16,9 +16,9 @@
-->
<target name="partitioning.setup" depends="common.init">
<property name="java.part.oculusvr"
value="com/jogamp/oculusvr/** jogamp/oculusvr/**"/>
value="com/jogamp/oculusvr/* jogamp/oculusvr/*"/>
<property name="java.part.oculusvr.exclude"
value="" />
value="com/jogamp/oculusvr/renderer/*" />
</target>

<!-- ================================================================== -->
Expand Down Expand Up @@ -163,6 +163,7 @@
<target name="java.compile" depends="java.generate">
<!-- Perform the second pass Java compile; everything except portion of fixed function emulation depending on generated code. -->
<javac destdir="${classes}"
excludes="${java.part.oculusvr.exclude}"
fork="yes"
includeAntRuntime="false"
memoryMaximumSize="${javac.memorymax}"
Expand All @@ -171,7 +172,8 @@
target="${target.targetlevel}"
bootclasspath="${target.rt.jar}"
debug="${javacdebug}" debuglevel="${javacdebuglevel}">
<classpath refid="nativewindow_gluegen.classpath"/>
<!-- classpath refid="nativewindow_gluegen.classpath"/ -->
<classpath refid="jogl_nativewindow_gluegen.classpath"/>
<src path="${src.java}" />
<src path="${src.generated.java}" />
</javac>
Expand Down
5 changes: 3 additions & 2 deletions make/config/nativewindow/jawt-common.cfg
Expand Up @@ -10,10 +10,11 @@ HierarchicalNativeOutput false
Opaque boolean jboolean
Opaque long struct jawt_DrawingSurface*

ReturnValueCapacity GetDrawingSurface sizeof(JAWT_DrawingSurface)
ReturnValueCapacity GetDrawingSurfaceInfo sizeof(JAWT_DrawingSurfaceInfo)
ReturnValueCapacity JAWT.GetDrawingSurface sizeof(JAWT_DrawingSurface)
ReturnValueCapacity JAWT_DrawingSurface.GetDrawingSurfaceInfo sizeof(JAWT_DrawingSurfaceInfo)

IgnoreField JAWT GetComponent
IgnoreField JAWT_DrawingSurface target
IgnoreField JAWT_DrawingSurfaceInfo platformInfo

IncludeAs CustomJavaCode JAWT jawt-CustomJavaCode.java
Expand Down
22 changes: 17 additions & 5 deletions make/config/oculusvr/oculusvr-common.cfg
Expand Up @@ -8,11 +8,11 @@ NativeOutputDir gensrc/native/oculusvr
# Raise OVRException instead of RuntimeException in glue code
RuntimeExceptionType OVRException

# We also have to hack its return type for now because we can't make
# just that void* opaque
Opaque long ovrHmd

#ReturnValueCapacity alcOpenDevice 0
# We utilize OvrHmdContext as specified below as a 'typesafe' opaque instance,
# which is typedefed to ovrHmd - hence no type-unsafe opaque 'long' is required.
# typedef struct ovrHmdStruct {
# } OvrHmdContext;
#Opaque long ovrHmd

# Mappings for data types
Opaque boolean ovrBool
Expand All @@ -25,6 +25,18 @@ ReturnsString ovrHmd_GetLastError
ReturnsString ovrHmd_GetLatencyTestResult
ReturnsString ovrHmd_GetString

ReturnsString ovrHmdDesc.ProductName
ReturnsString ovrHmdDesc.Manufacturer
ReturnsString ovrHmdDesc.DisplayDeviceName
ReturnsString ovrSensorDesc.SerialNumber

ReturnedArrayLength ovrHmdDesc.Handle 1
ReturnedArrayLength ovrDistortionMesh.pVertexData getVertexCount()
ReturnedArrayLength ovrDistortionMesh.pIndexData getIndexCount()

ReturnValueCapacity ovrHmd_Create sizeof(ovrHmd)
ReturnValueCapacity ovrHmd_CreateDebug sizeof(ovrHmd)

ArgumentIsString ovrHmd_GetFloat 1
ArgumentIsString ovrHmd_SetFloat 1
ArgumentIsString ovrHmd_GetFloatArray 1
Expand Down
4 changes: 4 additions & 0 deletions make/config/oculusvr/oculusvr.c
@@ -1 +1,5 @@

typedef struct ovrHmdStruct {
} OvrHmdContext;

#include "OVR_CAPI.h"
71 changes: 57 additions & 14 deletions src/oculusvr/classes/com/jogamp/oculusvr/OVRVersion.java
@@ -1,5 +1,5 @@
/**
* Copyright 2010 JogAmp Community. All rights reserved.
* Copyright 2014 JogAmp Community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
Expand Down Expand Up @@ -64,19 +64,10 @@ public static StringBuilder getAvailableCapabilitiesInfo(final int ovrHmdIndex,
if( !OVR.ovr_Initialize() ) { // recursive ..
sb.append("\tOVR not available").append(Platform.getNewline());
} else {
final long ovrHmdHandle = OVR.ovrHmd_Create(ovrHmdIndex);
if( 0 != ovrHmdHandle ) {
ovrHmdDesc hmdDesc = ovrHmdDesc.create();
OVR.ovrHmd_GetDesc(ovrHmdHandle, hmdDesc);
sb.append("\thmd."+ovrHmdIndex+".type:\t"+hmdDesc.getType()).append(Platform.getNewline());
sb.append("\thmd."+ovrHmdIndex+".hmdCaps:\t"+hmdDesc.getHmdCaps()).append(Platform.getNewline());
sb.append("\thmd."+ovrHmdIndex+".distorCaps:\t"+hmdDesc.getDistortionCaps()).append(Platform.getNewline());
sb.append("\thmd."+ovrHmdIndex+".sensorCaps:\t"+hmdDesc.getSensorCaps()).append(Platform.getNewline());
final ovrSizei resolution = hmdDesc.getResolution();
sb.append("\thmd."+ovrHmdIndex+".resolution:\t"+resolution.getW()+"x"+resolution.getH()).append(Platform.getNewline());
ovrVector2i winPos = hmdDesc.getWindowsPos();
sb.append("\thmd."+ovrHmdIndex+".winPos:\t"+winPos.getX()+" / "+winPos.getY()).append(Platform.getNewline());
OVR.ovrHmd_Destroy(ovrHmdHandle);
final OvrHmdContext ovrHmdCtx = OVR.ovrHmd_Create(ovrHmdIndex);
if( null != ovrHmdCtx ) {
getAvailableCapabilitiesInfo(ovrHmdCtx, ovrHmdIndex, sb);
OVR.ovrHmd_Destroy(ovrHmdCtx);
} else {
sb.append("\thmd."+ovrHmdIndex+" not available").append(Platform.getNewline());
}
Expand All @@ -85,6 +76,58 @@ public static StringBuilder getAvailableCapabilitiesInfo(final int ovrHmdIndex,
sb.append(Platform.getNewline());
return sb;
}
/**
*
* @param ovrHmdCtx
* @param ovrHmdIndex only for informal purposes, OVR HMD index of created <code>ovrHmdHandle</code>
* @param sb
* @return
*/
public static StringBuilder getAvailableCapabilitiesInfo(final OvrHmdContext ovrHmdCtx, final int ovrHmdIndex, StringBuilder sb) {
if(null == ovrHmdCtx) {
throw new IllegalArgumentException("null ovrHmdHandle");
}
if(null==sb) {
sb = new StringBuilder();
}
ovrHmdDesc hmdDesc = ovrHmdDesc.create();
OVR.ovrHmd_GetDesc(ovrHmdCtx, hmdDesc);
getAvailableCapabilitiesInfo(hmdDesc, ovrHmdIndex, sb);

ovrSensorDesc sensorDesc = ovrSensorDesc.create();
if( OVR.ovrHmd_GetSensorDesc(ovrHmdCtx, sensorDesc) ) {
sb.append("\thmd."+ovrHmdIndex+".sensor.productId:\t0x"+Integer.toHexString(sensorDesc.getProductId())).append(Platform.getNewline());
sb.append("\thmd."+ovrHmdIndex+".sensor.vendorId:\t0x"+Integer.toHexString(sensorDesc.getVendorId())).append(Platform.getNewline());
sb.append("\thmd."+ovrHmdIndex+".sensor.serial:\t"+sensorDesc.getSerialNumberAsString()).append(Platform.getNewline());
} else {
sb.append("\thmd."+ovrHmdIndex+".sensor:\tn/a").append(Platform.getNewline());
}
return sb;
}
/**
*
* @param hmdDesc
* @param ovrHmdIndex only for informal purposes, OVR HMD index of <code>hmdDesc</code>
* @param sb
* @return
*/
public static StringBuilder getAvailableCapabilitiesInfo(ovrHmdDesc hmdDesc, final int ovrHmdIndex, StringBuilder sb) {
if(null==sb) {
sb = new StringBuilder();
}
sb.append("\thmd."+ovrHmdIndex+".productName:\t"+hmdDesc.getProductNameAsString()).append(Platform.getNewline());
sb.append("\thmd."+ovrHmdIndex+".vendorName:\t"+hmdDesc.getManufacturerAsString()).append(Platform.getNewline());
sb.append("\thmd."+ovrHmdIndex+".deviceName:\t"+hmdDesc.getDisplayDeviceNameAsString()).append(Platform.getNewline());
sb.append("\thmd."+ovrHmdIndex+".type:\t"+hmdDesc.getType()).append(Platform.getNewline());
sb.append("\thmd."+ovrHmdIndex+".hmdCaps:\t"+hmdDesc.getHmdCaps()).append(Platform.getNewline());
sb.append("\thmd."+ovrHmdIndex+".distorCaps:\t"+hmdDesc.getDistortionCaps()).append(Platform.getNewline());
sb.append("\thmd."+ovrHmdIndex+".sensorCaps:\t"+hmdDesc.getSensorCaps()).append(Platform.getNewline());
final ovrSizei resolution = hmdDesc.getResolution();
sb.append("\thmd."+ovrHmdIndex+".resolution:\t"+resolution.getW()+"x"+resolution.getH()).append(Platform.getNewline());
ovrVector2i winPos = hmdDesc.getWindowsPos();
sb.append("\thmd."+ovrHmdIndex+".winPos:\t"+winPos.getX()+" / "+winPos.getY()).append(Platform.getNewline());
return sb;
}

public static StringBuilder getAllAvailableCapabilitiesInfo(StringBuilder sb) {
if(null==sb) {
Expand Down

0 comments on commit a515faf

Please sign in to comment.