List of usage examples for org.lwjgl.opengl GL11 glGetError
@NativeType("GLenum") public static int glGetError()
From source file:itemrender.client.rendering.FBOHelper.java
License:MIT License
public static void checkGlErrors(String message) { int error = GL11.glGetError(); if (error != 0) { String error_name = GLU.gluErrorString(error); ItemRenderMod.instance.log.error("########## GL ERROR ##########"); ItemRenderMod.instance.log.error("@ " + message); ItemRenderMod.instance.log.error(error + ": " + error_name); }//w w w .j a v a2 s. c o m }
From source file:ivengine.Util.java
License:Creative Commons License
/** * Stores a variable amount of textures defined by URLS <filenames> into a texture array. Uses a magfilter <magfilter>, a minfilter <minfilter>. * If <mipmap> is true, mipmaps will be activated. * If <anisotropic> is true, anisotropic filtering will be activated, if supported. *///from w w w .jav a 2s .c o m public static int loadTextureAtlasIntoTextureArray(URL[] filenames, int magfilter, int minfilter, boolean mipmap, boolean anisotropic) { int tex = GL11.glGenTextures(); GL11.glBindTexture(GL30.GL_TEXTURE_2D_ARRAY, tex); GL11.glTexParameteri(GL30.GL_TEXTURE_2D_ARRAY, GL11.GL_TEXTURE_MAG_FILTER, magfilter); GL11.glTexParameteri(GL30.GL_TEXTURE_2D_ARRAY, GL11.GL_TEXTURE_MIN_FILTER, minfilter); GL11.glTexParameteri(GL30.GL_TEXTURE_2D_ARRAY, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT); GL11.glTexParameteri(GL30.GL_TEXTURE_2D_ARRAY, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT); ByteBuffer buf = null; PNGDecoder decoder = null; try { InputStream in = filenames[0].openStream(); decoder = new PNGDecoder(in); buf = BufferUtils.createByteBuffer(4 * decoder.getWidth() * decoder.getHeight()); decoder.decode(buf, decoder.getWidth() * 4, Format.RGBA); buf.flip(); in.close(); } catch (IOException e) { e.printStackTrace(); System.exit(-1); } int tileWidth = decoder.getWidth(); System.out.println(tileWidth); int tileHeight = decoder.getHeight(); System.out.println(tileHeight); GL12.glTexImage3D(GL30.GL_TEXTURE_2D_ARRAY, 0, GL11.GL_RGBA, tileWidth, tileHeight, filenames.length, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (ByteBuffer) null); for (int i = 0; i < filenames.length; i++) { GL12.glTexSubImage3D(GL30.GL_TEXTURE_2D_ARRAY, 0, /*tileWidth*x*/0, /*tileHeight*y*/0, i, tileWidth, tileHeight, 1, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, buf); buf.rewind(); if (i < filenames.length - 1) loadTexture(filenames[i + 1], buf); } if (mipmap) GL30.glGenerateMipmap(GL30.GL_TEXTURE_2D_ARRAY); if (anisotropic) { if (GLContext.getCapabilities().GL_EXT_texture_filter_anisotropic) { float maxanis = GL11.glGetFloat(EXTTextureFilterAnisotropic.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT); System.out.println("Anisotropic filtering activated with a resolution of " + maxanis); System.out.println(GL11.glGetError()); GL11.glTexParameterf(GL30.GL_TEXTURE_2D_ARRAY, EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT, maxanis); System.out.println(GL11.glGetError()); } else { System.err.println( "WARNING - Anisotropic filtering not supported by this graphics card. Setting it as disabled"); } } GL11.glBindTexture(GL30.GL_TEXTURE_2D_ARRAY, 0); return tex; }
From source file:ivorius.ivtoolkit.rendering.IvOpenGLHelper.java
License:Apache License
public static void checkGLError(Logger logger, String category) { int error;//from w w w. jav a2s. c o m while ((error = GL11.glGetError()) != 0) { String s1 = GLU.gluErrorString(error); logger.error("########## GL ERROR ##########"); logger.error("@ " + category); logger.error(error + ": " + s1); } }
From source file:jake2.desktop.LWJGLAdapter.java
License:Open Source License
@Override public int glGetError() { return GL11.glGetError(); }
From source file:jpcsp.graphics.RE.RenderingEngineLwjgl.java
License:Open Source License
@Override public boolean checkAndLogErrors(String logComment) { boolean hasError = false; while (true) { int error; try {/*from w w w . j a v a 2 s. c o m*/ error = GL11.glGetError(); } catch (NullPointerException e) { // Ignore Exception error = GL11.GL_NO_ERROR; } if (error == GL11.GL_NO_ERROR) { break; } hasError = true; if (logComment != null) { String errorComment; switch (error) { case GL11.GL_INVALID_ENUM: errorComment = "GL_INVALID_ENUM"; break; case GL11.GL_INVALID_OPERATION: errorComment = "GL_INVALID_OPERATION"; break; case GL11.GL_INVALID_VALUE: errorComment = "GL_INVALID_VALUE"; break; default: errorComment = String.format("0x%X", error); break; } // Build a stack trace and exclude uninteresting RE stack elements: // - exclude this method (first stack trace element) // - exclude method checkAndLogErrors // - exclude methods from class BaseRenderingEngineProxy StackTraceElement[] stackTrace = new Throwable().getStackTrace(); StringBuilder stackTraceLog = new StringBuilder(); int count = 0; for (int i = 1; i < stackTrace.length && count < 6; i++) { String className = stackTrace[i].getClassName(); if (!BaseRenderingEngineProxy.class.getName().equals(className) && !CheckErrorsProxy.class.getName().equals(className)) { stackTraceLog.append(stackTrace[i]); stackTraceLog.append("\n"); count++; } } log.error(String.format("Error %s: %s\n%s", logComment, errorComment, stackTraceLog.toString())); } } return hasError; }
From source file:kuake2.render.lwjgl.Main.java
License:Open Source License
/** * R_Init2//from ww w . ja va2 s . com */ protected boolean R_Init2() { VID.MenuInit(); /* ** get our various GL strings */ gl_config.vendor_string = GL11.glGetString(GL11.GL_VENDOR); VID.Printf(Defines.PRINT_ALL, "GL_VENDOR: " + gl_config.vendor_string + '\n'); gl_config.renderer_string = GL11.glGetString(GL11.GL_RENDERER); VID.Printf(Defines.PRINT_ALL, "GL_RENDERER: " + gl_config.renderer_string + '\n'); gl_config.version_string = GL11.glGetString(GL11.GL_VERSION); VID.Printf(Defines.PRINT_ALL, "GL_VERSION: " + gl_config.version_string + '\n'); gl_config.extensions_string = GL11.glGetString(GL11.GL_EXTENSIONS); VID.Printf(Defines.PRINT_ALL, "GL_EXTENSIONS: " + gl_config.extensions_string + '\n'); gl_config.parseOpenGLVersion(); String renderer_buffer = gl_config.renderer_string.toLowerCase(); String vendor_buffer = gl_config.vendor_string.toLowerCase(); if (renderer_buffer.indexOf("voodoo") >= 0) { if (renderer_buffer.indexOf("rush") < 0) gl_config.renderer = GL_RENDERER_VOODOO; else gl_config.renderer = GL_RENDERER_VOODOO_RUSH; } else if (vendor_buffer.indexOf("sgi") >= 0) gl_config.renderer = GL_RENDERER_SGI; else if (renderer_buffer.indexOf("permedia") >= 0) gl_config.renderer = GL_RENDERER_PERMEDIA2; else if (renderer_buffer.indexOf("glint") >= 0) gl_config.renderer = GL_RENDERER_GLINT_MX; else if (renderer_buffer.indexOf("glzicd") >= 0) gl_config.renderer = GL_RENDERER_REALIZM; else if (renderer_buffer.indexOf("gdi") >= 0) gl_config.renderer = GL_RENDERER_MCD; else if (renderer_buffer.indexOf("pcx2") >= 0) gl_config.renderer = GL_RENDERER_PCX2; else if (renderer_buffer.indexOf("verite") >= 0) gl_config.renderer = GL_RENDERER_RENDITION; else gl_config.renderer = GL_RENDERER_OTHER; String monolightmap = gl_monolightmap.string.toUpperCase(); if (monolightmap.length() < 2 || monolightmap.charAt(1) != 'F') { if (gl_config.renderer == GL_RENDERER_PERMEDIA2) { Cvar.Set("gl_monolightmap", "A"); VID.Printf(Defines.PRINT_ALL, "...using gl_monolightmap 'a'\n"); } else if ((gl_config.renderer & GL_RENDERER_POWERVR) != 0) { Cvar.Set("gl_monolightmap", "0"); } else { Cvar.Set("gl_monolightmap", "0"); } } // power vr can't have anything stay in the framebuffer, so // the screen needs to redraw the tiled background every frame if ((gl_config.renderer & GL_RENDERER_POWERVR) != 0) { Cvar.Set("scr_drawall", "1"); } else { Cvar.Set("scr_drawall", "0"); } // MCD has buffering issues if (gl_config.renderer == GL_RENDERER_MCD) { Cvar.SetValue("gl_finish", 1); } if ((gl_config.renderer & GL_RENDERER_3DLABS) != 0) { if (gl_3dlabs_broken.value != 0.0f) gl_config.allow_cds = false; else gl_config.allow_cds = true; } else { gl_config.allow_cds = true; } if (gl_config.allow_cds) VID.Printf(Defines.PRINT_ALL, "...allowing CDS\n"); else VID.Printf(Defines.PRINT_ALL, "...disabling CDS\n"); /* ** grab extensions */ if (gl_config.extensions_string.indexOf("GL_EXT_compiled_vertex_array") >= 0 || gl_config.extensions_string.indexOf("GL_SGI_compiled_vertex_array") >= 0) { VID.Printf(Defines.PRINT_ALL, "...enabling GL_EXT_compiled_vertex_array\n"); // qglLockArraysEXT = ( void * ) qwglGetProcAddress( "glLockArraysEXT" ); if (gl_ext_compiled_vertex_array.value != 0.0f) qglLockArraysEXT = true; else qglLockArraysEXT = false; // qglUnlockArraysEXT = ( void * ) qwglGetProcAddress( "glUnlockArraysEXT" ); //qglUnlockArraysEXT = true; } else { VID.Printf(Defines.PRINT_ALL, "...GL_EXT_compiled_vertex_array not found\n"); qglLockArraysEXT = false; } if (gl_config.extensions_string.indexOf("WGL_EXT_swap_control") >= 0) { qwglSwapIntervalEXT = true; VID.Printf(Defines.PRINT_ALL, "...enabling WGL_EXT_swap_control\n"); } else { qwglSwapIntervalEXT = false; VID.Printf(Defines.PRINT_ALL, "...WGL_EXT_swap_control not found\n"); } if (gl_config.extensions_string.indexOf("GL_EXT_point_parameters") >= 0) { if (gl_ext_pointparameters.value != 0.0f) { // qglPointParameterfEXT = ( void (APIENTRY *)( GLenum, GLfloat ) ) qwglGetProcAddress( "glPointParameterfEXT" ); qglPointParameterfEXT = true; // qglPointParameterfvEXT = ( void (APIENTRY *)( GLenum, const GLfloat * ) ) qwglGetProcAddress( "glPointParameterfvEXT" ); VID.Printf(Defines.PRINT_ALL, "...using GL_EXT_point_parameters\n"); } else { VID.Printf(Defines.PRINT_ALL, "...ignoring GL_EXT_point_parameters\n"); } } else { VID.Printf(Defines.PRINT_ALL, "...GL_EXT_point_parameters not found\n"); } // #ifdef __linux__ // if ( strstr( gl_config.extensions_string, "3DFX_set_global_palette" )) // { // if ( gl_ext_palettedtexture->value ) // { // VID.Printf( Defines.PRINT_ALL, "...using 3DFX_set_global_palette\n" ); // qgl3DfxSetPaletteEXT = ( void ( APIENTRY * ) (GLuint *) )qwglGetProcAddress( "gl3DfxSetPaletteEXT" ); //// qglColorTableEXT = Fake_glColorTableEXT; // } // else // { // VID.Printf( Defines.PRINT_ALL, "...ignoring 3DFX_set_global_palette\n" ); // } // } // else // { // VID.Printf( Defines.PRINT_ALL, "...3DFX_set_global_palette not found\n" ); // } // #endif if (!qglColorTableEXT && gl_config.extensions_string.indexOf("GL_EXT_paletted_texture") >= 0 && gl_config.extensions_string.indexOf("GL_EXT_shared_texture_palette") >= 0) { if (gl_ext_palettedtexture.value != 0.0f) { VID.Printf(Defines.PRINT_ALL, "...using GL_EXT_shared_texture_palette\n"); qglColorTableEXT = false; // true; TODO jogl bug } else { VID.Printf(Defines.PRINT_ALL, "...ignoring GL_EXT_shared_texture_palette\n"); qglColorTableEXT = false; } } else { VID.Printf(Defines.PRINT_ALL, "...GL_EXT_shared_texture_palette not found\n"); } if (gl_config.extensions_string.indexOf("GL_ARB_multitexture") >= 0) { VID.Printf(Defines.PRINT_ALL, "...using GL_ARB_multitexture\n"); qglActiveTextureARB = true; GL_TEXTURE0 = ARBMultitexture.GL_TEXTURE0_ARB; GL_TEXTURE1 = ARBMultitexture.GL_TEXTURE1_ARB; } else { VID.Printf(Defines.PRINT_ALL, "...GL_ARB_multitexture not found\n"); } if (!(qglActiveTextureARB)) return false; GL_SetDefaultState(); GL_InitImages(); Mod_Init(); R_InitParticleTexture(); Draw_InitLocal(); int err = GL11.glGetError(); if (err != GL11.GL_NO_ERROR) VID.Printf(Defines.PRINT_ALL, "glGetError() = 0x%x\n\t%s\n", new Vargs(2).add(err).add("" + GL11.glGetString(err))); return true; }
From source file:kubex.KubexGame.java
License:Creative Commons License
/** * Inits the game resources (Images, pools, shaders, objects, etc.) *///w w w . j a v a 2s .c o m private void initResources() throws IOException { //Inits static pools FloatBufferPool.init(Chunk.CHUNK_DIMENSION * Chunk.CHUNK_DIMENSION * Chunk.CHUNK_DIMENSION * 2 * 6 * 6, 20); ByteArrayPool.init(Chunk.CHUNK_DIMENSION, (settings.RENDER_DISTANCE * 2 + 1) * World.HEIGHT * (settings.RENDER_DISTANCE * 2 + 1) * 2); glEnable(GL11.GL_CULL_FACE); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); glEnable(GL11.GL_BLEND); glClearColor(0.6f, 0.8f, 1.0f, 0f); //Inits shaders GL20.glUseProgram(0); textManager = new GlobalTextManager(); this.DVSP = new DepthVoxelShaderProgram(true); this.VSP = new TerrainVoxelShaderProgram(true); this.HSP = new HudShaderProgram(true); this.DTSP = this.settings.SHADOWS_ENABLED ? new DeferredTerrainShaderProgram(true) : new DeferredTerrainUnshadowShaderProgram(true); this.DRSP = this.settings.REFLECTIONS_ENABLED ? new DeferredReflectionsShaderProgram(true) : new DeferredNoReflectionsShaderProgram(true); this.DUTSP = this.settings.SHADOWS_ENABLED ? new DeferredUnderwaterTerrainShaderProgram(true) : new DeferredUnderwaterUnshadowTerrainShaderProgram(true); this.DUFSP = new DeferredUnderwaterFinalShaderProgram(true); //Inits essential objects this.TM = new TimeManager(); this.cam = new Camera(CAMERA_NEAR, CAMERA_FAR, 80f, (float) (X_RES * 3 / 4) / Y_RES); //FOV more width than height BY DESIGN, so blocks looks more "plane". Looks nicer that way, i think. this.camInvProjEnv = new CameraInverseProjEnvelope(this.cam); this.shadowsManager = new ShadowsManager(SHADOW_SPLITS, this.cam); this.liquidRenderer = new DepthPeelingLiquidRenderer(LIQUID_LAYERS); this.sunCam = new Camera(new Matrix4f()); this.sunCam.moveTo(0, 5, 0); this.sunCam.setPitch(0); this.sky = new Sky(cam, this.sunCam); File mapRoute = new File(this.settings.MAP_ROUTE); mapRoute.mkdir(); //Creates the maps folder this.fileManager = new FileManager(mapRoute, settings.RENDER_DISTANCE); this.fileManager.getSettingsFromFile(settings); //Reads default settings from settings file. this.world = new World(this.VSP, this.cam, this.sunCam, this.shadowsManager, this.sky, fileManager, this.settings); this.finalDrawManager = new FinalDrawManager(this.world, this.sky, this.shadowsManager, this.liquidRenderer, this.camInvProjEnv.getInvProjMatrix(), CAMERA_NEAR, CAMERA_FAR); this.hud = new Hud(this.HSP, X_RES, Y_RES); //Load textures here glActiveTexture(TEXTURE_FETCH[TILES_TEXTURE_LOCATION]); //GL_NEAREST for that blocky look //loads the tiles textures into a array tilesTexture = Util.loadTextureAtlasIntoTextureArray(FileLoader.loadTileImages(), GL11.GL_NEAREST, GL11.GL_NEAREST_MIPMAP_LINEAR, true, settings.ANISOTROPIC_FILTERING_ENABLED); Util.loadPNGTexture(FileLoader.loadWaterNormalImage(), TEXTURE_FETCH[WATER_NORMAL_TEXTURE_LOCATION]); //loads the water normal texture glActiveTexture(GL_TEXTURE0); nightDomeTexture = TextureLoader.getTexture("JPG", ResourceLoader.getResourceAsStream("images/nightdome.jpg")); //loads the nightdome //Without this, text printing using Slick-Utils doesn't work. Seems it still uses some old mode OpenGL. GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_LIGHTING); GL11.glClearDepth(1); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glViewport(0, 0, X_RES, Y_RES); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, X_RES, Y_RES, 0, 1, -1); GL11.glMatrixMode(GL11.GL_MODELVIEW); //First pass deferred rendering this.baseFbo = glGenFramebuffers(); glBindFramebuffer(GL_FRAMEBUFFER, this.baseFbo); int colorTexture = glGenTextures(); int brightnessNormalsTexture = glGenTextures(); //Creates and inits the base color texture as a RGB texture glActiveTexture(TEXTURE_FETCH[BASEFBO_COLOR_TEXTURE_LOCATION]); glBindTexture(GL_TEXTURE_2D, colorTexture); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, X_RES, Y_RES, 0, GL_RGB, GL_UNSIGNED_BYTE, (FloatBuffer) null); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); GL30.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorTexture, 0); //Creates and inits the brightness and normals texture as a RGBA texture glActiveTexture(TEXTURE_FETCH[BASEFBO_NORMALS_BRIGHTNESS_TEXTURE_LOCATION]); glBindTexture(GL_TEXTURE_2D, brightnessNormalsTexture); glTexImage2D(GL_TEXTURE_2D, 0, GL11.GL_RGBA, X_RES, Y_RES, 0, GL11.GL_RGBA, GL_UNSIGNED_BYTE, (FloatBuffer) null); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); GL30.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, brightnessNormalsTexture, 0); //The depth buffer of this FBO will be a texture, too. This will make depth sorting slower but we will be able to access depth values later. int baseFboDepth = glGenTextures(); glActiveTexture(TEXTURE_FETCH[BASEFBO_DEPTH_TEXTURE_LOCATION]); glBindTexture(GL_TEXTURE_2D, baseFboDepth); glTexImage2D(GL_TEXTURE_2D, 0, GL14.GL_DEPTH_COMPONENT24, X_RES, Y_RES, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, (FloatBuffer) null); System.out.println("ERR" + GL11.glGetError()); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); GL30.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, baseFboDepth, 0); //Set the depth texture as the default render depth target IntBuffer drawBuffers = BufferUtils.createIntBuffer(2); //Drawing to 2 textures drawBuffers.put(GL_COLOR_ATTACHMENT0); drawBuffers.put(GL_COLOR_ATTACHMENT1); drawBuffers.flip(); GL20.glDrawBuffers(drawBuffers); //Second pass deferred rendering this.deferredFbo = glGenFramebuffers(); glBindFramebuffer(GL_FRAMEBUFFER, this.deferredFbo); int deferredColorTex = glGenTextures(); //Only uses one texture, a RGBA color texture glActiveTexture(TEXTURE_FETCH[DEFERREDFBO_COLOR_TEXTURE_LOCATION]); glBindTexture(GL_TEXTURE_2D, deferredColorTex); glTexImage2D(GL_TEXTURE_2D, 0, GL11.GL_RGBA, X_RES, Y_RES, 0, GL11.GL_RGBA, GL_UNSIGNED_BYTE, (FloatBuffer) null); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); GL30.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, deferredColorTex, 0); drawBuffers = BufferUtils.createIntBuffer(1); drawBuffers.put(GL_COLOR_ATTACHMENT0); drawBuffers.flip(); GL20.glDrawBuffers(drawBuffers); //If shadows are enabled, we init each shadow map texture, placed in an array if (this.settings.SHADOWS_ENABLED) { int shadowTexture = glGenTextures(); glActiveTexture(TEXTURE_FETCH[SHADOW_TEXTURE_LOCATION]); glBindTexture(GL30.GL_TEXTURE_2D_ARRAY, shadowTexture); //Creates a texture array to place the shadows in GL12.glTexImage3D(GL30.GL_TEXTURE_2D_ARRAY, 0, GL14.GL_DEPTH_COMPONENT16, SHADOW_XRES, SHADOW_YRES, this.shadowsManager.getNumberSplits(), 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, (FloatBuffer) null); System.out.println("ERR" + GL11.glGetError()); glTexParameteri(GL30.GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); //Needed to do hardware PCF comparisons via shader glTexParameteri(GL30.GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); //Needed to do hardware PCF comparisons via shader glTexParameteri(GL30.GL_TEXTURE_2D_ARRAY, GL14.GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE); //Needed to do hardware PCF comparisons via shader this.shadowFbos = new int[this.shadowsManager.getNumberSplits()]; //Creates one framebuffer per shadow map for (int i = 0; i < this.shadowsManager.getNumberSplits(); i++) { this.shadowFbos[i] = glGenFramebuffers(); glBindFramebuffer(GL_FRAMEBUFFER, this.shadowFbos[i]); GL30.glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, shadowTexture, 0, i); //Each framebuffer will have one texture layer (one index of the texture array created before) assigned as render target drawBuffers = BufferUtils.createIntBuffer(0); GL20.glDrawBuffers(drawBuffers); } } //Liquid layers depth generation. Equal to the shadows depth textures generation. int liquidLayers = glGenTextures(); glActiveTexture(TEXTURE_FETCH[LIQUIDLAYERS_TEXTURE_LOCATION]); glBindTexture(GL30.GL_TEXTURE_2D_ARRAY, liquidLayers); GL12.glTexImage3D(GL30.GL_TEXTURE_2D_ARRAY, 0, GL14.GL_DEPTH_COMPONENT24, X_RES, Y_RES, this.liquidRenderer.getNumLayers(), 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, (FloatBuffer) null); glTexParameteri(GL30.GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); //We will compare manually the depth in the shader, we will not perform PCF of any sort in this case glTexParameteri(GL30.GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); int currentLiquidNormalTex = glGenTextures(); glActiveTexture(KubexGame.TEXTURE_FETCH[KubexGame.CURRENT_LIQUID_NORMAL_TEXTURE_LOCATION]); glBindTexture(GL_TEXTURE_2D, currentLiquidNormalTex); glTexImage2D(GL_TEXTURE_2D, 0, GL11.GL_RGB, X_RES, Y_RES, 0, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, (FloatBuffer) null); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); this.liquidRenderer.initResources(liquidLayers, currentLiquidNormalTex); //Reset active texture and fbo to the default glActiveTexture(GL13.GL_TEXTURE0); glBindFramebuffer(GL_FRAMEBUFFER, 0); }
From source file:lyonlancer5.xatrocore.lib.internal.SplashProgress.java
License:Open Source License
public static void checkGLError(String where) { int err = GL11.glGetError(); if (err != 0) { throw new IllegalStateException(where + ": " + GLU.gluErrorString(err)); }// www . j a v a 2s . c o m }
From source file:main.java.com.YeAJG.game.Game.java
License:Open Source License
public static void exitOnGLError(String errorMessage) { int errorValue = GL11.glGetError(); if (errorValue != GL11.GL_NO_ERROR) { String errorString = GLU.gluErrorString(errorValue); logger.error(errorMessage + ": " + errorString); if (Display.isCreated()) Display.destroy();/*from w w w. ja va 2 s . c o m*/ System.exit(-1); } }
From source file:me.thehutch.fusion.engine.util.RenderUtil.java
License:Open Source License
public static void checkGLError() { final int status = GL11.glGetError(); if (status != GL_NO_ERROR) { throw new IllegalStateException("OpenGL Error: " + GLU.gluErrorString(status)); }/*w ww .ja v a 2 s.c o m*/ }