private long setupTextureChain() { // Set up the information for the texture buffer chain thing OVRTextureSwapChainDesc swapChainDesc = OVRTextureSwapChainDesc.calloc() .Type(ovrTexture_2D) .ArraySize(1) .Format(OVR_FORMAT_R8G8B8A8_UNORM_SRGB) .Width(textureW) .Height(textureH) .MipLevels(1) .SampleCount(1) .StaticImage(false); // ovrFalse // Create the chain PointerBuffer textureSetPB = createPointerBuffer(1); if (OVRGL.ovr_CreateTextureSwapChainGL(session, swapChainDesc, textureSetPB) != ovrSuccess) { throw new RuntimeException("Failed to create Swap Texture Set"); } swapChainDesc.free(); return textureSetPB.get(); // TODO is this a memory leak? }
public void setupLayers() { //Layers layer0 = OVRLayerEyeFov.calloc(); layer0.Header().Type(ovrLayerType_EyeFov); layer0.Header().Flags(ovrLayerFlag_TextureOriginAtBottomLeft); chains = new long[2]; for (int eye = 0; eye < 2; eye++) { long eyeChain = setupTextureChain(); chains[eye] = eyeChain; OVRRecti viewport = OVRRecti.calloc(); viewport.Pos().x(0); viewport.Pos().y(0); viewport.Size().w(textureW); viewport.Size().h(textureH); layer0.ColorTexture(eye, eyeChain); layer0.Viewport(eye, viewport); layer0.Fov(eye, fovPorts[eye]); viewport.free(); // we update pose only when we have it in the render loop } layers = createPointerBuffer(1); layers.put(0, layer0); }
public static PointerBuffer getAddressesFromCapabilities(Object caps) { List<Field> fields = getFieldsFromCapabilities(caps.getClass()); PointerBuffer addresses = BufferUtils.createPointerBuffer(fields.size()); try { for (int i = 0; i < fields.size(); i++) { long a = fields.get(i).getLong(caps); addresses.put(i, a != NULL ? a : FUNCTION_MISSING_ABORT); } } catch (IllegalAccessException e) { throw new RuntimeException(e); } return addresses; }
PointerBuffer properties = BufferUtils.createPointerBuffer(3); properties.put(CL10.CL_CONTEXT_PLATFORM).put(platform.getPointer()).put(0).flip(); int err = 0;
protected void initStatic() { if(egl_display != 0) return; egl_display = EGL10.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY); EGL10.eglInitialize(egl_display, new int[] {1}, new int[] {1}); EGLCapabilities caps = EGL.createDisplayCapabilities(egl_display); if(debug && caps.EGL_KHR_debug) setEGLDebugFunction(true, true, true, true); if(!caps.EGL14 || !EGL12.eglBindAPI(EGL14.EGL_OPENGL_API)) throw new Error("could not bind OpenGL"); int[] attrs = {EGL13.EGL_CONFORMANT, EGL14.EGL_OPENGL_BIT, EGL10.EGL_STENCIL_SIZE, 1, EGL10.EGL_NONE}; PointerBuffer cfgs = BufferUtils.createPointerBuffer(1); int[] num_config = new int[1]; EGL10.eglChooseConfig(egl_display, attrs, cfgs, num_config); if(num_config[0] == 0) throw new Error("could not found egl configs!"); egl_config = cfgs.get(0); int i = debug ? 0 : 4; while(egl_context == 0 && ctx_attrs.length > i) { int[] current_ctx_attrs = ctx_attrs[i]; egl_context = EGL10.eglCreateContext(egl_display, egl_config, 0, current_ctx_attrs); i++; if(egl_context != 0 && EGL10.eglGetError() != EGL10.EGL_SUCCESS) { EGL10.eglDestroyContext(egl_display, egl_context); egl_context = 0; } } }