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

The following examples show how to use org.lwjgl.opengl.GL11#glPolygonMode() . 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: SelectionDelegate.java    From tribaltrouble with GNU General Public License v2.0 6 votes vote down vote up
public final void render2D() {
	if (selection) {
		GL11.glColor3f(.3f, 1f, 0f);
		GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_LINE);
		GL11.glPolygonMode(GL11.GL_BACK, GL11.GL_LINE);
		GL11.glDisable(GL11.GL_CULL_FACE);
		GL11.glDisable(GL11.GL_TEXTURE_2D);
		GL11.glBegin(GL11.GL_QUADS);
			GL11.glVertex3f(selection_x1, selection_y1, 0f);
			GL11.glVertex3f(selection_x2, selection_y1, 0f);
			GL11.glVertex3f(selection_x2, selection_y2, 0f);
			GL11.glVertex3f(selection_x1, selection_y2, 0f);
		GL11.glEnd();
		GL11.glEnable(GL11.GL_TEXTURE_2D);
		GL11.glEnable(GL11.GL_CULL_FACE);
		GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_FILL);
		GL11.glPolygonMode(GL11.GL_BACK, GL11.GL_FILL);
	}
}
 
Example 2
Source File: DebugRender.java    From tribaltrouble with GNU General Public License v2.0 6 votes vote down vote up
public final static void drawQuad(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, float z, float r, float g, float b) {
	GL11.glDisable(GL11.GL_TEXTURE_2D);
	GL11.glColor3f(r, g, b);
	GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_LINE);
	GL11.glPolygonMode(GL11.GL_BACK, GL11.GL_LINE);
	GL11.glDisable(GL11.GL_CULL_FACE);
	GL11.glBegin(GL11.GL_QUADS);
		GL11.glVertex3f(x1, y1, z);
		GL11.glVertex3f(x2, y2, z);
		GL11.glVertex3f(x3, y3, z);
		GL11.glVertex3f(x4, y4, z);
	GL11.glEnd();
	GL11.glEnable(GL11.GL_CULL_FACE);
	GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_FILL);
	GL11.glPolygonMode(GL11.GL_BACK, GL11.GL_FILL);
	GL11.glEnable(GL11.GL_TEXTURE_2D);
}
 
Example 3
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 4
Source File: Model.java    From pycode-minecraft with MIT License 4 votes vote down vote up
public void genList() {
        this.glList = GL11.glGenLists(1);
        GL11.glNewList(this.glList, GL11.GL_COMPILE);
//        if use_texture: glEnable(GL_TEXTURE_2D)
        GL11.glFrontFace(GL11.GL_CCW);
        GL11.glEnable(GL11.GL_CULL_FACE);

        GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_FILL);
        GL11.glDepthFunc(GL11.GL_LESS);
        GL11.glCullFace(GL11.GL_BACK);
        String currentMaterial = "";
        Material mtl;
        for (Face face : this.faces) {
            if (!face.material.equals(currentMaterial)) {
                currentMaterial = face.material;
                mtl = this.materials.get(face.material);
                if (mtl == null) {
                    GL11.glColor3f(1, 1, 1);
                } else {
//                    if 'texture_Kd' in mtl:
//                    # use diffuse texmap
//                    glBindTexture(GL_TEXTURE_2D, mtl['texture_Kd'])
                    GL11.glColor3f(mtl.diffuse.x, mtl.diffuse.y, mtl.diffuse.z);
                }
            }

            GL11.glBegin(GL11.GL_POLYGON);
            for (int i = 0; i < face.vertexes.size(); i++) {
                if (face.normals.get(i) != 0) {
                    Vector3f n = this.normals.get(face.normals.get(i));
                    GL11.glNormal3f(n.x, n.y, n.z);
                }
//                if texture_coords[i]:
//                    glTexCoord2fv(self.texcoords[texture_coords[i] - 1])
                Vector3f v = this.vertices.get(face.vertexes.get(i));
                GL11.glVertex3f(v.x, v.y, v.z);
            }
            GL11.glEnd();
        }

        GL11.glCullFace(GL11.GL_BACK);
        GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_FILL);

        GL11.glDisable(GL11.GL_CULL_FACE);

//      if use_texture: glDisable(GL11.GL_TEXTURE_2D);
        GL11.glEndList();
    }
 
Example 5
Source File: GlUtils.java    From Mundus with Apache License 2.0 4 votes vote down vote up
public static void polygonModeFill() {
    GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
}
 
Example 6
Source File: GlUtils.java    From Mundus with Apache License 2.0 4 votes vote down vote up
public static void polygonModeWireframe() {
    GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
}
 
Example 7
Source File: DefaultRenderer.java    From tribaltrouble with GNU General Public License v2.0 4 votes vote down vote up
public void render(AmbientAudio ambient, CameraState frustum_state, GUIRoot gui_root) {
		ambient.updateSoundListener(frustum_state, world.getHeightMap());
		if (Globals.line_mode || cheat.line_mode) {
			GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_LINE);
			GL11.glPolygonMode(GL11.GL_BACK, GL11.GL_LINE);
		}

		GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, light_array);
		if (Globals.draw_sky) {
			sky.render();
		}

		fog_info.enableFog(frustum_state.getCurrentZ());
		if (Globals.draw_sky) {
			sky.renderSeaBottom();
		}

		// render landscape (must be before trees and misc, cause they use data calculated here)
		if (Globals.process_landscape) {
			landscape_renderer.prepareAll(frustum_state, false);
			landscape_renderer.renderAll();
		}
		// frustum check and placement
		if (Globals.process_trees) {
			tree_renderer.setup(frustum_state);
			world.getTreeRoot().visit(tree_renderer);
		}
		if (Globals.process_misc) {
			element_renderer.setup(frustum_state);
			world.getElementRoot().visit(element_renderer);
		}
		
		// Sort sprites
		sprite_sorter.distributeModels();
		
		// render shadows
		if (Globals.process_shadows) {
			render_queues.renderShadows(landscape_renderer);
		}

		gui_root.getDelegate().render3D(landscape_renderer, render_queues);
		
		// render
		if (Globals.process_trees) {
			tree_renderer.renderAll();
		}
		if (Globals.process_misc) {
			render_queues.renderAll();
		}

		drawAxes();

		if (Globals.draw_water)
			water.render(sky);

		if (Globals.process_misc) 
			render_queues.renderBlends();

		LightningRenderer.render(render_queues, element_renderer.getRenderState().getLightningQueue(), frustum_state);
		EmitterRenderer.render(render_queues, element_renderer.getRenderState().getEmitterQueue(), frustum_state);
		renderRallyPoint(frustum_state);

/*		float landscape_x = GUIRoot.getGUIRoot().getLandscapeLocationX();
		float landscape_y = GUIRoot.getGUIRoot().getLandscapeLocationY();
		if (Globals.isBoundsEnabled(Globals.BOUNDING_REGIONS)) {
			UnitGrid.getGrid().debugRenderRegions(landscape_x, landscape_y);
		}
*/
		if (Globals.isBoundsEnabled(Globals.BOUNDING_OCCUPATION)) {
			picker.debugRender();
		}

/*		if (Globals.isBoundsEnabled(Globals.BOUNDING_UNIT_GRID)) {
			java.util.Iterator it = com.oddlabs.tt.model.SelectionArmy.getSelection().getSet().iterator();
			while (it.hasNext()) {
				Object next = it.next();
				if (next instanceof com.oddlabs.tt.model.Unit) {
					com.oddlabs.tt.model.Unit s_unit = (com.oddlabs.tt.model.Unit)next;
					s_unit.debugRender();
				}
			}
//			UnitGrid.getGrid().debugRender(landscape_x, landscape_y);
		}*/
		fog_info.disableFog();
		if (Globals.line_mode || (cheat.line_mode)) {
			GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_FILL);
			GL11.glPolygonMode(GL11.GL_BACK, GL11.GL_FILL);
		}
	}