Renamed all cases of FSAA to the more accurately-named MSAA. The FSAA names (canvas:getFSAA, t.window.fsaa, etc.) still exist for now, for backwards-compatibility.

This commit is contained in:
Alex Szpakowski
2014-06-13 23:28:00 -03:00
parent 431b6a56ce
commit 23d3cbc2e2
16 changed files with 110 additions and 87 deletions
+1
View File
@@ -208,6 +208,7 @@ StringMap<Graphics::SystemLimit, Graphics::LIMIT_MAX_ENUM>::Entry Graphics::syst
{"texturesize", Graphics::LIMIT_TEXTURE_SIZE}, {"texturesize", Graphics::LIMIT_TEXTURE_SIZE},
{"multicanvas", Graphics::LIMIT_MULTI_CANVAS}, {"multicanvas", Graphics::LIMIT_MULTI_CANVAS},
{"canvasfsaa", Graphics::LIMIT_CANVAS_FSAA}, {"canvasfsaa", Graphics::LIMIT_CANVAS_FSAA},
{"canvasmsaa", Graphics::LIMIT_CANVAS_MSAA},
}; };
StringMap<Graphics::SystemLimit, Graphics::LIMIT_MAX_ENUM> Graphics::systemLimits(Graphics::systemLimitEntries, sizeof(Graphics::systemLimitEntries)); StringMap<Graphics::SystemLimit, Graphics::LIMIT_MAX_ENUM> Graphics::systemLimits(Graphics::systemLimitEntries, sizeof(Graphics::systemLimitEntries));
+2 -1
View File
@@ -114,7 +114,8 @@ public:
LIMIT_POINT_SIZE, LIMIT_POINT_SIZE,
LIMIT_TEXTURE_SIZE, LIMIT_TEXTURE_SIZE,
LIMIT_MULTI_CANVAS, LIMIT_MULTI_CANVAS,
LIMIT_CANVAS_FSAA, LIMIT_CANVAS_FSAA, // For backward-compatibility. TODO: remove!
LIMIT_CANVAS_MSAA,
LIMIT_MAX_ENUM LIMIT_MAX_ENUM
}; };
+37 -37
View File
@@ -423,15 +423,15 @@ static void getStrategy()
} }
} }
Canvas::Canvas(int width, int height, Format format, int fsaa) Canvas::Canvas(int width, int height, Format format, int msaa)
: fbo(0) : fbo(0)
, resolve_fbo(0) , resolve_fbo(0)
, texture(0) , texture(0)
, fsaa_buffer(0) , msaa_buffer(0)
, depth_stencil(0) , depth_stencil(0)
, format(format) , format(format)
, fsaa_samples(fsaa) , msaa_samples(msaa)
, fsaa_dirty(false) , msaa_dirty(false)
{ {
this->width = width; this->width = width;
this->height = height; this->height = height;
@@ -473,7 +473,7 @@ Canvas::~Canvas()
unloadVolatile(); unloadVolatile();
} }
bool Canvas::createFSAAFBO(GLenum internalformat) bool Canvas::createMSAAFBO(GLenum internalformat)
{ {
// Create our FBO without a texture. // Create our FBO without a texture.
status = strategy->createFBO(fbo, 0); status = strategy->createFBO(fbo, 0);
@@ -488,7 +488,7 @@ bool Canvas::createFSAAFBO(GLenum internalformat)
} }
// Create and attach the MSAA buffer for our FBO. // Create and attach the MSAA buffer for our FBO.
if (strategy->createMSAABuffer(width, height, fsaa_samples, internalformat, fsaa_buffer)) if (strategy->createMSAABuffer(width, height, msaa_samples, internalformat, msaa_buffer))
status = GL_FRAMEBUFFER_COMPLETE; status = GL_FRAMEBUFFER_COMPLETE;
else else
status = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; status = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
@@ -500,10 +500,10 @@ bool Canvas::createFSAAFBO(GLenum internalformat)
if (status != GL_FRAMEBUFFER_COMPLETE) if (status != GL_FRAMEBUFFER_COMPLETE)
{ {
// Clean up. // Clean up.
strategy->deleteFBO(fbo, 0, fsaa_buffer); strategy->deleteFBO(fbo, 0, msaa_buffer);
strategy->deleteFBO(resolve_fbo, 0, 0); strategy->deleteFBO(resolve_fbo, 0, 0);
fbo = fsaa_buffer = resolve_fbo = 0; fbo = msaa_buffer = resolve_fbo = 0;
fsaa_samples = 0; msaa_samples = 0;
} }
if (current != this) if (current != this)
@@ -515,7 +515,7 @@ bool Canvas::createFSAAFBO(GLenum internalformat)
bool Canvas::loadVolatile() bool Canvas::loadVolatile()
{ {
fbo = depth_stencil = texture = 0; fbo = depth_stencil = texture = 0;
resolve_fbo = fsaa_buffer = 0; resolve_fbo = msaa_buffer = 0;
status = GL_FRAMEBUFFER_COMPLETE; status = GL_FRAMEBUFFER_COMPLETE;
// glTexImage2D is guaranteed to error in this case. // glTexImage2D is guaranteed to error in this case.
@@ -562,16 +562,16 @@ bool Canvas::loadVolatile()
glGetIntegerv(GL_MAX_SAMPLES, &max_samples); glGetIntegerv(GL_MAX_SAMPLES, &max_samples);
} }
if (fsaa_samples > max_samples) if (msaa_samples > max_samples)
fsaa_samples = max_samples; msaa_samples = max_samples;
// Try to create a FSAA FBO if requested. // Try to create a MSAA FBO if requested.
bool fsaasuccess = false; bool msaasuccess = false;
if (fsaa_samples > 1) if (msaa_samples > 1)
fsaasuccess = createFSAAFBO(internalformat); msaasuccess = createMSAAFBO(internalformat);
// On failure (or no requested FSAA), fall back to a regular FBO. // On failure (or no requested MSAA), fall back to a regular FBO.
if (!fsaasuccess) if (!msaasuccess)
status = strategy->createFBO(fbo, texture); status = strategy->createFBO(fbo, texture);
if (status != GL_FRAMEBUFFER_COMPLETE) if (status != GL_FRAMEBUFFER_COMPLETE)
@@ -579,20 +579,20 @@ bool Canvas::loadVolatile()
clear(Color(0, 0, 0, 0)); clear(Color(0, 0, 0, 0));
fsaa_dirty = (fsaa_buffer != 0); msaa_dirty = (msaa_buffer != 0);
return true; return true;
} }
void Canvas::unloadVolatile() void Canvas::unloadVolatile()
{ {
strategy->deleteFBO(fbo, depth_stencil, fsaa_buffer); strategy->deleteFBO(fbo, depth_stencil, msaa_buffer);
strategy->deleteFBO(resolve_fbo, 0, 0); strategy->deleteFBO(resolve_fbo, 0, 0);
gl.deleteTexture(texture); gl.deleteTexture(texture);
fbo = depth_stencil = texture = 0; fbo = depth_stencil = texture = 0;
resolve_fbo = fsaa_buffer = 0; resolve_fbo = msaa_buffer = 0;
for (size_t i = 0; i < attachedCanvases.size(); i++) for (size_t i = 0; i < attachedCanvases.size(); i++)
attachedCanvases[i]->release(); attachedCanvases[i]->release();
@@ -708,8 +708,8 @@ void Canvas::setupGrab()
else if (screenHasSRGB) else if (screenHasSRGB)
glDisable(GL_FRAMEBUFFER_SRGB); glDisable(GL_FRAMEBUFFER_SRGB);
if (fsaa_buffer != 0) if (msaa_buffer != 0)
fsaa_dirty = true; msaa_dirty = true;
} }
void Canvas::startGrab(const std::vector<Canvas *> &canvases) void Canvas::startGrab(const std::vector<Canvas *> &canvases)
@@ -726,8 +726,8 @@ void Canvas::startGrab(const std::vector<Canvas *> &canvases)
if ((int) canvases.size() + 1 > gl.getMaxRenderTargets()) if ((int) canvases.size() + 1 > gl.getMaxRenderTargets())
throw love::Exception("This system can't simultaniously render to %d canvases.", canvases.size()+1); throw love::Exception("This system can't simultaniously render to %d canvases.", canvases.size()+1);
if (fsaa_samples != 0) if (msaa_samples != 0)
throw love::Exception("Multi-canvas rendering is not supported with FSAA."); throw love::Exception("Multi-canvas rendering is not supported with MSAA.");
} }
for (size_t i = 0; i < canvases.size(); i++) for (size_t i = 0; i < canvases.size(); i++)
@@ -738,8 +738,8 @@ void Canvas::startGrab(const std::vector<Canvas *> &canvases)
if (canvases[i]->getTextureFormat() != format) if (canvases[i]->getTextureFormat() != format)
throw love::Exception("All canvas arguments must have the same texture format."); throw love::Exception("All canvas arguments must have the same texture format.");
if (canvases[i]->getFSAA() != 0) if (canvases[i]->getMSAA() != 0)
throw love::Exception("Multi-canvas rendering is not supported with FSAA."); throw love::Exception("Multi-canvas rendering is not supported with MSAA.");
if (!canvaseschanged && canvases[i] != attachedCanvases[i]) if (!canvaseschanged && canvases[i] != attachedCanvases[i])
canvaseschanged = true; canvaseschanged = true;
@@ -860,8 +860,8 @@ void Canvas::clear(Color c)
if (current != this) if (current != this)
strategy->bindFBO(previous); strategy->bindFBO(previous);
if (fsaa_buffer != 0) if (msaa_buffer != 0)
fsaa_dirty = true; msaa_dirty = true;
} }
bool Canvas::checkCreateStencil() bool Canvas::checkCreateStencil()
@@ -873,7 +873,7 @@ bool Canvas::checkCreateStencil()
if (current != this) if (current != this)
strategy->bindFBO(fbo); strategy->bindFBO(fbo);
bool success = strategy->createStencil(width, height, fsaa_samples, depth_stencil); bool success = strategy->createStencil(width, height, msaa_samples, depth_stencil);
if (current && current != this) if (current && current != this)
strategy->bindFBO(current->fbo); strategy->bindFBO(current->fbo);
@@ -892,9 +892,9 @@ love::image::ImageData *Canvas::getImageData(love::image::Image *image)
GLubyte *pixels = new GLubyte[size]; GLubyte *pixels = new GLubyte[size];
// Our texture is attached to 'resolve_fbo' when we use MSAA. // Our texture is attached to 'resolve_fbo' when we use MSAA.
if (fsaa_samples > 1 && (GLEE_VERSION_3_0 || GLEE_ARB_framebuffer_object)) if (msaa_samples > 1 && (GLEE_VERSION_3_0 || GLEE_ARB_framebuffer_object))
glBindFramebuffer(GL_READ_FRAMEBUFFER, resolve_fbo); glBindFramebuffer(GL_READ_FRAMEBUFFER, resolve_fbo);
else if (fsaa_samples > 1 && GLEE_EXT_framebuffer_multisample) else if (msaa_samples > 1 && GLEE_EXT_framebuffer_multisample)
glBindFramebufferEXT(GL_READ_FRAMEBUFFER, resolve_fbo); glBindFramebufferEXT(GL_READ_FRAMEBUFFER, resolve_fbo);
else else
strategy->bindFBO(fbo); strategy->bindFBO(fbo);
@@ -916,9 +916,9 @@ void Canvas::getPixel(unsigned char* pixel_rgba, int x, int y)
resolveMSAA(); resolveMSAA();
// Our texture is attached to 'resolve_fbo' when we use MSAA. // Our texture is attached to 'resolve_fbo' when we use MSAA.
if (fsaa_samples > 1 && (GLEE_VERSION_3_0 || GLEE_ARB_framebuffer_object)) if (msaa_samples > 1 && (GLEE_VERSION_3_0 || GLEE_ARB_framebuffer_object))
glBindFramebuffer(GL_READ_FRAMEBUFFER, resolve_fbo); glBindFramebuffer(GL_READ_FRAMEBUFFER, resolve_fbo);
else if (fsaa_samples > 1 && GLEE_EXT_framebuffer_multisample) else if (msaa_samples > 1 && GLEE_EXT_framebuffer_multisample)
glBindFramebufferEXT(GL_READ_FRAMEBUFFER, resolve_fbo); glBindFramebufferEXT(GL_READ_FRAMEBUFFER, resolve_fbo);
else if (current != this) else if (current != this)
strategy->bindFBO(fbo); strategy->bindFBO(fbo);
@@ -933,10 +933,10 @@ void Canvas::getPixel(unsigned char* pixel_rgba, int x, int y)
bool Canvas::resolveMSAA() bool Canvas::resolveMSAA()
{ {
if (resolve_fbo == 0 || fsaa_buffer == 0) if (resolve_fbo == 0 || msaa_buffer == 0)
return false; return false;
if (!fsaa_dirty) if (!msaa_dirty)
return true; return true;
GLuint previous = 0; GLuint previous = 0;
@@ -964,7 +964,7 @@ bool Canvas::resolveMSAA()
strategy->bindFBO(previous); strategy->bindFBO(previous);
if (current != this) if (current != this)
fsaa_dirty = false; msaa_dirty = false;
return true; return true;
} }
+7 -7
View File
@@ -57,7 +57,7 @@ public:
FORMAT_MAX_ENUM FORMAT_MAX_ENUM
}; };
Canvas(int width, int height, Format format = FORMAT_NORMAL, int fsaa = 0); Canvas(int width, int height, Format format = FORMAT_NORMAL, int msaa = 0);
virtual ~Canvas(); virtual ~Canvas();
// Implements Volatile. // Implements Volatile.
@@ -108,9 +108,9 @@ public:
return format; return format;
} }
inline int getFSAA() const inline int getMSAA() const
{ {
return fsaa_samples; return msaa_samples;
} }
bool resolveMSAA(); bool resolveMSAA();
@@ -133,7 +133,7 @@ public:
private: private:
bool createFSAAFBO(GLenum internalformat); bool createMSAAFBO(GLenum internalformat);
static Format getSizedFormat(Format format); static Format getSizedFormat(Format format);
static void convertFormat(Format format, GLenum &internalformat, GLenum &externalformat, GLenum &type); static void convertFormat(Format format, GLenum &internalformat, GLenum &externalformat, GLenum &type);
@@ -142,7 +142,7 @@ private:
GLuint resolve_fbo; GLuint resolve_fbo;
GLuint texture; GLuint texture;
GLuint fsaa_buffer; GLuint msaa_buffer;
GLuint depth_stencil; GLuint depth_stencil;
Format format; Format format;
@@ -151,8 +151,8 @@ private:
std::vector<Canvas *> attachedCanvases; std::vector<Canvas *> attachedCanvases;
int fsaa_samples; int msaa_samples;
bool fsaa_dirty; bool msaa_dirty;
void setupGrab(); void setupGrab();
void drawv(const Matrix &t, const Vertex *v); void drawv(const Matrix &t, const Vertex *v);
+4 -3
View File
@@ -483,7 +483,7 @@ ParticleSystem *Graphics::newParticleSystem(Texture *texture, int size)
return new ParticleSystem(texture, size); return new ParticleSystem(texture, size);
} }
Canvas *Graphics::newCanvas(int width, int height, Canvas::Format format, int fsaa) Canvas *Graphics::newCanvas(int width, int height, Canvas::Format format, int msaa)
{ {
if (!Canvas::isFormatSupported(format)) if (!Canvas::isFormatSupported(format))
{ {
@@ -500,7 +500,7 @@ Canvas *Graphics::newCanvas(int width, int height, Canvas::Format format, int fs
while (GL_NO_ERROR != glGetError()) while (GL_NO_ERROR != glGetError())
/* clear opengl error flag */; /* clear opengl error flag */;
Canvas *canvas = new Canvas(width, height, format, fsaa); Canvas *canvas = new Canvas(width, height, format, msaa);
GLenum err = canvas->getStatus(); GLenum err = canvas->getStatus();
// everything ok, return canvas (early out) // everything ok, return canvas (early out)
@@ -1107,7 +1107,8 @@ double Graphics::getSystemLimit(SystemLimit limittype) const
case Graphics::LIMIT_MULTI_CANVAS: case Graphics::LIMIT_MULTI_CANVAS:
limit = (double) gl.getMaxRenderTargets(); limit = (double) gl.getMaxRenderTargets();
break; break;
case Graphics::LIMIT_CANVAS_FSAA: case Graphics::LIMIT_CANVAS_FSAA: // For backward-compatibility.
case Graphics::LIMIT_CANVAS_MSAA:
if (GLEE_VERSION_3_0 || GLEE_ARB_framebuffer_object if (GLEE_VERSION_3_0 || GLEE_ARB_framebuffer_object
|| GLEE_EXT_framebuffer_multisample) || GLEE_EXT_framebuffer_multisample)
{ {
+1 -1
View File
@@ -208,7 +208,7 @@ public:
ParticleSystem *newParticleSystem(Texture *texture, int size); ParticleSystem *newParticleSystem(Texture *texture, int size);
Canvas *newCanvas(int width, int height, Canvas::Format format = Canvas::FORMAT_NORMAL, int fsaa = 0); Canvas *newCanvas(int width, int height, Canvas::Format format = Canvas::FORMAT_NORMAL, int msaa = 0);
Shader *newShader(const Shader::ShaderSources &sources); Shader *newShader(const Shader::ShaderSources &sources);
+4 -3
View File
@@ -122,10 +122,10 @@ int w_Canvas_getFormat(lua_State *L)
return 1; return 1;
} }
int w_Canvas_getFSAA(lua_State *L) int w_Canvas_getMSAA(lua_State *L)
{ {
Canvas *canvas = luax_checkcanvas(L, 1); Canvas *canvas = luax_checkcanvas(L, 1);
lua_pushinteger(L, canvas->getFSAA()); lua_pushinteger(L, canvas->getMSAA());
return 1; return 1;
} }
@@ -145,7 +145,8 @@ static const luaL_Reg functions[] =
{ "getPixel", w_Canvas_getPixel }, { "getPixel", w_Canvas_getPixel },
{ "clear", w_Canvas_clear }, { "clear", w_Canvas_clear },
{ "getFormat", w_Canvas_getFormat }, { "getFormat", w_Canvas_getFormat },
{ "getFSAA", w_Canvas_getFSAA }, { "getMSAA", w_Canvas_getMSAA },
{ "getFSAA", w_Canvas_getMSAA }, // For backward-compatibility. TODO: remove!
// Deprecated since 0.9.1. // Deprecated since 0.9.1.
{ "getType", w_Canvas_getFormat }, { "getType", w_Canvas_getFormat },
+1 -1
View File
@@ -40,7 +40,7 @@ int w_Canvas_getImageData(lua_State *L);
int w_Canvas_getPixel(lua_State * L); int w_Canvas_getPixel(lua_State * L);
int w_Canvas_clear(lua_State *L); int w_Canvas_clear(lua_State *L);
int w_Canvas_getFormat(lua_State *L); int w_Canvas_getFormat(lua_State *L);
int w_Canvas_getFSAA(lua_State *L); int w_Canvas_getMSAA(lua_State *L);
extern "C" int luaopen_canvas(lua_State *L); extern "C" int luaopen_canvas(lua_State *L);
} // opengl } // opengl
@@ -349,7 +349,7 @@ int w_newCanvas(lua_State *L)
int width = luaL_optint(L, 1, instance->getWidth()); int width = luaL_optint(L, 1, instance->getWidth());
int height = luaL_optint(L, 2, instance->getHeight()); int height = luaL_optint(L, 2, instance->getHeight());
const char *str = luaL_optstring(L, 3, "normal"); const char *str = luaL_optstring(L, 3, "normal");
int fsaa = luaL_optint(L, 4, 0); int msaa = luaL_optint(L, 4, 0);
Canvas::Format format; Canvas::Format format;
if (!Canvas::getConstant(str, format)) if (!Canvas::getConstant(str, format))
@@ -357,7 +357,7 @@ int w_newCanvas(lua_State *L)
Canvas *canvas = nullptr; Canvas *canvas = nullptr;
luax_catchexcept(L, luax_catchexcept(L,
[&](){ canvas = instance->newCanvas(width, height, format, fsaa); } [&](){ canvas = instance->newCanvas(width, height, format, msaa); }
); );
if (canvas == nullptr) if (canvas == nullptr)
+2 -1
View File
@@ -42,7 +42,7 @@ WindowSettings::WindowSettings()
: fullscreen(false) : fullscreen(false)
, fstype(Window::FULLSCREEN_TYPE_NORMAL) , fstype(Window::FULLSCREEN_TYPE_NORMAL)
, vsync(true) , vsync(true)
, fsaa(0) , msaa(0)
, resizable(false) , resizable(false)
, minwidth(1) , minwidth(1)
, minheight(1) , minheight(1)
@@ -80,6 +80,7 @@ StringMap<Window::Setting, Window::SETTING_MAX_ENUM>::Entry Window::settingEntri
{"fullscreentype", SETTING_FULLSCREEN_TYPE}, {"fullscreentype", SETTING_FULLSCREEN_TYPE},
{"vsync", SETTING_VSYNC}, {"vsync", SETTING_VSYNC},
{"fsaa", SETTING_FSAA}, {"fsaa", SETTING_FSAA},
{"msaa", SETTING_MSAA},
{"resizable", SETTING_RESIZABLE}, {"resizable", SETTING_RESIZABLE},
{"minwidth", SETTING_MIN_WIDTH}, {"minwidth", SETTING_MIN_WIDTH},
{"minheight", SETTING_MIN_HEIGHT}, {"minheight", SETTING_MIN_HEIGHT},
+3 -2
View File
@@ -49,7 +49,8 @@ public:
SETTING_FULLSCREEN, SETTING_FULLSCREEN,
SETTING_FULLSCREEN_TYPE, SETTING_FULLSCREEN_TYPE,
SETTING_VSYNC, SETTING_VSYNC,
SETTING_FSAA, SETTING_FSAA, // For backward-compatibility. TODO: remove!
SETTING_MSAA,
SETTING_RESIZABLE, SETTING_RESIZABLE,
SETTING_MIN_WIDTH, SETTING_MIN_WIDTH,
SETTING_MIN_HEIGHT, SETTING_MIN_HEIGHT,
@@ -150,7 +151,7 @@ struct WindowSettings
bool fullscreen; // = false bool fullscreen; // = false
Window::FullscreenType fstype; // = FULLSCREEN_TYPE_NORMAL Window::FullscreenType fstype; // = FULLSCREEN_TYPE_NORMAL
bool vsync; // = true bool vsync; // = true
int fsaa; // = 0 int msaa; // = 0
bool resizable; // = false bool resizable; // = false
int minwidth; // = 1 int minwidth; // = 1
int minheight; // = 1 int minheight; // = 1
+20 -20
View File
@@ -139,7 +139,7 @@ bool Window::setWindow(int width, int height, WindowSettings *settings)
wflags &= testflags; wflags &= testflags;
if (sdlflags != wflags || width != curMode.width || height != curMode.height if (sdlflags != wflags || width != curMode.width || height != curMode.height
|| f.display != curdisplay || f.fsaa != curMode.settings.fsaa) || f.display != curdisplay || f.msaa != curMode.settings.msaa)
{ {
SDL_DestroyWindow(window); SDL_DestroyWindow(window);
window = 0; window = 0;
@@ -158,21 +158,21 @@ bool Window::setWindow(int width, int height, WindowSettings *settings)
created = false; created = false;
// In Windows and Linux, some GL attributes are set on window creation. // In Windows and Linux, some GL attributes are set on window creation.
setWindowGLAttributes(f.fsaa, f.sRGB); setWindowGLAttributes(f.msaa, f.sRGB);
const char *title = windowTitle.c_str(); const char *title = windowTitle.c_str();
int pos = f.centered ? centeredpos : uncenteredpos; int pos = f.centered ? centeredpos : uncenteredpos;
window = SDL_CreateWindow(title, pos, pos, width, height, sdlflags); window = SDL_CreateWindow(title, pos, pos, width, height, sdlflags);
if (!window && f.fsaa > 0) if (!window && f.msaa > 0)
{ {
// FSAA might have caused the failure, disable it and try again. // MSAA 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); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);
window = SDL_CreateWindow(title, pos, pos, width, height, sdlflags); window = SDL_CreateWindow(title, pos, pos, width, height, sdlflags);
f.fsaa = 0; f.msaa = 0;
} }
// Make sure the window keeps any previously set icon. // Make sure the window keeps any previously set icon.
@@ -194,7 +194,7 @@ bool Window::setWindow(int width, int height, WindowSettings *settings)
SDL_RaiseWindow(window); SDL_RaiseWindow(window);
if (!setContext(f.fsaa, f.vsync, f.sRGB)) if (!setContext(f.msaa, f.vsync, f.sRGB))
return false; return false;
created = true; created = true;
@@ -231,9 +231,9 @@ bool Window::onWindowResize(int width, int height)
return true; return true;
} }
bool Window::setContext(int fsaa, bool vsync, bool sRGB) bool Window::setContext(int msaa, bool vsync, bool sRGB)
{ {
// We would normally only need to recreate the context if FSAA changes or // We would normally only need to recreate the context if MSAA changes or
// SDL_GL_MakeCurrent is unsuccessful, but in Windows MakeCurrent can // SDL_GL_MakeCurrent is unsuccessful, but in Windows MakeCurrent can
// sometimes claim success but the context will actually be trashed. // sometimes claim success but the context will actually be trashed.
if (context) if (context)
@@ -243,13 +243,13 @@ bool Window::setContext(int fsaa, bool vsync, bool sRGB)
} }
// Make sure the proper attributes are set. // Make sure the proper attributes are set.
setWindowGLAttributes(fsaa, sRGB); setWindowGLAttributes(msaa, sRGB);
context = SDL_GL_CreateContext(window); context = SDL_GL_CreateContext(window);
if (!context && fsaa > 0) if (!context && msaa > 0)
{ {
// FSAA might have caused the failure, disable it and try again. // MSAA 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); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);
context = SDL_GL_CreateContext(window); context = SDL_GL_CreateContext(window);
@@ -276,26 +276,26 @@ bool Window::setContext(int fsaa, bool vsync, bool sRGB)
// Set vertical synchronization. // Set vertical synchronization.
SDL_GL_SetSwapInterval(vsync ? 1 : 0); SDL_GL_SetSwapInterval(vsync ? 1 : 0);
// Verify FSAA setting. // Verify MSAA setting.
int buffers; int buffers;
int samples; int samples;
SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &buffers); SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &buffers);
SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &samples); SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &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 && msaa) || (samples != msaa))
{ {
std::cerr << "Warning, FSAA setting failed! (Result: buffers: " << buffers << ", samples: " << samples << ")" << std::endl; std::cerr << "Warning, MSAA setting failed! (Result: buffers: " << buffers << ", samples: " << samples << ")" << std::endl;
fsaa = (buffers > 0) ? samples : 0; msaa = (buffers > 0) ? samples : 0;
} }
curMode.settings.fsaa = fsaa; curMode.settings.msaa = msaa;
curMode.settings.vsync = SDL_GL_GetSwapInterval() != 0; curMode.settings.vsync = SDL_GL_GetSwapInterval() != 0;
return true; return true;
} }
void Window::setWindowGLAttributes(int fsaa, bool /* sRGB */) const void Window::setWindowGLAttributes(int msaa, bool /* sRGB */) const
{ {
// Set GL window attributes. // Set GL window attributes.
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
@@ -306,9 +306,9 @@ void Window::setWindowGLAttributes(int fsaa, bool /* sRGB */) const
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 1); SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 1);
SDL_GL_SetAttribute(SDL_GL_RETAINED_BACKING, 0); SDL_GL_SetAttribute(SDL_GL_RETAINED_BACKING, 0);
// FSAA. // MSAA.
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, (fsaa > 0) ? 1 : 0); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, (msaa > 0) ? 1 : 0);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, (fsaa > 0) ? fsaa : 0); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, (msaa > 0) ? msaa : 0);
/* FIXME: Enable this code but make sure to try to re-create the window and /* FIXME: Enable this code but make sure to try to re-create the window and
* context with this disabled, if creation fails with it enabled. * context with this disabled, if creation fails with it enabled.
+2 -2
View File
@@ -90,8 +90,8 @@ public:
private: private:
bool setContext(int fsaa, bool vsync, bool sRGB); bool setContext(int msaa, bool vsync, bool sRGB);
void setWindowGLAttributes(int fsaa, bool sRGB) const; void setWindowGLAttributes(int msaa, bool sRGB) const;
// Update the saved window settings based on the window's actual state. // Update the saved window settings based on the window's actual state.
void updateSettings(const WindowSettings &newsettings); void updateSettings(const WindowSettings &newsettings);
+10 -3
View File
@@ -88,7 +88,7 @@ int w_setMode(lua_State *L)
settings.fullscreen = luax_boolflag(L, 3, settingName(Window::SETTING_FULLSCREEN), false); settings.fullscreen = luax_boolflag(L, 3, settingName(Window::SETTING_FULLSCREEN), false);
settings.vsync = luax_boolflag(L, 3, settingName(Window::SETTING_VSYNC), true); settings.vsync = luax_boolflag(L, 3, settingName(Window::SETTING_VSYNC), true);
settings.fsaa = luax_intflag(L, 3, settingName(Window::SETTING_FSAA), 0); settings.msaa = luax_intflag(L, 3, settingName(Window::SETTING_MSAA), 0);
settings.resizable = luax_boolflag(L, 3, settingName(Window::SETTING_RESIZABLE), false); settings.resizable = luax_boolflag(L, 3, settingName(Window::SETTING_RESIZABLE), false);
settings.minwidth = luax_intflag(L, 3, settingName(Window::SETTING_MIN_WIDTH), 1); settings.minwidth = luax_intflag(L, 3, settingName(Window::SETTING_MIN_WIDTH), 1);
settings.minheight = luax_intflag(L, 3, settingName(Window::SETTING_MIN_HEIGHT), 1); settings.minheight = luax_intflag(L, 3, settingName(Window::SETTING_MIN_HEIGHT), 1);
@@ -98,6 +98,10 @@ int w_setMode(lua_State *L)
settings.highdpi = luax_boolflag(L, 3, settingName(Window::SETTING_HIGHDPI), false); settings.highdpi = luax_boolflag(L, 3, settingName(Window::SETTING_HIGHDPI), false);
settings.sRGB = luax_boolflag(L, 3, settingName(Window::SETTING_SRGB), false); settings.sRGB = luax_boolflag(L, 3, settingName(Window::SETTING_SRGB), false);
// For backward-compatibility. TODO: remove!
int fsaa = luax_intflag(L, 3, settingName(Window::SETTING_FSAA), 0);
if (fsaa > settings.msaa) settings.msaa = fsaa;
// Display index is 1-based in Lua and 0-based internally. // Display index is 1-based in Lua and 0-based internally.
settings.display--; settings.display--;
@@ -130,8 +134,11 @@ int w_getMode(lua_State *L)
luax_pushboolean(L, settings.vsync); luax_pushboolean(L, settings.vsync);
lua_setfield(L, -2, settingName(Window::SETTING_VSYNC)); lua_setfield(L, -2, settingName(Window::SETTING_VSYNC));
lua_pushinteger(L, settings.fsaa); lua_pushinteger(L, settings.msaa);
lua_setfield(L, -2, settingName(Window::SETTING_FSAA)); lua_setfield(L, -2, settingName(Window::SETTING_MSAA));
lua_pushinteger(L, settings.msaa);
lua_setfield(L, -2, settingName(Window::SETTING_FSAA)); // For backward-compatibility. TODO: remove!
luax_pushboolean(L, settings.resizable); luax_pushboolean(L, settings.resizable);
lua_setfield(L, -2, settingName(Window::SETTING_RESIZABLE)); lua_setfield(L, -2, settingName(Window::SETTING_RESIZABLE));
+4 -2
View File
@@ -304,7 +304,8 @@ function love.init()
fullscreentype = "normal", fullscreentype = "normal",
display = 1, display = 1,
vsync = true, vsync = true,
fsaa = 0, msaa = 0,
fsaa = 0, -- For backward-compatibility. TODO: remove!
borderless = false, borderless = false,
resizable = false, resizable = false,
centered = true, centered = true,
@@ -391,7 +392,8 @@ function love.init()
fullscreen = c.window.fullscreen, fullscreen = c.window.fullscreen,
fullscreentype = c.window.fullscreentype, fullscreentype = c.window.fullscreentype,
vsync = c.window.vsync, vsync = c.window.vsync,
fsaa = c.window.fsaa, fsaa = c.window.fsaa, -- For backward-compatibility. TODO: remove!
msaa = c.window.msaa,
resizable = c.window.resizable, resizable = c.window.resizable,
minwidth = c.window.minwidth, minwidth = c.window.minwidth,
minheight = c.window.minheight, minheight = c.window.minheight,
+10 -2
View File
@@ -552,7 +552,11 @@ const unsigned char boot_lua[] =
0x3d, 0x20, 0x22, 0x6e, 0x6f, 0x72, 0x6d, 0x61, 0x6c, 0x22, 0x2c, 0x0a, 0x3d, 0x20, 0x22, 0x6e, 0x6f, 0x72, 0x6d, 0x61, 0x6c, 0x22, 0x2c, 0x0a,
0x09, 0x09, 0x09, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x20, 0x3d, 0x20, 0x31, 0x2c, 0x0a, 0x09, 0x09, 0x09, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x20, 0x3d, 0x20, 0x31, 0x2c, 0x0a,
0x09, 0x09, 0x09, 0x76, 0x73, 0x79, 0x6e, 0x63, 0x20, 0x3d, 0x20, 0x74, 0x72, 0x75, 0x65, 0x2c, 0x0a, 0x09, 0x09, 0x09, 0x76, 0x73, 0x79, 0x6e, 0x63, 0x20, 0x3d, 0x20, 0x74, 0x72, 0x75, 0x65, 0x2c, 0x0a,
0x09, 0x09, 0x09, 0x66, 0x73, 0x61, 0x61, 0x20, 0x3d, 0x20, 0x30, 0x2c, 0x0a, 0x09, 0x09, 0x09, 0x6d, 0x73, 0x61, 0x61, 0x20, 0x3d, 0x20, 0x30, 0x2c, 0x0a,
0x09, 0x09, 0x09, 0x66, 0x73, 0x61, 0x61, 0x20, 0x3d, 0x20, 0x30, 0x2c, 0x20, 0x2d, 0x2d, 0x20, 0x46, 0x6f,
0x72, 0x20, 0x62, 0x61, 0x63, 0x6b, 0x77, 0x61, 0x72, 0x64, 0x2d, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x74, 0x69,
0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x2e, 0x20, 0x54, 0x4f, 0x44, 0x4f, 0x3a, 0x20, 0x72, 0x65, 0x6d, 0x6f,
0x76, 0x65, 0x21, 0x0a,
0x09, 0x09, 0x09, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x6c, 0x65, 0x73, 0x73, 0x20, 0x3d, 0x20, 0x66, 0x61, 0x09, 0x09, 0x09, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x6c, 0x65, 0x73, 0x73, 0x20, 0x3d, 0x20, 0x66, 0x61,
0x6c, 0x73, 0x65, 0x2c, 0x0a, 0x6c, 0x73, 0x65, 0x2c, 0x0a,
0x09, 0x09, 0x09, 0x72, 0x65, 0x73, 0x69, 0x7a, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x3d, 0x20, 0x66, 0x61, 0x6c, 0x09, 0x09, 0x09, 0x72, 0x65, 0x73, 0x69, 0x7a, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x3d, 0x20, 0x66, 0x61, 0x6c,
@@ -680,7 +684,11 @@ const unsigned char boot_lua[] =
0x09, 0x09, 0x09, 0x76, 0x73, 0x79, 0x6e, 0x63, 0x20, 0x3d, 0x20, 0x63, 0x2e, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x09, 0x09, 0x09, 0x76, 0x73, 0x79, 0x6e, 0x63, 0x20, 0x3d, 0x20, 0x63, 0x2e, 0x77, 0x69, 0x6e, 0x64, 0x6f,
0x77, 0x2e, 0x76, 0x73, 0x79, 0x6e, 0x63, 0x2c, 0x0a, 0x77, 0x2e, 0x76, 0x73, 0x79, 0x6e, 0x63, 0x2c, 0x0a,
0x09, 0x09, 0x09, 0x66, 0x73, 0x61, 0x61, 0x20, 0x3d, 0x20, 0x63, 0x2e, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x09, 0x09, 0x09, 0x66, 0x73, 0x61, 0x61, 0x20, 0x3d, 0x20, 0x63, 0x2e, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77,
0x2e, 0x66, 0x73, 0x61, 0x61, 0x2c, 0x0a, 0x2e, 0x66, 0x73, 0x61, 0x61, 0x2c, 0x20, 0x2d, 0x2d, 0x20, 0x46, 0x6f, 0x72, 0x20, 0x62, 0x61, 0x63, 0x6b,
0x77, 0x61, 0x72, 0x64, 0x2d, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x74, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79,
0x2e, 0x20, 0x54, 0x4f, 0x44, 0x4f, 0x3a, 0x20, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x21, 0x0a,
0x09, 0x09, 0x09, 0x6d, 0x73, 0x61, 0x61, 0x20, 0x3d, 0x20, 0x63, 0x2e, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77,
0x2e, 0x6d, 0x73, 0x61, 0x61, 0x2c, 0x0a,
0x09, 0x09, 0x09, 0x72, 0x65, 0x73, 0x69, 0x7a, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x3d, 0x20, 0x63, 0x2e, 0x77, 0x09, 0x09, 0x09, 0x72, 0x65, 0x73, 0x69, 0x7a, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x3d, 0x20, 0x63, 0x2e, 0x77,
0x69, 0x6e, 0x64, 0x6f, 0x77, 0x2e, 0x72, 0x65, 0x73, 0x69, 0x7a, 0x61, 0x62, 0x6c, 0x65, 0x2c, 0x0a, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x2e, 0x72, 0x65, 0x73, 0x69, 0x7a, 0x61, 0x62, 0x6c, 0x65, 0x2c, 0x0a,
0x09, 0x09, 0x09, 0x6d, 0x69, 0x6e, 0x77, 0x69, 0x64, 0x74, 0x68, 0x20, 0x3d, 0x20, 0x63, 0x2e, 0x77, 0x69, 0x09, 0x09, 0x09, 0x6d, 0x69, 0x6e, 0x77, 0x69, 0x64, 0x74, 0x68, 0x20, 0x3d, 0x20, 0x63, 0x2e, 0x77, 0x69,