Sign in to follow this  

Problem with fullscreen

This topic is 4261 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Untill now I've used fullscreen mode with the NeHeGL basecode and have had no problems. But now, I'm makeing a terrain engine for my game and strech a texture (tga) across the whole map. Here's the texture: Image hosting by Photobucket When I run the program in "not fullscreen" mode and then maximize the window it looks like this: Image hosting by Photobucket But when I run it in fullscreen mode it looks like this: Image hosting by Photobucket And here's the rendering code:
glLoadIdentity();
   Camera.Look();
  //glDisable(GL_ALPHA_TEST);
   glDepthMask(GL_TRUE);
   glDisable(GL_BLEND);
   
    // Activate the first texture ID and bind the tree background to it
    glActiveTextureARB(GL_TEXTURE0_ARB);
    glEnable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, g_Texture[0]);

    // If we want detail texturing on, let's render the second texture
    if(g_bDetail)
    {
        // Activate the second texture ID and bind the fog texture to it
        glActiveTextureARB(GL_TEXTURE1_ARB);
        glEnable(GL_TEXTURE_2D);
        
        // Here we turn on the COMBINE properties and increase our RGB
        // gamma for the detail texture.  2 seems to work just right.
        glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
        glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2);
        
        // Bind the detail texture
        glBindTexture(GL_TEXTURE_2D, g_Texture[1]);
    
        // Now we want to enter the texture matrix.  This will allow us
        // to change the tiling of the detail texture.
        glMatrixMode(GL_TEXTURE);

            // Reset the current matrix and apply our chosen scale value
            glLoadIdentity();
            glScalef((float)g_DetailScale, (float)g_DetailScale, 1);

        // Leave the texture matrix and set us back in the model view matrix
        glMatrixMode(GL_MODELVIEW);
    }
    //if(Frustum.BoxInFrustum( 0, 0, 0, 100, 100, 100 ))
    Render(map);
    
    glPolygonMode( GL_FRONT_AND_BACK, GL_FILL);
    // Turn the second multitexture pass off
    glActiveTextureARB(GL_TEXTURE1_ARB);
    glDisable(GL_TEXTURE_2D);

    // Turn the first multitexture pass off
    glActiveTextureARB(GL_TEXTURE0_ARB);        
    glDisable(GL_TEXTURE_2D);
    glEnable(GL_TEXTURE_2D);

...

//.....................the Render function....................
// The Render function is passed a pointer that points to the root
// node of a quadtree, then it check which nodes are visible and renders
// them with the RenderHeightMap function which renders a portion of the map
//.............................................................


void RenderHeightMap(BYTE pHeightMap[], int startX, int startY, int endX, int endY)
{
    int X = 0, Y = 0;                      
    float x, y, z;    
   // float scaleside=20, scalehieght = 8;                      
    bool bSwitchSides = false;
    if(render)
    glPolygonMode( GL_FRONT_AND_BACK, GL_FILL);
    if(!render)
    glPolygonMode( GL_FRONT_AND_BACK, GL_LINE);

    glEnable(GL_BLEND);
    for ( X = startX; X <= endX-STEP_SIZE; X += STEP_SIZE )
    {
        
        glBegin( GL_TRIANGLE_STRIP );           

           
            for ( Y = startY; Y <= endY-STEP_SIZE; Y += STEP_SIZE )
            {
                //////////       
                x = (float)X;                          
                y = (float)(SCALE_HEIGHT*Height(pHeightMap, 
                                      (float)X, (float)Y ));  
                z = (float)Y;                          


                SetTextureCoord( (float)x, (float)z );
                glVertex3f(x*SCALE_SIDE, y, z*SCALE_SIDE);        
                
               
                ///////////////////////////////      
                x = (float)(X + STEP_SIZE); 
                y = (float)(SCALE_HEIGHT*Height(pHeightMap, 
                    (float)(X + STEP_SIZE), (float)Y )); 
                z = (float)Y;


                SetTextureCoord( (float)x, (float)z );
                glVertex3f(x*SCALE_SIDE, y, z*SCALE_SIDE);   
                
                 /////////////
                x = (float)X; 
                y = (float)(SCALE_HEIGHT*Height(pHeightMap, (float)X, 
                          (float)(Y + STEP_SIZE) )); 
                z = (float)(Y + STEP_SIZE);


                SetTextureCoord( (float)x, (float)z );
                glVertex3f(x*SCALE_SIDE, y, z*SCALE_SIDE);     
                ////////////////////
                x = (float)(X + STEP_SIZE); 
                y = (float)(SCALE_HEIGHT*Height(pHeightMap, 
                (float)(X + STEP_SIZE), (float)(Y + STEP_SIZE) )); 
                z = (float)(Y + STEP_SIZE);

                SetTextureCoord( (float)x, (float)z );
                glVertex3f(x*SCALE_SIDE, y, z*SCALE_SIDE); 
                
              }
        
            glEnd();
    }
    glDisable(GL_BLEND);
    // Stop rendering triangle strips
   
} 


In the pictures above g_bDetail = false; The texture looks very,...Strange:( All the pixels are blocky and everything, even the clouds (skybox texture) are messed up. I know that the fullscreen enlarges the picture but I've never gotten anything like this before? What could the problem be? Please tell me if I've left out important information. Thanks!

Share this post


Link to post
Share on other sites
Check the resolution of your OpenGL context. If it's set low for windowed mode, and not changed for fullscreen, you may get poor results because you're running 640x480 (or whatever) stretched across your screen. Perhaps up the resolution for the fullscreen context and see if that helps.

Share this post


Link to post
Share on other sites
I'm not sure how to do that. The NeHeGL code has this:

BOOL ChangeScreenResolution (int width, int height, int bitsPerPixel) // Change The Screen Resolution
{
DEVMODE dmScreenSettings; // Device Mode
ZeroMemory (&dmScreenSettings, sizeof (DEVMODE)); // Make Sure Memory Is Cleared
dmScreenSettings.dmSize = sizeof (DEVMODE); // Size Of The Devmode Structure
dmScreenSettings.dmPelsWidth = width; // Select Screen Width
dmScreenSettings.dmPelsHeight = height; // Select Screen Height
dmScreenSettings.dmBitsPerPel = bitsPerPixel; // Select Bits Per Pixel
dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
if (ChangeDisplaySettings (&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
{
return FALSE; // Display Change Failed, Return False
}
return TRUE; // Display Change Was Successful, Return True
}

BOOL CreateWindowGL (GL_Window* window) // This Code Creates Our OpenGL Window
{
DWORD windowStyle = WS_OVERLAPPEDWINDOW; // Define Our Window Style
DWORD windowExtendedStyle = WS_EX_APPWINDOW; // Define The Window's Extended Style

ShowCursor(TRUE);
PIXELFORMATDESCRIPTOR pfd = // pfd Tells Windows How We Want Things To Be
{
sizeof (PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
1, // Version Number
PFD_DRAW_TO_WINDOW | // Format Must Support Window
PFD_SUPPORT_OPENGL | // Format Must Support OpenGL
PFD_DOUBLEBUFFER, // Must Support Double Buffering
PFD_TYPE_RGBA, // Request An RGBA Format
window->init.bitsPerPixel, // Select Our Color Depth
0, 0, 0, 0, 0, 0, // Color Bits Ignored
0, // No Alpha Buffer
0, // Shift Bit Ignored
0, // No Accumulation Buffer
0, 0, 0, 0, // Accumulation Bits Ignored
16, // 16Bit Z-Buffer (Depth Buffer)
0, // No Stencil Buffer
0, // No Auxiliary Buffer
PFD_MAIN_PLANE, // Main Drawing Layer
0, // Reserved
0, 0, 0 // Layer Masks Ignored
};

RECT windowRect = {0, 0, window->init.width, window->init.height}; // Define Our Window Coordinates

GLuint PixelFormat; // Will Hold The Selected Pixel Format

if (window->init.isFullScreen == TRUE) // Fullscreen Requested, Try Changing Video Modes
{
if (ChangeScreenResolution (window->init.width, window->init.height, window->init.bitsPerPixel) == FALSE)
{
// Fullscreen Mode Failed. Run In Windowed Mode Instead
MessageBox (HWND_DESKTOP, "Mode Switch Failed.\nRunning In Windowed Mode.", "Error", MB_OK | MB_ICONEXCLAMATION);
window->init.isFullScreen = FALSE; // Set isFullscreen To False (Windowed Mode)
}
else // Otherwise (If Fullscreen Mode Was Successful)
{
ShowCursor (FALSE); // Turn Off The Cursor
windowStyle = WS_POPUP; // Set The WindowStyle To WS_POPUP (Popup Window)
windowExtendedStyle |= WS_EX_TOPMOST; // Set The Extended Window Style To WS_EX_TOPMOST
} // (Top Window Covering Everything Else)
}



Should I change something there? And wont this kill my framerate?
Thanks.

Share this post


Link to post
Share on other sites
Before the height and width of the screen were set to (480,600), I changed them to (600, 800) and in windowed mode it looked like this:
Image hosting by Photobucket

and in fullscreen like this:
Image hosting by Photobucket

It looks like there's to much contrast or something?
Thanks.

Share this post


Link to post
Share on other sites
Yes, you should be using 32-bit color. I imagine the reason it looked okay in windowed mode is because in windowed mode it uses the desktop's color depth, which is probably 32, so you were getting a 32 bit pixel format instead of the 16 bit you were asking for. Also, be sure to ask for 24- or 32-bit textures when you create them (unless you want something else of course). To do that make sure you use GL_RGB8 or GL_RGBA8 as the internalformat parameter to glTexImage2D.

Share this post


Link to post
Share on other sites

This topic is 4261 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this