Combining simple and modern rendering

Hello,

i’m not sure if i expressed it correct: “simple and modern rendering”. I have a rendering-thread, rendering 3d-objects with the same light and projection- /view-matrices. Now i want to draw a simple cube-map as background. So i need no shaders, no light and not even depth-buffer - only nine textured quads, that are rotated like the view and that i draw before everything else.
So, for the beginning i used glBegin()…glEnd() for drawing (which i also still use to draw my frame-buffers to the screen). Unfortunately i get no restult. So my objects are still rendered, but the background stays black.

The code i currently use (with a lot of lined added in order of this problem) is this:


void        DrawCubeMap        () {   
    CheckGL("Errors left in cue");
    //glColor3f(1,1,1);       
    glDisable       (GL_LIGHTING);
    glEnable                    (GL_TEXTURE_2D);            

    glActiveTexture     (GL_TEXTURE1); 
     glBindTexture               (GL_TEXTURE_2D,  2);
    glUnmapBuffer       (GL_ARRAY_BUFFER);        
    glBindBuffer        (GL_ARRAY_BUFFER, 0);                //Print("4");
 
    glTexParameteri             (GL_TEXTURE_2D,  GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri             (GL_TEXTURE_2D,  GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glDisable       (GL_CULL_FACE);
    
    glDisable               (GL_COLOR_MATERIAL);                                                                

    glTexEnvf                   (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE,  GL_REPLACE);
    glViewport                  (0, 0, 1280, 800);
                    
    glUseProgram(0);
    glDisable       (GL_DEPTH_TEST);
   //  gluPerspective(90,1,1,100);
    CheckGL("Before draw cube");

    glBegin         (GL_QUADS);  
    glNormal3f( 0.0f, 0.0f, 0.5f);
        glTexCoord2f(0.253, 0.002);     glVertex3f  (-50,  50, -50);                
        glTexCoord2f(0.497, 0.002);     glVertex3f  ( 50,  50, -50); 

[...]

        glTexCoord2f(0.497, 0.997);     glVertex3f  ( 50,  50,  50);                
        glTexCoord2f(0.253, 0.997);     glVertex3f  (-50,  50,  50); 
    glEnd           ();    

    glFlush(); 

    CheckGL("After draw cube");
    glEnable       (GL_DEPTH_TEST);
}

For me this looks okay, but maybe i’m blind and a fresh view from outside helps…

Thank you,
Frank

This is the wrong way around. Each texture unit has its own enable states for fixed-function texturing. So you’re enabling texturing for whichever texture unit happened to be the active texture unit, then set the active texture unit to unit 1 and modify the state for that unit (but don’t enable texturing for it).

Also, ensure you aren’t enabling fixed-function texturing for unit 0 elsewhere.

To be honest, I’d suggest using a shader for the cube map so that you don’t have to deal with fixed-function texturing at all. You can still use the legacy vertex-specification functions if necessary (use the gl_Vertex, gl_Normal and gl_MultiTexCoord* attributes in the vertex shader).

You shouldn’t be hard-coding texture handles. Use values obtained from glGenTextures() or glCreateTextures().

This is the wrong way around.

This i tested immediately without succes. But these lines i put there after having no result without them. Normally all textures are active and the texture should be bound already entering this function. But there may be some errors or artefacts in my code, so i tried to bind it again dirctly before rendering. Originally i expected to get an output with this code only:


    glDisable       (GL_DEPTH_TEST);

    glBegin         (GL_QUADS);  
    glNormal3f( 0.0f, 0.0f, 0.5f);
        glTexCoord2f(0.253, 0.002);     glVertex3f  (-50,  50, -50);                
        glTexCoord2f(0.497, 0.002);     glVertex3f  ( 50,  50, -50); 
 
[...]
 
        glTexCoord2f(0.497, 0.997);     glVertex3f  ( 50,  50,  50);                
        glTexCoord2f(0.253, 0.997);     glVertex3f  (-50,  50,  50); 
    glEnd           ();    
 
    glFlush(); 
 
    glEnable       (GL_DEPTH_TEST);

Everything else i added later.

To be honest, I’d suggest using a shader for the cube map so that you don’t have to deal with fixed-function texturing at all.

Yes, this would be good. I think about rewriting my hole program since at least 2 years but still i find out, that i have to learn too much. If i would have rewritten it one year ago, i would have have made a lot of mistakes, that i will not do now anymore. I’m not a professional and finally i have to find a compromis between state-of-the-art programming and having a working program that i can use somtimes for live-vjing. So, it would have been nice to (simply) have a background…

Kind regards,
Frank