ARB
Main Page
Namespaces
Classes
Files
File List
File Members
RNA3D
RNA3D_Textures.cxx
Go to the documentation of this file.
1
#include "
RNA3D_GlobalHeader.hxx
"
2
#include "
RNA3D_Global.hxx
"
3
#include "
RNA3D_Textures.hxx
"
4
#include "
RNA3D_OpenGLEngine.hxx
"
5
6
#include <string>
7
#include <iostream>
8
#include <stdlib.h>
9
10
#include <
arbdb.h
>
11
12
13
using namespace
std
;
14
15
Texture2D::Texture2D() {
16
}
17
18
Texture2D::~Texture2D() {
19
}
20
21
static
char
*
GetImageFile
(
int
ImageId) {
22
const
char
*imageName =
NULp
;
23
24
switch
(ImageId) {
25
case
CIRCLE
: imageName =
"Circle.png"
;
break
;
26
case
DIAMOND
: imageName =
"Diamond.png"
;
break
;
27
case
POLYGON
: imageName =
"Polygon.png"
;
break
;
28
case
STAR
: imageName =
"Star.png"
;
break
;
29
case
RECTANGLE
: imageName =
"Rectangle.png"
;
break
;
30
case
RECTANGLE_ROUND
: imageName =
"RectangleRound.png"
;
break
;
31
case
STAR_SMOOTH
: imageName =
"StarSmooth.png"
;
break
;
32
case
CONE_UP
: imageName =
"ConeUp.png"
;
break
;
33
case
CONE_DOWN
: imageName =
"ConeDown.png"
;
break
;
34
case
CROSS
: imageName =
"Cross.png"
;
break
;
35
case
QUESTION
: imageName =
"Question.png"
;
break
;
36
case
DANGER
: imageName =
"Danger.png"
;
break
;
37
case
HEXAGON
: imageName =
"Hexagon.png"
;
break
;
38
case
LETTER_A
: imageName =
"LetterA.png"
;
break
;
39
case
LETTER_G
: imageName =
"LetterG.png"
;
break
;
40
case
LETTER_C
: imageName =
"LetterC.png"
;
break
;
41
case
LETTER_U
: imageName =
"LetterU.png"
;
break
;
42
}
43
44
if
(!imageName) {
45
throw
string
(
GBS_global_string
(
"Illegal image id %i"
, ImageId));
46
}
47
48
char
*fname =
GB_lib_file
(
false
,
"rna3d/images/"
, imageName);
49
if
(!fname) {
50
throw
string
(
"File not found: "
)+imageName;
51
}
52
return
fname;
53
}
54
55
// Load Bitmaps And Convert To Textures
56
void
Texture2D::LoadGLTextures() {
57
58
for
(
int
i = 0; i <
SHAPE_MAX
; i++)
59
{
60
char
*ImageFile =
GetImageFile
(i);
61
pngInfo
info
;
62
63
// Using pngLoadAndBind to set texture parameters automatically.
64
texture[i] =
pngBind
(ImageFile,
GLPNG_NOMIPMAP
,
GLPNG_ALPHA
, &info, GL_CLAMP, GL_NEAREST, GL_NEAREST);
65
66
if
(texture[i] == 0) {
67
throw
string
(
GBS_global_string
(
"Error loading %s"
, ImageFile));
68
}
69
70
if
(!
RNA3D
->
bPointSpritesSupported
) {
71
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
72
}
73
else
{
74
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
75
}
76
77
#ifdef DEBUG
78
cout<<ImageFile<<
" : Size = "
<<info.
Width
<<
" x "
<<info.
Height
<<
", Depth = "
79
<<info.
Depth
<<
", Alpha = "
<<info.
Alpha
<<endl;
80
#endif
81
82
free(ImageFile);
83
}
84
85
}
LETTER_G
Definition:
RNA3D_Textures.hxx:17
string
return string(buffer, length)
GetImageFile
static char * GetImageFile(int ImageId)
Definition:
RNA3D_Textures.cxx:21
LETTER_C
Definition:
RNA3D_Textures.hxx:18
GBS_global_string
const char * GBS_global_string(const char *templat,...)
Definition:
arb_msg.cxx:203
std
STL namespace.
GLPNG_NOMIPMAP
#define GLPNG_NOMIPMAP
Definition:
glpng.h:58
arbdb.h
STAR_SMOOTH
Definition:
RNA3D_Textures.hxx:9
CONE_UP
Definition:
RNA3D_Textures.hxx:10
pngBind
unsigned int APIENTRY pngBind(const char *filename, int mipmap, int trans, pngInfo *info, int wrapst, int minfilter, int magfilter)
Definition:
glpng.c:569
STAR
Definition:
RNA3D_Textures.hxx:6
LETTER_A
Definition:
RNA3D_Textures.hxx:16
RECTANGLE_ROUND
Definition:
RNA3D_Textures.hxx:8
CROSS
Definition:
RNA3D_Textures.hxx:12
RNA3D_Textures.hxx
pngInfo::Alpha
unsigned int Alpha
Definition:
glpng.h:80
pngInfo::Height
unsigned int Height
Definition:
glpng.h:78
HEXAGON
Definition:
RNA3D_Textures.hxx:15
DIAMOND
Definition:
RNA3D_Textures.hxx:4
GLPNG_ALPHA
#define GLPNG_ALPHA
Definition:
glpng.h:64
pngInfo
Definition:
glpng.h:76
GB_lib_file
char * GB_lib_file(bool warn_when_not_found, const char *libprefix, const char *filename)
Definition:
adfile.cxx:198
DANGER
Definition:
RNA3D_Textures.hxx:14
CIRCLE
Definition:
RNA3D_Textures.hxx:3
RECTANGLE
Definition:
RNA3D_Textures.hxx:7
pngInfo::Width
unsigned int Width
Definition:
glpng.h:77
RNA3D_OpenGLEngine.hxx
pngInfo::Depth
unsigned int Depth
Definition:
glpng.h:79
POLYGON
Definition:
RNA3D_Textures.hxx:5
RNA3D_Global::bPointSpritesSupported
bool bPointSpritesSupported
Definition:
RNA3D_Global.hxx:120
NULp
#define NULp
Definition:
cxxforward.h:116
RNA3D_GlobalHeader.hxx
QUESTION
Definition:
RNA3D_Textures.hxx:13
RNA3D
RNA3D_Global * RNA3D
Definition:
RNA3D_OpenGLEngine.cxx:22
SHAPE_MAX
Definition:
RNA3D_Textures.hxx:20
LETTER_U
Definition:
RNA3D_Textures.hxx:19
info
static int info[maxsites+1]
Definition:
arb_dnarates.cxx:57
CONE_DOWN
Definition:
RNA3D_Textures.hxx:11
RNA3D_Global.hxx
Generated by
1.8.8