标签: glcanvas

Java OpenGL 绘制纹理

我可以在 com.jogamp.opengl.awt.GLCanvas 上绘制一个纹理,但我想在 bufferedimage 更改时更新纹理。我写了这样的显示方法:

    public void display(GLAutoDrawable glAutoDrawable) {
        try {
            if (gl2 == null) {
                gl2 = glAutoDrawable.getGL().getGL2();  // get the OpenGL 2 graphics context
            }
            gl2.glClear(gl2.GL_COLOR_BUFFER_BIT | gl2.GL_DEPTH_BUFFER_BIT); // clear color and depth buffers
            gl2.glLoadIdentity();  // reset the model-view matrix


            if (image != null) {

                if (image != null) {
                    int[] pixels_raw = new int[this.camPanel.width * this.camPanel.height];
                    pixels_raw = image.getRGB(0, 0, this.camPanel.width, this.camPanel.height, null, 0, this.camPanel.width);

                    pixels.rewind();
                    for (int j = this.camPanel.height - 1; j >= 0; …
Run Code Online (Sandbox Code Playgroud)

java opengl jogl glcanvas

0
推荐指数
1
解决办法
166
查看次数

标签 统计

glcanvas ×1

java ×1

jogl ×1

opengl ×1