ich bastel ja gerade wieder mit OpenGL und der SDL herum und irgendwie, ich weiß leider nicht wieso, habe ich bei der Fullscreen-Initialisierung ein Fenster / Viewport der nicht in der linken oberen Ecke sondern versetzt (ca. 200x200) anfängt. Habe daher einen Balken oberhalb und links des Fensters, auf welches der Desktop zu sehen ist. Weiß vielleicht jeman woran das liegen kann?
Hier der Code für die Initialisierung des Fensters:
Code: Alles auswählen
SdlWindow::SdlWindow(const IApplication* application, const WindowDescription* windowDescription /* = NULL */)
: d(new SdlWindowImpl(application, windowDescription))
{
int red = 0, green = 0, blue = 0, alpha = 0;
d->GetRequestedColorMode(&red, &green, &blue, &alpha);
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, red);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, green);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, blue);
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, alpha);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, d->windowDescription->ColorDepth);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
auto windowDimension = d->GetRequestedWindowDimension();
d->window = SDL_SetVideoMode(windowDimension.Width, windowDimension.Height, d->windowDescription->ColorDepth, d->GetVideoFlags());
if (d->window == NULL)
ANEGMA_THROW(ExceptionType::IllegalState, _T("Unable to create gl window"), NULL);
if (d->windowDescription.get() != NULL)
{
if (d->windowDescription->Center && !d->windowDescription->IsFullScreenRequested())
Center();
SetTitle(d->windowDescription->Title);
}
else
{
SetTitle(_T("OpenGL Fx"));
}
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT);
SDL_GL_SwapBuffers();
}
Hinter diesen beiden Werten / Methoden sowie den anderen Methoden, die in dem Code aufgerufen werden, verbirgt sich auch nichts besonderes was den Fehler erklären könnte:
Code: Alles auswählen
Uint32 SdlWindowImpl::GetVideoFlags() const
{
Uint32 sdlFlags = (SDL_HWSURFACE | SDL_HWPALETTE | SDL_DOUBLEBUF | SDL_OPENGL);
if (windowDescription->FullScreen)
sdlFlags |= SDL_FULLSCREEN;
else if (windowDescription->FullScreenWindowed)
sdlFlags |= SDL_NOFRAME;
else
{
if (windowDescription->Borderless)
sdlFlags |= SDL_NOFRAME;
else if (windowDescription->ResizingAllowed)
sdlFlags |= SDL_RESIZABLE;
}
return sdlFlags;
}
Dimension2D<int> SdlWindowImpl::GetRequestedWindowDimension() const
{
return (windowDescription->FullScreenWindowed) ? GetDesktopDimension() : windowDescription->Dimension;
}
Dimension2D<int> SdlWindowImpl::GetDesktopDimension() const
{
RECT desktopRect;
if (FALSE == GetWindowRect(GetDesktopWindow(), &desktopRect))
ANEGMA_THROW(ExceptionType::IllegalState, _T("Unable to get desktop rectangle"), NULL);
return Dimension2D<int>((desktopRect.right - desktopRect.left), (desktopRect.bottom - desktopRect.top));
}
void SdlWindowImpl::GetRequestedColorMode(int* red, int* green, int* blue, int* alpha) const
{
auto colorMode = windowDescription->ColorMode;
const int r = boost::numeric_cast<int>(floor(boost::numeric_cast<double>(colorMode / 1000)));
colorMode -= (r * 1000);
const int g = boost::numeric_cast<int>(floor(boost::numeric_cast<double>(colorMode / 100)));
colorMode -= (g * 100);
const int b = boost::numeric_cast<int>(floor(boost::numeric_cast<double>(colorMode / 10)));
colorMode -= (b * 10);
const int a = boost::numeric_cast<int>(floor(boost::numeric_cast<double>(colorMode / 1)));
if (red)
(*red) = r;
if (green)
(*green) = g;
if (blue)
(*blue) = b;
if (alpha)
(*alpha) = a;
}
Code: Alles auswählen
namespace anegma {
namespace core {
struct WindowDescription
{
Point<int> Location;
Dimension2D<int> Dimension;
String Title;
bool FullScreen;
bool FullScreenWindowed;
bool Borderless;
bool ResizingAllowed;
bool Center;
bool GrabFocus;
unsigned int FSAA;
unsigned int ColorDepth;
unsigned int ColorMode;
WindowDescription()
: Location(100, 100),
Dimension(640, 480),
Title(_T("OpenGL Fx")),
FullScreen(false),
FullScreenWindowed(false),
Borderless(false),
ResizingAllowed(false),
Center(false),
GrabFocus(true),
FSAA(0),
ColorDepth(32),
ColorMode(8888)
{ }
WindowDescription(const WindowDescription* windowDescription)
: Location(windowDescription->Location),
Dimension(windowDescription->Dimension),
Title(windowDescription->Title),
FullScreen(windowDescription->FullScreen),
FullScreenWindowed(windowDescription->FullScreenWindowed),
Borderless(windowDescription->Borderless),
ResizingAllowed(windowDescription->ResizingAllowed),
Center(windowDescription->Center),
GrabFocus(windowDescription->GrabFocus),
FSAA(windowDescription->FSAA),
ColorDepth(windowDescription->ColorDepth),
ColorMode(windowDescription->ColorMode)
{ }
bool IsFullScreenRequested() const
{
return (FullScreen || FullScreenWindowed);
}
};