glContext.enableGLDebugMessage(true); int res = glContext.makeCurrent(); if (res == GLContext.CONTEXT_NOT_CURRENT) this.gl = glContext.getGL().getGL4(); gl.setSwapInterval(0); gl.getContext().glDebugMessageControl(gl.GL_DEBUG_SOURCE_API, gl.GL_DEBUG_TYPE_OTHER, gl.GL_DEBUG_SEVERITY_NOTIFICATION, 0, null, 0, false);
protected void initContextFirstTime(){ if (GLContext.getCurrent().getGLVersionNumber().getMajor() < 2) { throw new RendererException("OpenGL 2.0 or higher is " + "required for jMonkeyEngine"); if (GLContext.getCurrentGL().isExtensionAvailable("GL_ARB_debug_output") && settings.getBoolean("GraphicsDebug")) { GLContext.getCurrent().enableGLDebugMessage(true); GLContext.getCurrent().addGLDebugListener(new JoglGLDebugOutputHandler());
@Override protected void initContextFirstTime(){ offscreenDrawable.getContext().makeCurrent(); try { super.initContextFirstTime(); } finally { offscreenDrawable.getContext().release(); } }
protected void begin(TextRenderer renderer) { setTextColorRespectComposite(renderer); GL2 gl = g2d.getGLContext().getGL().getGL2(); gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); gl.glPushMatrix(); gl.glScalef(1, -1, 1); gl.glTranslatef(0, -g2d.getCanvasHeight(), 0); renderer.begin3DRendering(); }
@Override void updatePointAttributes(Context ctx, float pointSize, boolean pointAntialiasing) { if (VERBOSE) System.err.println("JoglPipeline.updatePointAttributes()"); GL2 gl = context(ctx).getGL().getGL2(); gl.glPointSize(pointSize); // XXXX: Polygon Mode check, blend enable if (pointAntialiasing) { gl.glEnable(GL2.GL_POINT_SMOOTH); } else { gl.glDisable(GL2.GL_POINT_SMOOTH); } }
final GLContext ctx = gl.getContext(); sb.append("Swap Interval ").append(gl.getSwapInterval()); sb.append(Platform.getNewline()); sb.append("GL Profile ").append(gl.getGLProfile()); sb.append(Platform.getNewline()); sb.append("GL Version ").append(ctx.getGLVersion()).append(" [GL ").append(ctx.getGLVersionNumber()).append(", vendor ").append(ctx.getGLVendorVersionNumber()).append("]"); sb.append(Platform.getNewline()); sb.append("Quirks ").append(ctx.getRendererQuirks()); sb.append(Platform.getNewline()); sb.append("Impl. class ").append(gl.getClass().getCanonicalName()); sb.append("GLSL ").append(gl.hasGLSL()).append(", has-compiler-func: ").append(gl.isFunctionAvailable("glCompileShader")); if(gl.hasGLSL()) { sb.append(", version: ").append(gl.glGetString(GL2ES2.GL_SHADING_LANGUAGE_VERSION)).append(" / ").append(ctx.getGLSLVersionNumber()); sb.append("GL FBO: basic ").append(gl.hasBasicFBOSupport()).append(", full ").append(gl.hasFullFBOSupport()); sb.append(Platform.getNewline()); sb.append("GL_EXTENSIONS ").append(ctx.getGLExtensionCount()); sb.append(Platform.getNewline()); if( withExtensions ) { sb.append(" ").append(ctx.getGLExtensionsString()); sb.append(Platform.getNewline()); sb.append("GLX_EXTENSIONS ").append(ctx.getPlatformExtensionCount()); sb.append(Platform.getNewline()); if( withExtensions ) { sb.append(" ").append(ctx.getPlatformExtensionsString()); sb.append(Platform.getNewline());
@Override public void glPolygonMode(int param1, int param2) { GLContext.getCurrentGL().getGL2().glPolygonMode(param1, param2); }
glContext.makeCurrent(); GL2 gl = glContext.getGL().getGL2(); glContext.release(); glContext.destroy(); glDrawable.setRealized(false);
/** * Resets PACK pixel storage modes to their default value. */ public final void resetPack(final GL gl) { // Compared w/ ES2, ES3 and GL3-core spec gl.glPixelStorei(GL.GL_PACK_ALIGNMENT, 4); // es2, es3, gl3 if( gl.isGL2ES3() ) { gl.glPixelStorei(GL2ES3.GL_PACK_ROW_LENGTH, 0); // es3, gl3 gl.glPixelStorei(GL2ES3.GL_PACK_SKIP_ROWS, 0); // es3, gl3 gl.glPixelStorei(GL2ES3.GL_PACK_SKIP_PIXELS, 0); // es3, gl3 if( gl.isGL2GL3() ) { gl.glPixelStorei(GL2GL3.GL_PACK_SWAP_BYTES, GL.GL_FALSE); // gl3 gl.glPixelStorei(GL2GL3.GL_PACK_LSB_FIRST, GL.GL_FALSE); // gl3 if( gl.getContext().getGLVersionNumber().compareTo(GLContext.Version1_2) >= 0 ) { gl.glPixelStorei(GL2GL3.GL_PACK_IMAGE_HEIGHT, 0); // gl3, GL_VERSION_1_2 gl.glPixelStorei(GL2GL3.GL_PACK_SKIP_IMAGES, 0); // gl3, GL_VERSION_1_2 } } } } /**
if(pbuffer.getContext().makeCurrent()==GLContext.CONTEXT_NOT_CURRENT) gl = pbuffer.getGL().getGL2(); gl.glDeleteFramebuffers(1, texturet, 0); gl.glDeleteTextures(1, texturet, 1); gl.glDeleteTextures(1, texturet, 0); pbuffer.getContext().release();
public void renderWithSizeAndColor( int x, int y, @Nonnull String text, float sizeX, float sizeY, float r, float g, float b, float a) { final GL2 gl = GLContext.getCurrentGL().getGL2(); // enableBlend(); gl.glColor4f(r, g, b, a); internalRenderText(x, y, text, sizeX, sizeY, a); // disableBlend(); }
/** * Disposes this texture name. When practical, this method should be called * explicitly. Otherwise, it will be called when this object is finalized * during garbage collection. */ public synchronized void dispose() { if (_context!=null) { GLContext current = GLContext.getCurrent(); if (_context==current || _context.makeCurrent()==GLContext.CONTEXT_CURRENT) { try { //System.out.println("dispose: deleting name="+_name); int[] names = {_name}; glDeleteTextures(1,names,0); } finally { if (_context!=current) { _context.release(); current.makeCurrent(); } } } _context = null; _name = 0; } }
@Override void newDisplayList(Context ctx, int displayListId) { if (VERBOSE) System.err.println("JoglPipeline.newDisplayList()"); if (displayListId <= 0) { System.err.println("JAVA 3D ERROR : glNewList(" + displayListId + ") -- IGNORED"); } GL2 gl = context(ctx).getGL().getGL2(); gl.glNewList(displayListId, GL2.GL_COMPILE); }
public static final GL2 getCurrentGL2() throws GLException { GLContext curContext = GLContext.getCurrent(); if (curContext == null) { throw new GLException("No OpenGL context current on this thread"); } return curContext.getGL().getGL2(); }
GLContext lastContext = GLContext.getCurrent(); Runnable lastInitAction = null; if (lastContext != null) { lastContext.release(); res = context.makeCurrent(); if (GLContext.CONTEXT_NOT_CURRENT != res) { if(GLContext.CONTEXT_CURRENT_NEW == res) { try { if(destroyContext) { context.destroy(); } else { forceNativeRelease(context); final int res2 = lastContext.makeCurrent(); if (null != lastInitAction && res2 == GLContext.CONTEXT_CURRENT_NEW) { lastInitAction.run();
@Override void accum(Context ctx, float value) { if (VERBOSE) System.err.println("JoglPipeline.accum()"); GL2 gl = context(ctx).getGL().getGL2(); gl.glReadBuffer(GL.GL_BACK); gl.glAccum(GL2.GL_ACCUM, value); gl.glReadBuffer(GL.GL_FRONT); }
public final StringBuilder append(final StringBuilder sb) { sb.append("Version ").append(getGLVersion()).append(" [GL ").append(getGLVersionNumber()).append(", vendor ").append(getGLVendorVersionNumber()); sb.append("], options 0x"); sb.append(Integer.toHexString(ctxOptions)); sb.append(", this "); sb.append(toHexString(hashCode())); sb.append(", handle "); sb.append(toHexString(contextHandle)); sb.append(", isShared "+isShared()+", "); sb.append(getGL()); sb.append(",\n\t quirks: "); if(null != glRendererQuirks) { glRendererQuirks.toString(sb); } else { sb.append("n/a"); } if(getGLDrawable()!=getGLReadDrawable()) { sb.append(",\n\tRead Drawable : "); sb.append(getGLReadDrawable()); sb.append(",\n\tWrite Drawable: "); sb.append(getGLDrawable()); } else { sb.append(",\n\tDrawable: "); sb.append(getGLDrawable()); } return sb; }
public static void closestFit( final GL gl, final int target, final int width, final int height, final int internalFormat, final int format, final int type, final int[] newWidth, final int[] newHeight ) { if( gl.isGL2GL3() && gl.getContext().getGLVersionNumber().compareTo(GLContext.Version1_1) >= 0 ) { int widthPowerOf2 = nearestPower( width ); int heightPowerOf2 = nearestPower( height ); gl.glTexImage2D( proxyTarget, 1, internalFormat, widthAtLevelOne, heightAtLevelOne, 0, format, type, null ); } else if( (target == GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X) ||
private static void dumpGLInfo(final GLDrawableFactoryImpl factory, final AbstractGraphicsDevice device) { final GLContext ctx = factory.getOrCreateSharedContext(device); if(null != ctx) { System.err.println("GLProfile.dumpGLInfo: "+ctx); ctx.makeCurrent(); try { System.err.println(JoglVersion.getGLInfo(ctx.getGL(), null)); } finally { ctx.release(); } } else { System.err.println("GLProfile.dumpGLInfo: shared context n/a"); System.err.println(device.getClass().getSimpleName()+"[type "+ device.getType()+", connection "+device.getConnection()+"]:"); System.err.println(GLProfile.glAvailabilityToString(device, null, "\t", 1).toString()); } }