0

私は現在、頂点配列と VBO の b/c を学習しています。現在、「即時」レンダリング (glBegin を使用するなど) よりも優れている/高速であることを学びましたが、それははるかに簡単です。ボタンを作成する小さなプログラム (実際には単なるテスト) を作成しました。ボタンにカーソルを合わせると色が変わりますが、起動するたびにプログラムがクラッシュし、次のエラー メッセージが表示されます。

A fatal error has been detected by the Java Runtime Environment:

EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000000006875c490, pid=5708, tid=7148

JRE version: 7.0_21-b11
Java VM: Java HotSpot(TM) 64-Bit Server VM (23.21-b01 mixed mode windows-amd64 compressed oops)
Problematic frame:
C  [atio6axx.dll+0x20c490]  DrvPresentBuffers+0x1cb680

Failed to write core dump. Minidumps are not enabled by default on client versions of   Windows

 An error report file with more information is saved as:
C:\Users\UserNameHere\Desktop\Java\workspace\LWJGL Tutorials\hs_err_pid5708.log

If you would like to submit a bug report, please visit:
http://bugreport.sun.com/bugreport/crash.jsp
The crash happened outside the Java Virtual Machine in native code.
See problematic frame for where to report the bug.

私のコード

package testandothertutorials;

import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL15.*;

import java.nio.FloatBuffer;

import org.lwjgl.BufferUtils;
import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;

public class VBOMenu {

int WIDTH = 640;
int HEIGHT = 480;
float button[] = {
        //Left bottom triangle
        30, 60, 0,
        30, 30, 0,
        60, 30, 0,
        //Right top triangle
        60, 30, 0,
        60, 60, 0,
        30, 60, 0
};

public VBOMenu() {
    try {
        Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
        Display.setTitle("Vertex Arrays Demo");
        Display.create();
    } catch(LWJGLException e) {
        Display.destroy();
    }

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0, 640, 480, 0, 1, -1);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    final int amountOfVertices = 4;
    final int colorSize = 4;
    final int vertexSize = 4;

    FloatBuffer firstVertexData = BufferUtils.createFloatBuffer(button.length);
    firstVertexData.put(button);
    firstVertexData.flip();

    FloatBuffer unselColorData = BufferUtils.createFloatBuffer(colorSize); //The color that will be set when the menu is launched
    unselColorData.put(new float[] {0, 1, 0});
    unselColorData.flip();

    FloatBuffer selColorData = BufferUtils.createFloatBuffer(colorSize); //The color that will be set when the mouse hovers over the button
    selColorData.put(new float[] {0, 2, 0});
    selColorData.flip();

    int firstVertexHandle = glGenBuffers();
    glBindBuffer(GL_ARRAY_BUFFER, firstVertexHandle);
    glBufferData(GL_ARRAY_BUFFER, firstVertexData, GL_STATIC_DRAW);
    glBindBuffer(GL_ARRAY_BUFFER, 0);

    int unselColorHandle = glGenBuffers();
    glBindBuffer(GL_ARRAY_BUFFER, unselColorHandle);
    glBufferData(GL_ARRAY_BUFFER, unselColorData, GL_STATIC_DRAW);
    glBindBuffer(GL_ARRAY_BUFFER, 0);

    int selColorHandle = glGenBuffers();
    glBindBuffer(GL_ARRAY_BUFFER, selColorHandle);
    glBufferData(GL_ARRAY_BUFFER, selColorData, GL_STATIC_DRAW);
    glBindBuffer(GL_ARRAY_BUFFER, 0);


    boolean isRunning = true;

    while(isRunning) {
        glClear(GL_COLOR_BUFFER_BIT);

        glBindBuffer(GL_ARRAY_BUFFER, firstVertexHandle);
        glVertexPointer(vertexSize, GL_FLOAT, 0, 0l);

        glEnableClientState(GL_VERTEX_ARRAY);
        glEnableClientState(GL_COLOR_ARRAY);
        glDrawArrays(GL_TRIANGLES, 0, amountOfVertices);
        glDisableClientState(GL_COLOR_ARRAY);
        glDisableClientState(GL_VERTEX_ARRAY);

        Display.update();
        Display.sync(60);

        if(Display.isCloseRequested())
            isRunning = false;
    }

    glDeleteBuffers(firstVertexHandle);

    Display.destroy();
}

public static void main(String[] args) {
    new VBOMenu();
}

}

4

1 に答える 1