List of usage examples for org.lwjgl.opengl GL11 glCullFace
public static void glCullFace(@NativeType("GLenum") int mode)
From source file:org.jtrfp.mtmx.tools.internal.TruckViewerConfiguration.java
License:Open Source License
@Override public void initView() { GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity();//from www. j a v a2s . c om GL11.glFrustum(-1.0, 1.0, -1.0, 1.0, 1.5, 25.0); GL11.glMatrixMode(GL11.GL_MODELVIEW); //GL11.glClearDepth(0.5f); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glCullFace(GL11.GL_BACK); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_TEXTURE_2D); }
From source file:org.jtrfp.mtmx.tools.internal.WorldViewerConfiguration.java
License:Open Source License
@Override public void initView() { GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity();/*from www .jav a 2s . c o m*/ GL11.glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0f, 150 * IDrawer.WORLD_SCALE_XZ); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glCullFace(GL11.GL_BACK); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glEnable(GL11.GL_TEXTURE_2D); }
From source file:org.mkdev.ai.langton3d.core.App.java
License:GNU General Public License
private boolean initGL() { GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity();/*from www . java 2s .c om*/ GLU.gluPerspective(FOV, ((float) targetWidth) / ((float) targetHeight), 0.1f, 100.0f); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glCullFace(GL11.GL_BACK); GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_FASTEST); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST); setupLights(); setupFog(Settings.FOG_DENSITY, Settings.FOG_START, Settings.FOG_END); GL11.glEnable(GL11.GL_TEXTURE_2D); return true; }
From source file:org.ode4j.drawstuff.internal.DrawStuffGL.java
License:Open Source License
@Override // void dsDrawFrame (int width, int height, dsFunctions *fn, int pause) void dsDrawFrame(int width, int height, dsFunctions fn, boolean pause) { if (current_state < 1) dsDebug("internal error"); current_state = 2;/*from w w w .j a va 2s . co m*/ // setup stuff GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_LIGHT0); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_TEXTURE_GEN_S); GL11.glDisable(GL11.GL_TEXTURE_GEN_T); GL11.glShadeModel(GL11.GL_FLAT); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthFunc(GL11.GL_LESS); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glCullFace(GL11.GL_BACK); GL11.glFrontFace(GL11.GL_CCW); // setup viewport GL11.glViewport(0, 0, width, height); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); final float vnear = 0.1f; final float vfar = 100.0f; final float k = 0.8f; // view scale, 1 = +/- 45 degrees if (width >= height) { float k2 = (float) height / (float) width; GL11.glFrustum(-vnear * k, vnear * k, -vnear * k * k2, vnear * k * k2, vnear, vfar); } else { float k2 = (float) width / (float) height; GL11.glFrustum(-vnear * k * k2, vnear * k * k2, -vnear * k, vnear * k, vnear, vfar); } // setup lights. it makes a difference whether this is done in the // GL_PROJECTION matrix mode (lights are scene relative) or the // GL_MODELVIEW matrix mode (lights are camera relative, bad!). // static GLfloat light_ambient[] = { 0.5, 0.5, 0.5, 1.0 }; // static GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; // static GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 }; GL11.glLight(GL11.GL_LIGHT0, GL11.GL_AMBIENT, light_ambient); GL11.glLight(GL11.GL_LIGHT0, GL11.GL_DIFFUSE, light_diffuse); GL11.glLight(GL11.GL_LIGHT0, GL11.GL_SPECULAR, light_specular); GL11.glColor3f(1.0f, 1.0f, 1.0f); // clear the window GL11.glClearColor(0.5f, 0.5f, 0.5f, 0); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); // snapshot camera position (in MS Windows it is changed by the GUI thread) float[] view2_xyz = view_xyz.clone(); float[] view2_rxyz = view_rxyz.clone(); // memcpy (view2_xyz,view_xyz);//,sizeof(float)*3); // memcpy (view2_hpr,view_hpr);//,sizeof(float)*3); // go to GL_MODELVIEW matrix mode and set the camera GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); setCamera(view2_xyz[0], view2_xyz[1], view2_xyz[2], view2_rxyz[0], view2_rxyz[1], view2_rxyz[2]); // set the light position (for some reason we have to do this in model view. // static GLfloat light_position[] = { LIGHTX, LIGHTY, 1.0, 0.0 }; GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, light_position); // draw the background (ground, sky etc) drawSky(view2_xyz); drawGround(); // draw the little markers on the ground drawPyramidGrid(); // leave openGL in a known state - flat shaded white, no textures GL11.glEnable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glShadeModel(GL11.GL_FLAT); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthFunc(GL11.GL_LESS); GL11.glColor3f(1, 1, 1); setColor(1, 1, 1, 1); // draw the rest of the objects. set drawing state first. color[0] = 1; color[1] = 1; color[2] = 1; color[3] = 1; tnum = DS_TEXTURE_NUMBER.DS_NONE; //if (fn.step) fn.step(pause); }
From source file:org.oscim.gdx.LwjglGL20.java
License:Apache License
public void cullFace(int mode) { GL11.glCullFace(mode); }
From source file:org.spout.engine.SpoutRenderer.java
License:Open Source License
public void initRenderer(Canvas parent) { createWindow(parent);/*from w ww .j a v a 2s . c o m*/ if (Spout.debugMode()) { client.getLogger().info("SpoutClient Information"); client.getLogger().info("Operating System: " + System.getProperty("os.name")); client.getLogger().info("Renderer Mode: " + client.getRenderMode().toString()); client.getLogger().info("GL21: " + GLContext.getCapabilities().OpenGL21 + " GL32: " + GLContext.getCapabilities().OpenGL32); client.getLogger().info("Resolution: " + Display.getWidth() + "x" + Display.getHeight()); client.getLogger().info("OpenGL Information"); client.getLogger().info("Vendor: " + GL11.glGetString(GL11.GL_VENDOR)); client.getLogger().info("OpenGL Version: " + GL11.glGetString(GL11.GL_VERSION)); client.getLogger().info("GLSL Version: " + GL11.glGetString(GL20.GL_SHADING_LANGUAGE_VERSION)); client.getLogger().info("Max Textures: " + GL11.glGetInteger(GL20.GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS)); String extensions = "Extensions Supported: "; if (client.getRenderMode() == RenderMode.GL30 || client.getRenderMode() == RenderMode.GL40) { for (int i = 0; i < GL11.glGetInteger(GL30.GL_NUM_EXTENSIONS); i++) { extensions += GL30.glGetStringi(GL11.GL_EXTENSIONS, i) + " "; } } else { extensions += GL11.glGetString(GL11.GL_EXTENSIONS); } client.getLogger().info(extensions); } SpoutRenderer.checkGLError(); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glFrontFace(GL11.GL_CW); GL11.glCullFace(GL11.GL_BACK); SpoutRenderer.checkGLError(); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glClearColor((135.f / 255.0f), 206.f / 255.f, 250.f / 255.f, 1); SpoutRenderer.checkGLError(); //Init pool of BatchVertexRenderer BatchVertexRenderer.initPool(GL11.GL_TRIANGLES, 500); if (useReflexion) { reflected = new ClientRenderTexture(true, false, true); reflected.writeGPU(); // Test reflectedDebugBatch = new SpriteBatch(); Shader s1 = client.getFileSystem().getResource("shader://Spout/shaders/diffuse.ssf"); HashMap<String, Object> map1 = new HashMap<>(); map1.put("Diffuse", reflected); reflectedDebugMat = new ClientRenderMaterial(s1, map1); RenderPart screenPart1 = new RenderPart(); screenPart1.setSprite(new Rectangle(-1, -1, 0.5f, 0.5f)); screenPart1.setSource(new Rectangle(0, 1, 1, -1)); RenderPartPack pack1 = new RenderPartPack(reflectedDebugMat); pack1.add(screenPart1); reflectedDebugBatch.flush(pack1); // Test end } screenBatcher = new SpriteBatch(); t = new ClientRenderTexture(true, false, true); t.writeGPU(); Shader s = client.getFileSystem().getResource("shader://Spout/shaders/diffuse.ssf"); HashMap<String, Object> map = new HashMap<>(); map.put("Diffuse", t); mat = new ClientRenderMaterial(s, map); RenderPart screenPart = new RenderPart(); screenPart.setSprite(new Rectangle(-1, -1, 2, 2)); screenPart.setSource(new Rectangle(0, 1, 1, -1)); RenderPartPack pack = new RenderPartPack(mat); pack.add(screenPart); screenBatcher.flush(pack); }
From source file:org.spout.engine.SpoutRenderer.java
License:Open Source License
public void render(float dt) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); final Camera camera = client.getPlayer().getType(Camera.class); final SkydomeComponent skydome = client.getWorld().get(SkydomeComponent.class); // Render reflected world if (useReflexion) { reflected.activate();/* ww w . j a v a 2 s . c o m*/ GL11.glCullFace(GL11.GL_FRONT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); if (camera != null) { camera.updateReflectedView(); if (skydome != null && skydome.getModel() != null) { skydome.getModel().getRenderMaterial().getShader().setUniform("View", camera.getRotation()); skydome.getModel().getRenderMaterial().getShader().setUniform("Projection", camera.getProjection()); skydome.getModel().getRenderMaterial().getShader().setUniform("Model", Matrix4.IDENTITY); BaseMesh reflectedSkydomeMesh = (BaseMesh) skydome.getModel().getMesh(); if (!reflectedSkydomeMesh.isBatched()) { reflectedSkydomeMesh.batch(); } reflectedSkydomeMesh.render(skydome.getModel().getRenderMaterial()); } } worldRenderer.render(); entityRenderer.render(dt); GL11.glCullFace(GL11.GL_BACK); reflected.release(); } // Render normal world t.activate(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); if (camera != null) { camera.updateView(); if (skydome != null && skydome.getModel() != null) { skydome.getModel().getRenderMaterial().getShader().setUniform("View", camera.getRotation()); skydome.getModel().getRenderMaterial().getShader().setUniform("Projection", camera.getProjection()); skydome.getModel().getRenderMaterial().getShader().setUniform("Model", Matrix4.IDENTITY); BaseMesh skydomeMesh = (BaseMesh) skydome.getModel().getMesh(); if (!skydomeMesh.isBatched()) { skydomeMesh.batch(); } skydomeMesh.render(skydome.getModel().getRenderMaterial()); } } long start = System.nanoTime(); worldRenderer.render(); worldTime = System.nanoTime() - start; start = System.nanoTime(); entityRenderer.render(dt); entityTime = System.nanoTime() - start; start = System.nanoTime(); t.release(); // Render gui if (wireframe) { GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL); } screenBatcher.render(Matrix4.IDENTITY); if (useReflexion) { reflectedDebugBatch.render(Matrix4.IDENTITY); } //GUI -> Render all widgets for (Screen screen : screenStack.getVisibleScreens()) { for (Widget widget : screen.getWidgets()) { ((SpoutWidget) widget).render(); } } //GUI -> Give the main screen the mouse if no input screen is set final Screen input = screenStack.getInputScreen(); if (input == null) { Mouse.setGrabbed(true); } else { Mouse.setGrabbed(input.grabsMouse()); } //GUI -> Update debug info if (showDebugInfos) { int id = 0; Point position = client.getPlayer().getPhysics().getPosition(); debugScreen.spoutUpdate(id++, "Spout client! Logged as " + client.getPlayer().getDisplayName() + " in world: " + client.getWorld().getName()); debugScreen.spoutUpdate(id++, "x: " + position.getX() + "y: " + position.getY() + "z: " + position.getZ()); debugScreen.spoutUpdate(id++, "FPS: " + client.getScheduler().getFps() + " (" + (client.getScheduler().isRendererOverloaded() ? "Overloaded" : "Normal") + ")"); debugScreen.spoutUpdate(id++, "Chunks Loaded: " + client.getWorld().getNumLoadedChunks()); debugScreen.spoutUpdate(id++, "Total ChunkMeshBatchAggregators in Renderer: " + worldRenderer.getTotalChunks() + ""); debugScreen.spoutUpdate(id++, "Chunks Drawn: " + ((int) ((float) worldRenderer.getRenderedChunks() / (float) (worldRenderer.getTotalChunks()) * 100)) + "%" + " (" + worldRenderer.getRenderedChunks() + ")"); debugScreen.spoutUpdate(id++, "Occluded Chunks: " + (int) ((float) worldRenderer.getOccludedChunks() / worldRenderer.getTotalChunks() * 100) + "% (" + worldRenderer.getOccludedChunks() + ")"); debugScreen.spoutUpdate(id++, "Cull Chunks: " + (int) ((float) worldRenderer.getCulledChunks() / worldRenderer.getTotalChunks() * 100) + "% (" + worldRenderer.getCulledChunks() + ")"); debugScreen.spoutUpdate(id++, "Entities: " + entityRenderer.getRenderedEntities()); debugScreen.spoutUpdate(id++, "Buffer: " + worldRenderer.addedBatch + " / " + worldRenderer.updatedBatch); debugScreen.spoutUpdate(id++, "Mesh batch queue size: " + ((SpoutClient) Spout.getEngine()).getRenderer().getWorldRenderer().getBatchWaiting()); } for (Screen screen : screenStack.getVisibleScreens()) { for (Widget widget : screen.getWidgets()) { ((SpoutWidget) widget).render(); } } guiTime = System.nanoTime() - start; if (wireframe) { GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE); } }
From source file:org.terasology.rendering.dag.tasks.SetFacesToCullTask.java
License:Apache License
@Override public void execute() { GL11.glCullFace(mode); }
From source file:org.terasology.rendering.dag.WorldReflectionNode.java
License:Apache License
@Override public void process() { PerformanceMonitor.startActivity("rendering/worldreflection"); sceneReflected = frameBuffersManager.getFBO("sceneReflected"); sceneOpaque = frameBuffersManager.getFBO("sceneOpaque"); sceneReflected.bind();//from w w w . j a va 2 s.c o m setViewportToSizeOf(sceneReflected); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); GL11.glCullFace(GL11.GL_FRONT); playerCamera.setReflected(true); playerCamera.lookThroughNormalized(); // we don't want the reflected scene to be bobbing or moving with the player // TODO: convert backdropRenderer into a BackdropNode. backdropRenderer.render(playerCamera); playerCamera.lookThrough(); if (renderingConfig.isReflectiveWater()) { // TODO: the isReflectiveWater() block should include content of the whole process() method. // TODO: Eventually the check will be removed, when node insertion will signify that the feature is enabled. chunkShader.activateFeature(ShaderProgramFeature.FEATURE_USE_FORWARD_LIGHTING); worldRenderer.renderChunks(renderQueues.chunksOpaqueReflection, ChunkMesh.RenderPhase.OPAQUE, playerCamera, WorldRendererImpl.ChunkRenderMode.REFLECTION); chunkShader.deactivateFeature(ShaderProgramFeature.FEATURE_USE_FORWARD_LIGHTING); } playerCamera.setReflected(false); GL11.glCullFace(GL11.GL_BACK); bindDisplay(); setViewportToSizeOf(sceneOpaque); PerformanceMonitor.endActivity(); }
From source file:org.terasology.rendering.opengl.GraphicState.java
License:Apache License
/** * Sets the state for the rendering of the Reflected Scene. * * This is effectively an inverted rendering of the backdrop and * the opaque chunks of the landscape, to be used in water reflections. *///from w ww. ja va2s .c o m public void preRenderSetupReflectedScene() { buffers.sceneReflected.bind(); setViewportToSizeOf(buffers.sceneReflected); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); GL11.glCullFace(GL11.GL_FRONT); }