mirror of
https://github.com/love2d/love.git
synced 2026-08-17 19:23:38 +02:00
Removed direct OpenGL calls in the SDL Window module
This commit is contained in:
@@ -127,6 +127,9 @@ bool Graphics::setMode(int width, int height, bool fullscreen, bool vsync, int f
|
|||||||
|
|
||||||
initializeContext();
|
initializeContext();
|
||||||
|
|
||||||
|
// Make sure antialiasing works when set elsewhere
|
||||||
|
glEnable(GL_MULTISAMPLE);
|
||||||
|
|
||||||
// Enable blending
|
// Enable blending
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
|
|
||||||
@@ -138,6 +141,10 @@ bool Graphics::setMode(int width, int height, bool fullscreen, bool vsync, int f
|
|||||||
glEnable(GL_POINT_SMOOTH);
|
glEnable(GL_POINT_SMOOTH);
|
||||||
glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
|
glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
|
||||||
|
|
||||||
|
// Auto-generated mipmaps should be the best quality possible
|
||||||
|
if (GLEE_VERSION_1_4 || GLEE_SGIS_generate_mipmap)
|
||||||
|
glHint(GL_GENERATE_MIPMAP_HINT, GL_NICEST);
|
||||||
|
|
||||||
// Enable textures
|
// Enable textures
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
setActiveTextureUnit(0);
|
setActiveTextureUnit(0);
|
||||||
|
|||||||
@@ -1391,7 +1391,7 @@ extern "C" int luaopen_love_graphics(lua_State *L)
|
|||||||
{
|
{
|
||||||
instance = new Graphics();
|
instance = new Graphics();
|
||||||
}
|
}
|
||||||
catch(Exception &e)
|
catch (love::Exception &e)
|
||||||
{
|
{
|
||||||
return luaL_error(L, e.what());
|
return luaL_error(L, e.what());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,9 +24,6 @@
|
|||||||
// SDL
|
// SDL
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
// OpenGL
|
|
||||||
#include <SDL/SDL_opengl.h>
|
|
||||||
|
|
||||||
// LOVE
|
// LOVE
|
||||||
#include "common/config.h"
|
#include "common/config.h"
|
||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
@@ -41,13 +38,12 @@ namespace sdl
|
|||||||
Window::Window()
|
Window::Window()
|
||||||
: windowTitle("")
|
: windowTitle("")
|
||||||
, created(false)
|
, created(false)
|
||||||
, mouseVisible(true)
|
|
||||||
{
|
{
|
||||||
// Window should be centered.
|
// Window should be centered.
|
||||||
SDL_putenv(const_cast<char *>("SDL_VIDEO_CENTERED=center"));
|
SDL_putenv(const_cast<char *>("SDL_VIDEO_CENTERED=center"));
|
||||||
|
|
||||||
if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
|
if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
|
||||||
throw Exception(SDL_GetError());
|
throw love::Exception(SDL_GetError());
|
||||||
}
|
}
|
||||||
|
|
||||||
Window::~Window()
|
Window::~Window()
|
||||||
@@ -101,11 +97,8 @@ bool Window::setWindow(int width, int height, bool fullscreen, bool vsync, int f
|
|||||||
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 1);
|
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 1);
|
||||||
|
|
||||||
// FSAA
|
// FSAA
|
||||||
if (fsaa > 0)
|
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, (fsaa > 0) ? 1 : 0);
|
||||||
{
|
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, (fsaa > 0) ? fsaa : 0);
|
||||||
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
|
|
||||||
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, fsaa);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fullscreen?
|
// Fullscreen?
|
||||||
Uint32 sdlflags = fullscreen ? (SDL_OPENGL | SDL_FULLSCREEN) : SDL_OPENGL;
|
Uint32 sdlflags = fullscreen ? (SDL_OPENGL | SDL_FULLSCREEN) : SDL_OPENGL;
|
||||||
@@ -116,15 +109,10 @@ bool Window::setWindow(int width, int height, bool fullscreen, bool vsync, int f
|
|||||||
bool failed = true;
|
bool failed = true;
|
||||||
if (fsaa > 0)
|
if (fsaa > 0)
|
||||||
{
|
{
|
||||||
// FSAA might have failed, disable it and try again
|
// FSAA might have caused the failure, disable it and try again
|
||||||
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);
|
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);
|
||||||
failed = SDL_SetVideoMode(width, height, 32, sdlflags) == 0;
|
failed = SDL_SetVideoMode(width, height, 32, sdlflags) == 0;
|
||||||
if (failed)
|
|
||||||
{
|
|
||||||
// There might be no FSAA at all
|
|
||||||
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);
|
|
||||||
failed = SDL_SetVideoMode(width, height, 32, sdlflags) == 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (failed)
|
if (failed)
|
||||||
{
|
{
|
||||||
@@ -142,20 +130,17 @@ bool Window::setWindow(int width, int height, bool fullscreen, bool vsync, int f
|
|||||||
height = videoinfo->current_h;
|
height = videoinfo->current_h;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fsaa > 0)
|
int buffers;
|
||||||
glEnable(GL_MULTISAMPLE);
|
int samples;
|
||||||
|
|
||||||
GLint buffers;
|
SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &buffers);
|
||||||
GLint samples;
|
SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &samples);
|
||||||
|
|
||||||
glGetIntegerv(GL_SAMPLE_BUFFERS_ARB, &buffers);
|
|
||||||
glGetIntegerv(GL_SAMPLES_ARB, &samples);
|
|
||||||
|
|
||||||
// Don't fail because of this, but issue a warning.
|
// Don't fail because of this, but issue a warning.
|
||||||
if ((!buffers && fsaa) || (samples != fsaa))
|
if ((!buffers && fsaa) || (samples != fsaa))
|
||||||
{
|
{
|
||||||
std::cerr << "Warning, quality setting failed! (Result: buffers: " << buffers << ", samples: " << samples << ")" << std::endl;
|
std::cerr << "Warning, FSAA setting failed! (Result: buffers: " << buffers << ", samples: " << samples << ")" << std::endl;
|
||||||
fsaa = !buffers ? 0 : samples;
|
fsaa = (buffers > 0) ? samples : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the actual vsync status
|
// Get the actual vsync status
|
||||||
|
|||||||
@@ -74,7 +74,6 @@ private:
|
|||||||
int fsaa;
|
int fsaa;
|
||||||
} currentMode;
|
} currentMode;
|
||||||
bool created;
|
bool created;
|
||||||
bool mouseVisible;
|
|
||||||
}; // Window
|
}; // Window
|
||||||
|
|
||||||
} // sdl
|
} // sdl
|
||||||
|
|||||||
Reference in New Issue
Block a user