Hello Guest

OpenGL won't render

  • 2 Replies
  • 2047 Views
OpenGL won't render
« on: January 28, 2015, 00:27:49 »
I'm slowly growing desperate and hope someone here can help me out with the troubles I've got. I can't get LWJGL to show any OpenGL code I'm creating, no matter what I do. The example from the Wiki works fine, but everything I do by myself won't render. I'm aware that this is probably my fault and that's why I hope you can help me out.

I'm using LWJGL 2.9.2. I had problems with getting LWJGL working with my notebook at first, but the LWJGL works fine after I've updated my graphics drivers.

This is the code I'm using:

Code: [Select]
public class Test {
   
    public static void main(String[] args) {
        try {
            Display.setDisplayMode(new DisplayMode(640, 480));
            Display.setFullscreen(false);
            Display.setTitle("Trappers");
            Display.create();
        } catch(LWJGLException e) {
            System.out.println("[ERROR:] LWJGL display could not be created.");
            System.out.println(e.getMessage());
            System.exit(0);
        }
       
        initOpenGL();
       
        while(!Display.isCloseRequested()) {
            drawEnvironment();
            Display.update();
            Display.sync(60);
        }
        Display.destroy();
       
    }
   
    private static void initOpenGL() {
        glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
        glDisable(GL_DEPTH_TEST);
        glDisable(GL_LIGHTING);
        glViewport(0, 0, 640, 480);
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        gluOrtho2D(0.0f, 640, 0.0f, 480);
        glPushMatrix();
 
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
        glPushMatrix();
    }
   
   
    private static void drawEnvironment() {
        // Clear the screen and depth buffer
        glClear(GL_COLOR_BUFFER_BIT); 
        glLoadIdentity();
         
        // set the color of the quad (R,G,B,A)
        glColor3f(0.5f, 0.5f, 1.0f);
             
        // draw quad
        glBegin(GL_QUADS);
            glVertex2f(0.0f, 0.0f);
            glVertex2f(1.0f, 0.0f);
            glVertex2f(1.0f, 1.0f);
            glVertex2f(0.0f, 1.0f);
        glEnd();
        glFlush();
    }
       
}

I even set up a new class in the same project as the LWJGL test to make sure everything's configured correctly. Still won't draw anything. Note that I get a lot of "Could not locate symbol" errors when my applications start, but that's the case with the LWJGL example, too. The exact log looks as following:

Code: [Select]
[LWJGL] Initial mode: 1366 x 768 x 32 @60Hz
[LWJGL] MemoryUtil Accessor: AccessorUnsafe
Could not locate symbol glClientAttribDefaultEXT
Could not locate symbol glPushClientAttribDefaultEXT
Could not locate symbol glMatrixLoadfEXT
Could not locate symbol glMatrixLoaddEXT
Could not locate symbol glMatrixMultfEXT
Could not locate symbol glMatrixMultdEXT
Could not locate symbol glMatrixLoadIdentityEXT
Could not locate symbol glMatrixRotatefEXT
Could not locate symbol glMatrixRotatedEXT
Could not locate symbol glMatrixScalefEXT
Could not locate symbol glMatrixScaledEXT
Could not locate symbol glMatrixTranslatefEXT
Could not locate symbol glMatrixTranslatedEXT
Could not locate symbol glMatrixOrthoEXT
Could not locate symbol glMatrixFrustumEXT
Could not locate symbol glMatrixPushEXT
Could not locate symbol glMatrixPopEXT
Could not locate symbol glTextureParameteriEXT
Could not locate symbol glTextureParameterivEXT
Could not locate symbol glTextureParameterfEXT
Could not locate symbol glTextureParameterfvEXT
Could not locate symbol glTextureImage1DEXT
Could not locate symbol glTextureImage2DEXT
Could not locate symbol glTextureSubImage1DEXT
Could not locate symbol glTextureSubImage2DEXT
Could not locate symbol glCopyTextureImage1DEXT
Could not locate symbol glCopyTextureImage2DEXT
Could not locate symbol glCopyTextureSubImage1DEXT
Could not locate symbol glCopyTextureSubImage2DEXT
Could not locate symbol glGetTextureImageEXT
Could not locate symbol glGetTextureParameterfvEXT
Could not locate symbol glGetTextureParameterivEXT
Could not locate symbol glGetTextureLevelParameterfvEXT
Could not locate symbol glGetTextureLevelParameterivEXT
Could not locate symbol glTextureImage3DEXT
Could not locate symbol glTextureSubImage3DEXT
Could not locate symbol glCopyTextureSubImage3DEXT
Could not locate symbol glBindMultiTextureEXT
Could not locate symbol glMultiTexCoordPointerEXT
Could not locate symbol glMultiTexEnvfEXT
Could not locate symbol glMultiTexEnvfvEXT
Could not locate symbol glMultiTexEnviEXT
Could not locate symbol glMultiTexEnvivEXT
Could not locate symbol glMultiTexGendEXT
Could not locate symbol glMultiTexGendvEXT
Could not locate symbol glMultiTexGenfEXT
Could not locate symbol glMultiTexGenfvEXT
Could not locate symbol glMultiTexGeniEXT
Could not locate symbol glMultiTexGenivEXT
Could not locate symbol glGetMultiTexEnvfvEXT
Could not locate symbol glGetMultiTexEnvivEXT
Could not locate symbol glGetMultiTexGendvEXT
Could not locate symbol glGetMultiTexGenfvEXT
Could not locate symbol glGetMultiTexGenivEXT
Could not locate symbol glMultiTexParameteriEXT
Could not locate symbol glMultiTexParameterivEXT
Could not locate symbol glMultiTexParameterfEXT
Could not locate symbol glMultiTexParameterfvEXT
Could not locate symbol glMultiTexImage1DEXT
Could not locate symbol glMultiTexImage2DEXT
Could not locate symbol glMultiTexSubImage1DEXT
Could not locate symbol glMultiTexSubImage2DEXT
Could not locate symbol glCopyMultiTexImage1DEXT
Could not locate symbol glCopyMultiTexImage2DEXT
Could not locate symbol glCopyMultiTexSubImage1DEXT
Could not locate symbol glCopyMultiTexSubImage2DEXT
Could not locate symbol glGetMultiTexImageEXT
Could not locate symbol glGetMultiTexParameterfvEXT
Could not locate symbol glGetMultiTexParameterivEXT
Could not locate symbol glGetMultiTexLevelParameterfvEXT
Could not locate symbol glGetMultiTexLevelParameterivEXT
Could not locate symbol glMultiTexImage3DEXT
Could not locate symbol glMultiTexSubImage3DEXT
Could not locate symbol glCopyMultiTexSubImage3DEXT
Could not locate symbol glEnableClientStateIndexedEXT
Could not locate symbol glDisableClientStateIndexedEXT
Could not locate symbol glEnableClientStateiEXT
Could not locate symbol glDisableClientStateiEXT
Could not locate symbol glGetFloatIndexedvEXT
Could not locate symbol glGetDoubleIndexedvEXT
Could not locate symbol glGetPointerIndexedvEXT
Could not locate symbol glGetFloati_vEXT
Could not locate symbol glGetDoublei_vEXT
Could not locate symbol glGetPointeri_vEXT
Could not locate symbol glNamedProgramStringEXT
Could not locate symbol glNamedProgramLocalParameter4dEXT
Could not locate symbol glNamedProgramLocalParameter4dvEXT
Could not locate symbol glNamedProgramLocalParameter4fEXT
Could not locate symbol glNamedProgramLocalParameter4fvEXT
Could not locate symbol glGetNamedProgramLocalParameterdvEXT
Could not locate symbol glGetNamedProgramLocalParameterfvEXT
Could not locate symbol glGetNamedProgramivEXT
Could not locate symbol glGetNamedProgramStringEXT
Could not locate symbol glCompressedTextureImage3DEXT
Could not locate symbol glCompressedTextureImage2DEXT
Could not locate symbol glCompressedTextureImage1DEXT
Could not locate symbol glCompressedTextureSubImage3DEXT
Could not locate symbol glCompressedTextureSubImage2DEXT
Could not locate symbol glCompressedTextureSubImage1DEXT
Could not locate symbol glGetCompressedTextureImageEXT
Could not locate symbol glCompressedMultiTexImage3DEXT
Could not locate symbol glCompressedMultiTexImage2DEXT
Could not locate symbol glCompressedMultiTexImage1DEXT
Could not locate symbol glCompressedMultiTexSubImage3DEXT
Could not locate symbol glCompressedMultiTexSubImage2DEXT
Could not locate symbol glCompressedMultiTexSubImage1DEXT
Could not locate symbol glGetCompressedMultiTexImageEXT
Could not locate symbol glMatrixLoadTransposefEXT
Could not locate symbol glMatrixLoadTransposedEXT
Could not locate symbol glMatrixMultTransposefEXT
Could not locate symbol glMatrixMultTransposedEXT
Could not locate symbol glNamedBufferDataEXT
Could not locate symbol glNamedBufferSubDataEXT
Could not locate symbol glMapNamedBufferEXT
Could not locate symbol glUnmapNamedBufferEXT
Could not locate symbol glGetNamedBufferParameterivEXT
Could not locate symbol glGetNamedBufferPointervEXT
Could not locate symbol glGetNamedBufferSubDataEXT
Could not locate symbol glProgramUniform1fEXT
Could not locate symbol glProgramUniform2fEXT
Could not locate symbol glProgramUniform3fEXT
Could not locate symbol glProgramUniform4fEXT
Could not locate symbol glProgramUniform1iEXT
Could not locate symbol glProgramUniform2iEXT
Could not locate symbol glProgramUniform3iEXT
Could not locate symbol glProgramUniform4iEXT
Could not locate symbol glProgramUniform1fvEXT
Could not locate symbol glProgramUniform2fvEXT
Could not locate symbol glProgramUniform3fvEXT
Could not locate symbol glProgramUniform4fvEXT
Could not locate symbol glProgramUniform1ivEXT
Could not locate symbol glProgramUniform2ivEXT
Could not locate symbol glProgramUniform3ivEXT
Could not locate symbol glProgramUniform4ivEXT
Could not locate symbol glProgramUniformMatrix2fvEXT
Could not locate symbol glProgramUniformMatrix3fvEXT
Could not locate symbol glProgramUniformMatrix4fvEXT
Could not locate symbol glProgramUniformMatrix2x3fvEXT
Could not locate symbol glProgramUniformMatrix3x2fvEXT
Could not locate symbol glProgramUniformMatrix2x4fvEXT
Could not locate symbol glProgramUniformMatrix4x2fvEXT
Could not locate symbol glProgramUniformMatrix3x4fvEXT
Could not locate symbol glProgramUniformMatrix4x3fvEXT
Could not locate symbol glTextureParameterIivEXT
Could not locate symbol glTextureParameterIuivEXT
Could not locate symbol glGetTextureParameterIivEXT
Could not locate symbol glGetTextureParameterIuivEXT
Could not locate symbol glMultiTexParameterIivEXT
Could not locate symbol glMultiTexParameterIuivEXT
Could not locate symbol glGetMultiTexParameterIivEXT
Could not locate symbol glGetMultiTexParameterIuivEXT
Could not locate symbol glNamedProgramLocalParameters4fvEXT
Could not locate symbol glNamedRenderbufferStorageEXT
Could not locate symbol glGetNamedRenderbufferParameterivEXT
Could not locate symbol glNamedRenderbufferStorageMultisampleEXT
Could not locate symbol glCheckNamedFramebufferStatusEXT
Could not locate symbol glNamedFramebufferTexture1DEXT
Could not locate symbol glNamedFramebufferTexture2DEXT
Could not locate symbol glNamedFramebufferTexture3DEXT
Could not locate symbol glNamedFramebufferRenderbufferEXT
Could not locate symbol glGetNamedFramebufferAttachmentParameterivEXT
Could not locate symbol glGenerateTextureMipmapEXT
Could not locate symbol glGenerateMultiTexMipmapEXT
Could not locate symbol glFramebufferDrawBufferEXT
Could not locate symbol glFramebufferDrawBuffersEXT
[LWJGL] GL_EXT_direct_state_access was reported as available but an entry point is missing

I'm thankful for every kind of help you can provide!
« Last Edit: January 28, 2015, 00:29:35 by Tutzen »

*

Offline SHC

  • **
  • 94
    • GoHarsha.com
Re: OpenGL won't render
« Reply #1 on: January 28, 2015, 07:13:10 »
The problem is with your initializing code, and not with OpenGL. You are using glPushMatrix, where you should not be using that. Here is the corrected code.

Code: [Select]
public static void initOpenGL()
{
    // First set the clear color of the screen
    glClearColor(0, 0, 0, 0);

    // Now set the projection matrix to orthographic projection
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0, 640, 480, 0, 0.01f, 100f);

    // Now set the modelview matrix
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
}
This sets the projection coordinate system such that (0, 0) is the top-left of the window, and (640, 480) is the bottom right of the window. Then, you are trying to render a Quad, and that too in the color (0.5, 0.5, 1, 1). Here is how you would do that.

Code: [Select]
public static void drawEnvironment()
{
    // First clear the screen
    glClear(GL_COLOR_BUFFER_BIT);

    // Now draw the QUAD. You have to set the color every time.
    glBegin(GL_QUADS);
    {
        // Top-left vertex
        glColor3f(0.5f, 0.5f, 1f);
        glVertex2f(100, 100);

        // Top-right vertex
        glColor3f(0.5f, 0.5f, 1f);
        glVertex2f(200, 100);

        // Bottom-right vertex
        glColor3f(0.5f, 0.5f, 1f);
        glVertex2f(200, 200);

        // Bottom-left vertex
        glColor3f(0.5f, 0.5f, 1f);
        glVertex2f(100, 200);
    }
    glEnd();
}
This is how you draw the quad. With this specific example, the quad gets drawn from (100, 100) to (200, 200) on the screen. By the way, it is not advisable to learn these deprecated OpenGL stuff. If your hardware supports, start with GL3+ and stay with the modern approach.

Hope this helps.

Re: OpenGL won't render
« Reply #2 on: January 28, 2015, 09:28:49 »
Thank a lot, especially for answering so quickly! It's working now and yeah, I'm more or less new to OpenGL and I'd really like to learn the new approach from the get-go, the thing is that I already worked a bit with it like one and a half years ago and have to use it for a program I have to finish writing until next Monday - so I don't really think there's time to learn something completely new right now... but be sure that I'll catch up on that as soon as possible ;)

Anyways, thanks for your help!