本文整理汇总了Java中org.lwjgl.opengl.GLContext类的典型用法代码示例。如果您正苦于以下问题:Java GLContext类的具体用法?Java GLContext怎么用?Java GLContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GLContext类属于org.lwjgl.opengl包,在下文中一共展示了GLContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.lwjgl.opengl.GLContext; //导入依赖的package包/类
/**
* 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);
}
示例2: createWindow
import org.lwjgl.opengl.GLContext; //导入依赖的package包/类
/**
* Creates a GLFWWindow and gives it OpenGL context
*/
private void createWindow() {
// Hide the window during application initialization
Window.hint(GLFW.GLFW_VISIBLE, GL11.GL_FALSE);
// Setup MSAA 4x
Window.hint(GLFW.GLFW_SAMPLES, 4);
WINDOW.create(config.width, config.height, config.title);
// Make this thread and window the current context for OpenGL
WINDOW.makeContextCurrent();
GLContext.createFromCurrent();
// Set other specified window configurations
WINDOW.setVSyncEnabled(config.vSyncEnabled);
WINDOW.setPosition(config.position);
}
示例3: init
import org.lwjgl.opengl.GLContext; //导入依赖的package包/类
/**
* Initialize default state.
*/
private void init() {
if (glfwInit() != GL_TRUE) {
throw new IllegalStateException("GLFW failed to initialize!");
}
win = glfwCreateWindow(SCREEN_WIDTH, SCREEN_HEIGHT, TITLE, 0, 0);
glfwShowWindow(win);
glfwMakeContextCurrent(win);
GLContext.createFromCurrent();
GL.createCapabilities(true);
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
示例4: startup
import org.lwjgl.opengl.GLContext; //导入依赖的package包/类
public static void startup(Minecraft mc)
{
checkShadersModInstalled();
mc = Minecraft.getMinecraft();
capabilities = GLContext.getCapabilities();
glVersionString = GL11.glGetString(GL11.GL_VERSION);
glVendorString = GL11.glGetString(GL11.GL_VENDOR);
glRendererString = GL11.glGetString(GL11.GL_RENDERER);
SMCLog.info("ShadersMod version: 2.4.12");
SMCLog.info("OpenGL Version: " + glVersionString);
SMCLog.info("Vendor: " + glVendorString);
SMCLog.info("Renderer: " + glRendererString);
SMCLog.info("Capabilities: " + (capabilities.OpenGL20 ? " 2.0 " : " - ") + (capabilities.OpenGL21 ? " 2.1 " : " - ") + (capabilities.OpenGL30 ? " 3.0 " : " - ") + (capabilities.OpenGL32 ? " 3.2 " : " - ") + (capabilities.OpenGL40 ? " 4.0 " : " - "));
SMCLog.info("GL_MAX_DRAW_BUFFERS: " + GL11.glGetInteger(GL20.GL_MAX_DRAW_BUFFERS));
SMCLog.info("GL_MAX_COLOR_ATTACHMENTS_EXT: " + GL11.glGetInteger(36063));
SMCLog.info("GL_MAX_TEXTURE_IMAGE_UNITS: " + GL11.glGetInteger(GL20.GL_MAX_TEXTURE_IMAGE_UNITS));
hasGlGenMipmap = capabilities.OpenGL30;
loadConfig();
}
示例5: startup
import org.lwjgl.opengl.GLContext; //导入依赖的package包/类
public static void startup(Minecraft mc)
{
checkShadersModInstalled();
Shaders.mc = mc;
mc = Minecraft.getMinecraft();
capabilities = GLContext.getCapabilities();
glVersionString = GL11.glGetString(GL11.GL_VERSION);
glVendorString = GL11.glGetString(GL11.GL_VENDOR);
glRendererString = GL11.glGetString(GL11.GL_RENDERER);
SMCLog.info("ShadersMod version: 2.4.12");
SMCLog.info("OpenGL Version: " + glVersionString);
SMCLog.info("Vendor: " + glVendorString);
SMCLog.info("Renderer: " + glRendererString);
SMCLog.info("Capabilities: " + (capabilities.OpenGL20 ? " 2.0 " : " - ") + (capabilities.OpenGL21 ? " 2.1 " : " - ") + (capabilities.OpenGL30 ? " 3.0 " : " - ") + (capabilities.OpenGL32 ? " 3.2 " : " - ") + (capabilities.OpenGL40 ? " 4.0 " : " - "));
SMCLog.info("GL_MAX_DRAW_BUFFERS: " + GL11.glGetInteger(GL20.GL_MAX_DRAW_BUFFERS));
SMCLog.info("GL_MAX_COLOR_ATTACHMENTS_EXT: " + GL11.glGetInteger(36063));
SMCLog.info("GL_MAX_TEXTURE_IMAGE_UNITS: " + GL11.glGetInteger(GL20.GL_MAX_TEXTURE_IMAGE_UNITS));
hasGlGenMipmap = capabilities.OpenGL30;
loadConfig();
}
示例6: GuiMainMenu
import org.lwjgl.opengl.GLContext; //导入依赖的package包/类
public GuiMainMenu() {
this.openGLWarning2 = MORE_INFO_TEXT;
IResource iresource = null;
this.splashText = "uhoh";
this.splashText = Splashes.getSplashes()[new Random().nextInt(Splashes.getSplashes().length)];
this.updateCounter = RANDOM.nextFloat();
this.openGLWarning1 = "";
if (!GLContext.getCapabilities().OpenGL20 && !OpenGlHelper.areShadersSupported()) {
this.openGLWarning1 = I18n.format("title.oldgl1", new Object[0]);
this.openGLWarning2 = I18n.format("title.oldgl2", new Object[0]);
this.openGLWarningLink = "https://help.mojang.com/customer/portal/articles/325948?ref=game";
}
String s1 = System.getProperty("java.version");
if (s1 != null && (s1.startsWith("1.6") || s1.startsWith("1.7"))) {
this.openGLWarning1 = I18n.format("title.oldjava1", new Object[0]);
this.openGLWarning2 = I18n.format("title.oldjava2", new Object[0]);
this.openGLWarningLink = "https://help.mojang.com/customer/portal/articles/2636196?ref=game";
}
}
示例7: getMaximumAntialiasingSamples
import org.lwjgl.opengl.GLContext; //导入依赖的package包/类
/**
* @return Maxiumum anti-aliasing samples supported. Required to have the LWJGL libraries loaded before calling
*/
public static int getMaximumAntialiasingSamples() {
int result = 0;
try {
Pbuffer pb = new Pbuffer( 10, 10, new PixelFormat( 24, 8, 24, 8, 0 ), null );
pb.makeCurrent();
boolean supported = GLContext.getCapabilities().GL_ARB_multisample;
if ( supported ) {
result = GL11.glGetInteger( GL30.GL_MAX_SAMPLES );
}
pb.destroy();
}
catch( LWJGLException e ) {
//e.printStackTrace();
}
return result;
}
示例8: getMaximumAntialiasingSamples
import org.lwjgl.opengl.GLContext; //导入依赖的package包/类
/**
* @return Maxiumum anti-aliasing samples supported. Required to have the LWJGL libraries loaded before calling
*/
public static int getMaximumAntialiasingSamples() {
int result = 0;
try {
Pbuffer pb = new Pbuffer( 10, 10, new PixelFormat( 32, 0, 24, 8, 0 ), null );
pb.makeCurrent();
boolean supported = GLContext.getCapabilities().GL_ARB_multisample;
if ( supported ) {
result = GL11.glGetInteger( GL30.GL_MAX_SAMPLES );
}
pb.destroy();
}
catch ( LWJGLException e ) {
//e.printStackTrace();
}
return result;
}
示例9: init
import org.lwjgl.opengl.GLContext; //导入依赖的package包/类
/**
* Initialize
*/
private static void init() throws Exception {
System.out.println("Timer resolution: " + Sys.getTimerResolution());
// Go into orthographic projection mode.
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0, Display.getDisplayMode().getWidth(), 0, Display.getDisplayMode().getHeight());
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight());
if ( !GLContext.getCapabilities().GL_ARB_vertex_buffer_object ) {
System.out.println("ARB VBO not supported!");
System.exit(1);
}
buffer_id = glGenBuffersARB();
glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffer_id);
vertices = ByteBuffer.allocateDirect(2 * 4 * 4).order(ByteOrder.nativeOrder()).asFloatBuffer();
vertices.put(-50).put(-50).put(50).put(-50).put(50).put(50).put(-50).put(50);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, 2 * 4 * 4, GL_STREAM_DRAW_ARB);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, 0);
}
示例10: initialize
import org.lwjgl.opengl.GLContext; //导入依赖的package包/类
public void initialize() {
//glDisable(GL_DEPTH_TEST);
glShadeModel(GL_SMOOTH);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
if (GLContext.getCapabilities().GL_ARB_texture_non_power_of_two) {
caps.add(Caps.NonPowerOfTwoTextures);
} else {
logger.log(Level.WARNING, "Your graphics card does not "
+ "support non-power-of-2 textures. "
+ "Some features might not work.");
}
if (GLContext.getCapabilities().OpenGL12){
gl12 = true;
}
}
示例11: printContextInitInfo
import org.lwjgl.opengl.GLContext; //导入依赖的package包/类
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);
}
}
示例12: loadTexture
import org.lwjgl.opengl.GLContext; //导入依赖的package包/类
public int loadTexture(String fileName) {
Texture texture = null;
try {
texture = TextureLoader.getTexture("PNG",
new FileInputStream(MainGameLoop.fileManager.getTextureFile(fileName)));
GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR);
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_LOD_BIAS, 0);
if (GLContext.getCapabilities().GL_EXT_texture_filter_anisotropic) {
float amount = Math.min(4f,
GL11.glGetFloat(EXTTextureFilterAnisotropic.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT));
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT,
amount);
} else {
System.out.println("Filter Anisotropic Not Supported");
}
} catch (Exception e) {
e.printStackTrace();
System.err.println("Tried to load texture " + fileName + ".png , didn't work");
System.exit(-1);
}
textures.add(texture.getTextureID());
return texture.getTextureID();
}
示例13: preInit
import org.lwjgl.opengl.GLContext; //导入依赖的package包/类
@Subscribe
public void preInit(FMLPreInitializationEvent evt) {
log = evt.getModLog();
ContextCapabilities caps = GLContext.getCapabilities();
copyImageSupported = caps.OpenGL43 || caps.GL_ARB_copy_image;
if(!copyImageSupported) {
log.warn("Fast animated textures require OpenGL 4.3 or ARB_copy_image extension, which were not detected. Using original slow path.");
} else {
log.info("Using fast animated textures.");
}
File configFile = evt.getSuggestedConfigurationFile();
Configuration config = new Configuration(configFile);
boolean enableFastAnimation = config.getBoolean("enableFastAnimation", "animfix", true, "Enable the faster animation mode. Set to false only if true causes issues.");
maxUpdateMip = config.getInt("maxUpdateMipLevel", "animfix", -1, -1, 4, "Set to a number to disable animation updates past that mip level. -1 means update all. Higher numbers update more levels.");
if(config.hasChanged()) {
config.save();
}
copyImageEnabled = copyImageSupported && enableFastAnimation;
}
示例14: Window
import org.lwjgl.opengl.GLContext; //导入依赖的package包/类
public Window(String title, int width, int height) {
Window.title = title;
Window.width = width;
Window.height = height;
glfwInit();
//glfwWindowHint(GLFW_DECORATED, GL_FALSE);
window = glfwCreateWindow(width, height, title, 0, 0);
glfwMakeContextCurrent(window);
GLContext.createFromCurrent();
glfwSwapInterval(1);
keyCallback = new KeyCallback();
mousePosCallback = new MousePosCallback();
glfwSetKeyCallback(window, keyCallback);
glfwSetCursorPosCallback(window, mousePosCallback);
}
示例15: initializeTextures
import org.lwjgl.opengl.GLContext; //导入依赖的package包/类
/**
* Initializes the texture constants to be used when rendering lightmap values
*/
public static void initializeTextures()
{
Config.initDisplay();
useMultitextureARB = GLContext.getCapabilities().GL_ARB_multitexture && !GLContext.getCapabilities().OpenGL13;
if (useMultitextureARB)
{
defaultTexUnit = 33984;
lightmapTexUnit = 33985;
}
else
{
defaultTexUnit = 33984;
lightmapTexUnit = 33985;
}
openGL14 = GLContext.getCapabilities().OpenGL14;
framebufferSupported = openGL14 && GLContext.getCapabilities().GL_ARB_framebuffer_object;
anisotropicFilteringSupported = GLContext.getCapabilities().GL_EXT_texture_filter_anisotropic;
anisotropicFilteringMax = (int)(anisotropicFilteringSupported ? GL11.glGetFloat(34047) : 0.0F);
GameSettings.Options.ANISOTROPIC_FILTERING.setValueMax((float)anisotropicFilteringMax);
openGL21 = GLContext.getCapabilities().OpenGL21;
shadersSupported = framebufferSupported && openGL21;
}