Graphics: optional MSAA

This commit is contained in:
Iliyas Jorio 2020-12-23 21:15:31 +01:00
parent b7ee239eb2
commit e7a7ca9663
4 changed files with 28 additions and 5 deletions

View File

@ -6,6 +6,7 @@
#include <iostream>
#include <memory>
#include <SDL.h>
#include <SDL_opengl.h>
using namespace Pomme;
using namespace Pomme::Graphics;
@ -100,7 +101,11 @@ CGrafPtr Pomme::Graphics::GetScreenPort(void)
return &screenPort->port;
}
void Pomme::Graphics::Init(const char* windowTitle, int windowWidth, int windowHeight)
void Pomme::Graphics::Init(
const char* windowTitle,
int windowWidth,
int windowHeight,
int msaaSamples)
{
if (0 != SDL_Init(SDL_INIT_VIDEO))
{
@ -113,6 +118,12 @@ void Pomme::Graphics::Init(const char* windowTitle, int windowWidth, int windowH
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
#endif
if (msaaSamples != 0)
{
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, msaaSamples);
}
gSDLWindow = SDL_CreateWindow(
windowTitle,
SDL_WINDOWPOS_UNDEFINED,

View File

@ -66,11 +66,11 @@ void HideCursor()
//-----------------------------------------------------------------------------
// Our own init
void Pomme::Init(const char* windowName)
void Pomme::Init(const InitParams& params)
{
Pomme::Time::Init();
Pomme::Files::Init();
Pomme::Graphics::Init(windowName, 640, 480);
Pomme::Graphics::Init(params.windowName, params.windowWidth, params.windowHeight, params.msaaSamples);
Pomme::Sound::Init();
Pomme::Input::Init();
}

View File

@ -41,7 +41,11 @@ namespace Pomme::Graphics
{ return (UInt32*) &data.data()[4 * (y * width + x)]; }
};
void Init(const char* windowTitle, int windowWidth, int windowHeight);
void Init(
const char* windowTitle,
int windowWidth,
int windowHeight,
int msaaSamples = 0);
void Shutdown();

View File

@ -9,7 +9,15 @@ namespace Pomme
virtual const char* what() const noexcept;
};
void Init(const char* applName);
struct InitParams
{
const char* windowName;
int windowWidth;
int windowHeight;
int msaaSamples;
};
void Init(const InitParams& params);
void Shutdown();
}