Java Code Examples for org.lwjgl.opengl.GL11#glLoadIdentity()

The following examples show how to use org.lwjgl.opengl.GL11#glLoadIdentity() . 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: PBufferGraphics.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * 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 2
Source File: FontHelper.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 6 votes vote down vote up
private static void set2DMode(FloatBuffer matrixData) {
    Minecraft mc = Minecraft.getMinecraft();
    ScaledResolution sr = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
    mc.entityRenderer.setupOverlayRendering();
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPushMatrix();
    //GL11.glLoadMatrix(matrixData);

    GL11.glLoadIdentity();
    GL11.glOrtho(0, mc.displayWidth, 0, mc.displayHeight, -1, 1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPushMatrix();
    GL11.glLoadIdentity();

    Matrix4f matrix = new Matrix4f();
    matrix.load(matrixData);
    GL11.glTranslatef(matrix.m30*sr.getScaleFactor(),-matrix.m31*sr.getScaleFactor(), 0f);

}
 
Example 3
Source File: PerspectiveCalculator.java    From ldparteditor with MIT License 6 votes vote down vote up
/**
 * Initializes the viewport and perspective
 */
public void initializeViewportPerspective() {
    if (c3d.getRenderer() instanceof OpenGLRenderer20) {
        // MARK OpenGL Viewport and Perspective
        Rectangle bounds = c3d.getBounds();
        Rectangle scaledBounds = c3d.getScaledBounds();
        GL11.glViewport(0, 0, scaledBounds.width, scaledBounds.height);
        GL11.glMatrixMode(GL11.GL_PROJECTION);
        GL11.glLoadIdentity();
        float viewport_width = bounds.width / View.PIXEL_PER_LDU / 2.0f;
        float viewport_height = bounds.height / View.PIXEL_PER_LDU / 2.0f;
        GL11.glOrtho(-viewport_width, viewport_width, -viewport_height, viewport_height, c3d.getzNear() * c3d.getZoom(), c3d.getzFar() * c3d.getZoom());
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glLoadIdentity();
    }
    calculateOriginData();
}
 
Example 4
Source File: LegacyCurveRenderState.java    From opsu with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Backup the current state of the relevant OpenGL state and change it to
 * what's needed to draw the curve.
 */
private RenderState saveRenderState() {
	RenderState state = new RenderState();
	state.smoothedPoly = GL11.glGetBoolean(GL11.GL_POLYGON_SMOOTH);
	state.blendEnabled = GL11.glGetBoolean(GL11.GL_BLEND);
	state.depthEnabled = GL11.glGetBoolean(GL11.GL_DEPTH_TEST);
	state.depthWriteEnabled = GL11.glGetBoolean(GL11.GL_DEPTH_WRITEMASK);
	state.texEnabled = GL11.glGetBoolean(GL11.GL_TEXTURE_2D);
	state.texUnit = GL11.glGetInteger(GL13.GL_ACTIVE_TEXTURE);
	state.oldProgram = GL11.glGetInteger(GL20.GL_CURRENT_PROGRAM);
	state.oldArrayBuffer = GL11.glGetInteger(GL15.GL_ARRAY_BUFFER_BINDING);
	GL11.glDisable(GL11.GL_POLYGON_SMOOTH);
	GL11.glDisable(GL11.GL_BLEND);
	GL11.glEnable(GL11.GL_DEPTH_TEST);
	GL11.glDepthMask(true);
	GL11.glDisable(GL11.GL_TEXTURE_2D);
	GL11.glEnable(GL11.GL_TEXTURE_1D);
	GL11.glBindTexture(GL11.GL_TEXTURE_1D, staticState.gradientTexture);
	GL11.glTexParameteri(GL11.GL_TEXTURE_1D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR);
	GL11.glTexParameteri(GL11.GL_TEXTURE_1D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
	GL11.glTexParameteri(GL11.GL_TEXTURE_1D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP);

	GL20.glUseProgram(0);

	GL11.glMatrixMode(GL11.GL_PROJECTION);
	GL11.glPushMatrix();
	GL11.glLoadIdentity();
	GL11.glMatrixMode(GL11.GL_MODELVIEW);
	GL11.glPushMatrix();
	GL11.glLoadIdentity();

	return state;
}
 
Example 5
Source File: TextureMapRenderer.java    From VanillaFix with MIT License 5 votes vote down vote up
public static void pushTextureIdentity() {
    int oldMatrixMode = GlStateManager.glGetInteger(GL11.GL_MATRIX_MODE);
    GL11.glMatrixMode(GL11.GL_TEXTURE);
    GL11.glPushMatrix();
    GL11.glLoadIdentity();
    GL11.glMatrixMode(oldMatrixMode);
}
 
Example 6
Source File: GUIRoot.java    From tribaltrouble with GNU General Public License v2.0 5 votes vote down vote up
public final void setupGUIView() {
	GL11.glDisable(GL11.GL_DEPTH_TEST);
	GL11.glEnable(GL11.GL_ALPHA_TEST);
	GL11.glAlphaFunc(GL11.GL_GREATER, 0f);
	GL11.glMatrixMode(GL11.GL_PROJECTION);
	GL11.glLoadIdentity();
	GLU.gluPerspective(Globals.FOV, LocalInput.getViewAspect(), Globals.VIEW_MIN, Globals.VIEW_MAX);
	GL11.glMultMatrix(matrix_buf);
	GL11.glMatrixMode(GL11.GL_MODELVIEW);
	GL11.glLoadIdentity();
	GL11.glEnable(GL11.GL_BLEND);
}
 
Example 7
Source File: Sky.java    From tribaltrouble with GNU General Public License v2.0 5 votes vote down vote up
public final void renderSeaBottom() {
	GL11.glDisable(GL11.GL_TEXTURE_2D);
	GL11.glColor3f(Globals.SEA_BOTTOM_COLOR[terrain_type][0], Globals.SEA_BOTTOM_COLOR[terrain_type][1], Globals.SEA_BOTTOM_COLOR[terrain_type][2]);

	GLStateStack.switchState(GLState.VERTEX_ARRAY);
	if (Globals.draw_detail) {
		GLState.activeTexture(GL13.GL_TEXTURE1);
		GL11.glEnable(GL11.GL_TEXTURE_2D);
		landscape_renderer.bindDetail();
		GL11.glMatrixMode(GL11.GL_TEXTURE);
		GL11.glLoadIdentity();
		GL11.glEnable(GL11.GL_TEXTURE_GEN_S);
		GL11.glEnable(GL11.GL_TEXTURE_GEN_T);
		GLUtils.setupTexGen(1, 1, 0, 0);
		GL11.glScalef(Globals.LANDSCAPE_DETAIL_REPEAT_RATE, Globals.LANDSCAPE_DETAIL_REPEAT_RATE, 1);
	}

	bottom_vertices.vertexPointer(3, 0, 0);
	water_indices.drawRangeElements(GL11.GL_TRIANGLES, 0, bottom_vertices.capacity()/3, water_indices.capacity(), 0);

	if (Globals.draw_detail) {
		GL11.glDisable(GL11.GL_TEXTURE_GEN_S);
		GL11.glDisable(GL11.GL_TEXTURE_GEN_T);
		GL11.glLoadIdentity();
		GL11.glMatrixMode(GL11.GL_MODELVIEW);
		GL11.glDisable(GL11.GL_TEXTURE_2D);
		GLState.activeTexture(GL13.GL_TEXTURE0);
	}

	GL11.glEnable(GL11.GL_TEXTURE_2D);
}
 
Example 8
Source File: Sky.java    From tribaltrouble with GNU General Public License v2.0 5 votes vote down vote up
private final void resetSky() {
	GL11.glDisable(GL11.GL_TEXTURE_2D);
	GL11.glLoadIdentity();
	GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_DECAL);
	GLState.activeTexture(GL13.GL_TEXTURE0);
	GL11.glLoadIdentity();
	GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_REPLACE);
	GL11.glMatrixMode(GL11.GL_MODELVIEW);
}
 
Example 9
Source File: Test.java    From tribaltrouble with GNU General Public License v2.0 5 votes vote down vote up
private final static void initGL() {
	GL11.glEnable(GL11.GL_TEXTURE_2D);

	GL11.glMatrixMode(GL11.GL_PROJECTION);
	GL11.glLoadIdentity();

	GLU.gluOrtho2D(0f, Display.getDisplayMode().getWidth(), 0f, Display.getDisplayMode().getHeight());
	GL11.glMatrixMode(GL11.GL_MODELVIEW);

	GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
	GL11.glEnable(GL11.GL_BLEND);
}
 
Example 10
Source File: PBufferUniqueGraphics.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Enter the orthographic mode 
 */
protected void enterOrtho() {
	GL11.glMatrixMode(GL11.GL_PROJECTION);
	GL11.glLoadIdentity();
	GL11.glOrtho(0, screenWidth, 0, screenHeight, 1, -1);
	GL11.glMatrixMode(GL11.GL_MODELVIEW);
}
 
Example 11
Source File: MapRenderer.java    From mapwriter with MIT License 5 votes vote down vote up
public void draw() {
	
	this.mapMode.setScreenRes();
	this.mapView.setMapWH(this.mapMode);
	this.mapView.setTextureSize(this.mw.textureSize);
	
	GL11.glPushMatrix();
	GL11.glLoadIdentity();
	
	// translate to center of minimap
	// z is -2000 so that it is drawn above the 3D world, but below GUI
	// elements which are typically at -3000
	GL11.glTranslated(this.mapMode.xTranslation, this.mapMode.yTranslation, -2000.0);
	
	// draw background, the map texture, and enabled overlays
	this.drawMap();
	
	if (this.mapMode.borderMode > 0) {
		this.drawBorder();
	}
	this.drawIcons();
	
	this.drawCoords();
	
	// some shader mods seem to need depth testing re-enabled
	GL11.glEnable(GL11.GL_DEPTH_TEST);
	GL11.glPopMatrix();
}
 
Example 12
Source File: MatrixUtil.java    From tectonicus with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void testOrthoMatrix(final int left, final int right, final int bottom, final int top, final int near, final int far)
{
	// Make an ortho matrix in opengl and pull it out into a Matrix4f
	GL11.glMatrixMode(GL11.GL_MODELVIEW);
	GL11.glLoadIdentity();
	GL11.glOrtho(left, right, bottom, top, near, far);
	FloatBuffer fromGlBuffer = BufferUtils.createFloatBuffer(16);
	GL11.glGetFloat(GL11.GL_MODELVIEW, fromGlBuffer);
	Matrix4f fromGl = new Matrix4f();
	fromGl.load(fromGlBuffer);
	
	Matrix4f manual = createOrthoMatrix(left, right, bottom, top, near, far);
	
	compare(fromGl, manual);
}
 
Example 13
Source File: LwjglRasteriser.java    From tectonicus with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void setCameraMatrix(Matrix4f matrix, Vector3f lookAt, Vector3f eye, Vector3f up)
{
	GL11.glMatrixMode(GL11.GL_MODELVIEW);
	GL11.glLoadIdentity();
	
	FloatBuffer buffer = BufferUtils.createFloatBuffer(16);
	matrix.store(buffer);
	buffer.flip();
	GL11.glLoadMatrix(buffer);
}
 
Example 14
Source File: CurveRenderState.java    From opsu-dance with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Backup the current state of the relevant OpenGL state and change it to
 * what's needed to draw the curve.
 */
private RenderState saveRenderState() {
	RenderState state = new RenderState();
	state.smoothedPoly = GL11.glGetBoolean(GL11.GL_POLYGON_SMOOTH);
	state.blendEnabled = GL11.glGetBoolean(GL11.GL_BLEND);
	state.depthEnabled = GL11.glGetBoolean(GL11.GL_DEPTH_TEST);
	state.depthWriteEnabled = GL11.glGetBoolean(GL11.GL_DEPTH_WRITEMASK);
	state.texEnabled = GL11.glGetBoolean(GL11.GL_TEXTURE_2D);
	state.texUnit = GL11.glGetInteger(GL13.GL_ACTIVE_TEXTURE);
	state.oldProgram = GL11.glGetInteger(GL20.GL_CURRENT_PROGRAM);
	state.oldArrayBuffer = GL11.glGetInteger(GL15.GL_ARRAY_BUFFER_BINDING);
	GL11.glDisable(GL11.GL_POLYGON_SMOOTH);
	GL11.glDisable(GL11.GL_BLEND);
	GL11.glEnable(GL11.GL_DEPTH_TEST);
	GL11.glDepthMask(true);
	GL11.glDisable(GL11.GL_TEXTURE_2D);
	GL11.glEnable(GL11.GL_TEXTURE_1D);
	GL11.glBindTexture(GL11.GL_TEXTURE_1D, staticState.gradientTexture);
	GL11.glTexParameteri(GL11.GL_TEXTURE_1D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR);
	GL11.glTexParameteri(GL11.GL_TEXTURE_1D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
	GL11.glTexParameteri(GL11.GL_TEXTURE_1D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP);

	GL20.glUseProgram(0);

	GL11.glMatrixMode(GL11.GL_PROJECTION);
	GL11.glPushMatrix();
	GL11.glLoadIdentity();
	GL11.glMatrixMode(GL11.GL_MODELVIEW);
	GL11.glPushMatrix();
	GL11.glLoadIdentity();

	return state;
}
 
Example 15
Source File: PBufferGraphics.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Enter the orthographic mode 
 */
protected void enterOrtho() {
	GL11.glMatrixMode(GL11.GL_PROJECTION);
	GL11.glLoadIdentity();
	GL11.glOrtho(0, screenWidth, 0, screenHeight, 1, -1);
	GL11.glMatrixMode(GL11.GL_MODELVIEW);
}
 
Example 16
Source File: LwJglRenderingEngine.java    From Gaalop with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void run() {
    startEngine();
    //long start = System.currentTimeMillis();
    while (!Display.isCloseRequested()) {
        //System.out.println(System.currentTimeMillis()-start);
        //start = System.currentTimeMillis();
        
        if (rendering.isNewDataSetAvailable()) {
            if (list != -1) GL11.glDeleteLists(list, 1);
            list = GL11.glGenLists(1);
            GL11.glNewList(list, GL11.GL_COMPILE);
            draw(rendering.getDataSet(), rendering.getVisibleObjects(), rendering.getLoadedPointClouds());
            GL11.glEndList();
            changed = true;
        }
        
        
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); // clear the screen
        GL11.glLoadIdentity(); // apply camPos before rotation

        GL11.glTranslatef(0.0f, 0.0f, -5.0f);
        // draw
        GLU.gluLookAt(camPos.x, camPos.y, camPos.z, // Position
                camPos.x + camDir.x, camPos.y + camDir.y, camPos.z + camDir.z, // Lookat
                camUp.x, camUp.y, camUp.z);               // Up-direction
        // apply rotation
        GL11.glRotatef(camAngleX, 0, 1, 0); // window x axis rotates around up vector
        GL11.glRotatef(camAngleY, 1, 0, 0); // window y axis rotates around x

        //Render the scene
        if (list != -1) GL11.glCallList(list);

        pollInput();
        Display.update();
        if (recorder != null) {
            if (changed || firstFrame) {
                recorder.makeScreenshot();
                changed = false;
            }
            firstFrame = false;
            Display.sync(25); // cap fps to 60fps
        }
        else 
            Display.sync(60); 
    }

    Display.destroy();
}
 
Example 17
Source File: Test.java    From tribaltrouble with GNU General Public License v2.0 4 votes vote down vote up
public final static void main(String[] args) {
		try {
			Display.setDisplayMode(new DisplayMode(DISPLAY_WIDTH, DISPLAY_HEIGHT));
			Display.create();
			initGL();

			// Load font
			InputStream font_is = Utils.makeURL("/fonts/tahoma.ttf").openStream();
			java.awt.Font src_font = java.awt.Font.createFont(java.awt.Font.TRUETYPE_FONT, font_is);
			java.awt.Font font = src_font.deriveFont(14f);

			// Load text
			InputStreamReader text_is = new InputStreamReader(Utils.makeURL("/test_text.txt").openStream());
			StringBuffer str_buffer = new StringBuffer();
			int c = text_is.read();
			do {
				str_buffer.append((char)c);
				c = text_is.read();
			} while (c != -1);
			String str = str_buffer.toString();

			// Build texture
			int[] pixels = new int[WIDTH*HEIGHT];
//			ByteBuffer pixel_data = ByteBuffer.wrap(pixels);						// NEW
//			pixelDataFromString(WIDTH, HEIGHT, str, font, pixels);					// NEW
			IntBuffer pixel_data = BufferUtils.createIntBuffer(WIDTH*HEIGHT);	// OLD
			pixel_data.put(pixels);													// OLD
			pixel_data.rewind();

			int texture_handle = createTexture(WIDTH, HEIGHT, pixel_data);
			
		FontRenderContext frc = g2d.getFontRenderContext();
		AttributedString att_str = new AttributedString(str);
		att_str.addAttribute(TextAttribute.FONT, font);
		AttributedCharacterIterator iterator = att_str.getIterator();
		LineBreakMeasurer measurer = new LineBreakMeasurer(iterator, frc);
		
			while (!Display.isCloseRequested()) {
long start_time = System.currentTimeMillis();
for (int i = 0; i < 10; i++) {
pixelDataFromString(WIDTH, HEIGHT, str, font, pixels, measurer);
pixel_data.put(pixels); // OLD
pixel_data.rewind();

//texture_handle = createTexture(WIDTH, HEIGHT, pixel_data);
updateTexture(WIDTH, HEIGHT, pixel_data);
				GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
				GL11.glLoadIdentity();
				
				// Background
				/*
				GL11.glDisable(GL11.GL_TEXTURE_2D);
				GL11.glColor4f(.1f, .1f, .1f, 1f);
				GL11.glBegin(GL11.GL_QUADS);
				GL11.glVertex3f(0f, DISPLAY_HEIGHT-RENDER_SIZE, 1f);
				GL11.glVertex3f(RENDER_SIZE, DISPLAY_HEIGHT-RENDER_SIZE, 1f);
				GL11.glVertex3f(RENDER_SIZE, DISPLAY_HEIGHT, 1f);
				GL11.glVertex3f(0f, DISPLAY_HEIGHT, 1f);
				GL11.glEnd();
				*/

				// Text
				GL11.glEnable(GL11.GL_TEXTURE_2D);
				GL11.glColor4f(1f, 1f, 1f, 1f);
				GL11.glBegin(GL11.GL_QUADS);
				GL11.glTexCoord2f(0f, 1f);
				GL11.glVertex3f(0f, DISPLAY_HEIGHT-RENDER_SIZE, 1f);
				GL11.glTexCoord2f(1f, 1f);
				GL11.glVertex3f(RENDER_SIZE, DISPLAY_HEIGHT-RENDER_SIZE, 1f);
				GL11.glTexCoord2f(1f, 0f);
				GL11.glVertex3f(RENDER_SIZE, DISPLAY_HEIGHT, 1f);
				GL11.glTexCoord2f(0f, 0f);
				GL11.glVertex3f(0f, DISPLAY_HEIGHT, 1f);
				GL11.glEnd();
				Display.update();
}
long total_time = System.currentTimeMillis() - start_time;
System.out.println("total_time = " + total_time);

			}
			Display.destroy();
		} catch (Exception t) {
			t.printStackTrace();
		}
	}
 
Example 18
Source File: RenderUtils.java    From LookingGlass with GNU General Public License v3.0 4 votes vote down vote up
@SideOnly(Side.CLIENT)
public final static void renderWorldToTexture(float renderTime, int framebuffer, int width, int height) {
	if (framebuffer == 0) return;
	Minecraft mc = Minecraft.getMinecraft();
	if (mc.skipRenderWorld) return;
	EntityRenderer entityRenderer = mc.entityRenderer;

	//Backup current render settings
	int heightBackup = mc.displayHeight;
	int widthBackup = mc.displayWidth;

	int thirdPersonBackup = mc.gameSettings.thirdPersonView;
	boolean hideGuiBackup = mc.gameSettings.hideGUI;
	int particleBackup = mc.gameSettings.particleSetting;
	boolean anaglyphBackup = mc.gameSettings.anaglyph;
	int renderDistanceBackup = mc.gameSettings.renderDistanceChunks;
	float FOVbackup = mc.gameSettings.fovSetting;

	//Render world
	try {
		//Set all of the render setting to work on the proxy world
		mc.displayHeight = height;
		mc.displayWidth = width;

		//TODO: params (FOV, Particle setting, renderDistance)
		mc.gameSettings.thirdPersonView = 0;
		mc.gameSettings.hideGUI = true;
		//mc.gameSettings.particleSetting = ;
		mc.gameSettings.anaglyph = false;
		//mc.gameSettings.renderDistanceChunks = ;  
		//mc.gameSettings.fovSetting = ;

		//Set gl options
		GL11.glViewport(0, 0, mc.displayWidth, mc.displayHeight);
		GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
		EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, framebuffer);
		GL11.glClearColor(1.0f, 0.0f, 0.0f, 0.5f);
		GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);

		int i1 = mc.gameSettings.limitFramerate;
		if (mc.isFramerateLimitBelowMax()) {
			entityRenderer.renderWorld(renderTime, (1000000000 / i1));
		} else {
			entityRenderer.renderWorld(renderTime, 0L);
		}
	} catch (Exception e) {
		try {
			//Clean up the tessellator, just in case.
			Tessellator.instance.draw();
		} catch (Exception e2) {
			//It might throw an exception, but that just means we didn't need to clean it up (this time)
		}
		throw new RuntimeException("Error while rendering proxy world", e);
	} finally {
		GL11.glEnable(GL11.GL_TEXTURE_2D);
		EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, 0);

		GL11.glViewport(0, 0, widthBackup, heightBackup);
		GL11.glLoadIdentity();

		mc.gameSettings.thirdPersonView = thirdPersonBackup;
		mc.gameSettings.hideGUI = hideGuiBackup;
		mc.gameSettings.particleSetting = particleBackup;
		mc.gameSettings.anaglyph = anaglyphBackup;
		mc.gameSettings.renderDistanceChunks = renderDistanceBackup;
		mc.gameSettings.fovSetting = FOVbackup;

		mc.displayHeight = heightBackup;
		mc.displayWidth = widthBackup;
	}
}
 
Example 19
Source File: Renderer.java    From AnyaBasic with MIT License 4 votes vote down vote up
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 20
Source File: StenciledTextureRenderer.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public void render(RenderGlobal context, float partialTickTime) {
	GL11.glMatrixMode(GL11.GL_PROJECTION);
	GL11.glPushMatrix();
	GL11.glLoadIdentity();

	GL11.glMatrixMode(GL11.GL_MODELVIEW);
	GL11.glPushMatrix();
	GL11.glLoadIdentity();

	GL11.glOrtho(-1, +1, -1, +1, -1, +1);

	GL11.glEnable(GL11.GL_STENCIL_TEST);
	GL11.glStencilMask(stencilMask);
	GL11.glStencilOp(GL11.GL_KEEP, GL11.GL_KEEP, GL11.GL_KEEP);
	GL11.glStencilFunc(GL11.GL_EQUAL, stencilMask, stencilMask);

	TextureUtils.bindTextureToClient(texture);

	RenderUtils.disableLightmap();
	GlStateManager.disableLighting();

	GlStateManager.color(1, 1, 1);

	GL11.glBegin(GL11.GL_QUADS);
	GL11.glTexCoord2f(0, 0);
	GL11.glVertex3f(-1, -1, 0);

	GL11.glTexCoord2f(1, 0);
	GL11.glVertex3f(+1, -1, 0);

	GL11.glTexCoord2f(1, 1);
	GL11.glVertex3f(+1, +1, 0);

	GL11.glTexCoord2f(0, 1);
	GL11.glVertex3f(-1, +1, 0);

	GL11.glEnd();

	// mask should prevent this command from clearing other bits
	GL11.glClearStencil(0);
	GL11.glClear(GL11.GL_STENCIL_BUFFER_BIT);

	GL11.glDisable(GL11.GL_STENCIL_TEST);

	RenderUtils.enableLightmap();
	GlStateManager.enableLighting();

	GL11.glMatrixMode(GL11.GL_PROJECTION);
	GL11.glPopMatrix();

	GL11.glMatrixMode(GL11.GL_MODELVIEW);
	GL11.glPopMatrix();

}