Example usage for org.lwjgl.opengl GL11 GL_NO_ERROR

List of usage examples for org.lwjgl.opengl GL11 GL_NO_ERROR

Introduction

In this page you can find the example usage for org.lwjgl.opengl GL11 GL_NO_ERROR.

Prototype

int GL_NO_ERROR

To view the source code for org.lwjgl.opengl GL11 GL_NO_ERROR.

Click Source Link

Document

ErrorCode

Usage

From source file:de.ikosa.mars.viewer.glviewer.engine.GLHardcodedShader.java

License:Open Source License

private static void validateCompilation(int shaderId) {
    int compileStatus = GL20.glGetShaderi(shaderId, GL20.GL_COMPILE_STATUS);
    int error = GL11.glGetError();

    if (error != GL11.GL_NO_ERROR) {
        ML.f(String.format("Error getting compilation status: 0x%x", error));
    } else if (compileStatus == GL11.GL_FALSE) {
        int logLength = GL20.glGetShaderi(shaderId, GL20.GL_INFO_LOG_LENGTH);
        String log = GL20.glGetShaderInfoLog(shaderId, logLength);
        ML.f(String.format("Error compiling shader: %s", log));
    }// w w  w.j  av a2s  .c o  m
}

From source file:de.ikosa.mars.viewer.glviewer.engine.GLHardcodedShader.java

License:Open Source License

private static void validateLinkage(int programId) {
    int linkStatus = GL20.glGetProgrami(programId, GL20.GL_LINK_STATUS);
    int error = GL11.glGetError();

    if (error != GL11.GL_NO_ERROR) {
        ML.f(String.format("Error getting link status: 0x%x", error));
    } else if (linkStatus == GL11.GL_FALSE) {
        int logLength = GL20.glGetProgrami(programId, GL20.GL_INFO_LOG_LENGTH);
        String log = GL20.glGetProgramInfoLog(programId, logLength);
        ML.f(String.format("Error linking program: %s", log));
    }//from w  w w .  j  av a2 s . c o m
}

From source file:de.ikosa.mars.viewer.glviewer.engine.GLRenderer2Stage.java

License:Open Source License

public static void errorCheck(String message) {
    int error = GL11.glGetError();
    if (error != GL11.GL_NO_ERROR)
        ML.f(String.format("OpenGL Error while %s. (0x%04x)", message, error));
}

From source file:de.ikosa.mars.viewer.glviewer.engine.GLShaderBuilder.java

License:Open Source License

private void validateCompilation(int shaderId) {
    int compileStatus = GL20.glGetShaderi(shaderId, GL20.GL_COMPILE_STATUS);
    int error = GL11.glGetError();

    if (error != GL11.GL_NO_ERROR) {
        ML.f(String.format("Error getting compilation status: 0x%x", error));
    } else if (compileStatus == GL11.GL_FALSE) {
        int logLength = GL20.glGetShaderi(shaderId, GL20.GL_INFO_LOG_LENGTH);
        String log = GL20.glGetShaderInfoLog(shaderId, logLength);
        ML.f(String.format("Error compiling shader: %s", log));
    }//from   w  ww.ja  va  2 s .com
}

From source file:de.ikosa.mars.viewer.glviewer.engine.GLShaderBuilder.java

License:Open Source License

private void validateLinkage(int programId) {
    int linkStatus = GL20.glGetProgrami(programId, GL20.GL_LINK_STATUS);
    int error = GL11.glGetError();

    if (error != GL11.GL_NO_ERROR) {
        ML.f(String.format("Error getting link status: 0x%x", error));
    } else if (linkStatus == GL11.GL_FALSE) {
        int logLength = GL20.glGetProgrami(programId, GL20.GL_INFO_LOG_LENGTH);
        String log = GL20.glGetProgramInfoLog(programId, logLength);
        ML.f(String.format("Error linking program: %s", log));
    }//from   ww  w .  ja v a2  s . com
}

From source file:de.ikosa.mars.viewer.glviewer.engine.GLTexture.java

License:Open Source License

public float[][] toHeightMap(int samplesX, int samplesY) {
    float[][] height = new float[samplesX][samplesY];

    ML.d(String.format("Loading texture for height map \"%s\"...", getName()));

    // check size
    int texSizeX = getSizeX();
    int texSizeY = getSizeY();
    if (texSizeX != samplesX | texSizeY != samplesY)
        ML.f(String.format("Texture size doesn't match height map size! (%d x %d) vs. (%d x %d)", texSizeX,
                texSizeY, samplesX, samplesY));

    // create buffer
    ShortBuffer byteBuffer = BufferUtils.createShortBuffer(texSizeX * texSizeY);

    // and go// w w w  .ja  va2s  . c om
    GL11.glGetTexImage(GL11.GL_TEXTURE_2D, 0, GL11.GL_RED, GL11.GL_UNSIGNED_SHORT, byteBuffer);

    int error = GL11.glGetError();
    if (error != GL11.GL_NO_ERROR)
        ML.f(String.format("Cannot load height map from texture (GL error %x)", error));

    // read samples
    for (int x = 0; x < texSizeX; x++)
        for (int y = 0; y < texSizeY; y++) {
            short sValue = byteBuffer.get((samplesX * y + x));

            int value = fromShort(sValue);
            height[x][y] = value / 65535.0f;
        }

    return height;
}

From source file:de.ikosa.mars.viewer.glviewer.engine.GLTexture.java

License:Open Source License

public TerrainType[][] toTerrainMap(int samplesX, int samplesY) {
    TerrainType[][] height = new TerrainType[samplesX][samplesY];

    ML.d(String.format("Loading texture for terrain map \"%s\"...", getName()));

    // check size
    int texSizeX = getSizeX();
    int texSizeY = getSizeY();
    if (texSizeX != samplesX | texSizeY != samplesY)
        ML.f(String.format("Texture size doesn't match terrain map size! (%d x %d) vs. (%d x %d)", texSizeX,
                texSizeY, samplesX, samplesY));

    // create buffer
    ByteBuffer byteBuffer = BufferUtils.createByteBuffer(texSizeX * texSizeY * 4);

    // and go//from w  ww  . j  ava  2 s .  c o  m
    GL11.glGetTexImage(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, byteBuffer);

    int error = GL11.glGetError();
    if (error != GL11.GL_NO_ERROR)
        ML.f(String.format("Cannot load terrain map from texture (GL error %x)", error));

    // read samples
    for (int x = 0; x < texSizeX; x++)
        for (int y = 0; y < texSizeY; y++) {
            float r = fromByte(byteBuffer.get(4 * (samplesX * y + x))) / 255.0f;
            float g = fromByte(byteBuffer.get(4 * (samplesX * y + x) + 1)) / 255.0f;
            float b = fromByte(byteBuffer.get(4 * (samplesX * y + x) + 2)) / 255.0f;
            height[x][y] = TerrainType.fromColor(r, g, b);
        }

    return height;
}

From source file:engine.render.TexturedQuad.java

private void exitOnGLError(String errorMessage) {
    int errorValue = GL11.glGetError();
    System.err.println("GL error code: " + errorValue);
    if (errorValue != GL11.GL_NO_ERROR) {
        String errorString = GLU.gluErrorString(errorValue);
        System.err.println("ERROR - " + errorMessage + ": " + errorString);

        if (Display.isCreated()) {
            Display.destroy();//from   w w w .  ja v a  2 s  .  c o m
        }
        System.exit(-1);
    }
}

From source file:fr.guillaume.prive.viper.core.graphic.GraphicMotor.java

public static void exitOnGLError(String errorMessage) {
    int errorValue = GL11.glGetError();
    if (errorValue != GL11.GL_NO_ERROR) {
        String errorString = GLU.gluErrorString(errorValue);
        System.err.println("ERROR - " + errorMessage + ": " + errorString);
        if (Display.isCreated())
            Display.destroy();//from   w  w w  . j a  va2s  . c  o  m
        {
            System.exit(-1);
        }
    }
}

From source file:jpcsp.graphics.RE.RenderingEngineLwjgl.java

License:Open Source License

@Override
public boolean checkAndLogErrors(String logComment) {
    boolean hasError = false;
    while (true) {
        int error;
        try {//from  ww  w.j a va2 s.c  o  m
            error = GL11.glGetError();
        } catch (NullPointerException e) {
            // Ignore Exception
            error = GL11.GL_NO_ERROR;
        }

        if (error == GL11.GL_NO_ERROR) {
            break;
        }

        hasError = true;
        if (logComment != null) {
            String errorComment;
            switch (error) {
            case GL11.GL_INVALID_ENUM:
                errorComment = "GL_INVALID_ENUM";
                break;
            case GL11.GL_INVALID_OPERATION:
                errorComment = "GL_INVALID_OPERATION";
                break;
            case GL11.GL_INVALID_VALUE:
                errorComment = "GL_INVALID_VALUE";
                break;
            default:
                errorComment = String.format("0x%X", error);
                break;
            }

            // Build a stack trace and exclude uninteresting RE stack elements:
            // - exclude this method (first stack trace element)
            // - exclude method checkAndLogErrors
            // - exclude methods from class BaseRenderingEngineProxy
            StackTraceElement[] stackTrace = new Throwable().getStackTrace();
            StringBuilder stackTraceLog = new StringBuilder();
            int count = 0;
            for (int i = 1; i < stackTrace.length && count < 6; i++) {
                String className = stackTrace[i].getClassName();
                if (!BaseRenderingEngineProxy.class.getName().equals(className)
                        && !CheckErrorsProxy.class.getName().equals(className)) {
                    stackTraceLog.append(stackTrace[i]);
                    stackTraceLog.append("\n");
                    count++;
                }
            }

            log.error(String.format("Error %s: %s\n%s", logComment, errorComment, stackTraceLog.toString()));
        }
    }

    return hasError;
}