From 758251edfd4820607014dea661c03e22d04d4459 Mon Sep 17 00:00:00 2001 From: janwas Date: Wed, 11 May 2005 22:40:19 +0000 Subject: [PATCH] further debug_out -> debug_printf; (comment) cleanup ogl_tex: minor formatting improvements This was SVN commit r2286. --- source/lib/lib.h | 2 +- source/lib/res/ogl_tex.cpp | 24 +++++++++------ source/lib/sysdep/win/win.cpp | 49 ++++++++++++++---------------- source/lib/sysdep/win/wposix.cpp | 4 +-- source/lib/sysdep/win/wpthread.cpp | 2 +- 5 files changed, 40 insertions(+), 41 deletions(-) diff --git a/source/lib/lib.h b/source/lib/lib.h index 3ef6518c89..3052047424 100755 --- a/source/lib/lib.h +++ b/source/lib/lib.h @@ -111,7 +111,7 @@ STMT(\ int err__ = (int)((func) & UINT_MAX);\ if(err__ < 0)\ {\ - debug_out("%s:%d: FYI: CHECK_ERR reports that a function failed."\ + debug_printf("%s:%d: FYI: CHECK_ERR reports that a function failed."\ "feel free to ignore or suppress this warning.\n", __FILE__, __LINE__);\ return err__;\ }\ diff --git a/source/lib/res/ogl_tex.cpp b/source/lib/res/ogl_tex.cpp index 5169b16e56..cbe6026f35 100755 --- a/source/lib/res/ogl_tex.cpp +++ b/source/lib/res/ogl_tex.cpp @@ -326,7 +326,7 @@ static int tex_validate(const uint line, const Tex* t) if(msg) { - debug_out("tex_validate at line %d failed: %s (error code %d)\n", line, msg, err); + debug_printf("tex_validate at line %d failed: %s (error code %d)\n", line, msg, err); debug_warn("tex_validate failed"); return err; } @@ -439,8 +439,15 @@ int tex_upload(const Handle ht, int filter_ovr, int int_fmt_ovr, int fmt_ovr) bool is_compressed = fmt_is_s3tc(fmt); bool has_mipmaps = (t->ti.flags & TEX_MIPMAPS ? true : false); - enum { auto_uncomp, auto_comp, mipped_uncomp, mipped_comp, normal_uncomp, normal_comp, broken_comp, glubuild }; - int states[4][4] = { + enum UploadState + { + auto_uncomp, auto_comp, + mipped_uncomp, mipped_comp, + normal_uncomp, normal_comp, + broken_comp, + glubuild + }; + static const int states[4][4] = { { auto_uncomp, mipped_uncomp, normal_uncomp, normal_uncomp }, { auto_comp, mipped_comp, normal_comp, normal_comp }, { broken_comp, mipped_comp, normal_comp, normal_comp }, @@ -452,7 +459,7 @@ int tex_upload(const Handle ht, int filter_ovr, int int_fmt_ovr, int fmt_ovr) if(state == auto_uncomp || state == auto_comp) { glTexParameteri(GL_TEXTURE_2D, auto_mipmap_gen, GL_TRUE); - state = (state == auto_uncomp ? normal_uncomp : normal_comp); + state = (state == auto_uncomp)? normal_uncomp : normal_comp; } if(state == broken_comp) @@ -463,17 +470,14 @@ int tex_upload(const Handle ht, int filter_ovr, int int_fmt_ovr, int fmt_ovr) if(state == glubuild) gluBuild2DMipmaps(GL_TEXTURE_2D, int_fmt, w, h, fmt, GL_UNSIGNED_BYTE, tex_data); - else - if(state == normal_uncomp) + else if(state == normal_uncomp) glTexImage2D(GL_TEXTURE_2D, 0, int_fmt, w, h, 0, fmt, GL_UNSIGNED_BYTE, tex_data); - else - if(state == normal_comp) + else if(state == normal_comp) { const GLsizei tex_size = w * h * bpp / 8; glCompressedTexImage2DARB(GL_TEXTURE_2D, 0, fmt, w, h, 0, tex_size, tex_data); } - else - if(state == mipped_uncomp || state == mipped_comp) + else if(state == mipped_uncomp || state == mipped_comp) { int level = 0; GLsizei level_w = w; diff --git a/source/lib/sysdep/win/win.cpp b/source/lib/sysdep/win/win.cpp index 3f3d0c69b8..b793600c43 100755 --- a/source/lib/sysdep/win/win.cpp +++ b/source/lib/sysdep/win/win.cpp @@ -68,10 +68,14 @@ char win_exe_dir[MAX_PATH+1]; // (they're more convenient) // - -inline void debug_check_heap() +void display_msg(const char* caption, const char* msg) { - _heapchk(); + MessageBoxA(0, msg, caption, MB_ICONEXCLAMATION); +} + +void wdisplay_msg(const wchar_t* caption, const wchar_t* msg) +{ + MessageBoxW(0, msg, caption, MB_ICONEXCLAMATION); } @@ -122,24 +126,11 @@ int pick_directory(char* path, size_t buf_size) } -void display_msg(const char* caption, const char* msg) -{ - MessageBoxA(0, msg, caption, MB_ICONEXCLAMATION); -} - -void wdisplay_msg(const wchar_t* caption, const wchar_t* msg) -{ - MessageBoxW(0, msg, caption, MB_ICONEXCLAMATION); -} - - - - - - - - - +/////////////////////////////////////////////////////////////////////////////// +// +// clipboard +// +/////////////////////////////////////////////////////////////////////////////// int clipboard_set(const wchar_t* text) { @@ -221,7 +212,7 @@ int clipboard_free(wchar_t* copy) /////////////////////////////////////////////////////////////////////////////// // -// init and shutdown mechanism +// module init and shutdown mechanism // /////////////////////////////////////////////////////////////////////////////// @@ -291,14 +282,14 @@ static void call_func_tbl(_PIFV* begin, _PIFV* end) /////////////////////////////////////////////////////////////////////////////// - - +// // locking for win-specific code +// +/////////////////////////////////////////////////////////////////////////////// + // several init functions are before _cinit. // can't guarantee POSIX static mutex init has been done by then. - - static CRITICAL_SECTION cs[NUM_CS]; static bool cs_valid; @@ -335,7 +326,10 @@ static void cs_shutdown() /////////////////////////////////////////////////////////////////////////////// - +// +// startup +// +/////////////////////////////////////////////////////////////////////////////// // entry -> pre_libc -> WinMainCRTStartup -> WinMain -> pre_main -> main // at_exit is called as the last of the atexit handlers @@ -424,6 +418,7 @@ void memory_debug_extreme_turbo_plus() } #endif + int entry() { pre_libc_init(); diff --git a/source/lib/sysdep/win/wposix.cpp b/source/lib/sysdep/win/wposix.cpp index e1e055f58e..e0271a2a06 100755 --- a/source/lib/sysdep/win/wposix.cpp +++ b/source/lib/sysdep/win/wposix.cpp @@ -75,7 +75,7 @@ int open(const char* fn, int oflag, ...) WIN_RESTORE_LAST_ERROR; #ifdef PARANOIA -debug_out("open %s = %d\n", fn, fd); +debug_printf("open %s = %d\n", fn, fd); #endif // cases when we don't want to open a second AIO-capable handle: @@ -110,7 +110,7 @@ no_aio: int close(int fd) { #ifdef PARANOIA -debug_out("close %d\n", fd); +debug_printf("close %d\n", fd); #endif assert(3 <= fd && fd < 256); diff --git a/source/lib/sysdep/win/wpthread.cpp b/source/lib/sysdep/win/wpthread.cpp index c9c7827971..a3c8630ae1 100644 --- a/source/lib/sysdep/win/wpthread.cpp +++ b/source/lib/sysdep/win/wpthread.cpp @@ -293,7 +293,7 @@ int pthread_cancel(pthread_t thread) { HANDLE hThread = pthread_t_to_HANDLE(thread); TerminateThread(hThread, 0); - debug_out("WARNING: pthread_cancel is unsafe\n"); + debug_printf("WARNING: pthread_cancel is unsafe\n"); return 0; }