[Add] Added support for FSAA.
This commit is contained in:
parent
25aa3e905f
commit
a6fe5f8a2d
24
src/conf.c
24
src/conf.c
@ -87,6 +87,7 @@ void conf_setDefaults(void) {
|
|||||||
gl_screen.w = 800;
|
gl_screen.w = 800;
|
||||||
gl_screen.h = 600;
|
gl_screen.h = 600;
|
||||||
gl_screen.flags = 0;
|
gl_screen.flags = 0;
|
||||||
|
gl_screen.fsaa = 4; /* Only used if activated. */
|
||||||
/* Openal. */
|
/* Openal. */
|
||||||
nosound = 0;
|
nosound = 0;
|
||||||
/* Joystick. */
|
/* Joystick. */
|
||||||
@ -98,13 +99,16 @@ void conf_setDefaults(void) {
|
|||||||
|
|
||||||
/* Ok.. Parse a config file plox. */
|
/* Ok.. Parse a config file plox. */
|
||||||
int conf_loadConfig(const char* file) {
|
int conf_loadConfig(const char* file) {
|
||||||
int i = 0;
|
int i;
|
||||||
double d = 0.;
|
double d;
|
||||||
char* str, *mod;
|
char* str, *mod;
|
||||||
int type, key, reverse;
|
int type, key, reverse;
|
||||||
int w, h;
|
int w, h, fsaa;
|
||||||
SDLMod m;
|
SDLMod m;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
d = 0.;
|
||||||
|
|
||||||
lua_State* L = llua_newState();
|
lua_State* L = llua_newState();
|
||||||
if(luaL_dofile(L, file) == 0) {
|
if(luaL_dofile(L, file) == 0) {
|
||||||
/* Conf file exists indeed. */
|
/* Conf file exists indeed. */
|
||||||
@ -112,6 +116,8 @@ int conf_loadConfig(const char* file) {
|
|||||||
conf_loadString("data", data);
|
conf_loadString("data", data);
|
||||||
|
|
||||||
/* OpenGL properties.. */
|
/* OpenGL properties.. */
|
||||||
|
|
||||||
|
/* Dimensions. */
|
||||||
w = h = 0;
|
w = h = 0;
|
||||||
conf_loadInt("width", w);
|
conf_loadInt("width", w);
|
||||||
conf_loadInt("height", h);
|
conf_loadInt("height", h);
|
||||||
@ -124,8 +130,18 @@ int conf_loadConfig(const char* file) {
|
|||||||
gl_screen.h = h;
|
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);
|
conf_loadBool("fullscreen", i);
|
||||||
if(i) { gl_screen.flags |= OPENGL_FULLSCREEN; i = 0; }
|
if(i) { gl_screen.flags |= OPENGL_FULLSCREEN; i = 0; }
|
||||||
|
/* Anti Aliasing. */
|
||||||
conf_loadBool("aa", i);
|
conf_loadBool("aa", i);
|
||||||
if(i) {
|
if(i) {
|
||||||
gl_screen.flags |= OPENGL_AA_POINT | OPENGL_AA_LINE || OPENGL_AA_POLYGON;
|
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; }
|
if(i) { gl_screen.flags |= OPENGL_AA_LINE; i = 0; }
|
||||||
conf_loadBool("aa_polygon", i);
|
conf_loadBool("aa_polygon", i);
|
||||||
if(i) { gl_screen.flags |= OPENGL_AA_POLYGON; i = 0; }
|
if(i) { gl_screen.flags |= OPENGL_AA_POLYGON; i = 0; }
|
||||||
|
/* vsync. */
|
||||||
conf_loadBool("vsync", i);
|
conf_loadBool("vsync", i);
|
||||||
if(i) { gl_screen.flags |= OPENGL_VSYNC; i = 0; }
|
if(i) { gl_screen.flags |= OPENGL_VSYNC; i = 0; }
|
||||||
/* FPS. */
|
/* FPS. */
|
||||||
@ -165,7 +182,6 @@ int conf_loadConfig(const char* file) {
|
|||||||
lua_remove(L, -1);
|
lua_remove(L, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If there are any keybindings. Grab them. */
|
|
||||||
for(i = 0; strcmp(keybindNames[i], "end"); i++) {
|
for(i = 0; strcmp(keybindNames[i], "end"); i++) {
|
||||||
lua_getglobal(L, keybindNames[i]);
|
lua_getglobal(L, keybindNames[i]);
|
||||||
str = NULL;
|
str = NULL;
|
||||||
|
18
src/opengl.c
18
src/opengl.c
@ -872,6 +872,10 @@ int gl_init(void) {
|
|||||||
|
|
||||||
/* Set opengl flags. */
|
/* Set opengl flags. */
|
||||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); /* Ideally want double buffering. */
|
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))
|
if(gl_has(OPENGL_VSYNC))
|
||||||
SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1);
|
SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1);
|
||||||
|
|
||||||
@ -890,7 +894,7 @@ int gl_init(void) {
|
|||||||
WARN("No fullscreen modes available");
|
WARN("No fullscreen modes available");
|
||||||
if(flags & SDL_FULLSCREEN) {
|
if(flags & SDL_FULLSCREEN) {
|
||||||
WARN("Disabling fullscreen mode");
|
WARN("Disabling fullscreen mode");
|
||||||
flags ^= SDL_FULLSCREEN;
|
flags &= ~SDL_FULLSCREEN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(modes == (SDL_Rect**)-1)
|
else if(modes == (SDL_Rect**)-1)
|
||||||
@ -941,8 +945,16 @@ int gl_init(void) {
|
|||||||
|
|
||||||
/* Actually creating the screen. */
|
/* Actually creating the screen. */
|
||||||
if(SDL_SetVideoMode(SCREEN_W, SCREEN_H, gl_screen.depth, flags) == NULL) {
|
if(SDL_SetVideoMode(SCREEN_W, SCREEN_H, gl_screen.depth, flags) == NULL) {
|
||||||
ERR("Unable to create OpenGL window: %s", SDL_GetError());
|
if(gl_has(OPENGL_FSAA)) {
|
||||||
return -1;
|
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. */
|
/* Grab some info. */
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#define OPENGL_FRAG_SHADER (1<<6) /**< Fragment shaders. */
|
#define OPENGL_FRAG_SHADER (1<<6) /**< Fragment shaders. */
|
||||||
#define OPENGL_VERT_SHADER (1<<7) /**< Vertex shaders. */
|
#define OPENGL_VERT_SHADER (1<<7) /**< Vertex shaders. */
|
||||||
#define OPENGL_DIM_DEF (1<<8) /**< Dimensions specifically defined. */
|
#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. */
|
#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 flags; /**< Store different properties. */
|
||||||
int tex_max; /**< Max texture size. */
|
int tex_max; /**< Max texture size. */
|
||||||
int multitex_max; /**< Max multitexture levels. */
|
int multitex_max; /**< Max multitexture levels. */
|
||||||
|
int fsaa; /**< Full scene Anti-Aliasing level. */
|
||||||
} glInfo;
|
} glInfo;
|
||||||
extern glInfo gl_screen; /* Local structure set with gl_init etc. */
|
extern glInfo gl_screen; /* Local structure set with gl_init etc. */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user