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


Java GL4.glGenerateMipmap方法代码示例

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


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

示例1: initTextureMaps

import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private boolean initTextureMaps(GL4 gl4) {

        try {
            BufferedImage bufferedImage = ImageIO.read(new File(TEXTURE_PATH));
            byte[] dataBytes = ((DataBufferByte) bufferedImage.getRaster().getDataBuffer()).getData();
            ByteBuffer bufferedImageBuffer = GLBuffers.newDirectByteBuffer(dataBytes);

            gl4.glGenTextures(1, textureName);
            gl4.glActiveTexture(GL_TEXTURE0);
            gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(0));

            gl4.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, bufferedImage.getWidth(), bufferedImage.getHeight(), 0,
                    GL_RGB, GL_UNSIGNED_BYTE, bufferedImageBuffer);

            gl4.glGenerateMipmap(GL_TEXTURE_2D);

            gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
            gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
            gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
            gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

            FloatBuffer maxAnis = GLBuffers.newDirectFloatBuffer(1);
            gl4.glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, maxAnis);
            gl4.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, maxAnis.get(0));

            gl4.glBindTexture(GL_TEXTURE_2D, 0);

            BufferUtils.destroyDirectBuffer(maxAnis);
            BufferUtils.destroyDirectBuffer(bufferedImageBuffer);

        } catch (IOException ex) {
            Logger.getLogger(Application.class.getName()).log(Level.SEVERE, null, ex);
        }
        return true;
    }
 
开发者ID:java-opengl-labs,项目名称:jogl-hello-vr,代码行数:36,代码来源:Scene.java

示例2: initTexture

import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private void initTexture(GL4 gl4, RenderModel_TextureMap_t diffuseTexture) {

        // create and populate the texture
        gl4.glGenTextures(1, textureName);
        gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(0));

        ByteBuffer buffer = GLBuffers.newDirectByteBuffer(diffuseTexture.dataSize());
        byte[] data = diffuseTexture.rubTextureMapData.getByteArray(0, diffuseTexture.dataSize());

        IntStreamEx.range(diffuseTexture.dataSize()).forEach(i -> buffer.put(i, data[i]));

        gl4.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, diffuseTexture.unWidth, diffuseTexture.unHeight,
                0, GL_RGBA, GL_UNSIGNED_BYTE, buffer);

        // If this renders black ask McJohn what's wrong.
        gl4.glGenerateMipmap(GL_TEXTURE_2D);

        gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
        gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
        gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
        gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);

        FloatBuffer largest = GLBuffers.newDirectFloatBuffer(1);
        gl4.glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, largest);
        gl4.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, largest.get(0));

        gl4.glBindTexture(GL_TEXTURE_2D, 0);

        BufferUtils.destroyDirectBuffer(buffer);
        BufferUtils.destroyDirectBuffer(largest);
    }
 
开发者ID:java-opengl-labs,项目名称:jogl-hello-vr,代码行数:32,代码来源:Model.java

示例3: initTexture

import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private boolean initTexture(GL4 gl4) {

        try {
            jgli.Texture2d texture = new Texture2d(jgli.Load.load(TEXTURE_ROOT + "/" + TEXTURE_DIFFUSE));

            gl4.glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

            gl4.glGenTextures(1, textureName);

            gl4.glActiveTexture(GL_TEXTURE0);
            gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(0));
            gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
            gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, texture.levels() - 1);
            gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
            gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
            gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
            gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

            jgli.Gl.Format format = jgli.Gl.translate(texture.format());
            for (int level = 0; level < texture.levels(); ++level) {
                gl4.glTexImage2D(GL_TEXTURE_2D, level,
                        format.internal.value,
                        texture.dimensions(level)[0], texture.dimensions(level)[1],
                        0,
                        format.external.value, format.type.value,
                        texture.data(level));
            }

            gl4.glGenerateMipmap(GL_TEXTURE_2D);

            gl4.glPixelStorei(GL_UNPACK_ALIGNMENT, 4);

        } catch (IOException ex) {
            Logger.getLogger(Gl_410_glsl_block.class.getName()).log(Level.SEVERE, null, ex);
        }
        return checkError(gl4, "initTexture");
    }
 
开发者ID:java-opengl-labs,项目名称:jogl-samples,代码行数:38,代码来源:Gl_410_glsl_block.java

示例4: initTexture

import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private boolean initTexture(GL4 gl4) {

        jgli.Texture2d texture = new Texture2d(jgli.Format.FORMAT_RGBA8_UNORM_PACK8, new int[]{64, 64});
        jgli.Gl.Format format = jgli.Gl.translate(texture.format());

        texture.clear(0, 0, 0, new byte[]{(byte) 255, (byte) 0, (byte) 0, (byte) 255});
        texture.clear(0, 0, 1, new byte[]{(byte) 255, (byte) 128, (byte) 0, (byte) 255});
        texture.clear(0, 0, 2, new byte[]{(byte) 255, (byte) 255, (byte) 0, (byte) 255});
        texture.clear(0, 0, 3, new byte[]{(byte) 0, (byte) 255, (byte) 0, (byte) 255});
        texture.clear(0, 0, 4, new byte[]{(byte) 0, (byte) 255, (byte) 255, (byte) 255});
        texture.clear(0, 0, 5, new byte[]{(byte) 0, (byte) 0, (byte) 255, (byte) 255});
        texture.clear(0, 0, 6, new byte[]{(byte) 255, (byte) 0, (byte) 0, (byte) 255});

        gl4.glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

        gl4.glGenTextures(1, textureName);
        gl4.glActiveTexture(GL_TEXTURE0);
        gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(0));
        gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
        gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, texture.levels() - 1);
        gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR);
        gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
        gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
        gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
        gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_RED);
        gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, GL_GREEN);
        gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_BLUE);
        gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_ALPHA);
        gl4.glTexStorage2D(GL_TEXTURE_2D, texture.levels(),
                format.internal.value, texture.dimensions()[0], texture.dimensions()[1]);

        for (int level = 0; level < texture.levels(); ++level) {
            gl4.glTexSubImage2D(GL_TEXTURE_2D, level,
                    0, 0,
                    texture.dimensions(level)[0], texture.dimensions(level)[1],
                    format.external.value, format.type.value,
                    texture.data(level));
        }

        if (texture.levels() == 1) {
            gl4.glGenerateMipmap(GL_TEXTURE_2D);
        }

        gl4.glPixelStorei(GL_UNPACK_ALIGNMENT, 4);

        return true;
    }
 
开发者ID:java-opengl-labs,项目名称:jogl-samples,代码行数:48,代码来源:Gl_450_texture_derivative.java

示例5: initTexture

import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private boolean initTexture(GL4 gl4) {

        try {
            jgli.Texture2d texture = new Texture2d(jgli.Load.load(TEXTURE_ROOT + "/" + TEXTURE_DIFFUSE));
            assert (!texture.empty());
            jgli.Gl.Format format = jgli.Gl.translate(texture.format());

            gl4.glGenTextures(Texture.MAX, textureName);

            gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.DIFFUSE));
            gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 4);
            gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, texture.levels() - 1);
            gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
            gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
            gl4.glTexStorage2D(GL_TEXTURE_2D, texture.levels(), format.internal.value,
                    texture.dimensions(0)[0], texture.dimensions(0)[1]);

            for (int level = 0; level < texture.levels(); ++level) {
                gl4.glTexSubImage2D(GL_TEXTURE_2D, level,
                        0, 0,
                        texture.dimensions(level)[0], texture.dimensions(level)[1],
                        format.external.value, format.type.value,
                        texture.data(level));
            }

            if (texture.levels() == 1) {
                gl4.glGenerateMipmap(GL_TEXTURE_2D);
            }

            gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.COLORBUFFER));
            gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
            gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
            gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
            gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
            gl4.glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, (int) (windowSize.x * FRAMEBUFFER_SCALE),
                    (int) (windowSize.y * FRAMEBUFFER_SCALE));

        } catch (IOException ex) {
            Logger.getLogger(Gl_420_sampler_fetch.class.getName()).log(Level.SEVERE, null, ex);
        }
        return true;
    }
 
开发者ID:java-opengl-labs,项目名称:jogl-samples,代码行数:43,代码来源:Gl_420_sampler_fetch.java


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