Java Code Examples for org.lwjgl.opengl.GL11#glShadeModel()
The following examples show how to use
org.lwjgl.opengl.GL11#glShadeModel() .
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: LwJglRenderingEngine.java From Gaalop with GNU Lesser General Public License v3.0 | 7 votes |
/** * Starts the lwjgl engine and shows a window, where the point clouds are rendered */ public void startEngine() { int width = 800; int height = 600; try { Display.setDisplayMode(new DisplayMode(width, height)); Display.setFullscreen(false); Display.setTitle("Gaalop Visualization Window"); Display.create(); } catch (LWJGLException e) { e.printStackTrace(); System.exit(0); } GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glShadeModel(GL11.GL_SMOOTH); changeSize(width, height); GL11.glDisable(GL11.GL_LIGHTING); // init OpenGL GL11.glViewport(0, 0, width, height); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GLU.gluPerspective((float) 65.0, (float) width / (float) height, (float) 0.1, 100); GL11.glMatrixMode(GL11.GL_MODELVIEW); }
Example 2
Source File: ImmediateModeOGLRenderer.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 7 votes |
/** * @see org.newdawn.slick.opengl.renderer.SGL#initDisplay(int, int) */ public void initDisplay(int width, int height) { this.width = width; this.height = height; String extensions = GL11.glGetString(GL11.GL_EXTENSIONS); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_LIGHTING); GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); GL11.glClearDepth(1); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glViewport(0,0,width,height); GL11.glMatrixMode(GL11.GL_MODELVIEW); }
Example 3
Source File: FBOGraphics.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Initialise the GL context */ protected void initGL() { GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_LIGHTING); GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); GL11.glClearDepth(1); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glViewport(0,0,screenWidth,screenHeight); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); enterOrtho(); }
Example 4
Source File: PBufferGraphics.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Initialise the GL context */ protected void initGL() { GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_LIGHTING); GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); GL11.glClearDepth(1); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glViewport(0,0,screenWidth,screenHeight); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); enterOrtho(); }
Example 5
Source File: ClickGui.java From Wurst7 with GNU General Public License v3.0 | 6 votes |
public void renderPinnedWindows(MatrixStack matrixStack, float partialTicks) { GL11.glDisable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glLineWidth(1); for(Window window : windows) if(window.isPinned() && !window.isInvisible()) renderWindow(matrixStack, window, Integer.MIN_VALUE, Integer.MIN_VALUE, partialTicks); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_BLEND); }
Example 6
Source File: PBufferUniqueGraphics.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Initialise the GL context */ protected void initGL() { GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_LIGHTING); GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); GL11.glClearDepth(1); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glViewport(0,0,screenWidth,screenHeight); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); enterOrtho(); }
Example 7
Source File: ClickGui.java From ForgeWurst with GNU General Public License v3.0 | 6 votes |
public void renderPinnedWindows(float partialTicks) { GL11.glDisable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glLineWidth(1); for(Window window : windows) if(window.isPinned() && !window.isInvisible()) renderWindow(window, Integer.MIN_VALUE, Integer.MIN_VALUE, partialTicks); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_TEXTURE_2D); }
Example 8
Source File: Renderer.java From tribaltrouble with GNU General Public License v2.0 | 5 votes |
public final static void initGL() { VBO.releaseAll(); GL11.glFrontFace(GL11.GL_CCW); GL11.glCullFace(GL11.GL_BACK); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glPixelStorei(GL11.GL_PACK_ROW_LENGTH, 0); GL11.glPixelStorei(GL11.GL_PACK_SKIP_PIXELS, 0); GL11.glPixelStorei(GL11.GL_PACK_SKIP_ROWS, 0); GL11.glPixelStorei(GL11.GL_PACK_ALIGNMENT, 1); GL11.glPixelStorei(GL11.GL_PACK_SWAP_BYTES, 0); GL11.glPixelStorei(GL11.GL_UNPACK_ROW_LENGTH, 0); GL11.glPixelStorei(GL11.GL_UNPACK_SKIP_PIXELS, 0); GL11.glPixelStorei(GL11.GL_UNPACK_SKIP_ROWS, 0); GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1); GL11.glPixelStorei(GL11.GL_UNPACK_SWAP_BYTES, 0); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glShadeModel(GL11.GL_SMOOTH); // GL11.glAlphaFunc(GL11.GL_GREATER, Globals.ALPHA_CUTOFF); // Setup landscape texture coordinate gen GL11.glTexGeni(GL11.GL_S, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR); GL11.glTexGeni(GL11.GL_T, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_REPLACE); GLState.activeTexture(GL13.GL_TEXTURE1); GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_DECAL); GL11.glTexGeni(GL11.GL_S, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR); GL11.glTexGeni(GL11.GL_T, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR); GLState.activeTexture(GL13.GL_TEXTURE0); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glPointSize(7.0f); clearScreen(); GL11.glClearDepth(1.0); }
Example 9
Source File: Gui.java From Slyther with MIT License | 5 votes |
public void drawTexture(float x, float y, float width, float height) { GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glBegin(GL11.GL_QUADS); GL11.glShadeModel(GL11.GL_FLAT); GL11.glTexCoord2f(0, 0); GL11.glVertex2f(x, y); GL11.glTexCoord2f(1, 0); GL11.glVertex2f(x + width, y); GL11.glTexCoord2f(1, 1); GL11.glVertex2f(x + width, y + height); GL11.glTexCoord2f(0, 1); GL11.glVertex2f(x, y + height); GL11.glEnd(); }
Example 10
Source File: Gui.java From Slyther with MIT License | 5 votes |
public void drawTexture(float x, float y, float u, float v, float width, float height, float textureWidth, float textureHeight) { float uMultiplier = 1.0F / textureWidth; float vMultiplier = 1.0F / textureHeight; GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glBegin(GL11.GL_QUADS); GL11.glShadeModel(GL11.GL_FLAT); drawVertex(x, y + height, u, v + height, uMultiplier, vMultiplier); drawVertex(x + width, y + height, u + width, v + height, uMultiplier, vMultiplier); drawVertex(x + width, y, u + width, v, uMultiplier, vMultiplier); drawVertex(x, y, u, v, uMultiplier, vMultiplier); GL11.glEnd(); }
Example 11
Source File: GLUtils.java From ehacks-pro with GNU General Public License v3.0 | 5 votes |
public static void drawGradientRect(double x, double y, double x2, double y2, int col1, int col2) { float f = (col1 >> 24 & 255) / 255.0f; float f1 = (col1 >> 16 & 255) / 255.0f; float f2 = (col1 >> 8 & 255) / 255.0f; float f3 = (col1 & 255) / 255.0f; float f4 = (col2 >> 24 & 255) / 255.0f; float f5 = (col2 >> 16 & 255) / 255.0f; float f6 = (col2 >> 8 & 255) / 255.0f; float f7 = (col2 & 255) / 255.0f; GL11.glEnable(3042); GL11.glDisable(3553); GL11.glBlendFunc(770, 771); GL11.glEnable(2848); GL11.glShadeModel(7425); GL11.glPushMatrix(); GL11.glBegin(7); GL11.glColor4f(f1, f2, f3, f); GL11.glVertex2d(x2, y); GL11.glVertex2d(x, y); GL11.glColor4f(f5, f6, f7, f4); GL11.glVertex2d(x, y2); GL11.glVertex2d(x2, y2); GL11.glEnd(); GL11.glPopMatrix(); GL11.glEnable(3553); GL11.glDisable(3042); GL11.glDisable(2848); GL11.glShadeModel(7424); }
Example 12
Source File: TerminalManagerClient.java From OpenPeripheral-Addons with MIT License | 5 votes |
private void tryDrawSurface(long guid, SurfaceType type, float partialTicks, ScaledResolution resolution) { SurfaceClient surface = surfaces.get(guid, type); if (surface != null) { GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_ENABLE_BIT); GL11.glShadeModel(GL11.GL_SMOOTH); final RenderState renderState = new RenderState(); renderState.forceKnownState(); for (Drawable drawable : surface.getSortedDrawables()) if (drawable.shouldRender()) drawable.draw(resolution, renderState, partialTicks); GL11.glPopAttrib(); } }
Example 13
Source File: Window.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
protected void fillGradient(int x1, int y1, int x2, int y2, int color1, int color2) { float float_1 = (float)(color1 >> 24 & 255) / 255.0F; float float_2 = (float)(color1 >> 16 & 255) / 255.0F; float float_3 = (float)(color1 >> 8 & 255) / 255.0F; float float_4 = (float)(color1 & 255) / 255.0F; float float_5 = (float)(color2 >> 24 & 255) / 255.0F; float float_6 = (float)(color2 >> 16 & 255) / 255.0F; float float_7 = (float)(color2 >> 8 & 255) / 255.0F; float float_8 = (float)(color2 & 255) / 255.0F; GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_ALPHA_TEST); GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO); GL11.glShadeModel(7425); Tessellator tessellator_1 = Tessellator.getInstance(); BufferBuilder bufferBuilder_1 = tessellator_1.getBuffer(); bufferBuilder_1.begin(7, VertexFormats.POSITION_COLOR); bufferBuilder_1.vertex((double)x1, (double)y1, 0).color(float_2, float_3, float_4, float_1).next(); bufferBuilder_1.vertex((double)x1, (double)y2, 0).color(float_2, float_3, float_4, float_1).next(); bufferBuilder_1.vertex((double)x2, (double)y2, 0).color(float_6, float_7, float_8, float_5).next(); bufferBuilder_1.vertex((double)x2, (double)y1, 0).color(float_6, float_7, float_8, float_5).next(); tessellator_1.draw(); GL11.glShadeModel(7424); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_TEXTURE_2D); }
Example 14
Source File: TestUtils.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Initialise the GL display * * @param width The width of the display * @param height The height of the display */ private void initGL(int width, int height) { try { Display.setDisplayMode(new DisplayMode(width,height)); Display.create(); Display.setVSyncEnabled(true); } catch (LWJGLException e) { e.printStackTrace(); System.exit(0); } GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_LIGHTING); GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); GL11.glClearDepth(1); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glViewport(0,0,width,height); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, width, height, 0, 1, -1); GL11.glMatrixMode(GL11.GL_MODELVIEW); }
Example 15
Source File: Window.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
private void fillGradient(int x1, int y1, int x2, int y2, int color1, int color2) { float float_1 = (float)(color1 >> 24 & 255) / 255.0F; float float_2 = (float)(color1 >> 16 & 255) / 255.0F; float float_3 = (float)(color1 >> 8 & 255) / 255.0F; float float_4 = (float)(color1 & 255) / 255.0F; float float_5 = (float)(color2 >> 24 & 255) / 255.0F; float float_6 = (float)(color2 >> 16 & 255) / 255.0F; float float_7 = (float)(color2 >> 8 & 255) / 255.0F; float float_8 = (float)(color2 & 255) / 255.0F; GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_ALPHA_TEST); GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO); GL11.glShadeModel(7425); Tessellator tessellator_1 = Tessellator.getInstance(); BufferBuilder bufferBuilder_1 = tessellator_1.getBufferBuilder(); bufferBuilder_1.begin(7, VertexFormats.POSITION_COLOR); bufferBuilder_1.vertex((double)x1, (double)y1, 0).color(float_2, float_3, float_4, float_1).next(); bufferBuilder_1.vertex((double)x1, (double)y2, 0).color(float_2, float_3, float_4, float_1).next(); bufferBuilder_1.vertex((double)x2, (double)y2, 0).color(float_6, float_7, float_8, float_5).next(); bufferBuilder_1.vertex((double)x2, (double)y1, 0).color(float_6, float_7, float_8, float_5).next(); tessellator_1.draw(); GL11.glShadeModel(7424); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_TEXTURE_2D); }
Example 16
Source File: Renderer.java From AnyaBasic with MIT License | 4 votes |
Renderer( int screenWidth, int screenHeight ) { try { Display.setDisplayMode(new DisplayMode(screenWidth, screenHeight)); Display.create(); Display.setTitle( "AnyaBasic 0.4.0 beta" ); } catch( LWJGLException e ) { e.printStackTrace(); } this.screenWidth = screenWidth; this.screenHeight = screenHeight; GL11.glViewport( 0, 0, screenWidth, screenHeight ); GL11.glMatrixMode( GL11.GL_PROJECTION ); GL11.glLoadIdentity(); GL11.glOrtho( 0, screenWidth, screenHeight, 0, 1, -1 ); GL11.glMatrixMode( GL11.GL_MODELVIEW ); GL11.glLoadIdentity(); GL11.glShadeModel(GL11.GL_SMOOTH); //set shading to smooth(try GL_FLAT) GL11.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); //set Clear color to BLACK GL11.glClearDepth(1.0f); //Set Depth buffer to 1(z-Buffer) GL11.glDisable(GL11.GL_DEPTH_TEST); //Disable Depth Testing so that our z-buffer works GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glEnable(GL11.GL_COLOR_MATERIAL); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable( GL11.GL_ALPHA_TEST ); GL11.glAlphaFunc(GL11.GL_GREATER, 0); GL11.glEnable( GL11.GL_BLEND ); GL11.glBlendFunc( GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA ); GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_FILL); GL11.glMatrixMode( GL11.GL_MODELVIEW ); GL11.glLoadIdentity(); GL11.glTranslatef( 0.375f, 0.375f, 0 ); // magic trick }
Example 17
Source File: SlytherClient.java From Slyther with MIT License | 4 votes |
@Override public void run() { double delta = 0; long previousTime = System.nanoTime(); long timer = System.currentTimeMillis(); int ups = 0; double nanoUpdates = 1000000000.0 / 30.0; GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_LIGHTING); GL11.glClearColor(0.0F, 0.0F, 0.0F, 0.0F); GL11.glClearDepth(1); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); setupDisplay(); boolean doResize = false; while (!Display.isCloseRequested()) { if (Display.wasResized() && doResize) { setupDisplay(); } doResize = true; long currentTime = System.nanoTime(); double currentTickDelta = (currentTime - previousTime) / nanoUpdates; delta += currentTickDelta; frameDelta = (frameDelta + currentTickDelta) % 1.0; previousTime = currentTime; while (delta >= 1) { update(); renderHandler.update(); delta--; ups++; } GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); GL11.glPushMatrix(); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); renderHandler.render(); fps++; if (System.currentTimeMillis() - timer > 1000) { int bytesPerSecond = 0; int packetsPerSecond = 0; if (networkManager != null) { bytesPerSecond = networkManager.bytesPerSecond; packetsPerSecond = networkManager.packetsPerSecond; networkManager.bytesPerSecond = 0; networkManager.packetsPerSecond = 0; } Display.setTitle("Slyther - FPS: " + fps + " - UPS: " + ups + " - BPS: " + bytesPerSecond + " - PPS: " + packetsPerSecond); fps = 0; timer += 1000; ups = 0; } GL11.glPopMatrix(); Display.sync(60); Display.update(); } if (networkManager != null && networkManager.isOpen()) { networkManager.closeConnection(ClientNetworkManager.SHUTDOWN_CODE, ""); } try { ConfigHandler.INSTANCE.saveConfig(CONFIGURATION_FILE, configuration); } catch (IOException e) { Log.error("Failed to save config"); Log.catching(e); } Display.destroy(); }
Example 18
Source File: ClickGui.java From Wurst7 with GNU General Public License v3.0 | 4 votes |
public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) { updateColors(); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glLineWidth(1); tooltip = ""; for(Window window : windows) { if(window.isInvisible()) continue; // dragging if(window.isDragging()) if(leftMouseButtonPressed) window.dragTo(mouseX, mouseY); else { window.stopDragging(); saveWindows(); } // scrollbar dragging if(window.isDraggingScrollbar()) if(leftMouseButtonPressed) window.dragScrollbarTo(mouseY); else window.stopDraggingScrollbar(); renderWindow(matrixStack, window, mouseX, mouseY, partialTicks); } GL11.glDisable(GL11.GL_TEXTURE_2D); renderPopupsAndTooltip(matrixStack, mouseX, mouseY); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_BLEND); }
Example 19
Source File: OpenGLRenderer20.java From ldparteditor with MIT License | 4 votes |
/** * Initializes the Scene and gives OpenGL-Hints */ @Override public void init() { // MARK OpenGL Hints and Initialization GL11.glDepthMask(true); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glDepthFunc(GL11.GL_LESS); GL11.glClearDepth(1.0f); GL11.glClearColor(View.background_Colour_r[0], View.background_Colour_g[0], View.background_Colour_b[0], 1.0f); GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); GL11.glPointSize(5); // GL11.glLineWidth(2); GL11.glEnable(GL11.GL_LIGHTING); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glEnable(GL11.GL_NORMALIZE); GL11.glEnable(GL11.GL_LIGHT0); GL11.glEnable(GL11.GL_LIGHT1); GL11.glEnable(GL11.GL_LIGHT2); GL11.glEnable(GL11.GL_LIGHT3); GL11.glLightModelfv(GL11.GL_LIGHT_MODEL_AMBIENT, BufferFactory.floatBuffer(new float[] { 0.1f, 0.1f, 0.1f, 1f })); GL11.glLightfv(GL11.GL_LIGHT0, GL11.GL_DIFFUSE, BufferFactory.floatBuffer(new float[] { View.light1_Colour_r[0], View.light1_Colour_g[0], View.light1_Colour_b[0], 1f })); GL11.glLightfv(GL11.GL_LIGHT0, GL11.GL_SPECULAR, BufferFactory.floatBuffer(new float[] { View.light1_specular_Colour_r[0], View.light1_specular_Colour_g[0], View.light1_specular_Colour_b[0], 1f })); GL11.glLightf(GL11.GL_LIGHT0, GL11.GL_LINEAR_ATTENUATION, .001f); GL11.glLightfv(GL11.GL_LIGHT1, GL11.GL_DIFFUSE, BufferFactory.floatBuffer(new float[] { View.light2_Colour_r[0], View.light2_Colour_g[0], View.light2_Colour_b[0], 1f })); GL11.glLightfv(GL11.GL_LIGHT1, GL11.GL_SPECULAR, BufferFactory.floatBuffer(new float[] { View.light2_specular_Colour_r[0], View.light2_specular_Colour_g[0], View.light2_specular_Colour_b[0], 1f })); GL11.glLightf(GL11.GL_LIGHT1, GL11.GL_LINEAR_ATTENUATION, .001f); GL11.glLightfv(GL11.GL_LIGHT2, GL11.GL_DIFFUSE, BufferFactory.floatBuffer(new float[] { View.light3_Colour_r[0], View.light3_Colour_g[0], View.light3_Colour_b[0], 1f })); GL11.glLightfv(GL11.GL_LIGHT2, GL11.GL_SPECULAR, BufferFactory.floatBuffer(new float[] { View.light3_specular_Colour_r[0], View.light3_specular_Colour_g[0], View.light3_specular_Colour_b[0], 1f })); GL11.glLightf(GL11.GL_LIGHT2, GL11.GL_LINEAR_ATTENUATION, .001f); GL11.glLightfv(GL11.GL_LIGHT3, GL11.GL_DIFFUSE, BufferFactory.floatBuffer(new float[] { View.light4_Colour_r[0], View.light4_Colour_g[0], View.light4_Colour_b[0], 1f })); GL11.glLightfv(GL11.GL_LIGHT3, GL11.GL_SPECULAR, BufferFactory.floatBuffer(new float[] { View.light4_specular_Colour_r[0], View.light4_specular_Colour_g[0], View.light4_specular_Colour_b[0], 1f })); GL11.glLightf(GL11.GL_LIGHT3, GL11.GL_LINEAR_ATTENUATION, .001f); GL11.glEnable(GL11.GL_COLOR_MATERIAL); GL11.glColorMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE); GL11.glMaterialfv(GL11.GL_FRONT, GL11.GL_SPECULAR, BufferFactory.floatBuffer(new float[] { 1.0f, 1.0f, 1.0f, 1.0f })); GL11.glMaterialf(GL11.GL_FRONT, GL11.GL_SHININESS, 128f); GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); if (fsGlossId == -1) { vsGlossId = loadGlossVertexShader(); fsGlossId = loadGlossFragmentShader(); if (pGlossId == -1 && vsGlossId != -1 && fsGlossId != -1) { pGlossId = GL20.glCreateProgram(); GL20.glAttachShader(pGlossId, vsGlossId); GL20.glAttachShader(pGlossId, fsGlossId); GL20.glLinkProgram(pGlossId); GL20.glValidateProgram(pGlossId); baseImageLoc = GL20.glGetUniformLocation(pGlossId, "colorMap"); //$NON-NLS-1$ glossMapLoc = GL20.glGetUniformLocation(pGlossId, "glossMap"); //$NON-NLS-1$ cubeMapLoc = GL20.glGetUniformLocation(pGlossId, "cubeMap"); //$NON-NLS-1$ cubeMapMatteLoc = GL20.glGetUniformLocation(pGlossId, "cubeMapMatte"); //$NON-NLS-1$ cubeMapMetalLoc = GL20.glGetUniformLocation(pGlossId, "cubeMapMetal"); //$NON-NLS-1$ alphaSwitchLoc = GL20.glGetUniformLocation(pGlossId, "alphaSwitch"); //$NON-NLS-1$ normalSwitchLoc = GL20.glGetUniformLocation(pGlossId, "normalSwitch"); //$NON-NLS-1$ noTextureSwitch = GL20.glGetUniformLocation(pGlossId, "noTextureSwitch"); //$NON-NLS-1$ noGlossMapSwitch = GL20.glGetUniformLocation(pGlossId, "noGlossMapSwitch"); //$NON-NLS-1$ cubeMapSwitch = GL20.glGetUniformLocation(pGlossId, "cubeMapSwitch"); //$NON-NLS-1$ noLightSwitch = GL20.glGetUniformLocation(pGlossId, "noLightSwitch"); //$NON-NLS-1$ } } }
Example 20
Source File: TabGui.java From Wurst7 with GNU General Public License v3.0 | 4 votes |
public void render(MatrixStack matrixStack, float partialTicks) { if(tabGuiOtf.isHidden()) return; GL11.glDisable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glPushMatrix(); Window sr = WurstClient.MC.getWindow(); int x = 2; int y = 23; GL11.glTranslatef(x, y, 0); drawBox(0, 0, width, height); double factor = sr.getScaleFactor(); GL11.glScissor((int)(x * factor), (int)((sr.getScaledHeight() - height - y) * factor), (int)(width * factor), (int)(height * factor)); GL11.glEnable(GL11.GL_SCISSOR_TEST); int textY = 1; GL11.glEnable(GL11.GL_TEXTURE_2D); for(int i = 0; i < tabs.size(); i++) { String tabName = tabs.get(i).name; if(i == selected) tabName = (tabOpened ? "<" : ">") + tabName; WurstClient.MC.textRenderer.draw(matrixStack, tabName, 2, textY, 0xffffffff); textY += 10; } GL11.glEnable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_SCISSOR_TEST); if(tabOpened) { GL11.glPushMatrix(); GL11.glDisable(GL11.GL_TEXTURE_2D); Tab tab = tabs.get(selected); int tabX = x + width + 2; int tabY = y; GL11.glTranslatef(width + 2, 0, 0); drawBox(0, 0, tab.width, tab.height); GL11.glScissor((int)(tabX * factor), (int)((sr.getScaledHeight() - tab.height - tabY) * factor), (int)(tab.width * factor), (int)(tab.height * factor)); GL11.glEnable(GL11.GL_SCISSOR_TEST); int tabTextY = 1; GL11.glEnable(GL11.GL_TEXTURE_2D); for(int i = 0; i < tab.features.size(); i++) { Feature feature = tab.features.get(i); String fName = feature.getName(); if(feature.isEnabled()) fName = "\u00a7a" + fName + "\u00a7r"; if(i == tab.selected) fName = ">" + fName; WurstClient.MC.textRenderer.draw(matrixStack, fName, 2, tabTextY, 0xffffffff); tabTextY += 10; } GL11.glEnable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_SCISSOR_TEST); GL11.glPopMatrix(); } GL11.glPopMatrix(); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_CULL_FACE); }