[Add] Added support for FSAA.

This commit is contained in:
Allanis 2014-03-06 04:59:02 +00:00
parent 25aa3e905f
commit a6fe5f8a2d
3 changed files with 37 additions and 7 deletions

View File

@ -87,6 +87,7 @@ void conf_setDefaults(void) {
gl_screen.w = 800;
gl_screen.h = 600;
gl_screen.flags = 0;
gl_screen.fsaa = 4; /* Only used if activated. */
/* Openal. */
nosound = 0;
/* Joystick. */
@ -98,13 +99,16 @@ void conf_setDefaults(void) {
/* Ok.. Parse a config file plox. */
int conf_loadConfig(const char* file) {
int i = 0;
double d = 0.;
int i;
double d;
char* str, *mod;
int type, key, reverse;
int w, h;
int w, h, fsaa;
SDLMod m;
i = 0;
d = 0.;
lua_State* L = llua_newState();
if(luaL_dofile(L, file) == 0) {
/* Conf file exists indeed. */
@ -112,6 +116,8 @@ int conf_loadConfig(const char* file) {
conf_loadString("data", data);
/* OpenGL properties.. */
/* Dimensions. */
w = h = 0;
conf_loadInt("width", w);
conf_loadInt("height", h);
@ -124,8 +130,18 @@ int conf_loadConfig(const char* file) {
gl_screen.h = h;
}
/* FSAA */
fsaa = 0;
conf_loadInt("fsaa", fsaa);
if(fsaa > 0) {
gl_screen.flags |= OPENGL_FSAA;
gl_screen.fsaa = fsaa;
}
/* Fullscreen. */
conf_loadBool("fullscreen", i);
if(i) { gl_screen.flags |= OPENGL_FULLSCREEN; i = 0; }
/* Anti Aliasing. */
conf_loadBool("aa", i);
if(i) {
gl_screen.flags |= OPENGL_AA_POINT | OPENGL_AA_LINE || OPENGL_AA_POLYGON;
@ -137,6 +153,7 @@ int conf_loadConfig(const char* file) {
if(i) { gl_screen.flags |= OPENGL_AA_LINE; i = 0; }
conf_loadBool("aa_polygon", i);
if(i) { gl_screen.flags |= OPENGL_AA_POLYGON; i = 0; }
/* vsync. */
conf_loadBool("vsync", i);
if(i) { gl_screen.flags |= OPENGL_VSYNC; i = 0; }
/* FPS. */
@ -165,7 +182,6 @@ int conf_loadConfig(const char* file) {
lua_remove(L, -1);
}
/* If there are any keybindings. Grab them. */
for(i = 0; strcmp(keybindNames[i], "end"); i++) {
lua_getglobal(L, keybindNames[i]);
str = NULL;

View File

@ -872,6 +872,10 @@ int gl_init(void) {
/* Set opengl flags. */
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); /* Ideally want double buffering. */
if(gl_has(OPENGL_FSAA)) {
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, gl_screen.fsaa);
}
if(gl_has(OPENGL_VSYNC))
SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1);
@ -890,7 +894,7 @@ int gl_init(void) {
WARN("No fullscreen modes available");
if(flags & SDL_FULLSCREEN) {
WARN("Disabling fullscreen mode");
flags ^= SDL_FULLSCREEN;
flags &= ~SDL_FULLSCREEN;
}
}
else if(modes == (SDL_Rect**)-1)
@ -941,8 +945,16 @@ int gl_init(void) {
/* Actually creating the screen. */
if(SDL_SetVideoMode(SCREEN_W, SCREEN_H, gl_screen.depth, flags) == NULL) {
ERR("Unable to create OpenGL window: %s", SDL_GetError());
return -1;
if(gl_has(OPENGL_FSAA)) {
LOG("Disablin FSAA.");
gl_screen.flags &= ~OPENGL_FSAA;
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);
}
if(SDL_SetVideoMode(SCREEN_W, SCREEN_H, gl_screen.depth, flags)==NULL) {
ERR("Unable to create OpenGL window: %s", SDL_GetError());
return -1;
}
}
/* Grab some info. */

View File

@ -29,6 +29,7 @@
#define OPENGL_FRAG_SHADER (1<<6) /**< Fragment shaders. */
#define OPENGL_VERT_SHADER (1<<7) /**< Vertex shaders. */
#define OPENGL_DIM_DEF (1<<8) /**< Dimensions specifically defined. */
#define OPENGL_FSAA (1<<9) /**< Full screen Anti Aliasing. */
#define gl_has(f) (gl_screen.flags & (f)) /**< Check for the flag. */
/**
@ -47,6 +48,7 @@ typedef struct glInfo_ {
int flags; /**< Store different properties. */
int tex_max; /**< Max texture size. */
int multitex_max; /**< Max multitexture levels. */
int fsaa; /**< Full scene Anti-Aliasing level. */
} glInfo;
extern glInfo gl_screen; /* Local structure set with gl_init etc. */