7fd59977 |
1 | /*********************************************************************** |
2 | |
3 | FONCTION : |
4 | ---------- |
5 | File OpenGl_togl_texture.c : |
6 | |
7 | |
8 | REMARQUES: |
9 | ---------- |
10 | |
11 | |
12 | HISTORIQUE DES MODIFICATIONS : |
13 | -------------------------------- |
14 | 05-08-97 : PCT ; Support texture mapping |
15 | 20-11-97 : FMN ; Ajout call_togl_inquiretexture |
16 | Ajout coupure du texture mapping |
17 | |
18 | ************************************************************************/ |
19 | |
20 | #define OCC1188 /*SAV 23/12/02 - added methods to set background image */ |
21 | |
22 | /*----------------------------------------------------------------------*/ |
23 | /* |
24 | * Includes |
25 | */ |
26 | #include <stdlib.h> |
27 | #include <string.h> |
28 | #include <OpenGl_tgl_all.hxx> |
7fd59977 |
29 | #include <OpenGl_tgl_funcs.hxx> |
30 | #include <OpenGl_TextureBox.hxx> |
31 | |
7fd59977 |
32 | #ifdef OCC1188 |
33 | #include <GL/glu.h> |
34 | #endif |
35 | |
36 | /*----------------------------------------------------------------------*/ |
37 | |
38 | int EXPORT |
39 | call_togl_create_texture |
40 | ( |
41 | int Type, |
42 | unsigned int Width, |
43 | unsigned int Height, |
44 | unsigned char *Data, |
45 | char *FileName |
46 | ) |
47 | { |
48 | if (call_togl_inquiretexture ()) |
49 | { |
50 | switch (Type) |
51 | { |
52 | case 0: |
53 | return GetTextureData1D(FileName, Width, Height, Data); |
54 | |
55 | case 1: |
56 | return GetTextureData2D(FileName, Width, Height, Data); |
57 | |
58 | case 2: |
59 | return GetTextureData2DMipMap(FileName, Width, Height, Data); |
60 | |
61 | default: |
62 | return -1; |
63 | } |
64 | } |
65 | return -1 ; |
66 | } |
67 | |
68 | /*----------------------------------------------------------------------*/ |
69 | |
70 | void EXPORT |
71 | call_togl_destroy_texture |
72 | ( |
73 | int TexId |
74 | ) |
75 | { |
76 | if (call_togl_inquiretexture ()) |
77 | FreeTexture(TexId); |
78 | } |
79 | |
80 | /*----------------------------------------------------------------------*/ |
81 | |
82 | void EXPORT |
83 | call_togl_modify_texture |
84 | ( |
85 | int TexId, |
86 | CALL_DEF_INIT_TEXTURE *init_tex |
87 | ) |
88 | { |
89 | if (call_togl_inquiretexture ()) |
90 | { |
91 | if (init_tex->doModulate) |
92 | SetTextureModulate(TexId); |
93 | else |
94 | SetTextureDecal(TexId); |
95 | |
96 | if (init_tex->doRepeat) |
97 | SetTextureRepeat(TexId); |
98 | else |
99 | SetTextureClamp(TexId); |
100 | |
101 | switch (init_tex->Mode) |
102 | { |
103 | case 0: |
104 | SetModeObject(TexId, |
105 | &init_tex->sparams[0], &init_tex->tparams[0]); |
106 | break; |
107 | |
108 | case 1: |
109 | SetModeSphere(TexId); |
110 | break; |
111 | |
112 | case 2: |
113 | SetModeEye(TexId, |
114 | &init_tex->sparams[0], &init_tex->tparams[0]); |
115 | break; |
116 | |
117 | case 3: |
118 | SetModeManual(TexId); |
119 | break; |
120 | } |
121 | |
122 | if (init_tex->doLinear) |
123 | SetRenderLinear(TexId); |
124 | else |
125 | SetRenderNearest(TexId); |
126 | |
127 | SetTexturePosition(TexId, |
128 | init_tex->sx, init_tex->sy, |
129 | init_tex->tx, init_tex->ty, |
130 | init_tex->angle); |
131 | } |
132 | } |
133 | |
134 | /*----------------------------------------------------------------------*/ |
135 | |
7fd59977 |
136 | int EXPORT |
137 | call_togl_inquiretexture () |
138 | { |
139 | #if defined(__sun) |
140 | return 1; |
141 | #else |
142 | return 1; |
143 | #endif /* SUN */ |
144 | } |