1. rude
  2. love

Commits

Alex Szpakowski  committed 8c3108a

Removed direct OpenGL calls in the SDL Window module

  • Participants
  • Parent commits 130db8d
  • Branches default

Comments (0)

Files changed (4)

File src/modules/graphics/opengl/Graphics.cpp

View file
 
 	initializeContext();
 
+	// Make sure antialiasing works when set elsewhere
+	glEnable(GL_MULTISAMPLE);
+
 	// Enable blending
 	glEnable(GL_BLEND);
 
 	glEnable(GL_POINT_SMOOTH);
 	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
 	glEnable(GL_TEXTURE_2D);
 	setActiveTextureUnit(0);

File src/modules/graphics/opengl/wrap_Graphics.cpp

View file
 		{
 			instance = new Graphics();
 		}
-		catch(Exception &e)
+		catch (love::Exception &e)
 		{
 			return luaL_error(L, e.what());
 		}

File src/modules/window/sdl/Window.cpp

View file
 // SDL
 #include <SDL.h>
 
-// OpenGL
-#include <SDL/SDL_opengl.h>
-
 // LOVE
 #include "common/config.h"
 #include "Window.h"
 Window::Window()
 	: windowTitle("")
 	, created(false)
-	, mouseVisible(true)
 {
 	// Window should be centered.
 	SDL_putenv(const_cast<char *>("SDL_VIDEO_CENTERED=center"));
 
 	if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
-		throw Exception(SDL_GetError());
+		throw love::Exception(SDL_GetError());
 }
 
 Window::~Window()
 	SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 1);
 
 	// FSAA
-	if (fsaa > 0)
-	{
-		SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
-		SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, fsaa);
-	}
+	SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, (fsaa > 0) ? 1 : 0);
+	SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, (fsaa > 0) ? fsaa : 0);
 
 	// Fullscreen?
 	Uint32 sdlflags = fullscreen ? (SDL_OPENGL | SDL_FULLSCREEN) : SDL_OPENGL;
 		bool failed = true;
 		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_MULTISAMPLEBUFFERS, 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)
 		{
 		height = videoinfo->current_h;
 	}
 
-	if (fsaa > 0)
-		glEnable(GL_MULTISAMPLE);
+	int buffers;
+	int samples;
 
-	GLint buffers;
-	GLint samples;
-
-	glGetIntegerv(GL_SAMPLE_BUFFERS_ARB, &buffers);
-	glGetIntegerv(GL_SAMPLES_ARB, &samples);
+	SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &buffers);
+	SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &samples);
 
 	// Don't fail because of this, but issue a warning.
 	if ((!buffers && fsaa) || (samples != fsaa))
 	{
-		std::cerr << "Warning, quality setting failed! (Result: buffers: " << buffers << ", samples: " << samples << ")" << std::endl;
-		fsaa = !buffers ? 0 : samples;
+		std::cerr << "Warning, FSAA setting failed! (Result: buffers: " << buffers << ", samples: " << samples << ")" << std::endl;
+		fsaa = (buffers > 0) ? samples : 0;
 	}
 
 	// Get the actual vsync status

File src/modules/window/sdl/Window.h

View file
 		int fsaa;
 	} currentMode;
 	bool created;
-	bool mouseVisible;
 }; // Window
 
 } // sdl