34 #include <libFreeWRL.h>
35 #include "../vrml_parser/Structs.h"
36 #include "../main/headers.h"
37 #include "../opengl/OpenGL_Utils.h"
38 #include "../opengl/Textures.h"
39 #include "../scenegraph/Component_Shape.h"
40 #include "../scenegraph/LinearAlgebra.h"
41 #include "../scenegraph/Component_CubeMapTexturing.h"
42 #include "../input/EAIHelpers.h"
43 #include "../vrml_parser/CParseGeneral.h"
46 # define uint32 uint32_t
268 static int lookup_xxyyzz_face_from_count [] = {0,1,2,3,4,5};
271 #ifndef GL_EXT_texture_cube_map
272 # define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515
287 for (count=0; count<6; count++) {
290 getAppearanceProperties()->cubeFace = GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT+count;
296 iface = lookup_xxyyzz_face_from_count[count];
298 case 0: {POSSIBLE_PROTO_EXPANSION(
struct X3D_Node *, node->right,thistex);
break;}
299 case 1: {POSSIBLE_PROTO_EXPANSION(
struct X3D_Node *, node->left,thistex);
break;}
301 case 2: {POSSIBLE_PROTO_EXPANSION(
struct X3D_Node *, node->top,thistex);
break;}
302 case 3: {POSSIBLE_PROTO_EXPANSION(
struct X3D_Node *, node->bottom,thistex);
break;}
304 case 4: {POSSIBLE_PROTO_EXPANSION(
struct X3D_Node *, node->front,thistex);
break;}
305 case 5: {POSSIBLE_PROTO_EXPANSION(
struct X3D_Node *, node->back,thistex);
break;}
308 if (thistex != NULL) {
311 if ((thistex->_nodeType == NODE_ImageTexture) ||
312 (thistex->_nodeType == NODE_PixelTexture) ||
313 (thistex->_nodeType == NODE_MovieTexture) ||
314 (thistex->_nodeType == NODE_MultiTexture)) {
316 gglobal()->RenderFuncs.textureStackTop = 0;
318 render_node((
void *)thistex);
324 getAppearanceProperties()->cubeFace = 0;
342 #if !defined( mydds_h )
345 #define DDS_MAGIC 0x20534444
349 #define DDSD_CAPS 0x00000001
353 #define DDSD_PIXELFORMAT 0x00001000
356 #define DDSD_DEPTH 0x00800000
359 #define DDPF_ALPHAPIXELS 0x00000001
360 #define DDPF_FOURCC 0x00000004
361 #define DDPF_INDEXED 0x00000020
362 #define DDPF_RGB 0x00000040
365 #define DDSCAPS_COMPLEX 0x00000008
370 #define DDSCAPS2_CUBEMAP 0x00000200
371 #define DDSCAPS2_CUBEMAP_POSITIVEX 0x00000400
372 #define DDSCAPS2_CUBEMAP_NEGATIVEX 0x00000800
373 #define DDSCAPS2_CUBEMAP_POSITIVEY 0x00001000
374 #define DDSCAPS2_CUBEMAP_NEGATIVEY 0x00002000
375 #define DDSCAPS2_CUBEMAP_POSITIVEZ 0x00004000
376 #define DDSCAPS2_CUBEMAP_NEGATIVEZ 0x00008000
377 #define DDSCAPS2_VOLUME 0x00200000
387 #define D3DFMT_DXT1 0x31545844
389 #define D3DFMT_DXT3 0x33545844
391 #define D3DFMT_DXT5 0x35545844
394 #define PF_IS_DXT1(pf) \
395 ((pf.dwFlags & DDPF_FOURCC) && \
396 (pf.dwFourCC == (unsigned int) D3DFMT_DXT1))
398 #define PF_IS_DXT3(pf) \
399 ((pf.dwFlags & DDPF_FOURCC) && \
400 (pf.dwFourCC == (unsigned int) D3DFMT_DXT3))
402 #define PF_IS_DXT5(pf) \
403 ((pf.dwFlags & DDPF_FOURCC) && \
404 (pf.dwFourCC == (unsigned int) D3DFMT_DXT5))
406 #define PF_IS_BGRA8(pf) \
407 ((pf.dwFlags & DDPF_RGB) && \
408 (pf.dwFlags & DDPF_ALPHAPIXELS) && \
409 (pf.dwRGBBitCount == 32) && \
410 (pf.dwRBitMask == 0xff0000) && \
411 (pf.dwGBitMask == 0xff00) && \
412 (pf.dwBBitMask == 0xff) && \
413 (pf.dwAlphaBitMask == 0xff000000U))
415 #define PF_IS_RGB8(pf) \
416 ((pf.dwFlags & DDPF_RGB) && \
417 !(pf.dwFlags & DDPF_ALPHAPIXELS) && \
418 (pf.dwRGBBitCount == 24) && \
419 (pf.dwRBitMask == 0xff) && \
420 (pf.dwGBitMask == 0xff00) && \
421 (pf.dwBBitMask == 0xff0000))
423 #define PF_IS_BGR8(pf) \
424 ((pf.dwFlags & DDPF_RGB) && \
425 !(pf.dwFlags & DDPF_ALPHAPIXELS) && \
426 (pf.dwRGBBitCount == 24) && \
427 (pf.dwRBitMask == 0xff0000) && \
428 (pf.dwGBitMask == 0xff00) && \
429 (pf.dwBBitMask == 0xff))
431 #define PF_IS_BGR5A1(pf) \
432 ((pf.dwFlags & DDPF_RGB) && \
433 (pf.dwFlags & DDPF_ALPHAPIXELS) && \
434 (pf.dwRGBBitCount == 16) && \
435 (pf.dwRBitMask == 0x00007c00) && \
436 (pf.dwGBitMask == 0x000003e0) && \
437 (pf.dwBBitMask == 0x0000001f) && \
438 (pf.dwAlphaBitMask == 0x00008000))
440 #define PF_IS_BGR565(pf) \
441 ((pf.dwFlags & DDPF_RGB) && \
442 !(pf.dwFlags & DDPF_ALPHAPIXELS) && \
443 (pf.dwRGBBitCount == 16) && \
444 (pf.dwRBitMask == 0x0000f800) && \
445 (pf.dwGBitMask == 0x000007e0) && \
446 (pf.dwBBitMask == 0x0000001f))
448 #define PF_IS_INDEX8(pf) \
449 ((pf.dwFlags & DDPF_INDEXED) && \
450 (pf.dwRGBBitCount == 8))
452 #define PF_IS_VOLUME(pf) \
453 ((pf.dwFlags & DDSD_DEPTH))
462 unsigned int dwMagic;
464 unsigned int dwFlags;
465 unsigned int dwHeight;
466 unsigned int dwWidth;
467 unsigned int dwPitchOrLinearSize;
468 unsigned int dwDepth;
469 unsigned int dwMipMapCount;
470 unsigned int dwReserved1[ 11 ];
475 unsigned int dwFlags;
476 unsigned int dwFourCC;
477 unsigned int dwRGBBitCount;
478 unsigned int dwRBitMask;
479 unsigned int dwGBitMask;
480 unsigned int dwBBitMask;
481 unsigned int dwAlphaBitMask;
486 unsigned int dwCaps1;
487 unsigned int dwCaps2;
489 unsigned int dwReserved;
491 unsigned int dwReserved2;
503 unsigned int divSize;
504 unsigned int blockBytes;
505 GLenum internalFormat;
506 GLenum externalFormat;
511 true,
false,
false, 4, 8, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
514 true,
false,
false, 4, 16, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
517 true,
false,
false, 4, 16, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
520 #if defined (GL_BGRA)
523 false,
false,
false, 1, 4, GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE
526 false,
true,
false, 1, 2, GL_RGB5_A1, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV
529 false,
false,
true, 1, 1, GL_RGB8, GL_BGRA, GL_UNSIGNED_BYTE
531 #endif //BGRA textures supported
534 false,
false,
false, 1, 3, GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE
537 false,
false,
false, 1, 3, GL_RGB8, GL_BGR, GL_UNSIGNED_BYTE
540 false,
true,
false, 1, 2, GL_RGB5, GL_RGB, GL_UNSIGNED_SHORT_5_6_5
544 OLDCODE
static unsigned int GetLowestBitPos(
unsigned int value)
546 OLDCODE
unsigned int pos = 0;
547 OLDCODE assert(value != 0);
549 OLDCODE
while (!(value & 1))
553 OLDCODE
if(pos == 32)
break;
562 unsigned char *buffer, *bdata;
564 unsigned long fileLen;
570 int nchan, idoFrontBackSwap;
572 unsigned int xSize, ySize,zSize;
585 file = fopen(filename,
"rb");
590 xx=fread(sniffbuf, 4, 1, file);
592 if(strncmp(sniffbuf,
"DDS ",4)){
598 file = fopen(filename,
"rb");
603 fseek(file, 0, SEEK_END);
605 fseek(file, 0, SEEK_SET);
608 buffer=MALLOC(
unsigned char *, fileLen+1);
615 xx=fread(buffer, fileLen, 1, file);
619 if (fileLen <
sizeof(hdr))
623 memcpy( &hdr, buffer,
sizeof(hdr));
626 if ((hdr.dwMagic == DDS_MAGIC) && (hdr.dwSize == 124) &&
627 (hdr.dwFlags & DDSD_PIXELFORMAT) && (hdr.dwFlags & DDSD_CAPS)) {
633 ySize = hdr.dwHeight;
643 printf (
"looking to see what it is...\n");
644 printf (
"DDPF_FOURCC dwFlags %x mask %x, final %x\n",hdr.sPixelFormat.dwFlags,DDPF_FOURCC,hdr.sPixelFormat.dwFlags & DDPF_FOURCC);
646 printf (
"if it is a dwFourCC, %x and %x\n", hdr.sPixelFormat.dwFourCC ,D3DFMT_DXT1);
648 printf (
"dwFlags %x\n",hdr.sPixelFormat.dwFlags);
649 printf (
"dwRGBBitCount %d\n",hdr.sPixelFormat.dwRGBBitCount);
650 printf (
"dwRBitMask %x\n",hdr.sPixelFormat.dwRBitMask);
651 printf (
"dwGBitMask %x\n",hdr.sPixelFormat.dwGBitMask);
652 printf (
"dwBBitMask %x\n",hdr.sPixelFormat.dwBBitMask);
653 printf (
"dwAlphaBitMask %x\n",hdr.sPixelFormat.dwAlphaBitMask);
654 printf (
"dwFlags and DDPF_ALPHAPIXELS... %x\n",DDPF_ALPHAPIXELS & hdr.sPixelFormat.dwFlags);
655 printf (
"dwflags & DDPF_RGB %x\n,",hdr.sPixelFormat.dwFlags & DDPF_RGB);
657 printf (
"dwFlags and DEPTH %x\n",hdr.dwFlags & DDSD_DEPTH);
658 printf (
"dwCaps1 and complex %x\n", (hdr.sCaps.dwCaps1 & DDSCAPS_COMPLEX));
659 printf (
"dwCaps1 and VOLUME %x\n", (hdr.sCaps.dwCaps1 & DDSCAPS2_VOLUME));
666 if(hdr.sPixelFormat.dwFlags & DDPF_FOURCC){
667 if( PF_IS_DXT1( hdr.sPixelFormat ) ) {
670 else if( PF_IS_DXT3( hdr.sPixelFormat ) ) {
673 else if( PF_IS_DXT5( hdr.sPixelFormat ) ) {
677 #if defined (GL_BGRA)
678 else if( PF_IS_BGRA8( hdr.sPixelFormat ) ) {
681 else if( PF_IS_BGR5A1( hdr.sPixelFormat ) ) {
682 li = &loadInfoBGR5A1;
684 else if( PF_IS_INDEX8( hdr.sPixelFormat ) ) {
685 li = &loadInfoIndex8;
689 else if( PF_IS_RGB8( hdr.sPixelFormat ) ) {
692 else if( PF_IS_BGR8( hdr.sPixelFormat ) ) {
695 else if( PF_IS_BGR565( hdr.sPixelFormat ) ) {
696 li = &loadInfoBGR565;
709 x = xSize = hdr.dwWidth;
710 y = ySize = hdr.dwHeight;
712 idoFrontBackSwap = 0;
713 if( PF_IS_VOLUME(hdr) )
714 z = zSize = hdr.dwDepth;
715 if( hdr.sCaps.dwCaps2 & DDSCAPS2_CUBEMAP){
717 if(hdr.sCaps.dwCaps2 & DDSCAPS2_CUBEMAP_POSITIVEX) facecount++;
718 if(hdr.sCaps.dwCaps2 & DDSCAPS2_CUBEMAP_NEGATIVEX) facecount++;
719 if(hdr.sCaps.dwCaps2 & DDSCAPS2_CUBEMAP_POSITIVEY) facecount++;
720 if(hdr.sCaps.dwCaps2 & DDSCAPS2_CUBEMAP_NEGATIVEY) facecount++;
721 if(hdr.sCaps.dwCaps2 & DDSCAPS2_CUBEMAP_POSITIVEZ) facecount++;
722 if(hdr.sCaps.dwCaps2 & DDSCAPS2_CUBEMAP_NEGATIVEZ) facecount++;
723 z = zSize = facecount;
725 idoFrontBackSwap = 1;
728 if(DDPF_ALPHAPIXELS & hdr.sPixelFormat.dwFlags) nchan = 4;
734 int ipix,jpix,bpp, ir, ig, ib;
736 unsigned char * rgbablob = malloc(x*y*z *4);
737 bpp = hdr.sPixelFormat.dwRGBBitCount / 8;
738 ir = 0; ig = 1; ib = 2;
739 if(hdr.sPixelFormat.dwRBitMask > hdr.sPixelFormat.dwBBitMask){
750 unsigned char *pixel,*rgba;
752 ii = idoFrontBackSwap && i == 4? 5 : i;
753 ii = idoFrontBackSwap && i == 5? 4 : i;
755 ipix = (i*y +j)*x +k;
756 jpix = (ii*y +(y-1-j))*x + k;
757 pixel = &bdata[ipix * bpp];
758 rgba = &rgbablob[jpix *4];
770 printf(
"pixel R=%x G=%x B=%x A=%x\n",rgba[0],rgba[1],rgba[2],rgba[3]);
778 this_tex->channels = nchan;
782 this_tex->texdata = rgbablob;
791 if( li->compressed ) {
812 }
else if( li->palette ) {
909 void add_node_to_broto_context(
struct X3D_Proto *currentContext,
struct X3D_Node *node);
912 if (node->__subTextures.n == 0) {
916 FREE_IF_NZ(node->__subTextures.p);
918 for (i=0; i<6; i++) {
922 node->__subTextures.p[i] = X3D_NODE(pt);
923 if(node->_executionContext)
924 add_node_to_broto_context(X3D_PROTO(node->_executionContext),X3D_NODE(node->__subTextures.p[i]));
928 node->__subTextures.n=6;
932 node->__regenSubTextures = TRUE;
943 if (node->__regenSubTextures) {
945 loadTextureNode(X3D_NODE(node),NULL);
948 if (node->__subTextures.n == 0)
return;
950 for (count=0; count<6; count++) {
953 getAppearanceProperties()->cubeFace = GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT+count;
956 iface = lookup_xxyyzz_face_from_count[count];
957 render_node(node->__subTextures.p[iface]);
961 getAppearanceProperties()->cubeFace = 0;
970 static int offsets[]={
998 ERROR_MSG(
"problem unpacking single image ImageCubeMap\n");
1002 if (node->_nodeType != NODE_ImageCubeMapTexture) {
1003 ERROR_MSG(
"internal error - expected ImageCubeMapTexture here");
1009 if ((me->x * 3) != (me->y*4)) {
1010 ERROR_MSG (
"expect an ImageCubeMap to be in a 4:3 ratio");
1018 if (node->__subTextures.n != 6) {
1019 ERROR_MSG(
"unpackImageCubeMap, there should be 6 PixelTexture nodes here\n");
1024 for (count=0; count <6; count++) {
1027 uint32 *tex = (uint32 *) me->texdata;
1028 struct X3D_PixelTexture *pt = X3D_PIXELTEXTURE(node->__subTextures.p[count]);
1029 int xSubIndex, ySubIndex;
1032 ySubIndex=offsets[count*2]*size; xSubIndex=offsets[count*2+1]*size;
1035 FREE_IF_NZ(pt->image.p);
1036 pt->image.n = size*size+3;
1037 pt->image.p = MALLOC(
int *, pt->image.n * sizeof (
int));
1038 pt->image.p[0] = size;
1039 pt->image.p[1] = size;
1043 for (y=ySubIndex; y<ySubIndex+size; y++) {
1044 for (x=xSubIndex; x<xSubIndex+size; x++) {
1046 unsigned char *rgba;
1051 pt->image.p[index] = ((val & 0xffffff) << 8) | ((val & 0xff000000) >> 24);
1053 rgba = (
unsigned char *)&tex[ipix];
1055 pt->image.p[index] = (rgba[0] << 24) + (rgba[1] << 16) + (rgba[2] << 8) + (rgba[3] << 0);
1065 node->__regenSubTextures = FALSE;
1068 FREE_IF_NZ(me->texdata);
1081 ERROR_MSG(
"problem unpacking single image ImageCubeMap\n");
1085 if (node->_nodeType != NODE_ImageCubeMapTexture) {
1086 ERROR_MSG(
"internal error - expected ImageCubeMapTexture here");
1091 if (node->__subTextures.n != 6) {
1092 ERROR_MSG(
"unpackImageCubeMap, there should be 6 PixelTexture nodes here\n");
1100 uint32 imlookup[] = {0,1,2,3,4,5};
1101 for (count=0; count <6; count++) {
1105 struct X3D_PixelTexture *pt = X3D_PIXELTEXTURE(node->__subTextures.p[count]);
1108 FREE_IF_NZ(pt->image.p);
1109 pt->image.n = me->x*me->y+3;
1110 pt->image.p = MALLOC(
int *, pt->image.n * sizeof (uint32));
1111 pt->image.p[0] = me->x;
1112 pt->image.p[1] = me->y;
1114 ioff = imlookup[count] * me->x * me->y;
1119 tex = (uint32 *) me->texdata;
1121 for(j=0;j<me->y;j++){
1122 for(i=0;i<me->x;i++){
1125 unsigned char* rgba;
1129 rgba = (
unsigned char*)&tex[ipix];
1130 pixint = (rgba[0] << 24) + (rgba[1] << 16) + (rgba[2] << 8) + rgba[3];
1131 pt->image.p[ipix+3] = pixint;
1138 node->__regenSubTextures = FALSE;
1141 FREE_IF_NZ(me->texdata);
1151 #include "RenderFuncs.h"
1153 Stack * gencube_stack;
1156 static void *Component_CubeMapTexturing_constructor(){
1163 void Component_CubeMapTexturing_init(
struct tComponent_CubeMapTexturing *t){
1166 t->prv = Component_CubeMapTexturing_constructor();
1169 p->gencube_stack = newStack(
usehit);
1174 void Component_CubeMapTexturing_clear(
struct tComponent_CubeMapTexturing *t){
1179 deleteVector(
usehit,p->gencube_stack);
1188 void pushnset_framebuffer(
int ibuffer);
1189 void popnset_framebuffer();
1191 #ifdef GL_DEPTH_COMPONENT32
1192 #define FW_GL_DEPTH_COMPONENT GL_DEPTH_COMPONENT32
1194 #define FW_GL_DEPTH_COMPONENT GL_DEPTH_COMPONENT16
1196 int haveFrameBufferObject();
1200 if (node->__subTextures.n == 0) {
1205 FREE_IF_NZ(node->__subTextures.p);
1207 for (i=0; i<6; i++) {
1210 node->__subTextures.p[i] = X3D_NODE(pt);
1211 if(node->_executionContext)
1212 add_node_to_broto_context(X3D_PROTO(node->_executionContext),X3D_NODE(node->__subTextures.p[i]));
1218 node->__subTextures.n=6;
1219 tti = getTableIndex(node->__textureTableIndex);
1220 tti->status = TEX_NEEDSBINDING;
1221 tti->x = tti->y = node->size;
1223 loadTextureNode(X3D_NODE(node),NULL);
1224 if(tti->ifbobuffer == 0 && haveFrameBufferObject() ){
1229 glGenFramebuffers(1, &tti->ifbobuffer);
1230 pushnset_framebuffer(tti->ifbobuffer);
1232 glGenRenderbuffers(1, &tti->idepthbuffer);
1233 glBindRenderbuffer(GL_RENDERBUFFER, tti->idepthbuffer);
1234 glRenderbufferStorage(GL_RENDERBUFFER, FW_GL_DEPTH_COMPONENT, isize,isize);
1235 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, tti->idepthbuffer);
1237 for(j=0;j<node->__subTextures.n;j++){
1248 glGenTextures(1,&tti->OpenGLTexture);
1249 glBindTexture(GL_TEXTURE_2D, tti->OpenGLTexture);
1251 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, isize, isize, 0, GL_RGBA , GL_UNSIGNED_BYTE, 0);
1252 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tti->OpenGLTexture, 0);
1254 popnset_framebuffer();
1268 void get_view_matrix(
double *savePosOri,
double *saveView);
1277 if(!strcmp(node->update->strptr,
"ALWAYS") || !strcmp(node->update->strptr,
"NEXT_FRAME_ONLY")){
1280 if(rs->render_geom && !rs->render_cube){
1288 for(i=0;i<vectorSize(p->gencube_stack);i++){
1289 uhit = vector_get(
usehit,p->gencube_stack,i);
1290 if(uhit.node == X3D_NODE(node)){
1296 double modelviewMatrix[16], mvmInverse[16];
1297 double worldmatrix[16], viewmatrix[16], saveView[16], savePosOri[16];
1300 FW_GL_GETDOUBLEV(GL_MODELVIEW_MATRIX, modelviewMatrix);
1301 get_view_matrix(savePosOri,saveView);
1302 matmultiplyAFFINE(viewmatrix,saveView,savePosOri);
1304 matinverseAFFINE(mvmInverse,modelviewMatrix);
1309 matmultiplyAFFINE(worldmatrix,viewmatrix,mvmInverse);
1312 uhit.node = X3D_NODE(node);
1314 memcpy(uhit.mvm,worldmatrix,16*
sizeof(
double));
1315 vector_pushBack(
usehit,p->gencube_stack,uhit);
1316 if(!strcmp(node->update->strptr,
"NEXT_FRAME_ONLY")){
1318 freeASCIIString(node->update);
1319 node->update = newASCIIString(
"NONE");
1337 if (node->__subTextures.n == 0)
return;
1339 for (count=0; count<6; count++) {
1342 getAppearanceProperties()->cubeFace = GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT+count;
1345 iface = lookup_xxyyzz_face_from_count[count];
1346 render_node(node->__subTextures.p[iface]);
1350 getAppearanceProperties()->cubeFace = 0;
1366 { 90.0,0.0,1.0,0.0},
1367 {-90.0,0.0,1.0,0.0},
1368 {-90.0,1.0,0.0,0.0},
1369 { 90.0,1.0,0.0,0.0},
1371 {180.0,0.0,1.0,0.0},
1375 void fw_gluPerspective_2(GLDOUBLE xcenter, GLDOUBLE fovy, GLDOUBLE aspect, GLDOUBLE zNear, GLDOUBLE zFar);
1376 void pushnset_viewport(
float *vpFraction);
1377 void popnset_viewport();
1381 void generate_GeneratedCubeMapTextures(){
1389 Stack *gencube_stack;
1392 static int iframe = 0;
1395 gencube_stack = p->gencube_stack;
1396 if(vectorSize(gencube_stack)){
1399 n = vectorSize(gencube_stack);
1403 double modelviewmatrix[16];
1405 float vp[4] = {0.0f,1.0f,0.0f,1.0f};
1408 uhit = vector_get(
usehit,gencube_stack,i);
1410 memcpy(modelviewmatrix,uhit.mvm,16*
sizeof(
double));
1413 tti = getTableIndex(node->__textureTableIndex);
1416 pushnset_framebuffer(tti->ifbobuffer);
1420 pushnset_viewport(vp);
1421 glViewport(0,0,isize,isize);
1427 for(j=0;j<node->__subTextures.n;j++){
1434 ttip = getTableIndex(nodep->__textureTableIndex);
1439 glClearColor(1.0f,0.0f,0.0f,1.0f);
1440 FW_GL_CLEAR(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
1444 FW_GL_MATRIX_MODE(GL_PROJECTION);
1445 FW_GL_LOAD_IDENTITY();
1447 fw_gluPerspective_2(0.0,90.0, 1.0, .1,10000.0);
1449 FW_GL_MATRIX_MODE(GL_MODELVIEW);
1450 FW_GL_LOAD_IDENTITY();
1451 fw_glSetDoublev(GL_MODELVIEW_MATRIX, modelviewmatrix);
1452 fw_glRotated(sideangle[j].angle,sideangle[j].x,sideangle[j].y,sideangle[j].z);
1458 if (!fwl_get_headlight()) {
1459 setLightState(HEADLIGHT_LIGHT,FALSE);
1460 setLightType(HEADLIGHT_LIGHT,2);
1464 PRINT_GL_ERROR_IF_ANY(
"XEvents::render, before render_hier");
1466 render_hier(rootNode(), VF_globalLight );
1467 PRINT_GL_ERROR_IF_ANY(
"XEvents::render, render_hier(VF_globalLight)");
1468 render_hier(rootNode(), VF_Other );
1471 profile_start(
"hier_geom");
1472 render_hier(rootNode(), VF_Geom | VF_Cube);
1473 profile_end(
"hier_geom");
1474 PRINT_GL_ERROR_IF_ANY(
"XEvents::render, render_hier(VF_Geom)");
1477 if (tg->RenderFuncs.have_transparency) {
1479 render_hier(rootNode(), VF_Geom | VF_Blend | VF_Cube);
1480 PRINT_GL_ERROR_IF_ANY(
"XEvents::render, render_hier(VF_Geom)");
1485 pixelType = GL_RGBA;
1487 if(!ttip->texdata || ttip->x != isize){
1488 FREE_IF_NZ(ttip->texdata);
1489 ttip->texdata = MALLOC (GLvoid *, bytesPerPixel*isize*isize);
1496 FW_GL_READPIXELS (0,0,isize,isize,pixelType,GL_UNSIGNED_BYTE, ttip->texdata);
1502 ttip->status = TEX_NEEDSBINDING;
1508 sprintf(namebuf,
"%s%d.web3dit",
"cubemapface_",j);
1509 saveImage_web3dit(ttip, namebuf);
1514 popnset_framebuffer();
1518 gencube_stack->n = 0;