Java Code Examples for org.lwjgl.opengl.GLContext#getCapabilities()

The following examples show how to use org.lwjgl.opengl.GLContext#getCapabilities() . 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: LwjglContext.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
protected void printContextInitInfo(){
    logger.log(Level.FINE, "Running on thread: {0}", Thread.currentThread().getName());

    logger.log(Level.INFO, "Adapter: {0}", Display.getAdapter());
    logger.log(Level.INFO, "Driver Version: {0}", Display.getVersion());

    String vendor = GL11.glGetString(GL11.GL_VENDOR);
    logger.log(Level.INFO, "Vendor: {0}", vendor);

    String version = GL11.glGetString(GL11.GL_VERSION);
    logger.log(Level.INFO, "OpenGL Version: {0}", version);

    String renderGl = GL11.glGetString(GL11.GL_RENDERER);
    logger.log(Level.INFO, "Renderer: {0}", renderGl);

    if (GLContext.getCapabilities().OpenGL20){
        String shadingLang = GL11.glGetString(GL20.GL_SHADING_LANGUAGE_VERSION);
        logger.log(Level.INFO, "GLSL Ver: {0}", shadingLang);
    }
}
 
Example 2
Source File: TextureGenerator.java    From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private static void throwIfLANotSupported() {
	if(!GLContext.getCapabilities().OpenGL30) {
		return;
	}
	
	if(!GLContext.getCapabilities().OpenGL32) {
		if(!GLContext.getCapabilities().GL_ARB_compatibility) {
			throw new ImageFormatUnsupportedException("Core OpenGL contexts cannot use Luminance/alpha.");
		}
	}
	else {
		int profileMask = glGetInteger(GL32.GL_CONTEXT_PROFILE_MASK);
		
		if((profileMask & GL32.GL_CONTEXT_CORE_PROFILE_BIT) != 0) {
			throw new ImageFormatUnsupportedException("Core OpenGL contexts cannot use Luminance/alpha.");
			
		}
	}
}
 
Example 3
Source File: Curve.java    From opsu-dance with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Init curves for given circle diameter
 * Should be called before any curves are drawn.
 * @param circleDiameter the circle diameter
 * @param borderColor the curve border color
 */
public static void init(float circleDiameter, Color borderColor) {
	Curve.borderColor = borderColor;

	ContextCapabilities capabilities = GLContext.getCapabilities();
	mmsliderSupported = capabilities.OpenGL30;
	if (mmsliderSupported) {
		CurveRenderState.init(circleDiameter);
	} else if (SkinService.skin.getSliderStyle() != Skin.STYLE_PEPPYSLIDER) {
		Log.warn("New slider style requires OpenGL 3.0.");
	}
}
 
Example 4
Source File: DynamicTextureWrapper.java    From MediaMod with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Initialize key components
 */
private static void init() {
    if (!INITIALIZED) {
        try {
            GLContext.getCapabilities();
        } catch (RuntimeException ignored) {
            return;
        }
        FULLY_TRANSPARENT_TEXTURE = FMLClientHandler.instance().getClient().getTextureManager().getDynamicTextureLocation(
                "mediamod", new DynamicTexture(FULLY_TRANSPARENT_IMAGE));
        INITIALIZED = true;
    }
}
 
Example 5
Source File: TextureGenerator.java    From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static void throwIfSRGBNotSupported() {
	if(!GLContext.getCapabilities().OpenGL21) {
		if(!GLContext.getCapabilities().GL_EXT_texture_sRGB) {
			throw new ImageFormatUnsupportedException("sRGB textures not supported.");
		}
	}
}
 
Example 6
Source File: Renderer.java    From tribaltrouble with GNU General Public License v2.0 5 votes vote down vote up
public final static void dumpWindowInfo() {
	int r = GLUtils.getGLInteger(GL11.GL_RED_BITS);
	int g = GLUtils.getGLInteger(GL11.GL_GREEN_BITS);
	int b = GLUtils.getGLInteger(GL11.GL_BLUE_BITS);
	int a = GLUtils.getGLInteger(GL11.GL_ALPHA_BITS);
	int depth = GLUtils.getGLInteger(GL11.GL_DEPTH_BITS);
	int stencil = GLUtils.getGLInteger(GL11.GL_STENCIL_BITS);
	int sample_buffers = 0;
	int samples = 0;
	if (GLContext.getCapabilities().GL_ARB_multisample) {
		sample_buffers = GLUtils.getGLInteger(ARBMultisample.GL_SAMPLE_BUFFERS_ARB);
		samples = GLUtils.getGLInteger(ARBMultisample.GL_SAMPLES_ARB);
	}
	System.out.println("r = " + r + " | g = " + g + " | b = " + b + " | a = " + a + " | depth = " + depth + " | stencil = " + stencil + " | sample_buffers = " + sample_buffers + " | samples = " + samples);
}
 
Example 7
Source File: TextureGenerator.java    From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static void throwIfFloatNotSupported() {
	if(!GLContext.getCapabilities().OpenGL30) {
		if(!GLContext.getCapabilities().GL_ARB_texture_float) {
			throw new ImageFormatUnsupportedException("Float textures not supported.");
		}
	}
}
 
Example 8
Source File: TextureGenerator.java    From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static void throwIfRGNotSupported() {
	if(!GLContext.getCapabilities().OpenGL30) {
		if(!GLContext.getCapabilities().GL_ARB_texture_rg) {
			throw new ImageFormatUnsupportedException("RG textures not supported.");
		}
	}
}
 
Example 9
Source File: TextureGenerator.java    From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static void throwIfRGTCNotSupported() {
	if(!GLContext.getCapabilities().OpenGL30) {
		if(!GLContext.getCapabilities().GL_ARB_texture_compression_rgtc || !GLContext.getCapabilities().GL_EXT_texture_compression_rgtc) {
			throw new ImageFormatUnsupportedException("RGTC, part of GL 3.0 and above, is not supported.");
		}
	}
}
 
Example 10
Source File: TextureGenerator.java    From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static void throwIfDepthNotSupported() {
	if(!GLContext.getCapabilities().OpenGL14) { // Yes, really. Depth textures are old.
		if(!GLContext.getCapabilities().GL_ARB_depth_texture) {
			throw new ImageFormatUnsupportedException("Depth textures not supported.");
		}
	}
}
 
Example 11
Source File: Curve.java    From opsu with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Set the width and height of the container that Curves get drawn into.
 * Should be called before any curves are drawn.
 * @param width the container width
 * @param height the container height
 * @param circleDiameter the circle diameter
 * @param borderColor the curve border color
 */
public static void init(int width, int height, float circleDiameter, Color borderColor) {
	Curve.borderColor = borderColor;

	ContextCapabilities capabilities = GLContext.getCapabilities();
	mmsliderSupported = capabilities.OpenGL30;
	if (mmsliderSupported) {
		CurveRenderState.init(width, height, circleDiameter);
		LegacyCurveRenderState.init(width, height, circleDiameter);
	} else {
		if (Options.getSkin().getSliderStyle() != Skin.STYLE_PEPPYSLIDER)
			Log.warn("New slider style requires OpenGL 3.0.");
	}
}
 
Example 12
Source File: ArtifactClientEventHandler.java    From Artifacts with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onFogRender(FogDensity event) {
	//Handle player "cloaking" with Obscurity component.
	Minecraft mc = Minecraft.getMinecraft();
	if((cloaked && !mc.thePlayer.isPotionActive(Potion.invisibility)) || mc.thePlayer.isPotionActive(Potion.blindness)) {
		cloaked = false;
	}
	
	//Make the fog max depend on the render distance.
	float fogMax = mc.gameSettings.renderDistanceChunks * 16;
	if(fogCurrent > fogMax) {
		fogCurrent = fogMax;
	}

       //Check if the effect should or shouldn't be applied (it shouldn't if the player already has a strong fog effect).
	if(!mc.thePlayer.isPotionActive(Potion.blindness) && !mc.thePlayer.isInsideOfMaterial(Material.water) && !mc.thePlayer.isInsideOfMaterial(Material.lava)) {
	   //Note to self - this didn't work that well: && !BlockQuickSand.headInQuicksand(mc.theWorld, MathHelper.floor_double(mc.thePlayer.posX), MathHelper.floor_double(mc.thePlayer.posY + mc.thePlayer.getEyeHeight()), MathHelper.floor_double(mc.thePlayer.posZ), mc.thePlayer)
		
		//If the player is cloaked, render the fog coming in. It stops when it reaches fogMin.
		if(cloaked) {
			event.setCanceled(true);
			if(fogCurrent > fogMin + 0.01) {
				fogCurrent -= (fogCurrent-fogMin)/fogMax * 0.3f;
			}
		}
		//Otherwise render the fog going out, then stop rendering when it reaches fogMax.
		else {
			if(fogCurrent < fogMax) {
				event.setCanceled(true);
				
				fogCurrent += 0.1f;
			}
		} 
	}
	else {
		//"Insta-move" the fog if it isn't rendering.
		if(cloaked) {
			fogCurrent = fogMin;
		}
		else {
			fogCurrent = fogMax;
		}
	}
	
	//Render the fog.
	if(event.isCanceled()) {
		GL11.glFogi(GL11.GL_FOG_MODE, GL11.GL_LINEAR);

		GL11.glFogf(GL11.GL_FOG_START, fogCurrent * 0.25F);
		GL11.glFogf(GL11.GL_FOG_END, fogCurrent);

		if (GLContext.getCapabilities().GL_NV_fog_distance)
		{
			GL11.glFogi(34138, 34139);
		}
	}
}
 
Example 13
Source File: TextureGenerator.java    From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static void throwIfDepthStencilNotSupported() {
	if(!GLContext.getCapabilities().OpenGL30) {
		if(!GLContext.getCapabilities().GL_EXT_packed_depth_stencil || !GLContext.getCapabilities().GL_ARB_framebuffer_object) {
			throw new ImageFormatUnsupportedException("Depth/stencil textures not supported.");
		}
	}
}
 
Example 14
Source File: TextureGenerator.java    From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private static void throwIfEXT_SRGBNotSupported() {
	if(!GLContext.getCapabilities().GL_EXT_texture_sRGB) {
		throw new ImageFormatUnsupportedException("sRGB and S3TC textures not supported.");
	}
}
 
Example 15
Source File: TextureGenerator.java    From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private static void throwIfBPTCNotSupported() {
	if(!GLContext.getCapabilities().GL_ARB_texture_compression_bptc) {
		throw new ImageFormatUnsupportedException("PBTC not supported.");
	}
}
 
Example 16
Source File: ImmediateModeOGLRenderer.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public boolean canTextureMirrorClamp() {
	return GLContext.getCapabilities().GL_EXT_texture_mirror_clamp;
}
 
Example 17
Source File: TextureGenerator.java    From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private static void throwIfEXT_IntegralNotSupported() {
	if(!GLContext.getCapabilities().GL_EXT_texture_integer) {
		throw new ImageFormatUnsupportedException("Integral texture extension not supported.");
	}
}
 
Example 18
Source File: ArraysHelper.java    From OpenModsLib with MIT License 4 votes vote down vote up
static void initialize() {
	ContextCapabilities caps = GLContext.getCapabilities();
	if (GLArrayMethods.isSupported(caps)) methods = new GLArrayMethods();
	else if (ARBArrayMethods.isSupported(caps)) methods = new ARBArrayMethods();
}
 
Example 19
Source File: Settings.java    From tribaltrouble with GNU General Public License v2.0 4 votes vote down vote up
public final boolean useTextureCompression() {
	return use_texture_compression && (GLContext.getCapabilities().GL_ARB_texture_compression || GLContext.getCapabilities().OpenGL13);
}
 
Example 20
Source File: BufferHelper.java    From OpenModsLib with MIT License 4 votes vote down vote up
static void initialize() {
	ContextCapabilities caps = GLContext.getCapabilities();
	if (GLBufferMethods.isSupported(caps)) methods = new GLBufferMethods();
	else if (ARBBufferMethods.isSupported(caps)) methods = new ARBBufferMethods();
}