小编Dah*_*ahl的帖子

How do you specify a texture image with internal format RGBA2?

This is how I would think it should be done. Creating a red texture:

        int width = 64;
        int height = 64;
        int size = width * height;
        byte red = (byte) 0b11_00_00_11; // 2-bit per channel
        ByteBuffer buffer = MemoryUtil.memAlloc(size);
        for (int p = 0; p < size; p++) buffer.put(red);
        texture = glGenTextures();
        glBindTexture(GL_TEXTURE_2D, texture);
        glPixelStorei(GL_UNPACK_ALIGNMENT,1);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA2, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer.flip());
        MemoryUtil.memFree(buffer);
Run Code Online (Sandbox Code Playgroud)

and in the fragment shader:

// The …
Run Code Online (Sandbox Code Playgroud)

opengl lwjgl

3
推荐指数
1
解决办法
123
查看次数

标签 统计

lwjgl ×1

opengl ×1