com.jme3.renderer.RendererException Java Examples
The following examples show how to use
com.jme3.renderer.RendererException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SkeletonControl.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
private boolean testHardwareSupported(RenderManager rm) { for (Material m : materials) { // Some of the animated mesh(es) do not support hardware skinning, // so it is not supported by the model. if (m.getMaterialDef().getMaterialParam("NumberOfBones") == null) { Logger.getLogger(SkeletonControl.class.getName()).log(Level.WARNING, "Not using hardware skinning for {0}, " + "because material {1} doesn''t support it.", new Object[]{spatial, m.getMaterialDef().getName()}); return false; } } switchToHardware(); try { rm.preloadScene(spatial); return true; } catch (RendererException e) { Logger.getLogger(SkeletonControl.class.getName()).log(Level.WARNING, "Could not enable HW skinning due to shader compile error:", e); return false; } }
Example #2
Source File: BaseMaterialEditor3DPart.java From jmonkeybuilder with Apache License 2.0 | 6 votes |
/** * Update the {@link Material} in the {@link EditorThread}. * * @param material the new material. */ @JmeThread protected void updateMaterialImpl(@NotNull final Material material) { final Geometry testBox = getTestBox(); testBox.setMaterial(material); final Geometry testQuad = getTestQuad(); testQuad.setMaterial(material); final Geometry testSphere = getTestSphere(); testSphere.setMaterial(material); final RenderManager renderManager = EditorUtil.getRenderManager(); try { renderManager.preloadScene(testBox); } catch (final RendererException | AssetNotFoundException | UnsupportedOperationException e) { handleMaterialException(e); testBox.setMaterial(EditorUtil.getDefaultMaterial()); testQuad.setMaterial(EditorUtil.getDefaultMaterial()); testSphere.setMaterial(EditorUtil.getDefaultMaterial()); } }
Example #3
Source File: IosGL.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
private static void checkLimit(Buffer buffer) { if (buffer == null) { return; } if (buffer.limit() == 0) { throw new RendererException("Attempting to upload empty buffer (limit = 0), that's an error"); } if (buffer.remaining() == 0) { throw new RendererException("Attempting to upload empty buffer (remaining = 0), that's an error"); } }
Example #4
Source File: LwjglRenderer.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
private void updateRenderBuffer(FrameBuffer fb, RenderBuffer rb) { int id = rb.getId(); if (id == -1) { glGenRenderbuffersEXT(intBuf1); id = intBuf1.get(0); rb.setId(id); } if (context.boundRB != id) { glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, id); context.boundRB = id; } if (fb.getWidth() > maxRBSize || fb.getHeight() > maxRBSize) { throw new RendererException("Resolution " + fb.getWidth() + ":" + fb.getHeight() + " is not supported."); } TextureUtil.checkFormatSupported(rb.getFormat()); if (fb.getSamples() > 1 && GLContext.getCapabilities().GL_EXT_framebuffer_multisample) { int samples = fb.getSamples(); if (maxFBOSamples < samples) { samples = maxFBOSamples; } glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, samples, TextureUtil.convertTextureFormat(rb.getFormat()), fb.getWidth(), fb.getHeight()); } else { glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, TextureUtil.convertTextureFormat(rb.getFormat()), fb.getWidth(), fb.getHeight()); } }
Example #5
Source File: MaterialDebugAppState.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
public Material reloadMaterial(Material mat) { //clear the entire cache, there might be more clever things to do, like clearing only the matdef, and the associated shaders. assetManager.clearCache(); //creating a dummy mat with the mat def of the mat to reload // Force the reloading of the asset, otherwise the new shader code will not be applied. Material dummy = new Material(assetManager, mat.getMaterialDef().getAssetName()); for (MatParam matParam : mat.getParams()) { dummy.setParam(matParam.getName(), matParam.getVarType(), matParam.getValue()); } dummy.getAdditionalRenderState().set(mat.getAdditionalRenderState()); //creating a dummy geom and assigning the dummy material to it Geometry dummyGeom = new Geometry("dummyGeom", new Box(1f, 1f, 1f)); dummyGeom.setMaterial(dummy); try { //preloading the dummyGeom, this call will compile the shader again renderManager.preloadScene(dummyGeom); } catch (RendererException e) { //compilation error, the shader code will be output to the console //the following code will output the error //System.err.println(e.getMessage()); Logger.getLogger(MaterialDebugAppState.class.getName()).log(Level.SEVERE, e.getMessage()); return null; } Logger.getLogger(MaterialDebugAppState.class.getName()).log(Level.INFO, "Material succesfully reloaded"); //System.out.println("Material succesfully reloaded"); return dummy; }
Example #6
Source File: TextureUtil.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
public GLImageFormat getImageFormatWithError(Format fmt, boolean isSrgb) { //if the passed format is one kind of depth there isno point in getting the srgb format; isSrgb = isSrgb && !fmt.isDepthFormat(); GLImageFormat glFmt = getImageFormat(fmt, isSrgb); if (glFmt == null && isSrgb) { glFmt = getImageFormat(fmt, false); logger.log(Level.WARNING, "No sRGB format available for ''{0}''. Failling back to linear.", fmt); } if (glFmt == null) { throw new RendererException("Image format '" + fmt + "' is unsupported by the video hardware."); } return glFmt; }
Example #7
Source File: LwjglRender.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
protected static void checkLimit(final Buffer buffer) { if (buffer == null) { return; } if (buffer.limit() == 0) { throw new RendererException("Attempting to upload empty buffer (limit = 0), that's an error"); } if (buffer.remaining() == 0) { throw new RendererException("Attempting to upload empty buffer (remaining = 0), that's an error"); } }
Example #8
Source File: JmeIosGLES.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static void checkGLError() { if (!ENABLE_ERROR_CHECKING) { return; } int error = glGetError(); if (error != 0) { String message = null;//GLU.gluErrorString(error); if (message == null) { throw new RendererException("An unknown [" + error + "] OpenGL error has occurred."); } else { throw new RendererException("An OpenGL error has occurred: " + message); } } }
Example #9
Source File: RendererUtil.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Checks for an OpenGL error and throws a {@link RendererException} if * there is one. Does nothing if {@link RendererUtil#ENABLE_ERROR_CHECKING} * is set to * <code>false</code>. */ public static void checkGLError() { if (!ENABLE_ERROR_CHECKING) { return; } int error = GLES20.glGetError(); if (error != 0) { String message = GLU.gluErrorString(error); if (message == null) { throw new RendererException("An unknown OpenGL error has occurred."); } else { throw new RendererException("An OpenGL error has occurred: " + message); } } }
Example #10
Source File: RendererUtil.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Checks for an OpenGL error and throws a {@link RendererException} if * there is one. Ignores the value of * {@link RendererUtil#ENABLE_ERROR_CHECKING}. */ public static void checkGLErrorForced() { int error = GLES20.glGetError(); if (error != 0) { String message = GLU.gluErrorString(error); if (message == null) { throw new RendererException("An unknown OpenGL error has occurred."); } else { throw new RendererException("An OpenGL error has occurred: " + message); } } }
Example #11
Source File: JmeFilePreviewManager.java From jmonkeybuilder with Apache License 2.0 | 5 votes |
/** * Try to load and show the model. * * @param model the model. */ @JmeThread private void tryToLoad(@NotNull Spatial model) { try { var renderManager = EditorUtil.getRenderManager(); renderManager.preloadScene(model); modelNode.attachChild(model); } catch (RendererException | AssetNotFoundException | UnsupportedOperationException e) { EditorUtil.handleException(LOGGER, this, e); } }
Example #12
Source File: LwjglGLExt.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
private static void checkLimit(Buffer buffer) { if (buffer == null) { return; } if (buffer.limit() == 0) { throw new RendererException("Attempting to upload empty buffer (limit = 0), that's an error"); } if (buffer.remaining() == 0) { throw new RendererException("Attempting to upload empty buffer (remaining = 0), that's an error"); } }
Example #13
Source File: LwjglGL.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
private static void checkLimit(Buffer buffer) { if (buffer == null) { return; } if (buffer.limit() == 0) { throw new RendererException("Attempting to upload empty buffer (limit = 0), that's an error"); } if (buffer.remaining() == 0) { throw new RendererException("Attempting to upload empty buffer (remaining = 0), that's an error"); } }
Example #14
Source File: JmeApplication.java From jmonkeybuilder with Apache License 2.0 | 5 votes |
@Override @JmeThread public void update() { var stamp = syncLock(); try { var executor = JmeThreadExecutor.getInstance(); executor.execute(); //System.out.println(cam.getRotation()); //System.out.println(cam.getLocation()); if (Config.ENABLE_3D) { super.update(); } } catch (AssetNotFoundException | NoSuchMethodError | RendererException | AssertionError | ArrayIndexOutOfBoundsException | NullPointerException | StackOverflowError | IllegalStateException | UnsupportedOperationException e) { LOGGER.warning(e); finishWorkOnError(e); } finally { syncUnlock(stamp); } listener.setLocation(cam.getLocation()); listener.setRotation(cam.getRotation()); }
Example #15
Source File: LwjglGLFboGL3.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
private static void checkLimit(Buffer buffer) { if (buffer == null) { return; } if (buffer.limit() == 0) { throw new RendererException("Attempting to upload empty buffer (limit = 0), that's an error"); } if (buffer.remaining() == 0) { throw new RendererException("Attempting to upload empty buffer (remaining = 0), that's an error"); } }
Example #16
Source File: AndroidGL.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
private static void checkLimit(Buffer buffer) { if (buffer == null) { return; } if (buffer.limit() == 0) { throw new RendererException("Attempting to upload empty buffer (limit = 0), that's an error"); } if (buffer.remaining() == 0) { throw new RendererException("Attempting to upload empty buffer (remaining = 0), that's an error"); } }
Example #17
Source File: LwjglGLFboEXT.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
private static void checkLimit(Buffer buffer) { if (buffer == null) { return; } if (buffer.limit() == 0) { throw new RendererException("Attempting to upload empty buffer (limit = 0), that's an error"); } if (buffer.remaining() == 0) { throw new RendererException("Attempting to upload empty buffer (remaining = 0), that's an error"); } }
Example #18
Source File: AbstractSceneEditor3DPart.java From jmonkeybuilder with Apache License 2.0 | 5 votes |
/** * The process of showing the model in the scene. */ @JmeThread private void openModelImpl(@NotNull final M model) { final Node modelNode = getModelNode(); final M currentModel = getCurrentModel(); if (currentModel != null) { detachPrevModel(modelNode, currentModel); } NodeUtils.visitGeometry(model, geometry -> { final RenderManager renderManager = EditorUtil.getRenderManager(); try { renderManager.preloadScene(geometry); } catch (final RendererException | AssetNotFoundException | UnsupportedOperationException e) { EditorUtil.handleException(LOGGER, this, new RuntimeException("Found invalid material in the geometry: [" + geometry.getName() + "]. " + "The material will be removed from the geometry.", e)); geometry.setMaterial(EditorUtil.getDefaultMaterial()); } }); PRE_TRANSFORM_HANDLERS.forEach(model, Consumer::accept); attachModel(model, modelNode); POST_TRANSFORM_HANDLERS.forEach(model, Consumer::accept); setCurrentModel(model); }
Example #19
Source File: GLDebug.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
protected void checkError() { int err = gl.glGetError(); if (err != 0) { throw new RendererException("An OpenGL error occurred - " + decodeError(err)); } }
Example #20
Source File: TextureUtil.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
public static void checkFormatSupported(Format fmt) { if (!isFormatSupported(fmt, GLContext.getCapabilities())) { throw new RendererException("Image format '" + fmt + "' is unsupported by the video hardware."); } }
Example #21
Source File: LwjglRenderer.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
public void copyFrameBuffer(FrameBuffer src, FrameBuffer dst, boolean copyDepth) { if (GLContext.getCapabilities().GL_EXT_framebuffer_blit) { int srcW = 0; int srcH = 0; int dstW = 0; int dstH = 0; int prevFBO = context.boundFBO; if (src != null && src.isUpdateNeeded()) { updateFrameBuffer(src); } if (dst != null && dst.isUpdateNeeded()) { updateFrameBuffer(dst); } if (src == null) { glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 0); // srcW = viewWidth; // srcH = viewHeight; } else { glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, src.getId()); srcW = src.getWidth(); srcH = src.getHeight(); } if (dst == null) { glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0); // dstW = viewWidth; // dstH = viewHeight; } else { glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, dst.getId()); dstW = dst.getWidth(); dstH = dst.getHeight(); } int mask = GL_COLOR_BUFFER_BIT; if (copyDepth) { mask |= GL_DEPTH_BUFFER_BIT; } glBlitFramebufferEXT(0, 0, srcW, srcH, 0, 0, dstW, dstH, mask, GL_NEAREST); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, prevFBO); try { checkFrameBufferError(); } catch (IllegalStateException ex) { logger.log(Level.SEVERE, "Source FBO:\n{0}", src); logger.log(Level.SEVERE, "Dest FBO:\n{0}", dst); throw ex; } } else { throw new RendererException("EXT_framebuffer_blit required."); // TODO: support non-blit copies? } }
Example #22
Source File: LwjglRenderer.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
public void updateShaderData(Shader shader) { int id = shader.getId(); boolean needRegister = false; if (id == -1) { // create program id = glCreateProgram(); if (id <= 0) { throw new RendererException("Invalid ID (" + id + ") received when trying to create shader program."); } shader.setId(id); needRegister = true; } for (ShaderSource source : shader.getSources()) { if (source.isUpdateNeeded()) { updateShaderSourceData(source, shader.getLanguage()); // shader has been compiled here } if (!source.isUsable()) { // it's useless.. just forget about everything.. shader.setUsable(false); shader.clearUpdateNeeded(); return; } glAttachShader(id, source.getId()); } if (caps.contains(Caps.OpenGL30)) { GL30.glBindFragDataLocation(id, 0, "outFragColor"); } // link shaders to program glLinkProgram(id); glGetProgram(id, GL_LINK_STATUS, intBuf1); boolean linkOK = intBuf1.get(0) == GL_TRUE; String infoLog = null; if (VALIDATE_SHADER || !linkOK) { glGetProgram(id, GL_INFO_LOG_LENGTH, intBuf1); int length = intBuf1.get(0); if (length > 3) { // get infos ByteBuffer logBuf = BufferUtils.createByteBuffer(length); glGetProgramInfoLog(id, null, logBuf); // convert to string, etc byte[] logBytes = new byte[length]; logBuf.get(logBytes, 0, length); infoLog = new String(logBytes); } } if (linkOK) { if (infoLog != null) { logger.log(Level.INFO, "shader link success. \n{0}", infoLog); } else { logger.fine("shader link success"); } } else { if (infoLog != null) { throw new RendererException("Shader link failure, shader:" + shader + " info:" + infoLog); } else { throw new RendererException("Shader link failure, shader:" + shader + " info: <not provided>"); } } shader.clearUpdateNeeded(); if (!linkOK) { // failure.. forget about everything shader.resetSources(); shader.setUsable(false); deleteShader(shader); } else { shader.setUsable(true); if (needRegister) { objManager.registerForCleanup(shader); statistics.onNewShader(); } else { // OpenGL spec: uniform locations may change after re-link resetUniformLocations(shader); } } }
Example #23
Source File: JoglRenderer.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
@Override public void updateShaderData(Shader shader) { if (glslVer != -1) { GL gl = GLContext.getCurrentGL(); int id = shader.getId(); boolean needRegister = false; if (id == -1) { // create program id = gl.getGL2().glCreateProgram(); if (id <= 0) { throw new RendererException( "Invalid ID received when trying to create shader program."); } shader.setId(id); needRegister = true; } for (ShaderSource source : shader.getSources()) { if (source.isUpdateNeeded()) { updateShaderSourceData(source, shader.getLanguage()); // shader has been compiled here } if (!source.isUsable()) { // it's useless.. just forget about everything.. shader.setUsable(false); shader.clearUpdateNeeded(); return; } gl.getGL2().glAttachShader(id, source.getId()); } // link shaders to program gl.getGL2().glLinkProgram(id); gl.getGL2().glGetProgramiv(id, GL2ES2.GL_LINK_STATUS, intBuf1); boolean linkOK = intBuf1.get(0) == GL.GL_TRUE; String infoLog = null; if (VALIDATE_SHADER || !linkOK) { gl.getGL2().glGetProgramiv(id, GL2ES2.GL_INFO_LOG_LENGTH, intBuf1); int length = intBuf1.get(0); if (length > 3) { // get infos ByteBuffer logBuf = BufferUtils.createByteBuffer(length); gl.getGL2().glGetProgramInfoLog(id, logBuf.limit(), intBuf1, logBuf); // convert to string, etc byte[] logBytes = new byte[length]; logBuf.get(logBytes, 0, length); infoLog = new String(logBytes); } } if (linkOK) { if (infoLog != null) { logger.log(Level.INFO, "shader link success. \n{0}", infoLog); } else { logger.fine("shader link success"); } } else { if (infoLog != null) { logger.log(Level.WARNING, "shader link failure. \n{0}", infoLog); } else { logger.warning("shader link failure"); } } shader.clearUpdateNeeded(); if (!linkOK) { // failure.. forget about everything shader.resetSources(); shader.setUsable(false); deleteShader(shader); } else { shader.setUsable(true); if (needRegister) { objManager.registerForCleanup(shader); statistics.onNewShader(); } else { // OpenGL spec: uniform locations may change after re-link resetUniformLocations(shader); } } } }
Example #24
Source File: LwjglContext.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
protected void initContextFirstTime() { final String renderer = settings.getRenderer(); final GLCapabilities capabilities = createCapabilities(!renderer.equals(AppSettings.LWJGL_OPENGL2)); if (!capabilities.OpenGL20) { throw new RendererException("OpenGL 2.0 or higher is required for jMonkeyEngine"); } else if (!SUPPORTED_RENDERS.contains(renderer)) { throw new UnsupportedOperationException("Unsupported renderer: " + renderer); } GL gl = new LwjglGL(); GLExt glext = new LwjglGLExt(); GLFbo glfbo; if (capabilities.OpenGL30) { glfbo = new LwjglGLFboGL3(); } else { glfbo = new LwjglGLFboEXT(); } if (settings.getBoolean("GraphicsDebug")) { gl = (GL) GLDebug.createProxy(gl, gl, GL.class, GL2.class, GL3.class, GL4.class); glext = (GLExt) GLDebug.createProxy(gl, glext, GLExt.class); glfbo = (GLFbo) GLDebug.createProxy(gl, glfbo, GLFbo.class); } if (settings.getBoolean("GraphicsTiming")) { GLTimingState timingState = new GLTimingState(); gl = (GL) GLTiming.createGLTiming(gl, timingState, GL.class, GL2.class, GL3.class, GL4.class); glext = (GLExt) GLTiming.createGLTiming(glext, timingState, GLExt.class); glfbo = (GLFbo) GLTiming.createGLTiming(glfbo, timingState, GLFbo.class); } if (settings.getBoolean("GraphicsTrace")) { gl = (GL) GLTracer.createDesktopGlTracer(gl, GL.class, GL2.class, GL3.class, GL4.class); glext = (GLExt) GLTracer.createDesktopGlTracer(glext, GLExt.class); glfbo = (GLFbo) GLTracer.createDesktopGlTracer(glfbo, GLFbo.class); } this.renderer = new GLRenderer(gl, glext, glfbo); this.renderer.initialize(); if (capabilities.GL_ARB_debug_output && settings.getBoolean("GraphicsDebug")) { ARBDebugOutput.glDebugMessageCallbackARB(new LwjglGLDebugOutputHandler(), 0); } this.renderer.setMainFrameBufferSrgb(settings.isGammaCorrection()); this.renderer.setLinearizeSrgbImages(settings.isGammaCorrection()); // Init input if (keyInput != null) { keyInput.initialize(); } if (mouseInput != null) { mouseInput.initialize(); } if (joyInput != null) { joyInput.initialize(); } GLFW.glfwSetJoystickCallback(new GLFWJoystickCallback() { @Override public void invoke(int jid, int event) { // Invoke the disconnected event before we reload the joysticks or we lose the reference to it. // Invoke the connected event after we reload the joysticks to obtain the reference to it. if ( event == GLFW.GLFW_CONNECTED ) { joyInput.reloadJoysticks(); joyInput.fireJoystickConnectedEvent(jid); } else { joyInput.fireJoystickDisconnectedEvent(jid); joyInput.reloadJoysticks(); } } }); renderable.set(true); }
Example #25
Source File: LwjglContextVR.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
protected void initContextFirstTime() { final GLCapabilities capabilities = createCapabilities(settings.getRenderer().equals(AppSettings.LWJGL_OPENGL32)); if (!capabilities.OpenGL20) { throw new RendererException("OpenGL 2.0 or higher is required for jMonkeyEngine"); } if (settings.getRenderer().equals(AppSettings.LWJGL_OPENGL2) || settings.getRenderer().equals(AppSettings.LWJGL_OPENGL32)) { GL gl = new LwjglGL(); GLExt glext = new LwjglGLExt(); GLFbo glfbo; if (capabilities.OpenGL30) { glfbo = new LwjglGLFboGL3(); } else { glfbo = new LwjglGLFboEXT(); } if (settings.getBoolean("GraphicsDebug")) { gl = (GL) GLDebug.createProxy(gl, gl, GL.class, GL2.class, GL3.class, GL4.class); glext = (GLExt) GLDebug.createProxy(gl, glext, GLExt.class); glfbo = (GLFbo) GLDebug.createProxy(gl, glfbo, GLFbo.class); } if (settings.getBoolean("GraphicsTiming")) { GLTimingState timingState = new GLTimingState(); gl = (GL) GLTiming.createGLTiming(gl, timingState, GL.class, GL2.class, GL3.class, GL4.class); glext = (GLExt) GLTiming.createGLTiming(glext, timingState, GLExt.class); glfbo = (GLFbo) GLTiming.createGLTiming(glfbo, timingState, GLFbo.class); } if (settings.getBoolean("GraphicsTrace")) { gl = (GL) GLTracer.createDesktopGlTracer(gl, GL.class, GL2.class, GL3.class, GL4.class); glext = (GLExt) GLTracer.createDesktopGlTracer(glext, GLExt.class); glfbo = (GLFbo) GLTracer.createDesktopGlTracer(glfbo, GLFbo.class); } renderer = new GLRenderer(gl, glext, glfbo); renderer.initialize(); } else { throw new UnsupportedOperationException("Unsupported renderer: " + settings.getRenderer()); } if (capabilities.GL_ARB_debug_output && settings.getBoolean("GraphicsDebug")) { ARBDebugOutput.glDebugMessageCallbackARB(new LwjglGLDebugOutputHandler(), 0); } renderer.setMainFrameBufferSrgb(settings.isGammaCorrection()); renderer.setLinearizeSrgbImages(settings.isGammaCorrection()); // Init input if (keyInput != null) { keyInput.initialize(); } if (mouseInput != null) { mouseInput.initialize(); } if (joyInput != null) { joyInput.initialize(); } renderable.set(true); }
Example #26
Source File: LwjglContext.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
protected void initContextFirstTime() { if (!GLContext.getCapabilities().OpenGL20) { throw new RendererException("OpenGL 2.0 or higher is " + "required for jMonkeyEngine"); } int vers[] = getGLVersion(settings.getRenderer()); if (vers != null) { GL gl = new LwjglGL(); GLExt glext = new LwjglGLExt(); GLFbo glfbo; if (GLContext.getCapabilities().OpenGL30) { glfbo = new LwjglGLFboGL3(); } else { glfbo = new LwjglGLFboEXT(); } if (settings.getBoolean("GraphicsDebug")) { gl = (GL) GLDebug.createProxy(gl, gl, GL.class, GL2.class, GL3.class, GL4.class); glext = (GLExt) GLDebug.createProxy(gl, glext, GLExt.class); glfbo = (GLFbo) GLDebug.createProxy(gl, glfbo, GLFbo.class); } if (settings.getBoolean("GraphicsTiming")) { GLTimingState timingState = new GLTimingState(); gl = (GL) GLTiming.createGLTiming(gl, timingState, GL.class, GL2.class, GL3.class, GL4.class); glext = (GLExt) GLTiming.createGLTiming(glext, timingState, GLExt.class); glfbo = (GLFbo) GLTiming.createGLTiming(glfbo, timingState, GLFbo.class); } if (settings.getBoolean("GraphicsTrace")) { gl = (GL) GLTracer.createDesktopGlTracer(gl, GL.class, GL2.class, GL3.class, GL4.class); glext = (GLExt) GLTracer.createDesktopGlTracer(glext, GLExt.class); glfbo = (GLFbo) GLTracer.createDesktopGlTracer(glfbo, GLFbo.class); } renderer = new GLRenderer(gl, glext, glfbo); renderer.initialize(); } else { throw new UnsupportedOperationException("Unsupported renderer: " + settings.getRenderer()); } if (GLContext.getCapabilities().GL_ARB_debug_output && settings.getBoolean("GraphicsDebug")) { ARBDebugOutput.glDebugMessageCallbackARB(new ARBDebugOutputCallback(new LwjglGLDebugOutputHandler())); } renderer.setMainFrameBufferSrgb(settings.isGammaCorrection()); renderer.setLinearizeSrgbImages(settings.isGammaCorrection()); // Init input if (keyInput != null) { keyInput.initialize(); } if (mouseInput != null) { mouseInput.initialize(); } if (joyInput != null) { joyInput.initialize(); } }
Example #27
Source File: RendererUtil.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Checks for an EGL error and throws a {@link RendererException} if there * is one. Ignores the value of {@link RendererUtil#ENABLE_ERROR_CHECKING}. */ public static void checkEGLError(EGL10 egl) { int error = egl.eglGetError(); if (error != EGL10.EGL_SUCCESS) { String errorMessage; switch (error) { case EGL10.EGL_SUCCESS: return; case EGL10.EGL_NOT_INITIALIZED: errorMessage = "EGL is not initialized, or could not be " + "initialized, for the specified EGL display connection. "; break; case EGL10.EGL_BAD_ACCESS: errorMessage = "EGL cannot access a requested resource " + "(for example a context is bound in another thread). "; break; case EGL10.EGL_BAD_ALLOC: errorMessage = "EGL failed to allocate resources for the requested operation."; break; case EGL10.EGL_BAD_ATTRIBUTE: errorMessage = "An unrecognized attribute or attribute " + "value was passed in the attribute list. "; break; case EGL10.EGL_BAD_CONTEXT: errorMessage = "An EGLContext argument does not name a valid EGL rendering context. "; break; case EGL10.EGL_BAD_CONFIG: errorMessage = "An EGLConfig argument does not name a valid EGL frame buffer configuration. "; break; case EGL10.EGL_BAD_CURRENT_SURFACE: errorMessage = "The current surface of the calling thread " + "is a window, pixel buffer or pixmap that is no longer valid. "; break; case EGL10.EGL_BAD_DISPLAY: errorMessage = "An EGLDisplay argument does not name a valid EGL display connection. "; break; case EGL10.EGL_BAD_SURFACE: errorMessage = "An EGLSurface argument does not name a " + "valid surface (window, pixel buffer or pixmap) configured for GL rendering. "; break; case EGL10.EGL_BAD_MATCH: errorMessage = "Arguments are inconsistent (for example, a " + "valid context requires buffers not supplied by a valid surface). "; break; case EGL10.EGL_BAD_PARAMETER: errorMessage = "One or more argument values are invalid."; break; case EGL10.EGL_BAD_NATIVE_PIXMAP: errorMessage = "A NativePixmapType argument does not refer to a valid native pixmap. "; break; case EGL10.EGL_BAD_NATIVE_WINDOW: errorMessage = "A NativeWindowType argument does not refer to a valid native window. "; break; case EGL11.EGL_CONTEXT_LOST: errorMessage = "A power management event has occurred. " + "The application must destroy all contexts and reinitialise " + "OpenGL ES state and objects to continue rendering. "; break; default: errorMessage = "Unknown"; } throw new RendererException("EGL error 0x" + Integer.toHexString(error) + ": " + errorMessage); } }