opengl : glut - soil, black screen



  • hallo,

    i versuche atm mit opengl : glut und soil einige texturen für meine skybox zu laden.
    jedoch bekomme i nur einen blackscreen.
    das laden der texturen funktioniert schon zu 100%, jedoch wird wie bereits schon gesagt nichts angeziegt ... obwohl i denke das i alles richtig gemacht habe.

    vielleicht könnt ihr mir helfen.
    hier mein code:

    // main.cpp
    #include "stdafx.h"
    
    void LoadGLTextures(void);      // load textures
    void display_skybox(void);      // display skybox
    
    GLuint      skybox[6];                      // skybox sites
    
    // display for rendering
    void display (void) {
        keyOperations();                    // key operations
    
        glClear(GL_COLOR_BUFFER_BIT);       // clear color buffer
        glLoadIdentity();                   // load identity
    
        glEnable(GL_TEXTURE_2D);            // enable texturing
        display_skybox();                   // display skybox
    
        glutSwapBuffers();                  // swap buffer
    }
    
    // main
    int main (int argc, char **argv) {
        glutInit(&argc, argv);                  // initialise glut
        glutInitDisplayMode (GLUT_DOUBLE);      // double buffering
        glutInitWindowSize (1440, 900);         // set width and height
        glutInitWindowPosition (50, 50);        // set position
        glutCreateWindow ("projekt 10");        // set title
    
        glutDisplayFunc(display);               // display for rendering
        glutIdleFunc(display);                  // display as idle method
    
        LoadGLTextures();                       // laod textures
    
        glutMainLoop();                         // enter main loop
    }
    
    // laod textures
    void LoadGLTextures(void) {
        skybox[0] = SOIL_load_OGL_texture                                           // skybox front
            (
            "Neuer Ordner/skybox_front.png",
            SOIL_LOAD_AUTO,
            SOIL_CREATE_NEW_ID,
            SOIL_FLAG_INVERT_Y
            );
        glBindTexture(GL_TEXTURE_2D, skybox[0]);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);        // clamp edges
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    
        skybox[1] = SOIL_load_OGL_texture                                           // skybox right
            (
            "Neuer Ordner/skybox_right.png",
            SOIL_LOAD_AUTO,
            SOIL_CREATE_NEW_ID,
            SOIL_FLAG_INVERT_Y
            );
        glBindTexture(GL_TEXTURE_2D, skybox[1]);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);        // clamp edges
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    
        skybox[2] = SOIL_load_OGL_texture                                           // skybox left
            (
            "Neuer Ordner/skybox_left.png",
            SOIL_LOAD_AUTO,
            SOIL_CREATE_NEW_ID,
            SOIL_FLAG_INVERT_Y
            );
        glBindTexture(GL_TEXTURE_2D, skybox[2]);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);        // clamp edges
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    
        skybox[3] = SOIL_load_OGL_texture                                           // skybox back
            (
            "Neuer Ordner/skybox_back.png",
            SOIL_LOAD_AUTO,
            SOIL_CREATE_NEW_ID,
            SOIL_FLAG_INVERT_Y
            );
        glBindTexture(GL_TEXTURE_2D, skybox[3]);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);        // clamp edges
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    }
    
    // display skybox
    void display_skybox(void) {
        glDisable(GL_DEPTH_TEST);
        glBindTexture(GL_TEXTURE_2D, skybox[0]);                        // skybox front
        glBegin(GL_QUADS);
            glTexCoord2f(0, 0); glVertex3f( 0.5f, -0.5f, -0.5f);
            glTexCoord2f(1, 0); glVertex3f(-0.5f, -0.5f, -0.5f);
            glTexCoord2f(1, 1); glVertex3f(-0.5f,  0.5f, -0.5f);
            glTexCoord2f(0, 1); glVertex3f( 0.5f,  0.5f, -0.5f);
        glEnd();
        glBindTexture(GL_TEXTURE_2D, skybox[2]);                        // skybox left
        glBegin(GL_QUADS);
            glTexCoord2f(0, 0); glVertex3f( 0.5f, -0.5f,  0.5f);
            glTexCoord2f(1, 0); glVertex3f( 0.5f, -0.5f, -0.5f);
            glTexCoord2f(1, 1); glVertex3f( 0.5f,  0.5f, -0.5f);
            glTexCoord2f(0, 1); glVertex3f( 0.5f,  0.5f,  0.5f);
        glEnd();
        glBindTexture(GL_TEXTURE_2D, skybox[3]);                        // skybox back
        glBegin(GL_QUADS);
            glTexCoord2f(0, 0); glVertex3f(-0.5f, -0.5f,  0.5f);
            glTexCoord2f(1, 0); glVertex3f( 0.5f, -0.5f,  0.5f);
            glTexCoord2f(1, 1); glVertex3f( 0.5f,  0.5f,  0.5f);
            glTexCoord2f(0, 1); glVertex3f(-0.5f,  0.5f,  0.5f);
        glEnd();
        glBindTexture(GL_TEXTURE_2D, skybox[1]);                        // skybox right
        glBegin(GL_QUADS);
            glTexCoord2f(0, 0); glVertex3f(-0.5f, -0.5f, -0.5f);
            glTexCoord2f(1, 0); glVertex3f(-0.5f, -0.5f,  0.5f);
            glTexCoord2f(1, 1); glVertex3f(-0.5f,  0.5f,  0.5f);
            glTexCoord2f(0, 1); glVertex3f(-0.5f,  0.5f, -0.5f);
        glEnd();
                                                                        // skybox top
                                                                        // skybox bottom
        glEnable(GL_DEPTH_TEST);
    }
    

    gruß und danke für eure hilfe.



  • i denke, i habe nun den primären fehler gefunden.
    für alle die, die es interessiert, i hatte vergessen
    den GL_DEPTH_BUFFER_BIT mit zu clearen, siehe void display(void).

    edit: + GLUT_DEPTH


Anmelden zum Antworten