32#include <libFreeWRL.h>
35#if defined(HAVE_STDARG_H)
39#if defined(HAVE_ERRNO_H)
43#if !defined(HAVE_STRNLEN)
48size_t __fw_strnlen(
const char *s,
size_t maxlen)
50 const char *end = memchr(s,
'\0', maxlen);
51 return end ? (size_t) (end - s) : maxlen;
56#if !defined(HAVE_STRNDUP)
58char *__fw_strndup(
const char *s,
size_t n)
60 size_t len = strnlen(s, n);
61 char *
new = MALLOC(
char *, len + 1);
75void fw_perror(FILE *f,
const char *format, ...)
82 vfprintf(f, format, ap);
86 FPRINTF(f,
"[System error: %s]\n", strerror(e));
88 FPRINTF(f,
"[System error: %d]\n", e);
103void internalc_init(
struct tinternalc* ic)
106ic->global_strictParsing = FALSE;
107ic->global_plugin_print = FALSE;
108ic->global_occlusion_disable = FALSE;
109ic->user_request_texture_size = 0;
110ic->global_print_opengl_errors = FALSE;
111ic->global_trace_threads = FALSE;
118void fwl_set_strictParsing (
bool flag) {
119 gglobal()->internalc.global_strictParsing = flag ;
126void fwl_set_plugin_print (
bool flag) { gglobal()->internalc.global_plugin_print = flag ; }
127void fwl_set_occlusion_disable (
bool flag) { gglobal()->internalc.global_occlusion_disable = flag; }
128void fwl_set_print_opengl_errors(
bool flag) { gglobal()->internalc.global_print_opengl_errors = flag;}
129void fwl_set_trace_threads (
bool flag) { gglobal()->internalc.global_trace_threads = flag;}
131void fwl_set_texture_size (
unsigned int texture_size) {
136 tg->internalc.user_request_texture_size = texture_size;
137 rdr_caps = tg->display.rdr_caps;
142 if (texture_size > rdr_caps->system_max_texture_size)
143 rdr_caps->runtime_max_texture_size = rdr_caps->system_max_texture_size;
146 rdr_caps->runtime_max_texture_size = texture_size;
152unsigned int fwl_get_texture_size() {
155 rdr_caps = tg->display.rdr_caps;
157 return rdr_caps->runtime_max_texture_size;
159#ifdef FREEWRL_THREAD_COLORIZED
165int printf_with_colored_threads(
const char *format, ...)
169 va_start( args, format );
171 printf(
"\033[22;%im", fw_thread_color(fw_thread_id()));
173 ret = vprintf( format, args );
175 printf(
"\033[22;%im", 39 );
182int fprintf_with_colored_threads(FILE *stream,
const char *format, ...)
186 va_start( args, format );
188 fprintf(stream,
"\033[22;%im", fw_thread_color(fw_thread_id()));
190 ret = vfprintf( stream, format, args );
192 fprintf(stream,
"\033[22;%im", 39 );