Java Code Examples for org.lwjgl.opengl.GL11#glClearDepth()
The following examples show how to use
org.lwjgl.opengl.GL11#glClearDepth() .
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: OpenGLRendererPrimitives20.java From ldparteditor with MIT License | 7 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.glEnable(GL11.GL_STENCIL_TEST); GL11.glClearDepth(1.0f); GL11.glClearColor(View.primitive_background_Colour_r[0], View.primitive_background_Colour_g[0], View.primitive_background_Colour_b[0], 1.0f); GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); GL11.glPointSize(4); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glEnable(GL11.GL_NORMALIZE); GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); }
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: 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 4
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 5
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 6
Source File: OpenGLRendererPrimitives33.java From ldparteditor with MIT License | 5 votes |
@Override public void init() { shaderProgram = new GLShader("primitive.vert", "primitive.frag"); //$NON-NLS-1$ //$NON-NLS-2$ stack.setShader(shaderProgram); shaderProgram.use(); GL11.glClearDepth(1.0f); GL11.glClearColor(View.primitive_background_Colour_r[0], View.primitive_background_Colour_g[0], View.primitive_background_Colour_b[0], 1.0f); }
Example 7
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 8
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 9
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 10
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 11
Source File: vboWithRGBA.java From ldparteditor with MIT License | 4 votes |
@Override public void init() { Matrix4f.setIdentity(viewport); shaderProgram = new GLShader("primitive.vert", "primitive.frag"); //$NON-NLS-1$ //$NON-NLS-2$ shaderProgram.use(); GL11.glClearDepth(1.0f); GL11.glClearColor(View.primitive_background_Colour_r[0], View.primitive_background_Colour_g[0], View.primitive_background_Colour_b[0], 1.0f); // Set up vertex data (and buffer(s)) and attribute pointers float[] vertices = new float[]{ 0.5f, 0.5f, 0.0f, // Top Right 0.0f, 0.0f, 1.0f, // Normal 1.0f, 0.0f, 0.0f, 1.0f, // Colour 0.5f, -0.5f, 0.0f, // Bottom Right 0.0f, 0.0f, 1.0f, // Normal 0.0f, 1.0f, 0.0f, 1.0f, // Colour -0.5f, -0.5f, 0.0f, // Bottom Left 0.0f, 0.0f, 1.0f, // Normal 0.0f, 0.0f, 1.0f, 1.0f, // Colour }; VAO = GL30.glGenVertexArrays(); VBO = GL15.glGenBuffers(); // Bind the Vertex Array Object first, then bind and set vertex buffer(s) and attribute pointer(s). GL30.glBindVertexArray(VAO); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, VBO); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, vertices, GL15.GL_STATIC_DRAW); GL20.glEnableVertexAttribArray(POSITION_SHADER_LOCATION); GL20.glVertexAttribPointer(POSITION_SHADER_LOCATION, 3, GL11.GL_FLOAT, false, (3 + 3 + 4) * 4, 0); GL20.glEnableVertexAttribArray(NORMAL_SHADER_LOCATION); GL20.glVertexAttribPointer(NORMAL_SHADER_LOCATION, 3, GL11.GL_FLOAT, false, (3 + 3 + 4) * 4, 3 * 4); GL20.glEnableVertexAttribArray(COLOUR_SHADER_LOCATION); GL20.glVertexAttribPointer(COLOUR_SHADER_LOCATION, 4, GL11.GL_FLOAT, false, (3 + 3 + 4) * 4, (3 + 3) * 4); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); // Note that this is allowed, the call to glVertexAttribPointer registered VBO as the currently bound vertex buffer object so afterwards we can safely unbind GL30.glBindVertexArray(0); // Unbind VAO (it's always a good thing to unbind any buffer/array to prevent strange bugs), remember: do NOT unbind the EBO, keep it bound to this VAO }
Example 12
Source File: vboWithIndices.java From ldparteditor with MIT License | 4 votes |
@Override public void init() { Matrix4f.setIdentity(viewport); shaderProgram = new GLShader("primitive.vert", "primitive.frag"); //$NON-NLS-1$ //$NON-NLS-2$ shaderProgram.use(); GL11.glClearDepth(1.0f); GL11.glClearColor(View.primitive_background_Colour_r[0], View.primitive_background_Colour_g[0], View.primitive_background_Colour_b[0], 1.0f); new Thread(new Runnable() { @Override public void run() { while (isRendering.get()) { final float zoom = cp.getZoom(); final Matrix4f viewport_translation = cp.getTranslation(); final float STEP = 22f * zoom * View.PIXEL_PER_LDU; cp.setRotationWidth(STEP); Matrix4f viewport_transform = new Matrix4f(); Matrix4f.setIdentity(viewport_transform); Matrix4f.scale(new Vector3f(zoom, zoom, zoom), viewport_transform, viewport_transform); Matrix4f.mul(viewport_transform, viewport_translation, viewport_transform); cp.setViewport(viewport_transform); viewport = viewport_transform; try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } } } }).start(); // Set up vertex data (and buffer(s)) and attribute pointers float[] vertices = new float[]{ 0.5f, 0.5f, 0.0f, // Top Right 0.5f, -0.5f, 0.0f, // Bottom Right -0.5f, -0.5f, 0.0f, // Bottom Left -0.5f, 0.5f, 0.0f // Top Left }; int[] indices = new int[]{ // Note that we start from 0! 0, 1, 3, // First Triangle 1, 2, 3 // Second Triangle }; VAO = GL30.glGenVertexArrays(); VBO = GL15.glGenBuffers(); EBO = GL15.glGenBuffers(); // Bind the Vertex Array Object first, then bind and set vertex buffer(s) and attribute pointer(s). GL30.glBindVertexArray(VAO); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, VBO); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, vertices, GL15.GL_STATIC_DRAW); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, EBO); GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, indices, GL15.GL_STATIC_DRAW); GL20.glEnableVertexAttribArray(POSITION_SHADER_LOCATION); GL20.glVertexAttribPointer(POSITION_SHADER_LOCATION, 3, GL11.GL_FLOAT, false, 3 * 4, 0); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); // Note that this is allowed, the call to glVertexAttribPointer registered VBO as the currently bound vertex buffer object so afterwards we can safely unbind GL30.glBindVertexArray(0); // Unbind VAO (it's always a good thing to unbind any buffer/array to prevent strange bugs), remember: do NOT unbind the EBO, keep it bound to this VAO }
Example 13
Source File: Snippet195.java From ldparteditor with MIT License | 4 votes |
public static void main(String[] args) { final Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); Composite comp = new Composite(shell, SWT.NONE); comp.setLayout(new FillLayout()); GLData data = new GLData(); data.doubleBuffer = true; final GLCanvas canvas = new GLCanvas(comp, SWT.NONE, data); canvas.setCurrent(); // try { // GLContext.useContext(canvas); // } catch (LWJGLException e) { // e.printStackTrace(); // } canvas.addListener(SWT.Resize, event -> { Rectangle bounds = canvas.getBounds(); float fAspect = (float) bounds.width / (float) bounds.height; canvas.setCurrent(); // try { // GLContext.useContext(canvas); // } catch (LWJGLException e) { // e.printStackTrace(); // } GL11.glViewport(0, 0, bounds.width, bounds.height); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GLU.gluPerspective(45.0f, fAspect, 0.5f, 400.0f); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); }); GL11.glClearColor(1.0f, 1.0f, 1.0f, 1.0f); GL11.glColor3f(1.0f, 0.0f, 0.0f); GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); GL11.glClearDepth(1.0); GL11.glLineWidth(2); GL11.glEnable(GL11.GL_DEPTH_TEST); shell.setText("SWT/LWJGL Example"); //$NON-NLS-1$ shell.setSize(640, 480); shell.open(); display.asyncExec(new Runnable() { int rot = 0; @Override public void run() { if (!canvas.isDisposed()) { canvas.setCurrent(); // try { // GLContext.useContext(canvas); // } catch (LWJGLException e) { // e.printStackTrace(); // } GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GL11.glLoadIdentity(); GL11.glTranslatef(0.0f, 0.0f, -10.0f); float frot = rot; GL11.glRotatef(0.15f * rot, 2.0f * frot, 10.0f * frot, 1.0f); GL11.glRotatef(0.3f * rot, 3.0f * frot, 1.0f * frot, 1.0f); rot++; GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL); GL11.glColor3f(0.9f, 0.9f, 0.9f); drawTorus(1, 1.9f + (float) Math.sin(0.004f * frot), 15, 15); GL11.glColor3f(0.9f, 0.9f, 0f); drawTorus(1.9f, 5.9f + (float) Math.sin(0.004f * frot), 15, 15); canvas.swapBuffers(); display.asyncExec(this); } } }); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
Example 14
Source File: OpenGLRenderer33.java From ldparteditor with MIT License | 4 votes |
@Override public void init() { if (shaderProgram.isDefault()) shaderProgram = new GLShader("renderer.vert", "renderer.frag"); //$NON-NLS-1$ //$NON-NLS-2$ if (shaderProgram2.isDefault()) shaderProgram2 = new GLShader("primitive.vert", "primitive.frag"); //$NON-NLS-1$ //$NON-NLS-2$ if (shaderProgram2D.isDefault()) shaderProgram2D = new GLShader("2D.vert", "2D.frag"); //$NON-NLS-1$ //$NON-NLS-2$ if (shaderProgramCondline.isDefault()) shaderProgramCondline = new GLShader("condline.vert", "condline.frag"); //$NON-NLS-1$ //$NON-NLS-2$ shaderProgramCondline.use(); GL20.glUniform1f(shaderProgramCondline.getUniformLocation("showAll"), c3d.getLineMode() == 1 ? 1f : 0f); //$NON-NLS-1$ GL20.glUniform1f(shaderProgramCondline.getUniformLocation("condlineMode"), c3d.getRenderMode() == 6 ? 1f : 0f); //$NON-NLS-1$ stack.setShader(shaderProgram); shaderProgram.use(); shaderProgram.texmapOff(); { GL20.glUniform1f(shaderProgram.getUniformLocation("l0_r"), View.light1_Colour_r[0]); //$NON-NLS-1$ GL20.glUniform1f(shaderProgram.getUniformLocation("l0_g"), View.light1_Colour_g[0]); //$NON-NLS-1$ GL20.glUniform1f(shaderProgram.getUniformLocation("l0_b"), View.light1_Colour_b[0]); //$NON-NLS-1$ GL20.glUniform1f(shaderProgram.getUniformLocation("l0s_r"), View.light1_specular_Colour_r[0]); //$NON-NLS-1$ GL20.glUniform1f(shaderProgram.getUniformLocation("l0s_g"), View.light1_specular_Colour_g[0]); //$NON-NLS-1$ GL20.glUniform1f(shaderProgram.getUniformLocation("l0s_b"), View.light1_specular_Colour_b[0]); //$NON-NLS-1$ GL20.glUniform1f(shaderProgram.getUniformLocation("l1_r"), View.light2_Colour_r[0]); //$NON-NLS-1$ GL20.glUniform1f(shaderProgram.getUniformLocation("l1_g"), View.light2_Colour_g[0]); //$NON-NLS-1$ GL20.glUniform1f(shaderProgram.getUniformLocation("l1_b"), View.light2_Colour_b[0]); //$NON-NLS-1$ GL20.glUniform1f(shaderProgram.getUniformLocation("l1s_r"), View.light2_specular_Colour_r[0]); //$NON-NLS-1$ GL20.glUniform1f(shaderProgram.getUniformLocation("l1s_g"), View.light2_specular_Colour_g[0]); //$NON-NLS-1$ GL20.glUniform1f(shaderProgram.getUniformLocation("l1s_b"), View.light2_specular_Colour_b[0]); //$NON-NLS-1$ GL20.glUniform1f(shaderProgram.getUniformLocation("l2_r"), View.light3_Colour_r[0]); //$NON-NLS-1$ GL20.glUniform1f(shaderProgram.getUniformLocation("l2_g"), View.light3_Colour_g[0]); //$NON-NLS-1$ GL20.glUniform1f(shaderProgram.getUniformLocation("l2_b"), View.light3_Colour_b[0]); //$NON-NLS-1$ GL20.glUniform1f(shaderProgram.getUniformLocation("l2s_r"), View.light3_specular_Colour_r[0]); //$NON-NLS-1$ GL20.glUniform1f(shaderProgram.getUniformLocation("l2s_g"), View.light3_specular_Colour_g[0]); //$NON-NLS-1$ GL20.glUniform1f(shaderProgram.getUniformLocation("l2s_b"), View.light3_specular_Colour_b[0]); //$NON-NLS-1$ GL20.glUniform1f(shaderProgram.getUniformLocation("l3_r"), View.light4_Colour_r[0]); //$NON-NLS-1$ GL20.glUniform1f(shaderProgram.getUniformLocation("l3_g"), View.light4_Colour_g[0]); //$NON-NLS-1$ GL20.glUniform1f(shaderProgram.getUniformLocation("l3_b"), View.light4_Colour_b[0]); //$NON-NLS-1$ GL20.glUniform1f(shaderProgram.getUniformLocation("l3s_r"), View.light4_specular_Colour_r[0]); //$NON-NLS-1$ GL20.glUniform1f(shaderProgram.getUniformLocation("l3s_g"), View.light4_specular_Colour_g[0]); //$NON-NLS-1$ GL20.glUniform1f(shaderProgram.getUniformLocation("l3s_b"), View.light4_specular_Colour_b[0]); //$NON-NLS-1$ shaderProgram.setFactor(1f); } 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.glPointSize(5); modelRenderer.init(); modelRendererLDrawStandard.init(); }
Example 15
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 16
Source File: ImmediateModeOGLRenderer.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * @see org.newdawn.slick.opengl.renderer.SGL#glClearDepth(float) */ public void glClearDepth(float value) { GL11.glClearDepth(value); }