I'll walk you through... I have a scene in OpenGL that's {0,0,800,600}. It's resize function:
GLvoid GL_ResizeScene(GLsizei width, GLsizei height)
{
if (height == 0)
height = 1;
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, win.width, win.height, 0, 0, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
This works fine in windowed mode. When I go to full-screen, I have two black borders: one on the left, and one on the right. This isn't what I want. I want my 800x600 screen to be stretched from left to right, without adding extra width pixels. This is for just me figuring it out, and not necessarily something I would ship with.
So, the next part of the puzzle... This is in my window init function.
RECT wRect;
wRect.left = 0;
wRect.top = 0;
wRect.right = (long)win->width;
wRect.bottom = (long)win->height;
// Check for full screen
if (win->blnFullScreen)
{
// Full screen mode. Set dimensions to fill the screen.
x = 0;
y = 0;
}
else
{
// Window mode. Center the window
x = ((GetSystemMetrics(SM_CXSCREEN) - win->width) / 2);
y = ((GetSystemMetrics(SM_CYSCREEN) - win->height) / 2);
}
// Screen settings
if (win->blnFullScreen)
{
DEVMODE dmScreenSettings;
memset(&dmScreenSettings, 0, sizeof(dmScreenSettings));
dmScreenSettings.dmSize = sizeof(dmScreenSettings);
dmScreenSettings.dmPelsWidth = win->width;
dmScreenSettings.dmPelsHeight = win->height;
dmScreenSettings.dmBitsPerPel = SCREEN_BPP;
dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
if (ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
{
// ...
}
// ...
// and just prior to the window creation
AdjustWindowRectEx(&wRect, dwStyle, FALSE, dwExStyle);
}
And after the window is created...
static 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
SCREEN_BPP, // 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
};
// ... nothing gives errors when applying
// ...
win->fpGame_Resize(win->width, win->height);
What can I do to stretch 800x600 to the far left and right without black borders? Thanks.