Example usage for org.lwjgl.opengl GL11 glGetError

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

Introduction

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

Prototype

@NativeType("GLenum")
public static int glGetError() 

Source Link

Document

Returns error information.

Usage

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.GLShader.java

License:Open Source License

public GLShader(int programId, int vertexShaderId, int fragmentShaderId) {
    this.programId = programId;
    this.vertexShaderId = vertexShaderId;
    this.fragmentShaderId = fragmentShaderId;

    use();/*from  w w  w .j  ava  2  s .  c  om*/

    // save uniform positions
    ul_col_Ambient = GL20.glGetUniformLocation(programId, "col_Ambient");
    ul_col_Diffuse = GL20.glGetUniformLocation(programId, "col_Diffuse");
    ul_col_Specular = GL20.glGetUniformLocation(programId, "col_Specular");

    ul_val_SpecularCoefficient = GL20.glGetUniformLocation(programId, "val_SpecularCoefficient");

    ul_mat_Projection = GL20.glGetUniformLocation(programId, "mat_Projection");
    ul_mat_View = GL20.glGetUniformLocation(programId, "mat_View");
    ul_mat_Model = GL20.glGetUniformLocation(programId, "mat_Model");

    ul_mat_Normal = GL20.glGetUniformLocation(programId, "mat_Normal");

    ul_PixelSizeH = GL20.glGetUniformLocation(programId, "pixelSizeH");
    ul_PixelSizeV = GL20.glGetUniformLocation(programId, "pixelSizeV");

    ul_val_drawModifier = GL20.glGetUniformLocation(programId, "val_drawModifier");

    int texSlot = 0;

    int ul_tex_Diffuse = GL20.glGetUniformLocation(programId, "tex_Diffuse");
    if (ul_tex_Diffuse >= 0) {
        tiu_Diffuse = texSlot++;
        GL20.glUniform1i(ul_tex_Diffuse, tiu_Diffuse);
    } else {
        tiu_Diffuse = -1;
    }

    int ul_tex_Color0 = GL20.glGetUniformLocation(programId, "tex_Color0");
    if (ul_tex_Color0 >= 0) {
        tiu_Color0 = texSlot++;
        GL20.glUniform1i(ul_tex_Color0, tiu_Color0);
    } else {
        tiu_Color0 = -1;
    }

    int ul_tex_Depth = GL20.glGetUniformLocation(programId, "tex_Depth");
    if (ul_tex_Depth >= 0) {
        tiu_Depth = texSlot++;
        GL20.glUniform1i(ul_tex_Depth, tiu_Depth);
    } else {
        tiu_Depth = -1;
    }

    int error = GL11.glGetError();
}

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  w  w. ja v a2 s .  co  m*/
}

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 va2s .  c  o  m
}

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 . j  av a2  s  .  c o m*/
    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/*  w w  w . j  av a  2 s.c om*/
    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 . j a v a2 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();/* ww  w . jav a 2 s .  co m*/
        {
            System.exit(-1);
        }
    }
}

From source file:fr.ign.cogit.geoxygene.appli.render.LwjglLayerRenderer.java

License:Open Source License

/**
 * Create a runnable for the renderer. A renderer create a new image to draw
 * into. If cancel() is called, the rendering stops as soon as possible.
 * When finished, set the variable rendering to false.
 * /*from w w w.  j av a 2s .c o  m*/
 * @return a new runnable
 * @see Runnable
 * @see #cancel()
 * @see #isRendering()
 */
@Override
public final Runnable createRunnable() {
    // this runnable is not dedicated to be launched into a thread.
    // It should be launched by a SyncRenderingManager which calls the run()
    // method as a singular method
    return new Runnable() {
        @Override
        public void run() {
            LayerViewGLPanel vp = LwjglLayerRenderer.this.getLayerViewPanel();
            try {
                // now, we are rendering and it's not finished yet
                LwjglLayerRenderer.this.setRendering(true);
                LwjglLayerRenderer.this.setRendered(false);
                // if the rendering is cancelled: stop
                if (LwjglLayerRenderer.this.isCancelled()) {
                    return;
                }
                // if either the width or the height of the panel is lesser
                // than or equal to 0, stop
                if (Math.min(vp.getWidth(), vp.getHeight()) <= 1) {
                    return;
                }
                // do the actual rendering
                try {

                    LwjglLayerRenderer.this.renderHook(vp.getViewport().getEnvelopeInModelCoordinates());
                    GLTools.glCheckError("LWJGLLayerRenderer::renderHook()");
                } catch (Throwable t) {
                    logger.warn(
                            "LwJGL Rendering failed for layer '" + LwjglLayerRenderer.this.getLayer().getName()
                                    + "': " + t.getMessage() + " (" + t.getClass().getSimpleName() + ")");
                    logger.warn("GL Status is '" + Util.translateGLErrorString(GL11.glGetError()) + "'");
                    t.printStackTrace();
                    return;
                }
            } finally {
                // we are no more in rendering progress
                LwjglLayerRenderer.this.setRendering(false);
            }
        }
    };
}

From source file:io.root.gfx.glutils.GL.java

License:Apache License

public static int glGetError() {
    return GL11.glGetError();
}