1 /* 2 * NodePixelTexture.h 3 * 4 * Copyright (C) 1999 Stephen F. White 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program (see the file "COPYING" for details); if 18 * not, write to the Free Software Foundation, Inc., 675 Mass Ave, 19 * Cambridge, MA 02139, USA. 20 */ 21 22 #pragma once 23 24 #include "Node.h" 25 #include "ProtoMacros.h" 26 #include "Proto.h" 27 #include "KambiTextureCommonFields.h" 28 #include "SFMFTypes.h" 29 30 class ProtoPixelTexture : public Proto { 31 public: 32 ProtoPixelTexture(Scene *scene); 33 virtual Node *create(Scene *scene); 34 getType()35 virtual int getType() const { return VRML_PIXEL_TEXTURE; } getNodeClass()36 virtual int getNodeClass() const 37 { return TEXTURE_NODE | TEXTURE_2D_NODE; } 38 isDeclaredInRwd_h()39 virtual bool isDeclaredInRwd_h() { return true; } 40 41 FieldIndex image; 42 FieldIndex repeatS; 43 FieldIndex repeatT; 44 FieldIndex blendMode; 45 FieldIndex textureProperties; 46 #ifdef HAVE_TEXTUREIMAGE_MODE 47 FieldIndex mode; 48 #endif 49 kambiTextureCommonFieldIndex() 50 kambiVrmlTextureCommonFieldIndex() 51 FieldIndex crossOrigin; 52 FieldIndex origChannelCount; 53 FieldIndex scale; 54 }; 55 56 class NodePixelTexture : public Node { 57 public: 58 NodePixelTexture(Scene *scene, Proto *proto); 59 NodePixelTexture(const NodePixelTexture &node); 60 virtual ~NodePixelTexture(); 61 62 virtual int getProfile(void) const; 63 virtual const char* getComponentName(void) const; 64 virtual int getComponentLevel(void) const; getX3dVersion(void)65 virtual int getX3dVersion(void) const { return 0; } copy()66 virtual Node *copy() const { return new NodePixelTexture(*this); } 67 virtual void setField(int field, FieldValue *value, int cf = -1); 68 void load(); 69 int isLoaded(); 70 isInvalidChildNode(void)71 virtual bool isInvalidChildNode(void) { return true; } 72 73 virtual void bind(GLuint textureId, GLuint textureName); 74 virtual void bind(); 75 virtual void unbind(); 76 getWasScaleRequired(void)77 virtual bool getWasScaleRequired(void) { return m_scaleRequired; } getNumComponents(void)78 virtual int getNumComponents(void) { return m_components; } 79 isTransparent(void)80 virtual bool isTransparent(void) { return m_isTransparent; } 81 hasCoverFields(void)82 virtual bool hasCoverFields(void) { return true; } 83 textureGlColorMode(void)84 virtual int textureGlColorMode(void) { return m_glColorMode; } 85 86 fieldMacros(SFImage, image, ProtoPixelTexture) 87 fieldMacros(SFBool, repeatS, ProtoPixelTexture) 88 fieldMacros(SFBool, repeatT, ProtoPixelTexture) 89 fieldMacros(SFInt32, blendMode, ProtoPixelTexture) 90 fieldMacros(SFNode, textureProperties, ProtoPixelTexture); 91 #ifdef HAVE_TEXTUREIMAGE_MODE 92 fieldMacros(SFInt32, mode, ProtoPixelTexture) 93 #endif 94 kambiTextureCommonFieldMacros(ProtoPixelTexture) 95 kambiVrmlTextureCommonFieldMacros(ProtoPixelTexture) 96 fieldMacros(SFString, crossOrigin, ProtoPixelTexture); 97 fieldMacros(SFInt32, origChannelCount, ProtoPixelTexture); 98 fieldMacros(SFBool, scale, ProtoPixelTexture); 99 100 protected: 101 unsigned char *m_image; 102 int m_imageStatus; 103 int m_textureWidth; 104 int m_textureHeight; 105 int m_components; 106 int m_glColorMode; 107 GLuint m_textureName; 108 bool m_scaleRequired; 109 bool m_isTransparent; 110 bool m_isAlphaNot0Not1; 111 }; 112 113