org.lwjgl.opengl.GLContext Java Examples

The following examples show how to use org.lwjgl.opengl.GLContext. 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: GraphicsFactory.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Initialise offscreen rendering by checking what buffers are supported
 * by the card
 * 
 * @throws SlickException Indicates no buffers are supported
 */
private static void init() throws SlickException {
	init = true;
	
	if (fbo) {
		fbo = GLContext.getCapabilities().GL_EXT_framebuffer_object;
	}
	pbuffer = (Pbuffer.getCapabilities() & Pbuffer.PBUFFER_SUPPORTED) != 0;
	pbufferRT = (Pbuffer.getCapabilities() & Pbuffer.RENDER_TEXTURE_SUPPORTED) != 0;
	
	if (!fbo && !pbuffer && !pbufferRT) {
		throw new SlickException("Your OpenGL card does not support offscreen buffers and hence can't handle the dynamic images required for this application.");
	}
	
	Log.info("Offscreen Buffers FBO="+fbo+" PBUFFER="+pbuffer+" PBUFFERRT="+pbufferRT);
}
 
Example #3
Source File: FramebufferBlitter.java    From OpenModsLib with MIT License 6 votes vote down vote up
public static boolean setup() {
	if (OpenGlHelper.framebufferSupported) {
		final ContextCapabilities caps = GLContext.getCapabilities();

		if (caps.OpenGL30) {
			Log.debug("Using OpenGL 3.0 FB blit");
			INSTANCE = new GL30Impl();
			return true;
		}

		if (caps.GL_EXT_framebuffer_blit) {
			Log.debug("Using EXT FB blit");
			INSTANCE = new ExtImpl();
			return true;
		}
	}

	Log.debug("FB blit not supported");
	return false;
}
 
Example #4
Source File: CurveRenderState.java    From opsu with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Reads the first row of the slider gradient texture and upload it as
 * a 1D texture to OpenGL if it hasn't already been done.
 */
public void initGradient() {
	if (gradientTexture == 0) {
		Image slider = GameImage.SLIDER_GRADIENT.getImage().getScaledCopy(1.0f / GameImage.getUIscale());
		staticState.gradientTexture = GL11.glGenTextures();
		ByteBuffer buff = BufferUtils.createByteBuffer(slider.getWidth() * 4);
		for (int i = 0; i < slider.getWidth(); ++i) {
			Color col = slider.getColor(i, 0);
			buff.put((byte) (255 * col.r));
			buff.put((byte) (255 * col.g));
			buff.put((byte) (255 * col.b));
			buff.put((byte) (255 * col.a));
		}
		buff.flip();
		GL11.glBindTexture(GL11.GL_TEXTURE_1D, gradientTexture);
		GL11.glTexImage1D(GL11.GL_TEXTURE_1D, 0, GL11.GL_RGBA, slider.getWidth(), 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, buff);
		ContextCapabilities capabilities = GLContext.getCapabilities();
		if (capabilities.OpenGL30) {
			GL30.glGenerateMipmap(GL11.GL_TEXTURE_1D);
		} else if (capabilities.GL_EXT_framebuffer_object) {
			EXTFramebufferObject.glGenerateMipmapEXT(GL11.GL_TEXTURE_1D);
		} else {
			GL11.glTexParameteri(GL11.GL_TEXTURE_1D, GL14.GL_GENERATE_MIPMAP, GL11.GL_TRUE);
		}
	}
}
 
Example #5
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 #6
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 #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 throwIfSharedExpNotSupported() {
	if(!GLContext.getCapabilities().OpenGL30) {
		if(!GLContext.getCapabilities().GL_EXT_texture_shared_exponent) {
			throw new ImageFormatUnsupportedException("Shared exponent texture format 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 throwIfFloatNotSupported() {
	if(!GLContext.getCapabilities().OpenGL30) {
		if(!GLContext.getCapabilities().GL_ARB_texture_float) {
			throw new ImageFormatUnsupportedException("Float 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 throwIfHalfFloatNotSupported() {
	if(!GLContext.getCapabilities().OpenGL30) {
		if(!GLContext.getCapabilities().GL_ARB_half_float_pixel) {
			throw new ImageFormatUnsupportedException("Half floats textures not supported.");
		}
	}
}
 
Example #10
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 #11
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 throwIfPackedFloatNotSupported() {
	if(!GLContext.getCapabilities().OpenGL30) {
		if(!GLContext.getCapabilities().GL_EXT_packed_float) {
			throw new ImageFormatUnsupportedException("Packed 11, 11, 10 float textures not supported.");
		}
	}
}
 
Example #12
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 throwIfIntegralNotSupported() {
	if(!GLContext.getCapabilities().OpenGL30) {
		if(!GLContext.getCapabilities().GL_EXT_texture_integer) {
			throw new ImageFormatUnsupportedException("Integral textures not supported.");
		}
	}
}
 
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 throwIfRGNotSupported() {
	if(!GLContext.getCapabilities().OpenGL30) {
		if(!GLContext.getCapabilities().GL_ARB_texture_rg) {
			throw new ImageFormatUnsupportedException("RG textures not supported.");
		}
	}
}
 
Example #14
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 throwIfSnormNotSupported() {
	if(!GLContext.getCapabilities().OpenGL31) {
		if(!GLContext.getCapabilities().GL_EXT_texture_snorm) {
			throw new ImageFormatUnsupportedException("Signed normalized textures not supported.");
		}
	}
}
 
Example #15
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 #16
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 throwIfDepthFloatNotSupported() {
	if(!GLContext.getCapabilities().OpenGL30) {
		if(!GLContext.getCapabilities().GL_NV_depth_buffer_float) {
			throw new ImageFormatUnsupportedException("Floating-point depth buffers not supported.");
		}
	}
}
 
Example #17
Source File: TextureGenerator.java    From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static boolean isTextureStorageSupported() {
	if(!GLContext.getCapabilities().OpenGL42) {
		if(!GLContext.getCapabilities().GL_ARB_texture_storage) {
			return false;
		}
	}
	
	return true;
}
 
Example #18
Source File: FBOGraphics.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Create a new graphics context around an FBO
 * 
 * @param image The image we're rendering to
 * @throws SlickException Indicates a failure to use pbuffers
 */
public FBOGraphics(Image image) throws SlickException {
	super(image.getTexture().getTextureWidth(), image.getTexture().getTextureHeight());
	this.image = image;
	
	Log.debug("Creating FBO "+image.getWidth()+"x"+image.getHeight());
	
	boolean FBOEnabled = GLContext.getCapabilities().GL_EXT_framebuffer_object;
	if (!FBOEnabled) {
		throw new SlickException("Your OpenGL card does not support FBO and hence can't handle the dynamic images required for this application.");
	}

	init();
}
 
Example #19
Source File: LwjglRenderer.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #20
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 #21
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 #22
Source File: TextureUtils.java    From OpenGL-Animation with The Unlicense 5 votes vote down vote up
protected static int loadTextureToOpenGL(TextureData data, TextureBuilder builder) {
	int texID = GL11.glGenTextures();
	GL13.glActiveTexture(GL13.GL_TEXTURE0);
	GL11.glBindTexture(GL11.GL_TEXTURE_2D, texID);
	GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);
	GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, data.getWidth(), data.getHeight(), 0, GL12.GL_BGRA,
			GL11.GL_UNSIGNED_BYTE, data.getBuffer());
	if (builder.isMipmap()) {
		GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);
		GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
		GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR);
		if (builder.isAnisotropic() && GLContext.getCapabilities().GL_EXT_texture_filter_anisotropic) {
			GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_LOD_BIAS, 0);
			GL11.glTexParameterf(GL11.GL_TEXTURE_2D, EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT,
					4.0f);
		}
	} else if (builder.isNearest()) {
		GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
		GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
	} else {
		GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
		GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
	}
	if (builder.isClampEdges()) {
		GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
		GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);
	} else {
		GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT);
		GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT);
	}
	GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
	return texID;
}
 
Example #23
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 #24
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 #25
Source File: Texture.java    From tribaltrouble with GNU General Public License v2.0 5 votes vote down vote up
private final void uploadDXTTexture(DXTImage dxt_image, TextureFile texture_file) {
		int detail_shift = getDetailShift(dxt_image.getNumMipMaps());
		int max_index = getMaxMipmapIndex(dxt_image.getNumMipMaps(), texture_file.getMaxMipmapLevel(), detail_shift);
		int total_size = 0;
		for (int i = 0; i < max_index; i++) {
			int mipmap_level = i + detail_shift;
			dxt_image.position(mipmap_level);
			if (GLContext.getCapabilities().GL_EXT_texture_compression_s3tc) {
				total_size += dxt_image.getMipMap().remaining();
				GLState.glCompressedTexImage2D(GL11.GL_TEXTURE_2D, i, dxt_image.getInternalFormat(), dxt_image.getWidth(mipmap_level), dxt_image.getHeight(mipmap_level), 0, dxt_image.getMipMap());
			} else {
				byte[] blocks = new byte[dxt_image.getMipMap().remaining()];
				dxt_image.getMipMap().get(blocks);
				Squish.CompressionType type = dxt_image.getInternalFormat() == EXTTextureCompressionS3TC.GL_COMPRESSED_RGBA_S3TC_DXT5_EXT ? Squish.CompressionType.DXT5 : Squish.CompressionType.DXT1;
				byte[] rgba = Squish.decompressImage(null, dxt_image.getWidth(mipmap_level), dxt_image.getHeight(mipmap_level), blocks, type);
				ByteBuffer buf = BufferUtils.createByteBuffer(rgba.length);
				buf.put(rgba);
				buf.flip();
				GL11.glTexImage2D(GL11.GL_TEXTURE_2D, i, texture_file.getInternalFormat(), dxt_image.getWidth(mipmap_level), dxt_image.getHeight(mipmap_level), 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, buf);
				total_size += determineMipMapSize(i, texture_file.getInternalFormat(), dxt_image.getWidth(mipmap_level), dxt_image.getHeight(mipmap_level));
			}
		}
		setSize(total_size);
/*for (int i = 0; i < max_index; i++) {
int mipmap_level = i + detail_shift;
GLUtils.saveTexture(i, new java.io.File(texture_file.getURL().getFile() + dxt_image.getWidth(mipmap_level) + "x" + dxt_image.getHeight(mipmap_level)).getName());
}*/
	}
 
Example #26
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 #27
Source File: OpenGLDisplay.java    From DareEngine with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Creates a new OpenGL display.
 * 
 * @param width The width of the display, in pixels.
 * @param height The height of the display, in pixels.
 * @param title The text appearing in the display's title bar.
 */
public OpenGLDisplay(int width, int height, String title) {
	glfwSetErrorCallback(errorCallback = errorCallbackPrint(System.err));

	if (glfwInit() != GL_TRUE) {
		throw new IllegalStateException("Unable to initialize GLFW");
	}

	glfwDefaultWindowHints();
	glfwWindowHint(GLFW_VISIBLE, GL_FALSE);
	glfwWindowHint(GLFW_RESIZABLE, GL_TRUE);

	window = glfwCreateWindow(width, height, title, NULL, NULL);
	if (window == NULL) {
		throw new RuntimeException("Failed to create the GLFW window");
	}

	ByteBuffer vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor());
	glfwSetWindowPos(window, (GLFWvidmode.width(vidmode) - width) / 2,
			(GLFWvidmode.height(vidmode) - height) / 2);

	glfwMakeContextCurrent(window);
	glfwSwapInterval(Debug.isIgnoringFrameCap() ? 0 : 1);

	glfwShowWindow(window);
	GLContext.createFromCurrent();

	device = new OpenGLRenderDevice(width, height);
	this.target = new RenderTarget(device, width, height, 0, 0);
	frameBuffer = new RenderContext(device, target);
	input = new OpenGLInput(window);
	audioDevice = new OpenALAudioDevice();
}
 
Example #28
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 #29
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 #30
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.");
	}
}