Commit graph

24 commits

Author SHA1 Message Date
Andrei Alexeyev
513d613387
Consistent indentation: indent with tabs, align with spaces (#104)
I would've preferred to just go with 4-spaces for indent and no tabs,
but lao is a bit conservative about it. :^)

Still, this is a ton better than mixing different styles all over the
place, especially within the same file.
2018-01-12 20:26:07 +02:00
Andrei Alexeyev
485c9a8ed6
Happy New Year! 2018-01-04 19:14:31 +02:00
Andrei Alexeyev
29acd5f58a meson: intel intrinsics, various improvements 2017-12-21 03:58:54 +01:00
Andrei Alexeyev
b61ef0bffc
more strict warnings; fixed some subtle bugs 2017-11-11 19:33:44 +02:00
Andrei "Akari" Alexeyev
7c9e54a71d
update copyright and credits 2017-09-12 04:28:15 +03:00
Andrei "Akari" Alexeyev
c76e16ef70
Add some potentially useful warnings 2017-05-07 02:02:56 +03:00
Andrei "Akari" Alexeyev
dc3aaf187b use extensions for GL debugging
this allows debugging to be enabled in pre-4.3 contexts
2017-04-19 00:48:07 +03:00
Andrei "Akari" Alexeyev
fc0cbe81ba oops! 2017-04-18 23:15:40 +03:00
Andrei "Akari" Alexeyev
266c24b1fb prefer GL_ARB_draw_instanced over GL_EXT_draw_instanced 2017-04-18 23:07:59 +03:00
Andrei "Akari" Alexeyev
bb98070253 TAISEI_GL_EXT_OVERRIDES environment variable
This is a workaround for broken gl implementations that lie about the
extensions they support. Syntax: a space-separated list of extensions to
consider supported regardless of what the gl extension string reports.
Prefix an extension with - to consider it unsupported instead.

Example: disable the GL_EXT_draw_instanced extension

    TAISEI_GL_EXT_OVERRIDES="-GL_EXT_draw_instanced" taisei
2017-04-18 23:00:49 +03:00
Andrei "Akari" Alexeyev
455039edb4 Implemented a custom assert() that uses the log system if possible
Bonus: no need to include assert.h
2017-03-15 11:21:39 +02:00
Andrei "Akari" Alexeyev
3d5344de3b Renamed log_err to log_fatal 2017-03-13 18:03:51 +02:00
Andrei "Akari" Alexeyev
45da155cb2 Implemented a simple and consistent logging subsystem
The goal of this change is mainly to clean up Taisei's codebase and
improve its console output. I've been frustrated by files littered with
inconsistent printf/fprintf/warnx/errx calls for a long time, and now I
actually did something about it.

All the above functions are now considered deprecated and result in a
compile-time warning when used. Instead, the following macros should be
used:

    log_debug(format, ...)
    log_info(format, ...)
    log_warn(format, ...)
    log_err(format, ...)

As you can see, all of them have the same printf-like interface. But
they have different functionality and purpose:

    log_debug is intended for very verbose and specific information. It
    does nothing in release builds, much like assert(), so don't use
    expressions with side-effects in its arguments.

    log_info is for various status updates that are expected during
    normal operation of the program.

    log_warn is for non-critical failures or other things that may be
    worth investigating, but don't inherently render the program
    non-functional.

    log_err is for when the only choice is to give up. Like errx, it
    also terminates the program. Unlike errx, it actually calls abort(),
    which means the cleanup functions are not ran -- but on the other
    hand, you get a debuggable backtrace. However, if you're trying to
    catch programming errors, consider using assert() instead.

All of them produce output that contains a timestamp, the log level
identifier, the calling function's name, and the formatted message.

The newline at the end of the format string is not required -- no, it is
actually *prohibited*. The logging system will take care of the line
breaks by itself, don't litter the code with that shit.

Internally, the logging system is based on the SDL_RWops abstraction,
and may have multiple, configurable destinations. This makes it easily
extensible. Currently, log_debug and log_info are set to write to
stdout, log_warn and log_err to stderr, and all of them also to the file
log.txt in the Taisei config directory.

Consequently, the nasty freopen hacks we used to make Taisei write to
log files on Windows are no longer needed -- which is a very good thing,
considering they probably would break if the configdir path contains
UTF-8 characters. SDL_RWFromFile does not suffer this limitation.

As an added bonus, it's also thread-safe.

Note about printf and fprintf: in very few cases, the logging system is
not a good substitute for these functions. That is, when you care about
writing exactly to stdout/stderr and about exactly how the output looks.

However, I insist on keeping the deprecation warnings on them to not
tempt anyone to use them for logging/debugging out of habit and/or
laziness.

For this reason, I've added a tsfprintf function to util.c. It is
functionally identical to fprintf, except it returns void. Yes, the name
is deliberately ugly. Avoid using it if possible, but if you must, only
use it to write to stdout or stderr. Do not write to actual files with
it, use SDL_RWops.
2017-03-13 07:45:01 +02:00
Andrei "Akari" Alexeyev
41bf5e5ad0 unload libgl on exit, fix SDL_RWclose in progress_write() 2017-02-28 17:04:24 +02:00
Andrei "Akari" Alexeyev
3b422b803e fixed an unlikely potential segfault 2017-02-28 05:24:56 +02:00
Andrei "Akari" Alexeyev
139134fe6a Shut up a stupid GCC warning 2017-02-25 15:24:54 +02:00
Andrei "Akari" Alexeyev
0091c7aca7 Refactored the gl loader into a polyglot macro monstrosity
We no longer link to libGL by default. All GL functions are loaded
dynamically through SDL apis. Use -DLINK_TO_LIBGL to enable linking, in
which case Taisei won't try to dynamically load any of the gl functions.

Previously we used a strange inconsistent setup where some functions
were loaded dynamically and others pulled from the linked library.

We also no longer link to libGLU even if LINK_TO_LIBGL is set. The only
function we used from that library was gluPerspective. taiseigl now
provides a simple substitute via glFrustum.

The SDL2 gl headers are now used instead of the system ones, this should
be more portable. The taiseigl.h header contains generated code
partially based on content from those headers. It also doubles as a
python3 script that actually generates that code and inserts it into
itself. It scans the Taisei source tree for gl* calls and generates code
only for the functions we use, and a few manually specified ones that
are called indirectly.

Assumptions such as "linux = glx" are no longer made. SDL takes care of
platform specifics, as it should.

The GL_EXT_draw_instanced/GL_ARB_draw_instanced extension detection has
been improved. Taisei should be able to figure out which one to use
without a compile-time check, and support for the ARB version has been
actually implemented for the laser snippet loader. I've tested it on
Windows 8 with Intel drivers that don't support the EXT version but do
support the ARB one, instanced drawing works and the lasers don't lag!
OSX should benefit from this change as well, although I've not yet
tested the OSX build, beyond simply compiling it.
2017-02-25 15:24:54 +02:00
Andrei "Akari" Alexeyev
eff4e311f7 Fallback to ARB_draw_instanced if EXT_draw_instanced is not available
Also fixed some osx and mingw cross-compile warnings
2017-02-18 11:24:45 +02:00
Andrei "Akari" Alexeyev
9a7a874783 Use the standard bool type instead of that stupid enum
Also removed all of the annoying trailing tabs/whitespaces
2017-02-11 05:56:47 +02:00
Andrei "Akari" Alexeyev
3027921705 Use SDL_platform.h for more reliable and portable platform detection 2017-02-08 01:32:14 +02:00
Kyungdahm Yun
be8be15893 Support Mac OS X build 2015-09-09 08:14:41 -07:00
Andrew "Akari" Alexeyew
779ff58684 Fixed all the () prototypes, changed to (void) 2012-08-10 23:08:51 +03:00
laochailan
e09428858e laser fallback for non instancing hardware 2012-08-02 15:34:27 +02:00
laochailan
f1c0afa585 added manual opengl function loader 2012-07-29 10:59:52 +02:00