当前位置: 首页>>代码示例>>Java>>正文


Java GL2.glTexCoord2f方法代码示例

本文整理汇总了Java中com.jogamp.opengl.GL2.glTexCoord2f方法的典型用法代码示例。如果您正苦于以下问题:Java GL2.glTexCoord2f方法的具体用法?Java GL2.glTexCoord2f怎么用?Java GL2.glTexCoord2f使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.jogamp.opengl.GL2的用法示例。


在下文中一共展示了GL2.glTexCoord2f方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: render

import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
protected void render(GL2 gl, int canvaswidth, int canvasheight) {
    gl.glClear(GL.GL_COLOR_BUFFER_BIT);

    gl.glLoadIdentity();

    // Draw a quad textured with the map image.
    float textureHeight = mapTexture.getHeight();
    float textureWidth = mapTexture.getWidth();
    float aspect = textureHeight / textureWidth;
    float height = canvasheight;
    float width = height / aspect;

    gl.glBindTexture(GL_TEXTURE_2D, textureName.get(0));
    gl.glEnable(GL.GL_TEXTURE_2D);
    gl.glColor3f(1, 1, 1);
    gl.glBegin(GL2.GL_POLYGON);
    gl.glTexCoord2f(0, 0);
    gl.glVertex2f(0, 0);
    gl.glTexCoord2f(1, 0);
    gl.glVertex2f(width, 0);
    gl.glTexCoord2f(1, 1);
    gl.glVertex2f(width, height);
    gl.glTexCoord2f(0, 1);
    gl.glVertex2f(0, height);
    gl.glEnd();
    gl.glBindTexture(GL_TEXTURE_2D, 0);

    // Draw river
    double elapsed = System.currentTimeMillis() - start_time;
    int current_frame_index = Math.min(data_points.length - 1,
            (int) (elapsed / ms_per_day));
    // We're going to interpolate in time between samples
    double tween = (elapsed - current_frame_index * ms_per_day) / ms_per_day;
    double depths[] = data_points[current_frame_index];
    double next_depths[] = data_points[Math.min(current_frame_index + 1, data_points.length - 1)];

    // The river's course
    int course[][] = {{298, 2}, {291, 7}, {284, 10}, {281, 17}, {278, 24}, {277, 33}, {275, 40}, {273, 48}, {270, 56}, {264, 62}, {258, 66}, {252, 70}, {246, 74}, {237, 75}, {228, 76}, {222, 81}, {217, 87}, {213, 93}, {209, 100}, {204, 105}, {198, 109}, {193, 114}, {189, 120}, {183, 127}, {178, 133}, {172, 137}, {165, 140}, {159, 145}, {154, 150}, {150, 157}, {148, 165}, {145, 173}, {141, 180}, {138, 188}, {134, 196}, {129, 202}, {125, 209}, {120, 216}, {114, 222}, {109, 227}, {102, 230}, {94, 233}, {87, 236}, {81, 240}, {74, 243}, {68, 247}, {61, 250}, {56, 255}, {52, 261}, {47, 267}, {41, 271}, {35, 276}, {28, 279}, {23, 284}, {19, 290}, {17, 299}, {16, 308}, {14, 317}, {8, 322}, {4, 328}, {5, 337}, {9, 343}, {9, 344}, {9, 345}, {9, 346}, {9, 347}, {9, 348}, {9, 349}, {9, 350}};

    gl.glLineWidth(20);
    gl.glBegin(GL2.GL_LINE_STRIP);
    for (int i = 0; i < course.length; ++i) {
        int station = (int) Math.floor(3 * (double) i / course.length);
        double shade = ((1 - tween) * depths[station] + tween * next_depths[station]) / 30;
        double redgreen = Math.max(0, 1.75 * shade - 1);
        double blue = shade * 2;
        gl.glColor3d(redgreen, redgreen, blue);
        gl.glVertex2d(width * (course[i][0]) / textureWidth,
                height * (course[i][1]) / textureHeight);
    }
    gl.glEnd();
}
 
开发者ID:hsswx7,项目名称:CS4500GroupProject,代码行数:53,代码来源:DrawMap.java


注:本文中的com.jogamp.opengl.GL2.glTexCoord2f方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。