36#include <libFreeWRL.h>
38#include "../vrml_parser/Structs.h"
39#include "../main/headers.h"
40#include "../opengl/OpenGL_Utils.h"
41#include "../scenegraph/Component_Shape.h"
42#include "../scenegraph/RenderFuncs.h"
43#include "../scenegraph/LinearAlgebra.h"
44#include "../scenegraph/Polyrep.h"
51int multitex_source[2];
58 GLint texture_in_unit[32];
59 GLint sampler_type[32];
63void *RenderTextures_constructor(){
68void RenderTextures_init(
struct tRenderTextures *t){
69 t->prv = RenderTextures_constructor();
71 ppRenderTextures p = (ppRenderTextures)t->prv;
73 t->textureParameterStack = (
void *)p->textureParameterStack;
74 p->textureUnit_used = 0;
78unsigned char* generate_checkerboard_texture_data_RGBA(
int size8,
int divisions8,
int black255,
int white255,
int opacity255) {
80 int checkerSize = texSize / divisions8;
81 unsigned char* texdata = malloc(texSize * texSize * 4);
83 memset(texdata, 0, texSize * texSize * 4);
84 unsigned char black[4];
85 unsigned char white[4];
87 black[0] = black[1] = black[2] = black255; black[3] = opacity255;
88 white[0] = white[1] = white[2] = white255; white[3] = opacity255;
89 for (
int i = 0; i < texSize; ++i) {
90 for (
int j = 0; j < texSize; ++j) {
91 int ii = i / checkerSize;
92 int jj = j / checkerSize;
93 int evenii = (ii % 2) == 0;
94 int evenjj = (jj % 2) == 0;
96 int drawWhite = evenii == evenjj;
100 int location = (i * texSize + j) * 4;
101 memcpy(&texdata[location], pixel, 4);
106static GLuint checkerboard_texture2D = 0;
107static GLuint checkerboard_textureCube = 0;
108static unsigned char* checkerboard_data = NULL;
109static int checkerboard_size = 64;
110void compile_checkerboard_texture2D() {
111 if (checkerboard_texture2D < 1) {
112 PRINT_GL_ERROR_IF_ANY(
"compile_checkerboard_texture2D start");
114 int texSize = checkerboard_size;
119 unsigned char* texdata = generate_checkerboard_texture_data_RGBA(texSize, divisions, black, white, opacity);
120 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
121 glGenTextures(1, &checkerboard_texture2D);
122 glBindTexture(GL_TEXTURE_2D, checkerboard_texture2D);
123 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
124 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
125 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
126 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
128 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texSize, texSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, texdata);
130 checkerboard_data = texdata;
131 PRINT_GL_ERROR_IF_ANY(
"compile_checkerboard_texture2D end");
135void compile_checkerboard_textureCube() {
136 if (checkerboard_textureCube < 1) {
137 compile_checkerboard_texture2D();
138 PRINT_GL_ERROR_IF_ANY(
"compile_checkerboard_textureCube start");
140 glActiveTexture(GL_TEXTURE0);
141 PRINT_GL_ERROR_IF_ANY(
"compile_checkerboard_textureCube very early");
142 glGenTextures(1, &checkerboard_textureCube);
143 glBindTexture(GL_TEXTURE_CUBE_MAP, checkerboard_textureCube);
144 PRINT_GL_ERROR_IF_ANY(
"compile_checkerboard_textureCube early");
146 PRINT_GL_ERROR_IF_ANY(
"compile_checkerboard_textureCube middle");
147 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
148 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
149 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
150 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
151 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
154 for (
int face = 0; face < 6; face++) {
155 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X+face, 0, GL_RGBA, checkerboard_size, checkerboard_size, 0, GL_RGBA, GL_UNSIGNED_BYTE, checkerboard_data);
165 PRINT_GL_ERROR_IF_ANY(
"compile_checkerboard_textureCube face");
168 PRINT_GL_ERROR_IF_ANY(
"compile_checkerboard_textureCube end");
177GLuint getCheckerboardTexture2D() {
178 compile_checkerboard_texture2D();
179 return checkerboard_texture2D;
181GLuint getCheckerboardTextureCube() {
182 compile_checkerboard_textureCube();
183 return checkerboard_textureCube;
185void clear_textureUnit_used(){
188 ttglobal tg = gglobal();
189 p = (ppRenderTextures)tg->RenderTextures.prv;
191 for (
int i = 0; i < 16; i++) {
192 glBindTextureUnit(i, 0);
196 p->textureUnit_used = 0;
198int next_textureUnit(){
200 ttglobal tg = gglobal();
201 p = (ppRenderTextures)tg->RenderTextures.prv;
202 p->textureUnit_used++;
203 return p->textureUnit_used -1;
206int textureUnit_used(){
208 ttglobal tg = gglobal();
209 p = (ppRenderTextures)tg->RenderTextures.prv;
210 return p->textureUnit_used;
212int bind_or_share_next_textureUnit(
const int samplerType, GLint texture){
221 ttglobal tg = gglobal();
222 p = (ppRenderTextures)tg->RenderTextures.prv;
226 for(
int i=0;i<p->textureUnit_used;i++){
227 if(p->texture_in_unit[i] == texture && samplerType == p->sampler_type[i]){
233 unit = next_textureUnit();
234 p->texture_in_unit[unit] = texture;
235 p->sampler_type[unit] = samplerType;
236 glBindTextureUnit(unit, 0);
237 glActiveTexture(GL_TEXTURE0+unit);
238 glBindTexture(samplerType,texture);
251static int setActiveTexture (
int c, GLint *texUnit, GLint *texMode)
254 ttglobal tg = gglobal();
255 p = (ppRenderTextures)tg->RenderTextures.prv;
266 if (getAppearanceProperties()->currentShaderProperties != NULL) {
267 printf (
"setActiveTexture %d, boundTextureStack is %d, sending to uniform %d\n",c,
268 tg->RenderFuncs.boundTextureStack[c],
269 getAppearanceProperties()->currentShaderProperties->TextureUnit[c]);
271 printf (
"setActiveTexture %d, boundTextureStack is %d, sending to uniform [NULL--No Shader]\n",c,
272 tg->RenderFuncs.boundTextureStack[c]);
280 if (p->textureParameterStack[c].multitex_mode[0] == INT_ID_UNDEFINED) {
283 printf (
"setActiveTexture - simple texture NOT a MultiTexture \n");
291 printf (
"setActiveTexture - firsttexture \n");
293 texMode[c]= GL_MODULATE;
300 if (p->textureParameterStack[c].multitex_source[0] != MTMODE_OFF) {
309 PRINT_GL_ERROR_IF_ANY(
"");
316void textureTransform_end(
void) {
318 ttglobal tg = gglobal();
321 printf (
"start of textureTransform_end\n");
327 FW_GL_MATRIX_MODE(GL_TEXTURE);
329 fw_glGetInteger(GL_TEXTURE_STACK_DEPTH, &ntransforms);
331 for (j = 0; j < ntransforms; j++)
334 tg->RenderFuncs.textureStackTop = 0;
335 tg->RenderFuncs.texturenode = NULL;
336 FW_GL_MATRIX_MODE(GL_MODELVIEW);
340void do_textureTransform0 (
struct X3D_Node *textureNode,
int ttnum,
char **tmap,
int *igen,
int *parameter_n,
float *parameter) {
342 *igen = TCGT_REGULAR;
344 if (textureNode->_nodeType == NODE_TextureTransform) {
347 *tmap = ttt->mapping ? ttt->mapping->strptr : NULL;
351 FW_GL_TRANSLATE_F(-((ttt->center).c[0]), -((ttt->center).c[1]), 0);
352 FW_GL_SCALE_F(((ttt->scale).c[0]), ((ttt->scale).c[1]), 1);
353 FW_GL_ROTATE_RADIANS(ttt->rotation, 0, 0, 1);
354 FW_GL_TRANSLATE_F(((ttt->center).c[0]), ((ttt->center).c[1]), 0);
355 FW_GL_TRANSLATE_F(((ttt->translation).c[0]), ((ttt->translation).c[1]), 0);
356 }
else if (textureNode->_nodeType == NODE_TextureTransformGenerator) {
358 *tmap = ttg->mapping ? ttg->mapping->strptr : NULL;
359 *igen = findFieldInARR((ttg)->mode->strptr, TEXTURECOORDINATEGENERATOR, TEXTURECOORDINATEGENERATOR_COUNT);
363 }
else if (textureNode->_nodeType == NODE_MultiTextureTransform) {
366 if (ttnum < mtt->textureTransform.n) {
369 if (ttt->_nodeType == NODE_TextureTransform) {
370 *tmap = ttt->mapping ? ttt->mapping->strptr : NULL;
373 FW_GL_TRANSLATE_F(-((ttt->center).c[0]), -((ttt->center).c[1]), 0);
374 FW_GL_SCALE_F(((ttt->scale).c[0]), ((ttt->scale).c[1]), 1);
375 FW_GL_ROTATE_RADIANS(ttt->rotation, 0, 0, 1);
376 FW_GL_TRANSLATE_F(((ttt->center).c[0]), ((ttt->center).c[1]), 0);
377 FW_GL_TRANSLATE_F(((ttt->translation).c[0]), ((ttt->translation).c[1]), 0);
378 }
else if(ttt->_nodeType == NODE_TextureTransformGenerator){
380 *tmap = ttg->mapping ? ttg->mapping->strptr : NULL;
381 *igen = findFieldInARR((ttg)->mode->strptr, TEXTURECOORDINATEGENERATOR, TEXTURECOORDINATEGENERATOR_COUNT);
383 *parameter_n = ttg->parameter.n;
384 memcpy(parameter, ttg->parameter.p, ttg->parameter.n *
sizeof(
float));
391 printf (
"MultiTextureTransform expected a textureTransform for texture %d, got %d %s \n",
392 ttnum, ttt->_nodeType, stringNodeType(ttt->_nodeType));
399 printf (
"not enough transforms in MultiTextureTransform -will fill with Identity matrix\n");
403 }
else if (textureNode->_nodeType == NODE_TextureTransform3D) {
406 *tmap = ttt->mapping ? ttt->mapping->strptr : NULL;
409 FW_GL_TRANSLATE_F(-((ttt->center).c[0]),-((ttt->center).c[1]), -((ttt->center).c[2]));
410 FW_GL_SCALE_F(((ttt->scale).c[0]),((ttt->scale).c[1]),((ttt->scale).c[2]));
411 FW_GL_ROTATE_RADIANS(ttt->rotation.c[3], ttt->rotation.c[0],ttt->rotation.c[1],ttt->rotation.c[2]);
412 FW_GL_TRANSLATE_F(((ttt->center).c[0]),((ttt->center).c[1]), ((ttt->center).c[2]));
413 FW_GL_TRANSLATE_F(((ttt->translation).c[0]), ((ttt->translation).c[1]), ((ttt->translation).c[2]));
414 }
else if (textureNode->_nodeType == NODE_TextureTransformMatrix3D) {
419 *tmap = ttt->mapping ? ttt->mapping->strptr : NULL;
422 mat[i] = (
double)ttt->matrix.c[i];
423 FW_GL_SETDOUBLEV(GL_TEXTURE_MATRIX,mat);
427 printf (
"expected a textureTransform node, got %d %s\n",textureNode->_nodeType, stringNodeType(textureNode->_nodeType));
439int isMultiTexture(
struct X3D_Node *node){
441 if(node && node->_nodeType == NODE_MultiTexture)
448int is_cubeMap(
struct X3D_Node* node) {
451 switch (node->_nodeType) {
452 case NODE_ComposedCubeMapTexture:
453 case NODE_ImageCubeMapTexture:
454 case NODE_GeneratedCubeMapTexture:
461int is_or_has_cubeMap(
struct X3D_Node* node) {
463 if (!node)
return ret;
467 if (node->_nodeType == NODE_MultiTexture) {
469 p = mnode->texture.p;
470 n = mnode->texture.n;
472 for (
int i = 0; i < n; i++) {
473 switch (p[i]->_nodeType) {
474 case NODE_ComposedCubeMapTexture:
475 case NODE_ImageCubeMapTexture:
476 case NODE_GeneratedCubeMapTexture:
485int is_or_has_Tex3D(
struct X3D_Node* node);
486char* trans_name_from_texture_mapping(
char* mmap,
char* scratch) {
490 memset(scratch, 0, 10);
492 if (mmap[0] ==
'T') scratch[0] = mmap[1];
493 else if (mmap[2] ==
'T') scratch[0] = mmap[3];
494 else strcpy(scratch, mmap);
498char* coord_name_from_texture_mapping(
char* mmap,
char* scratch) {
502 memset(scratch, 0, 10);
504 if (mmap[0] ==
'C') scratch[0] = mmap[1];
505 else if (mmap[2] ==
'C') scratch[0] = mmap[3];
506 else strcpy(scratch, mmap);
510int find_in_char_list(
char *name,
char** list,
int n) {
512 if(list && n && name)
514 if (strcmp(name, list[i]) == 0) {
521int find_or_make_combo_by_index(
int itrans,
int icoord,
int combo_list[][2],
int* ncombo) {
524 for (
int i = 0; i < *ncombo; i++) {
526 if (combo_list[i][0] == icoord && combo_list[i][1] == itrans) {
534 combo_list[iret][0] = icoord;
535 combo_list[iret][1] = itrans;
541int find_or_make_combo(
char* trans_name,
char* coord_name,
char** coord_name_list,
int ntcoord,
542 char** trans_name_list,
int ntrans,
int combo_list[][2],
int* ncombo) {
543 int itrans = find_in_char_list(trans_name, trans_name_list, ntrans);
544 int icoord = find_in_char_list(coord_name, coord_name_list, ntcoord);
545 int iret = find_or_make_combo_by_index(itrans, icoord, combo_list, ncombo);
564int next_or_last_sampler_compatible_trans(
int lasttrans,
int ntrans,
int jsamplr,
int* igen) {
567 for (
int i = 0; i < lasttrans + 1; i++){
568 if (jsamplr == 0 && igen[i] == TCGT_REGULAR) itrans = i;
569 if (jsamplr == 2 && igen[i] == TCGT_REGULAR) itrans = i;
570 if (jsamplr == 1 && igen[i] != TCGT_REGULAR) itrans = i;
573 for (
int i = lasttrans + 1; i < ntrans; i++) {
574 if (jsamplr == 1 && igen[i] != TCGT_REGULAR) {
578 if (jsamplr == 0 && igen[i] == TCGT_REGULAR) {
582 if (jsamplr == 2 && igen[i] == TCGT_REGULAR) {
591int getTextureDescriptors(
struct X3D_Node* textureNode,
int* textures,
int* modes,
int* sources,
int* funcs,
int* width,
int* height,
int* samplr);
592GLint tunit(
int index);
593void textureTransform_start() {
595 int i, isStrict, isMulti, isIdentity, ntransforms[2];
596 GLint texUnit[MAX_MULTITEXTURE];
598 GLint texMode[MAX_MULTITEXTURE];
599 s_shader_capabilities_t* me;
601 int itmap[MAX_MULTITEXTURE];
602 int igen[MAX_MULTITEXTURE];
607 int icombo[MAX_MULTITEXTURE + 2][2];
608 int immap[MAX_MULTITEXTURE];
611 char* tmap[MAX_MULTITEXTURE];
613 ttglobal tg = gglobal();
614 p = (ppRenderTextures)tg->RenderTextures.prv;
615 tnode = tg->RenderFuncs.texturenode;
617 me = getAppearanceProperties()->currentShaderProperties;
622 printf(
"passedInGenTex, using passed in genTex, textureStackTop %d\n", tg->RenderFuncs.textureStackTop);
623 printf(
"passedInGenTex, cubeFace %d\n", getAppearanceProperties()->cubeFace);
626 FW_GL_MATRIX_MODE(GL_TEXTURE);
627 if (oldway)
for (
int i = 0; i < MAX_MULTITEXTURE; i++) immap[i] = 0;
628 for (
int i = 0; i < MAX_MULTITEXTURE + 2; i++) {
629 icombo[i][0] = icombo[i][1] = -1;
640 if (!tg->RenderFuncs.shapenode) {
643 glUniform1i(me->cmap[0], icombo[0][0]);
644 glUniform1i(me->tmap[0], icombo[0][1]);
645 glUniform1i(me->ntexcombo, ncombo);
668 POSSIBLE_PROTO_EXPANSION(
struct X3D_Node*, sn->geometry, gn);
672 if (gn && gn->_intern) {
674 if (gr->itype == 2) {
677 ntcoord = prep->ntcoord;
681 else if (gr->itype == 3) {
685 static char* mrallmap[] = {
"0",
"1",
"2",
"3" };
686 static char* nullmap[4] = { NULL,NULL,NULL,NULL };
687 static char* usemap[4];
688 memcpy(usemap, nullmap, 4 *
sizeof(
char*));
690 for (
int i = 0; i < ntcoord; i++)
691 ccmap[i] = mrallmap[i];
698 matprop = getAppearanceProperties();
700 for (
int i = 0; i < MAX_MULTITEXTURE; i++) {
702 igen[i] = TCGT_REGULAR;
704 struct X3D_Node* tt = getThis_textureTransform();
706 int ntrans_specified = 0;
708 switch (tt->_nodeType) {
709 case NODE_TextureTransform:
710 case NODE_TextureTransform3D:
711 case NODE_TextureTransformMatrix3D:
712 case NODE_TextureTransformGenerator:
715 case NODE_MultiTextureTransform:
721 for (
int i = 0; i < ntrans; i++) {
723 FW_GL_LOAD_IDENTITY();
724 do_textureTransform0(tt, i, &tmap[i], &igen[i], & parameter_n, parameter);
728 ntrans_specified = ntrans;
730 for (
int ig = 0; ig < ntrans; ig++)
if (igen[ig] != TCGT_REGULAR) ngen++;
732 if (is_or_has_cubeMap(tnode) && !ngen) {
734 FW_GL_LOAD_IDENTITY();
735 igen[ntrans] = TCGT_CAMERASPACEREFLECTIONVECTOR;
740 if (is_or_has_Tex3D(tnode) && !ngen) {
741 if (tg->RenderFuncs.shapenode) {
746 float bbox[6], * bmin, * bmax;
751 for (i = 0; i < 3; i++) {
752 bmin[i] = gn->_extent[i * 2 + 1];
753 bmax[i] = gn->_extent[i * 2];
756 vecdif3f(bmax, bmax, bmin);
757 for (i = 0; i < 3; i++) {
759 bmax[i] = 1.0f / bmax[i];
775 FW_GL_LOAD_IDENTITY();
776 igen[ntrans] = TCGT_REGULAR;
778 FW_GL_SCALE_F(bmax[0], bmax[1], bmax[2]);
779 FW_GL_TRANSLATE_F(-bmin[0], -bmin[1], -bmin[2]);
783 glUniform1i(me->nTexMatrix, ntrans);
784 for (
int ig = 0; ig < MAX_MULTITEXTURE; ig++)
785 glUniform1i(me->tgen[ig], igen[ig]);
788 glUniform1i(me->parameter_n, parameter_n);
789 for (
int ig = 0; ig < parameter_n; ig++)
790 glUniform1f(me->parameter[ig], parameter[ig]);
793 int ntextures = tg->RenderFuncs.textureStackTop;
796 if (tnode && X3D_APPEARANCE(sn->appearance)->texture == tnode) {
799 for (
int i = 0; i < tg->RenderFuncs.textureStackTop; i++) {
800 int itrans = min(i, ntrans - 1);
801 int icoord = min(i, ntcoord - 1);
802 int jcombo = find_or_make_combo_by_index(itrans, icoord, &icombo[0], &ncombo);
803 matprop->fw_FrontMaterial.cmap[i] = jcombo;
810 if (tnode->_nodeType == NODE_MultiTexture) {
812 p = mnode->texture.p;
813 n = mnode->texture.n;
816 for (
int i = 0; i < n; i++) {
817 int jsamplr = is_cubeMap(p[i]) ? 1 : isTex3D(p[i]) ? 2 : 0;
818 int itrans = i > ntrans_specified - 1 ? -1 : i;
820 itrans = next_or_last_sampler_compatible_trans(lasttrans, ntrans, jsamplr, igen);
823 int icoord = min(i, ntcoord - 1);
824 int jcombo = find_or_make_combo_by_index(itrans, icoord, &icombo[0], &ncombo);
825 matprop->fw_FrontMaterial.cmap[i] = jcombo;
831 char** mmapf = matprop->fw_FrontMaterial.map;
832 char** mmapb = matprop->fw_BackMaterial.map;
833 for (
int i = 0; i < 7; i++) {
834 char scratch1[20], scratch2[20];
839 if (mmapf && mmapf[i]) {
840 trans_name = trans_name_from_texture_mapping(mmapf[i], scratch1);
841 coord_name = coord_name_from_texture_mapping(mmapf[i], scratch2);
842 jcombo = find_or_make_combo(trans_name, coord_name, ccmap, ntcoord,
843 tmap, ntrans, &icombo[0], &ncombo);
844 matprop->fw_FrontMaterial.cmap[i] = jcombo;
847 if (mmapb && mmapb[i]) {
848 trans_name = trans_name_from_texture_mapping(mmapb[i], scratch1);
849 coord_name = coord_name_from_texture_mapping(mmapb[i], scratch2);
850 jcombo = find_or_make_combo(trans_name, coord_name, ccmap, ntcoord,
851 tmap, ntrans, icombo, &ncombo);
852 matprop->fw_BackMaterial.cmap[i] = jcombo;
856 for (
int i = 0; i < ncombo; i++) {
859 glUniform1i(me->cmap[i], icombo[i][0]);
860 glUniform1i(me->tmap[i], icombo[i][1]);
862 glUniform1i(me->ntexcombo, ncombo);
871 tnode = tg->RenderFuncs.texturenode;
874 if (me->textureCount != -1) {
875 glUniform1i(me->textureCount, tg->RenderFuncs.textureStackTop);
877 if(tg->RenderFuncs.textureStackTop){
878 if(isMultiTexture(tnode)){
880 glUniform4f(me->multitextureColor,mtnode->color.c[0],mtnode->color.c[1],mtnode->color.c[2],mtnode->alpha);
882 if (isTex3D(tnode)) {
883 textureTableIndexStruct_s* tti;
884 tti = getTableTableFromTextureNode(tg->RenderFuncs.texturenode);
885 if (tti && tti->status >= TEX_LOADED) {
886 GLint ttiles, tex3dUseVertex, repeatSTR, magFilter;
888 GLUNIFORM1IV(me->tex3dTiles, 3, tti->tiles);
891 glUniform1i(me->tex3dUseVertex, 1);
893 glUniform1iv(me->repeatSTR, 3, tti->repeatSTR);
895 glUniform1i(me->magFilter, tti->magFilter);
899 if (tg->RenderFuncs.textureStackTop) {
905 int textures[4], modes[4], sources[4], funcs[4], width[4], height[4], samplr[4];
906 GLint saveTextureStackTop = tg->RenderFuncs.textureStackTop;
907 int ntdesc = getTextureDescriptors(tnode, textures, modes, sources, funcs, width, height,samplr);
911 mp = &myap->fw_FrontMaterial;
913 if (mp->type < 2) iuse = 1;
914 else if (mp->type == 2) iuse = 3;
915 else if (mp->type == 3) iuse = 3;
917 mp->tcount[iuse] += ntdesc;
918 mp->tstart[iuse] = nt;
921 for (
int j = 0; j < ntdesc; j++) {
924 mp->samplr[nt] = samplr[j];
925 if (mp->samplr[nt] == 1) {
928 printf(
"%s ", stringNodeType(tnode->_nodeType));
929 glGetTextureParameteriv(textures[j], GL_TEXTURE_TARGET, (GLint*)&target);
931 case GL_TEXTURE_CUBE_MAP: printf(
"CUBE MAP \n");
break;
932 case GL_TEXTURE_2D: printf(
"texture2D\n");
break;
933 case GL_TEXTURE_3D: printf(
"texture3D\n");
break;
934 case GL_TEXTURE_2D_ARRAY: printf(
"GL_TEXTURE_2D_ARRAY\n");
935 default: printf(
"unknown %d \n",target);
break;
938 PRINT_GL_ERROR_IF_ANY(
"TT_start_ bfor bind cube");
940 kunit = share_or_next_material_sampler_index_Cube(textures[j]);
942 PRINT_GL_ERROR_IF_ANY(
"TT_start_ aftr bind cube");
943 glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
944 PRINT_GL_ERROR_IF_ANY(
"TT_start_ aftr seamless");
948 kunit = share_or_next_material_sampler_index_2D(textures[j]);
950 mp->tindex[nt] = kunit;
951 mp->source[nt] = sources[j];
952 mp->mode[nt] = modes[j];
953 mp->func[nt] = funcs[j];
957 glUniform1i(me->myMaterialCmap[nt], mp->cmap[nt]);
958 if (mp->samplr[nt] == 1) {
959 iunit = tunitCube(kunit);
960 glUniform1i(me->textureUnitCube[kunit], iunit);
963 iunit = tunit2D(kunit);
964 glUniform1i(me->textureUnit[kunit], iunit);
966 mp->binding[nt] = iunit;
969 glUniform1i(me->myMaterialTindex[nt], mp->tindex[nt]);
970 glUniform1i(me->myMaterialMode[nt], mp->mode[nt]);
971 glUniform1i(me->myMaterialSource[nt], mp->source[nt]);
972 glUniform1i(me->myMaterialFunc[nt], mp->func[nt]);
973 glUniform1i(me->myMaterialSampler[nt], mp->samplr[nt]);
982 GLUNIFORM1I(me->myMaterialTcount[iuse], mp->tcount[iuse]);
983 GLUNIFORM1I(me->myMaterialTstart[iuse], mp->tstart[iuse]);
985 tg->RenderFuncs.textureStackTop = saveTextureStackTop;
990 printf (
" NOT sending in %d i+tu+mode because currentShaderProperties is NULL\n",tg->RenderFuncs.textureStackTop);
994 FW_GL_MATRIX_MODE(GL_MODELVIEW);
996 PRINT_GL_ERROR_IF_ANY(
"TT_start_finish");
1006 s_shader_capabilities_t *me;
1011 ttglobal tg = gglobal();
1015 me = getAppearanceProperties()->currentShaderProperties;
1022 FW_GL_BINDBUFFER(GL_ARRAY_BUFFER,genTexPtr->VBO);
1024 if (genTexPtr->pre_canned_textureCoords != NULL) {
1026 FW_GL_TEXCOORD_POINTER (2,GL_FLOAT,0,genTexPtr->pre_canned_textureCoords,c);
1028 FW_GL_TEXCOORD_POINTER (genTexPtr->TC_size,
1030 genTexPtr->TC_stride,
1031 genTexPtr->TC_pointer,c);
1034 genTexPtr = genTexPtr->next;
1037 glUniform1i(me->nTexCoordChannels,c);
1039 glUniform1i(me->flipuv, 0);