FreeWRL / FreeX3D 4.3.0
Textures.h
1/*
2
3
4Screen snapshot.
5
6*/
7
8/****************************************************************************
9 This file is part of the FreeWRL/FreeX3D Distribution.
10
11 Copyright 2009 CRC Canada. (http://www.crc.gc.ca)
12
13 FreeWRL/FreeX3D is free software: you can redistribute it and/or modify
14 it under the terms of the GNU Lesser Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 FreeWRL/FreeX3D is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with FreeWRL/FreeX3D. If not, see <http://www.gnu.org/licenses/>.
25****************************************************************************/
26
27
28#ifndef __FREEWRL_TEXTURES_H__
29#define __FREEWRL_TEXTURES_H__
30
31#define TEXTURE_INVALID 0
32
33/* Texture loading table :
34 newer Texture handling procedures
35 each texture has this kind of structure
36*/
38 struct X3D_Node* scenegraphNode;
39 int nodeType;
40 int status;
41 int hasAlpha;
42 GLuint OpenGLTexture;
43 GLuint ifbobuffer; //in case this texture is used as an fbo render target
44 GLuint idepthbuffer; //in case this texture is used as an fbo render target
45 int frames;
46 char *filename;
47 int x;
48 int y;
49 int z;
50 int tiles[3]; //when using TILED emulator for texture3D, nx, ny tiles, and resampled z
51 unsigned char *texdata;
52 GLint repeatSTR[3]; //repeatR - used for non-builtin-Texture3D ie shader will manually apply this rule
53 GLint magFilter; //needed in TEX3D frag shader for Z
54 int textureNumber;
55 int channels; //number of original image file image channels/components 0=no texture default, 1=Intensity 2=IntensityAlpha 3=RGB 4=RGBA
56 int no_gl; //if 1, skips move_to_opengl and keeps the texdata
57};
58typedef struct textureTableIndexStruct textureTableIndexStruct_s;
59textureTableIndexStruct_s* getTableTableFromTextureNode(struct X3D_Node* textureNode);
60
61//extern textureTableIndexStruct_s* loadThisTexture;
62//extern GLuint defaultBlankTexture;
63
64/* Vertex Array to Vertex Buffer Object migration - used to have a passedInGenTex()
65 when we had (for instance) Cone textures - put this as part of the VBO. */
66
67textureTableIndexStruct_s *getTableIndex(int indx);
68
70 GLfloat *pre_canned_textureCoords;
71 GLint TC_size; /* glTexCoordPointer - size param */
72 GLenum TC_type; /* glTexCoordPointer - type param */
73 GLsizei TC_stride; /* glTexCoordPointer - stride param */
74 GLvoid *TC_pointer; /* glTexCoordPointer - pointer to first element */
75 void *next; //next textureVertexInfo for MultitextureCoordinate
76 GLint VBO;
77};
78
79/* for texIsloaded structure */
80#define TEX_NOTLOADED 0
81#define TEX_LOADING 1
82#define TEX_READ 2
83#define TEX_NEEDSBINDING 3
84#define TEX_LOADED 4
85#define TEX_UNSQUASHED 5
86#define TEX_NOTFOUND 6
87
88const char *texst(int num);
89
90
91/* do we have to do textures?? */
92#define HAVETODOTEXTURES (gglobal()->RenderFuncs.textureStackTop != 0)
93
94void textureCoord_send(struct textureVertexInfo *tex);
95void textureTransform_start();
96void textureTransform_end();
97
98struct X3D_Node *getThis_textureTransform();
99
100extern int fwl_isTextureLoaded(int texno);
101extern int isTextureAlpha(int n);
102extern int display_status;
103int is_cubeMap(struct X3D_Node* node);
104
105/* appearance does material depending on last texture depth */
106#define NOTEXTURE 0
107#define TEXTURE_NO_ALPHA 1
108#define TEXTURE_ALPHA 2
109
110// OLDCODE void loadTextureNode (struct X3D_Node *node, struct multiTexParams *param);
111void loadTextureNode (struct X3D_Node *node, void *params);
112void bind_image(int type, struct Uni_String *parenturl, struct Multi_String url,
113 GLuint *texture_num,
114 int repeatS,
115 int repeatT,
116 void *param);
117
118/* other function protos */
119void init_multitexture_handling(void);
120
121
122//RenderTextures.c
123void clear_textureUnit_used();
124int next_textureUnit();
125int bind_or_share_next_textureUnit(const int samplerType, GLint texture);
126
127#endif /* __FREEWRL_TEXTURES_H__ */