GLES1RICE: Update from upstream
[mupen64plus-pandora.git] / source / gles2glide64 / src / GlideHQ / TxDbg.cpp
... / ...
CommitLineData
1/*
2 * Texture Filtering
3 * Version: 1.0
4 *
5 * Copyright (C) 2007 Hiroshi Morii All Rights Reserved.
6 * Email koolsmoky(at)users.sourceforge.net
7 * Web http://www.3dfxzone.it/koolsmoky
8 *
9 * this is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2, or (at your option)
12 * any later version.
13 *
14 * this is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with GNU Make; see the file COPYING. If not, write to
21 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24#define DBG_LEVEL 80
25
26#include "TxDbg.h"
27#include <string.h>
28#include <stdarg.h>
29#include <string>
30
31#define _GLIBCXX_HAVE_BROKEN_VSWPRINTF 1
32
33TxDbg::TxDbg()
34{
35 _level = DBG_LEVEL;
36
37 if (!_dbgfile)
38#ifdef GHQCHK
39 _dbgfile = fopen("ghqchk.txt", "w");
40#else
41 _dbgfile = fopen("glidehq.dbg", "w");
42#endif
43}
44
45TxDbg::~TxDbg()
46{
47 if (_dbgfile) {
48 fclose(_dbgfile);
49 _dbgfile = 0;
50 }
51
52 _level = DBG_LEVEL;
53}
54
55void
56TxDbg::output(const int level, const wchar_t *format, ...)
57{
58#ifdef _GLIBCXX_HAVE_BROKEN_VSWPRINTF
59 wchar_t newformat[4095];
60#else
61 std::wstring newformat;
62#endif
63
64 va_list args;
65
66 if (level > _level)
67 return;
68
69 va_start(args, format);
70#ifdef _GLIBCXX_HAVE_BROKEN_VSWPRINTF
71 swprintf(newformat, L"%d:\t", level);
72 wcscat(newformat, format);
73 vfwprintf(_dbgfile, newformat, args);
74#else
75 newformat = std::to_wstring(level) + L":\t" + format;
76 vfwprintf(_dbgfile, newformat.c_str(), args);
77#endif
78 fflush(_dbgfile);
79#ifdef GHQCHK
80 //vwprintf(newformat, args);
81 vwprintf(newformat.c_str(), args);
82#endif
83 va_end(args);
84}