root/OpenSceneGraph/trunk/src/osgWrappers/deprecated-dotosg/osg/Texture.cpp @ 13041

Revision 13041, 19.8 kB (checked in by robert, 2 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1#include <osg/Texture>
2#include <osg/Notify>
3#include <osg/io_utils>
4
5#include <osgDB/Registry>
6#include <osgDB/Input>
7#include <osgDB/Output>
8
9#include <stdlib.h>
10#include <string.h>
11
12using namespace osg;
13using namespace osgDB;
14
15// forward declare functions to use later.
16bool Texture_readLocalData(Object& obj, Input& fr);
17bool Texture_writeLocalData(const Object& obj, Output& fw);
18
19bool Texture_matchWrapStr(const char* str,Texture::WrapMode& wrap);
20const char* Texture_getWrapStr(Texture::WrapMode wrap);
21bool Texture_matchFilterStr(const char* str,Texture::FilterMode& filter);
22const char* Texture_getFilterStr(Texture::FilterMode filter);
23bool Texture_matchInternalFormatModeStr(const char* str,Texture::InternalFormatMode& mode);
24const char* Texture_getInternalFormatModeStr(Texture::InternalFormatMode mode);
25bool Texture_matchInternalFormatStr(const char* str,int& value);
26const char* Texture_getInternalFormatStr(int value);
27bool Texture_matchSourceTypeStr(const char* str,int& value);
28const char* Texture_getSourceTypeStr(int value);
29bool Texture_matchShadowCompareFuncStr(const char* str,Texture::ShadowCompareFunc& value);
30const char* Texture_getShadowCompareFuncStr(Texture::ShadowCompareFunc value);
31bool Texture_matchShadowTextureModeStr(const char* str,Texture::ShadowTextureMode& value);
32const char* Texture_getShadowTextureModeStr(Texture::ShadowTextureMode value);
33
34// register the read and write functions with the osgDB::Registry.
35REGISTER_DOTOSGWRAPPER(Texture)
36(
37    0,
38    "TextureBase",
39    "Object StateAttribute TextureBase",
40    &Texture_readLocalData,
41    &Texture_writeLocalData
42);
43
44
45bool Texture_readLocalData(Object& obj, Input& fr)
46{
47    bool iteratorAdvanced = false;
48
49    Texture& texture = static_cast<Texture&>(obj);
50
51    Texture::WrapMode wrap;
52    if (fr[0].matchWord("wrap_s") && Texture_matchWrapStr(fr[1].getStr(),wrap))
53    {
54        texture.setWrap(Texture::WRAP_S,wrap);
55        fr+=2;
56        iteratorAdvanced = true;
57    }
58
59    if (fr[0].matchWord("wrap_t") && Texture_matchWrapStr(fr[1].getStr(),wrap))
60    {
61        texture.setWrap(Texture::WRAP_T,wrap);
62        fr+=2;
63        iteratorAdvanced = true;
64    }
65
66    if (fr[0].matchWord("wrap_r") && Texture_matchWrapStr(fr[1].getStr(),wrap))
67    {
68        texture.setWrap(Texture::WRAP_R,wrap);
69        fr+=2;
70        iteratorAdvanced = true;
71    }
72
73    Texture::FilterMode filter;
74    if (fr[0].matchWord("min_filter") && Texture_matchFilterStr(fr[1].getStr(),filter))
75    {
76        texture.setFilter(Texture::MIN_FILTER,filter);
77        fr+=2;
78        iteratorAdvanced = true;
79    }
80
81    if (fr[0].matchWord("mag_filter") && Texture_matchFilterStr(fr[1].getStr(),filter))
82    {
83        texture.setFilter(Texture::MAG_FILTER,filter);
84        fr+=2;
85        iteratorAdvanced = true;
86    }
87
88    if (fr.matchSequence("maxAnisotropy %f"))
89    {
90        float anis=1.0f;
91        fr[1].getFloat(anis);
92        texture.setMaxAnisotropy(anis);
93        fr +=2 ;
94        iteratorAdvanced = true;
95    }
96
97    if (fr.matchSequence("borderColor %f %f %f %f"))
98    {
99        Vec4 color;
100        fr[1].getFloat(color[0]);
101        fr[2].getFloat(color[1]);
102        fr[3].getFloat(color[2]);
103        fr[4].getFloat(color[3]);
104        texture.setBorderColor(color);
105        fr +=5 ;
106        iteratorAdvanced = true;
107    }
108
109    if (fr.matchSequence("borderWidth %i"))
110    {
111        int width=0;
112        fr[1].getInt(width);
113        texture.setBorderWidth(width);
114        fr +=2 ;
115        iteratorAdvanced = true;
116    }
117
118    if (fr[0].matchWord("useHardwareMipMapGeneration"))
119    {
120        if (fr[1].matchWord("TRUE"))
121        {
122            texture.setUseHardwareMipMapGeneration(true);
123            fr +=2 ;
124            iteratorAdvanced = true;
125        }
126        else if (fr[1].matchWord("FALSE"))
127        {
128            texture.setUseHardwareMipMapGeneration(false);
129            fr +=2 ;
130            iteratorAdvanced = true;
131        }
132    }
133
134    if (fr[0].matchWord("unRefImageDataAfterApply"))
135    {
136        if (fr[1].matchWord("TRUE"))
137        {
138            texture.setUnRefImageDataAfterApply(true);
139            fr +=2 ;
140            iteratorAdvanced = true;
141        }
142        else if (fr[1].matchWord("FALSE"))
143        {
144            texture.setUnRefImageDataAfterApply(false);
145            fr +=2 ;
146            iteratorAdvanced = true;
147        }
148    }
149
150
151    Texture::InternalFormatMode mode;
152    if (fr[0].matchWord("internalFormatMode") && Texture_matchInternalFormatModeStr(fr[1].getStr(),mode))
153    {
154        texture.setInternalFormatMode(mode);
155        fr+=2;
156        iteratorAdvanced = true;
157    }
158
159    if (fr[0].matchWord("internalFormat"))
160    {
161        int value;
162        if (Texture_matchInternalFormatStr(fr[1].getStr(),value) || fr[1].getInt(value))
163        {
164            texture.setInternalFormat(value);
165            fr+=2;
166            iteratorAdvanced = true;
167        }
168    }
169
170    if (fr[0].matchWord("sourceFormat"))
171    {
172        int value;
173        if (Texture_matchInternalFormatStr(fr[1].getStr(),value) || fr[1].getInt(value))
174        {
175            texture.setSourceFormat(value);
176            fr+=2;
177            iteratorAdvanced = true;
178        }
179    }
180
181    if (fr[0].matchWord("sourceType"))
182    {
183        int value;
184        if (Texture_matchInternalFormatStr(fr[1].getStr(),value) || fr[1].getInt(value))
185        {
186            texture.setSourceType(value);
187            fr+=2;
188            iteratorAdvanced = true;
189        }
190    }
191
192    if (fr[0].matchWord("resizeNonPowerOfTwo"))
193    {
194        if (fr[1].matchWord("TRUE"))
195        {
196            texture.setResizeNonPowerOfTwoHint(true);
197            fr +=2 ;
198            iteratorAdvanced = true;
199        }
200        else if (fr[1].matchWord("FALSE"))
201        {
202            texture.setResizeNonPowerOfTwoHint(false);
203            fr +=2 ;
204            iteratorAdvanced = true;
205        }
206    }
207
208    if (fr[0].matchWord("shadowComparison"))
209    {
210        if (fr[1].matchWord("TRUE"))
211        {
212            texture.setShadowComparison(true);
213            fr +=2 ;
214            iteratorAdvanced = true;
215        }
216        else if (fr[1].matchWord("FALSE"))
217        {
218            texture.setShadowComparison(false);
219            fr +=2 ;
220            iteratorAdvanced = true;
221        }
222    }
223
224    if (fr[0].matchWord("shadowCompareFunc"))
225    {
226        Texture::ShadowCompareFunc value;
227        if (Texture_matchShadowCompareFuncStr(fr[1].getStr(),value))
228        {
229            texture.setShadowCompareFunc(value);
230            fr+=2;
231            iteratorAdvanced = true;
232        }
233    }
234
235    if (fr[0].matchWord("shadowTextureMode"))
236    {
237        Texture::ShadowTextureMode value;
238        if (Texture_matchShadowTextureModeStr(fr[1].getStr(),value))
239        {
240            texture.setShadowTextureMode(value);
241            fr+=2;
242            iteratorAdvanced = true;
243        }
244    }
245
246    return iteratorAdvanced;
247}
248
249
250bool Texture_writeLocalData(const Object& obj, Output& fw)
251{
252    const Texture& texture = static_cast<const Texture&>(obj);
253
254    fw.indent() << "wrap_s " << Texture_getWrapStr(texture.getWrap(Texture::WRAP_S)) << std::endl;
255    fw.indent() << "wrap_t " << Texture_getWrapStr(texture.getWrap(Texture::WRAP_T)) << std::endl;
256    fw.indent() << "wrap_r " << Texture_getWrapStr(texture.getWrap(Texture::WRAP_R)) << std::endl;
257
258    fw.indent() << "min_filter " << Texture_getFilterStr(texture.getFilter(Texture::MIN_FILTER)) << std::endl;
259    fw.indent() << "mag_filter " << Texture_getFilterStr(texture.getFilter(Texture::MAG_FILTER)) << std::endl;
260    fw.indent() << "maxAnisotropy " << texture.getMaxAnisotropy() << std::endl;
261
262    fw.indent() << "borderColor " << texture.getBorderColor() << std::endl;
263    fw.indent() << "borderWidth " << texture.getBorderWidth() << std::endl;
264
265    fw.indent() << "useHardwareMipMapGeneration "<< (texture.getUseHardwareMipMapGeneration()?"TRUE":"FALSE") << std::endl;
266    fw.indent() << "unRefImageDataAfterApply "<< (texture.getUnRefImageDataAfterApply()?"TRUE":"FALSE") << std::endl;
267
268    fw.indent() << "internalFormatMode " << Texture_getInternalFormatModeStr(texture.getInternalFormatMode()) << std::endl;
269    if (texture.getInternalFormatMode()==Texture::USE_USER_DEFINED_FORMAT)
270    {
271
272        const char* str = Texture_getInternalFormatStr(texture.getInternalFormat());
273
274        if (str) fw.indent() << "internalFormat " << str << std::endl;
275        else fw.indent() << "internalFormat " << texture.getInternalFormat() << std::endl;
276
277    }
278
279    if (texture.getSourceFormat())
280    {
281        const char* str = Texture_getInternalFormatStr(texture.getSourceFormat());
282
283        if (str) fw.indent() << "sourceFormat " << str << std::endl;
284        else fw.indent() << "sourceFormat " << texture.getSourceFormat() << std::endl;
285
286    }
287
288    if (texture.getSourceType())
289    {
290        const char* str = Texture_getSourceTypeStr(texture.getSourceType());
291
292        if (str) fw.indent() << "sourceType " << str << std::endl;
293        else fw.indent() << "sourceType " << texture.getSourceType() << std::endl;
294
295    }
296
297    fw.indent() << "resizeNonPowerOfTwo "<< (texture.getResizeNonPowerOfTwoHint()?"TRUE":"FALSE") << std::endl;
298
299    fw.indent() << "shadowComparison "<< (texture.getShadowComparison()?"TRUE":"FALSE") << std::endl;
300
301    fw.indent() << "shadowCompareFunc " << Texture_getShadowCompareFuncStr(texture.getShadowCompareFunc()) << std::endl;
302
303    fw.indent() << "shadowTextureMode " << Texture_getShadowTextureModeStr(texture.getShadowTextureMode()) << std::endl;
304
305    return true;
306}
307
308
309bool Texture_matchWrapStr(const char* str,Texture::WrapMode& wrap)
310{
311    if (strcmp(str,"CLAMP")==0) wrap = Texture::CLAMP;
312    else if (strcmp(str,"CLAMP_TO_EDGE")==0) wrap = Texture::CLAMP_TO_EDGE;
313    else if (strcmp(str,"CLAMP_TO_BORDER")==0) wrap = Texture::CLAMP_TO_BORDER;
314    else if (strcmp(str,"REPEAT")==0) wrap = Texture::REPEAT;
315    else if (strcmp(str,"MIRROR")==0) wrap = Texture::MIRROR;
316    else return false;
317    return true;
318}
319
320
321const char* Texture_getWrapStr(Texture::WrapMode wrap)
322{
323    switch(wrap)
324    {
325        case(Texture::CLAMP): return "CLAMP";
326        case(Texture::CLAMP_TO_EDGE): return "CLAMP_TO_EDGE";
327        case(Texture::CLAMP_TO_BORDER): return "CLAMP_TO_BORDER";
328        case(Texture::REPEAT): return "REPEAT";
329        case(Texture::MIRROR): return "MIRROR";
330    }
331    return "";
332}
333
334
335bool Texture_matchFilterStr(const char* str,Texture::FilterMode& filter)
336{
337    if (strcmp(str,"NEAREST")==0) filter = Texture::NEAREST;
338    else if (strcmp(str,"LINEAR")==0) filter = Texture::LINEAR;
339    else if (strcmp(str,"NEAREST_MIPMAP_NEAREST")==0) filter = Texture::NEAREST_MIPMAP_NEAREST;
340    else if (strcmp(str,"LINEAR_MIPMAP_NEAREST")==0) filter = Texture::LINEAR_MIPMAP_NEAREST;
341    else if (strcmp(str,"NEAREST_MIPMAP_LINEAR")==0) filter = Texture::NEAREST_MIPMAP_LINEAR;
342    else if (strcmp(str,"LINEAR_MIPMAP_LINEAR")==0) filter = Texture::LINEAR_MIPMAP_LINEAR;
343    else if (strcmp(str,"ANISOTROPIC")==0) filter = Texture::LINEAR;
344    else return false;
345    return true;
346}
347
348
349const char* Texture_getFilterStr(Texture::FilterMode filter)
350{
351    switch(filter)
352    {
353        case(Texture::NEAREST): return "NEAREST";
354        case(Texture::LINEAR): return "LINEAR";
355        case(Texture::NEAREST_MIPMAP_NEAREST): return "NEAREST_MIPMAP_NEAREST";
356        case(Texture::LINEAR_MIPMAP_NEAREST): return "LINEAR_MIPMAP_NEAREST";
357        case(Texture::NEAREST_MIPMAP_LINEAR): return "NEAREST_MIPMAP_LINEAR";
358        case(Texture::LINEAR_MIPMAP_LINEAR): return "LINEAR_MIPMAP_LINEAR";
359    }
360    return "";
361}
362
363bool Texture_matchInternalFormatModeStr(const char* str,Texture::InternalFormatMode& mode)
364{
365    if (strcmp(str,"USE_IMAGE_DATA_FORMAT")==0)          mode = Texture::USE_IMAGE_DATA_FORMAT;
366    else if (strcmp(str,"USE_USER_DEFINED_FORMAT")==0)   mode = Texture::USE_USER_DEFINED_FORMAT;
367    else if (strcmp(str,"USE_ARB_COMPRESSION")==0)       mode = Texture::USE_ARB_COMPRESSION;
368    else if (strcmp(str,"USE_S3TC_DXT1_COMPRESSION")==0) mode = Texture::USE_S3TC_DXT1_COMPRESSION;
369    else if (strcmp(str,"USE_S3TC_DXT3_COMPRESSION")==0) mode = Texture::USE_S3TC_DXT3_COMPRESSION;
370    else if (strcmp(str,"USE_S3TC_DXT5_COMPRESSION")==0) mode = Texture::USE_S3TC_DXT5_COMPRESSION;
371    else if (strcmp(str,"USE_PVRTC_2BPP_COMPRESSION")==0) mode = Texture::USE_PVRTC_2BPP_COMPRESSION;
372    else if (strcmp(str,"USE_PVRTC_4BPP_COMPRESSION")==0) mode = Texture::USE_PVRTC_4BPP_COMPRESSION;
373    else if (strcmp(str,"USE_ETC_COMPRESSION")==0)        mode = Texture::USE_ETC_COMPRESSION;
374    else if (strcmp(str,"USE_RGTC1_COMPRESSION")==0)      mode = Texture::USE_RGTC1_COMPRESSION;
375    else if (strcmp(str,"USE_RGTC2_COMPRESSION")==0)      mode = Texture::USE_RGTC2_COMPRESSION;
376    else if (strcmp(str,"USE_S3TC_DXT1c_COMPRESSION")==0) mode = Texture::USE_S3TC_DXT1c_COMPRESSION;
377    else if (strcmp(str,"USE_S3TC_DXT1a_COMPRESSION")==0) mode = Texture::USE_S3TC_DXT1a_COMPRESSION;
378    else return false;
379    return true;
380}
381
382
383const char* Texture_getInternalFormatModeStr(Texture::InternalFormatMode mode)
384{
385    switch(mode)
386    {
387        case(Texture::USE_IMAGE_DATA_FORMAT):        return "USE_IMAGE_DATA_FORMAT";
388        case(Texture::USE_USER_DEFINED_FORMAT):      return "USE_USER_DEFINED_FORMAT";
389        case(Texture::USE_ARB_COMPRESSION):          return "USE_ARB_COMPRESSION";
390        case(Texture::USE_S3TC_DXT1_COMPRESSION):    return "USE_S3TC_DXT1_COMPRESSION";
391        case(Texture::USE_S3TC_DXT3_COMPRESSION):    return "USE_S3TC_DXT3_COMPRESSION";
392        case(Texture::USE_S3TC_DXT5_COMPRESSION):    return "USE_S3TC_DXT5_COMPRESSION";
393        case(Texture::USE_PVRTC_2BPP_COMPRESSION):   return "USE_PVRTC_2BPP_COMPRESSION";
394        case(Texture::USE_PVRTC_4BPP_COMPRESSION):   return "USE_PVRTC_4BPP_COMPRESSION";
395        case(Texture::USE_ETC_COMPRESSION):          return "USE_ETC_COMPRESSION";
396        case(Texture::USE_RGTC1_COMPRESSION):        return "USE_RGTC1_COMPRESSION";
397        case(Texture::USE_RGTC2_COMPRESSION):        return "USE_RGTC2_COMPRESSION";
398        case(Texture::USE_S3TC_DXT1c_COMPRESSION):   return "USE_S3TC_DXT1c_COMPRESSION";
399        case(Texture::USE_S3TC_DXT1a_COMPRESSION):   return "USE_S3TC_DXT1a_COMPRESSION";
400    }
401    return "";
402}
403
404
405bool Texture_matchInternalFormatStr(const char* str,int& value)
406{
407    if (     strcmp(str,"GL_INTENSITY")==0) value = GL_INTENSITY;
408    else if (strcmp(str,"GL_LUMINANCE")==0) value = GL_LUMINANCE;
409    else if (strcmp(str,"GL_ALPHA")==0) value = GL_ALPHA;
410    else if (strcmp(str,"GL_LUMINANCE_ALPHA")==0) value = GL_LUMINANCE_ALPHA;
411    else if (strcmp(str,"GL_RGB")==0) value = GL_RGB;
412    else if (strcmp(str,"GL_RGBA")==0) value = GL_RGBA;
413    else if (strcmp(str,"GL_COMPRESSED_ALPHA_ARB")==0) value = GL_COMPRESSED_ALPHA_ARB;
414    else if (strcmp(str,"GL_COMPRESSED_LUMINANCE_ARB")==0) value = GL_COMPRESSED_LUMINANCE_ARB;
415    else if (strcmp(str,"GL_COMPRESSED_INTENSITY_ARB")==0) value = GL_COMPRESSED_INTENSITY_ARB;
416    else if (strcmp(str,"GL_COMPRESSED_LUMINANCE_ALPHA_ARB")==0) value = GL_COMPRESSED_LUMINANCE_ALPHA_ARB;
417    else if (strcmp(str,"GL_COMPRESSED_RGB_ARB")==0) value = GL_COMPRESSED_RGB_ARB;
418    else if (strcmp(str,"GL_COMPRESSED_RGBA_ARB")==0) value = GL_COMPRESSED_RGBA_ARB;
419    else if (strcmp(str,"GL_COMPRESSED_RGB_S3TC_DXT1_EXT")==0) value = GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
420    else if (strcmp(str,"GL_COMPRESSED_RGBA_S3TC_DXT1_EXT")==0) value = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
421    else if (strcmp(str,"GL_COMPRESSED_RGBA_S3TC_DXT3_EXT")==0) value = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
422    else if (strcmp(str,"GL_COMPRESSED_RGBA_S3TC_DXT5_EXT")==0) value = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
423    else
424    {
425        osgDB::Field::FieldType type = osgDB::Field::calculateFieldType(str);
426        if (type==osgDB::Field::INTEGER)
427        {
428            value = atoi(str);
429            return true;
430        }
431        else
432        {
433            return false;
434        }
435    }
436
437    return true;
438}
439
440
441const char* Texture_getInternalFormatStr(int value)
442{
443    switch(value)
444    {
445        case(GL_INTENSITY): return "GL_INTENSITY";
446        case(GL_LUMINANCE): return "GL_LUMINANCE";
447        case(GL_ALPHA): return "GL_ALPHA";
448        case(GL_LUMINANCE_ALPHA): return "GL_LUMINANCE_ALPHA";
449        case(GL_RGB): return "GL_RGB";
450        case(GL_RGBA): return "GL_RGBA";
451        case(GL_COMPRESSED_ALPHA_ARB): return "GL_COMPRESSED_ALPHA_ARB";
452        case(GL_COMPRESSED_LUMINANCE_ARB): return "GL_COMPRESSED_LUMINANCE_ARB";
453        case(GL_COMPRESSED_INTENSITY_ARB): return "GL_COMPRESSED_INTENSITY_ARB";
454        case(GL_COMPRESSED_LUMINANCE_ALPHA_ARB): return "GL_COMPRESSED_LUMINANCE_ALPHA_ARB";
455        case(GL_COMPRESSED_RGB_ARB): return "GL_COMPRESSED_RGB_ARB";
456        case(GL_COMPRESSED_RGBA_ARB): return "GL_COMPRESSED_RGBA_ARB";
457        case(GL_COMPRESSED_RGB_S3TC_DXT1_EXT): return "GL_COMPRESSED_RGB_S3TC_DXT1_EXT";
458        case(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT): return "GL_COMPRESSED_RGBA_S3TC_DXT1_EXT";
459        case(GL_COMPRESSED_RGBA_S3TC_DXT3_EXT): return "GL_COMPRESSED_RGBA_S3TC_DXT3_EXT";
460        case(GL_COMPRESSED_RGBA_S3TC_DXT5_EXT): return "GL_COMPRESSED_RGBA_S3TC_DXT5_EXT";
461    }
462    return NULL;
463}
464
465bool Texture_matchSourceTypeStr(const char* str,int& value)
466{
467    if (     strcmp(str,"GL_BYTE")==0) value = GL_BYTE;
468    else if (strcmp(str,"GL_SHORT")==0) value = GL_SHORT;
469    else if (strcmp(str,"GL_INT")==0) value = GL_INT;
470    else if (strcmp(str,"GL_UNSIGNED_BYTE")==0) value = GL_UNSIGNED_BYTE;
471    else if (strcmp(str,"GL_UNSIGNED_SHORT")==0) value = GL_UNSIGNED_SHORT;
472    else if (strcmp(str,"GL_UNSIGNED_INT")==0) value = GL_UNSIGNED_INT;
473    else if (strcmp(str,"GL_FLOAT")==0) value = GL_FLOAT;
474    else
475    {
476        osgDB::Field::FieldType type = osgDB::Field::calculateFieldType(str);
477        if (type==osgDB::Field::INTEGER)
478        {
479            value = atoi(str);
480            return true;
481        }
482        else
483        {
484            return false;
485        }
486    }
487
488    return true;
489}
490
491const char* Texture_getSourceTypeStr(int value)
492{
493    switch(value)
494    {
495        case(GL_BYTE): return "GL_BYTE";
496        case(GL_SHORT): return "GL_SHORT";
497        case(GL_INT): return "GL_INT";
498        case(GL_FLOAT): return "GL_FLOAT";
499        case(GL_UNSIGNED_BYTE): return "GL_UNSIGNED_BYTE";
500        case(GL_UNSIGNED_SHORT): return "GL_UNSIGNED_SHORT";
501        case(GL_UNSIGNED_INT): return "GL_UNSIGNED_INT";
502    }
503    return NULL;
504}
505
506bool Texture_matchShadowCompareFuncStr(const char* str, Texture::ShadowCompareFunc& value)
507{
508    if (     strcmp(str,"GL_NEVER")==0) value = Texture::NEVER;
509    else if (strcmp(str,"GL_LESS")==0) value = Texture::LESS;
510    else if (strcmp(str,"GL_EQUAL")==0) value = Texture::EQUAL;
511    else if (strcmp(str,"GL_LEQUAL")==0) value = Texture::LEQUAL;
512    else if (strcmp(str,"GL_GREATER")==0) value = Texture::GREATER;
513    else if (strcmp(str,"GL_NOTEQUAL")==0) value = Texture::NOTEQUAL;
514    else if (strcmp(str,"GL_GEQUAL")==0) value = Texture::GEQUAL;
515    else if (strcmp(str,"GL_ALWAYS")==0) value = Texture::ALWAYS;
516    else return false;
517
518    return true;
519}
520
521const char* Texture_getShadowCompareFuncStr(Texture::ShadowCompareFunc value)
522{
523    switch(value)
524    {
525        case(Texture::NEVER): return "GL_NEVER";
526        case(Texture::LESS): return "GL_LESS";
527        case(Texture::EQUAL): return "GL_EQUAL";
528        case(Texture::LEQUAL): return "GL_LEQUAL";
529        case(Texture::GREATER): return "GL_GREATER";
530        case(Texture::NOTEQUAL): return "GL_NOTEQUAL";
531        case(Texture::GEQUAL): return "GL_GEQUAL";
532        case(Texture::ALWAYS): return "GL_ALWAYS";
533    }
534    return NULL;
535}
536
537bool Texture_matchShadowTextureModeStr(const char* str,Texture::ShadowTextureMode& value)
538{
539    if (     strcmp(str,"GL_LUMINANCE")==0) value = Texture::LUMINANCE;
540    else if (strcmp(str,"GL_INTENSITY")==0) value = Texture::INTENSITY;
541    else if (strcmp(str,"GL_ALPHA")==0) value = Texture::ALPHA;
542    else return false;
543
544    return true;
545}
546
547const char* Texture_getShadowTextureModeStr(Texture::ShadowTextureMode value)
548{
549    switch(value)
550    {
551        case( Texture::LUMINANCE ): return "GL_LUMINANCE";
552        case( Texture::INTENSITY ): return "GL_INTENSITY";
553        case( Texture::ALPHA ): return "GL_ALPHA";
554    }
555    return NULL;
556}
Note: See TracBrowser for help on using the browser.