]> git.cworth.org Git - vogl/blob - src/voglcore/vogl.cpp
Initial vogl checkin
[vogl] / src / voglcore / vogl.cpp
1 /**************************************************************************
2  *
3  * Copyright 2013-2014 RAD Game Tools and Valve Software
4  * Copyright 2010-2014 Rich Geldreich and Tenacious Software LLC
5  * All Rights Reserved.
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a copy
8  * of this software and associated documentation files (the "Software"), to deal
9  * in the Software without restriction, including without limitation the rights
10  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11  * copies of the Software, and to permit persons to whom the Software is
12  * furnished to do so, subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included in
15  * all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23  * THE SOFTWARE.
24  *
25  **************************************************************************/
26
27 // File: vogl.cpp
28 #include "vogl_core.h"
29 #include "vogl.h"
30 #include "vogl_dynamic_stream.h"
31 #include "vogl_buffer_stream.h"
32 #include "vogl_ryg_dxt.hpp"
33 #include "vogl_pixel_format.h"
34
35 namespace vogl
36 {
37     class vogl_global_initializer
38     {
39     public:
40         vogl_global_initializer()
41         {
42             vogl_threading_init();
43
44             vogl_enable_fail_exceptions(true);
45
46             ryg_dxt::sInitDXT();
47         }
48     };
49
50     vogl_global_initializer g_vogl_initializer;
51 } // namespace vogl
52
53 using namespace vogl;
54
55 // TODO: Move or delete these straggler funcs, they are artifacts from when voglcore was crnlib
56
57 const char *vogl_get_format_string(vogl_format fmt)
58 {
59     return pixel_format_helpers::get_vogl_format_string(fmt);
60 }
61
62 const char *vogl_get_file_type_ext(vogl_file_type file_type)
63 {
64     switch (file_type)
65     {
66         case cCRNFileTypeDDS:
67             return "dds";
68         case cCRNFileTypeCRN:
69             return "crn";
70         default:
71             break;
72     }
73     return "?";
74 }
75
76 const char *vogl_get_mip_mode_desc(vogl_mip_mode m)
77 {
78     switch (m)
79     {
80         case cCRNMipModeUseSourceOrGenerateMips:
81             return "Use source/generate if none";
82         case cCRNMipModeUseSourceMips:
83             return "Only use source MIP maps (if any)";
84         case cCRNMipModeGenerateMips:
85             return "Always generate new MIP maps";
86         case cCRNMipModeNoMips:
87             return "No MIP maps";
88         default:
89             break;
90     }
91     return "?";
92 }
93
94 const char *vogl_get_mip_mode_name(vogl_mip_mode m)
95 {
96     switch (m)
97     {
98         case cCRNMipModeUseSourceOrGenerateMips:
99             return "UseSourceOrGenerate";
100         case cCRNMipModeUseSourceMips:
101             return "UseSource";
102         case cCRNMipModeGenerateMips:
103             return "Generate";
104         case cCRNMipModeNoMips:
105             return "None";
106         default:
107             break;
108     }
109     return "?";
110 }
111
112 const char *vogl_get_mip_filter_name(vogl_mip_filter f)
113 {
114     switch (f)
115     {
116         case cCRNMipFilterBox:
117             return "box";
118         case cCRNMipFilterTent:
119             return "tent";
120         case cCRNMipFilterLanczos4:
121             return "lanczos4";
122         case cCRNMipFilterMitchell:
123             return "mitchell";
124         case cCRNMipFilterKaiser:
125             return "kaiser";
126         default:
127             break;
128     }
129     return "?";
130 }
131
132 const char *vogl_get_scale_mode_desc(vogl_scale_mode sm)
133 {
134     switch (sm)
135     {
136         case cCRNSMDisabled:
137             return "disabled";
138         case cCRNSMAbsolute:
139             return "absolute";
140         case cCRNSMRelative:
141             return "relative";
142         case cCRNSMLowerPow2:
143             return "lowerpow2";
144         case cCRNSMNearestPow2:
145             return "nearestpow2";
146         case cCRNSMNextPow2:
147             return "nextpow2";
148         default:
149             break;
150     }
151     return "?";
152 }
153