當前位置: 首頁>>代碼示例>>Java>>正文


Java GL.glShadeModel方法代碼示例

本文整理匯總了Java中javax.media.opengl.GL.glShadeModel方法的典型用法代碼示例。如果您正苦於以下問題:Java GL.glShadeModel方法的具體用法?Java GL.glShadeModel怎麽用?Java GL.glShadeModel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.media.opengl.GL的用法示例。


在下文中一共展示了GL.glShadeModel方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: renderWaypoints

import javax.media.opengl.GL; //導入方法依賴的package包/類
/**
 * Render all waypoints (the circles in the map), data generated in createWaypointsList
 * @param gl
 * @param triangles
 */
private synchronized void renderWaypoints(GL gl, List<BlendTriangle> triangles) {
    GlColor color = new GlColor(new Color(NbPreferences.forModule(TimelinePanel.class).getInt(TimelinePanel.MapColor.WAYPOINTS_COLOR_KEY.getPrefKey(), TimelinePanel.MapColor.WAYPOINTS_COLOR_KEY.getDegaultARGB())));

    gl.glEnable(GL.GL_COLOR_MATERIAL);
    gl.glShadeModel(GL.GL_SMOOTH);

    gl.glBegin(GL.GL_TRIANGLES);
    for (BlendTriangle triangle : triangles) {
        for (BlendVertex v : triangle.getVerts()) {
            // take color according to width
            gl.glColor4d(color.r, color.g, color.b, color.a);
            gl.glVertex3d(v.getLocation().x, v.getLocation().y, v.getLocation().z + 0.1);
        }
    }
    gl.glEnd();
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:22,代碼來源:MapRenderer.java

示例2: renderPaths

import javax.media.opengl.GL; //導入方法依賴的package包/類
/**
 * Render triangles stored in pathTriangles with info from settings
 * @param gl
 */
private synchronized void renderPaths(GL gl, List<PathTriangle> triangles) {
    // Get colors from preferences
    GlColor lowColor = new GlColor(new Color(NbPreferences.forModule(TimelinePanel.class).getInt(TimelinePanel.MapColor.LOW_COLOR_KEY.getPrefKey(), TimelinePanel.MapColor.LOW_COLOR_KEY.getDegaultARGB())));
    GlColor highColor = new GlColor(new Color(NbPreferences.forModule(TimelinePanel.class).getInt(TimelinePanel.MapColor.HIGH_COLOR_KEY.getPrefKey(), TimelinePanel.MapColor.HIGH_COLOR_KEY.getDegaultARGB())));

    boolean includeFlagBehavior = NbPreferences.forModule(TimelinePanel.class).getBoolean(TimelinePanel.INCLUDE_FLAG_KEY, true);

    double deltaZ = this.map.getBox().getDeltaZ();
    double displaceZ = this.map.getBox().minZ;

    gl.glEnable(GL.GL_COLOR_MATERIAL);
    gl.glShadeModel(GL.GL_SMOOTH);

    gl.glBegin(GL.GL_TRIANGLES);
    for (PathTriangle triangle : triangles) {
        boolean render = false;
        if (includeFlagBehavior) {
            render = includeCanRenderPathFlag(triangle.getFlags());
        } else {
            render = excludeCanRenderFlag(triangle.getFlags());
        }
        
        if (render) {
            for (BlendVertex v : triangle.getVerts()) {
                Location vertexLoc = v.getLocation();
                GlColor color = lowColor.getMixedWith(highColor, (vertexLoc.z - displaceZ) / deltaZ);

                gl.glColor4d(color.r, color.g, color.b, color.a);
                gl.glVertex3d(vertexLoc.x, vertexLoc.y, vertexLoc.z);
            }
        }
    }
    gl.glEnd();
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:39,代碼來源:MapRenderer.java

示例3: init

import javax.media.opengl.GL; //導入方法依賴的package包/類
@Override
    public synchronized void init(GLAutoDrawable glDrawable) {
        GL gl = glDrawable.getGL();

        gl.glMatrixMode(GL.GL_PROJECTION);
        gl.glLoadIdentity();
        gl.glMatrixMode(GL.GL_MODELVIEW);
        gl.glLoadIdentity();

        gl.glEnable(GL.GL_DEPTH_TEST);
        gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);

        gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
        gl.glClearDepth(1.0);
        gl.glShadeModel(GL.GL_SMOOTH); // try setting this to GL_FLAT and see what happens.

/*        float[] lightAmbient = new float[]{0.5f, 0.5f, 0.5f, 1.0f};
        float[] lightDiffuse = new float[]{1.0f, 1.0f, 1.0f, 1.0f};
        float[] lightPosition = new float[]{
            0, 0, 0,
            //            (float)levelBox.getFlag().getCenterX(),
            //          (float)levelBox.getFlag().getCenterY(),
            //        (float)levelBox.getFlag().getCenterZ() + (float)levelBox.getFlag().getDeltaZ(),
            1.0f};
        gl.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, FloatBuffer.wrap(lightAmbient));
        gl.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, FloatBuffer.wrap(lightDiffuse));
        gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, FloatBuffer.wrap(lightPosition));
        gl.glEnable(GL.GL_LIGHT0);
  */
        gl.glDisable(GL.GL_LIGHTING);

        // Now preprocess our data for rendering
        agentRenderes.prepare(gl);
        mapRenderer.prepare(gl);
    }
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:36,代碼來源:EnvironmentRenderer.java

示例4: render

import javax.media.opengl.GL; //導入方法依賴的package包/類
@Override
public synchronized void render(GL gl) {
    /*
     * After a while it seems that using lighting and blending produces worse results
     * than this, at least in lucidity.
     *
    float[] lightAmbient = new float[]{0.5f, 0.5f, 0.5f, 1.0f};
    float[] lightDiffuse = new float[]{1.0f, 1.0f, 1.0f, 1.0f};
    float[] lightPosition = new float[]{
    0, 0, 1210,//0, 0, 0,
    //            (float)levelBox.getFlag().getCenterX(),
    //          (float)levelBox.getFlag().getCenterY(),
    //        (float)levelBox.getFlag().getCenterZ() + (float)levelBox.getFlag().getDeltaZ(),
    1.0f};
    gl.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, FloatBuffer.wrap(lightAmbient));
    gl.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, FloatBuffer.wrap(lightDiffuse));
    gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, FloatBuffer.wrap(lightPosition));
    gl.glEnable(GL.GL_LIGHT0);

    gl.glLightfv(GL.GL_LIGHT0, GL.GL_SPOT_DIRECTION, new float[]{0, 0, 1}, 0);
     */

    
    if (updateLists || ! gl.glIsList(waypointDisplayList) || !gl.glIsList(pathDisplayList)) {
        updateMapDisplayLists(gl);
        updateLists = false;
    }

    gl.glLoadName(glName);

    // Rendering like this is too CPU intensive, so using display lists
    // renderPaths(gl, pathTris);
    // renderWaypoints(gl, waypointsTris);


    // render grid and background
    gl.glShadeModel(GL.GL_FLAT);
    gl.glCallList(gridList);
    gl.glCallList(backgroundList);
    gl.glCallList(pathDisplayList);
    gl.glCallList(waypointDisplayList);

    gl.glLoadName(-1);
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:45,代碼來源:MapRenderer.java


注:本文中的javax.media.opengl.GL.glShadeModel方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。