00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00027
#ifndef SHTEXTURENODE_HPP
00028
#define SHTEXTURENODE_HPP
00029
00030
#include "ShDllExport.hpp"
00031
#include "ShVariableNode.hpp"
00032
#include "ShMemory.hpp"
00033
#include "ShRefCount.hpp"
00034
#include "ShVariable.hpp"
00035
00036
namespace SH {
00037
00041 enum ShTextureDims {
00042 SH_TEXTURE_1D,
00043 SH_TEXTURE_2D,
00044 SH_TEXTURE_RECT,
00045 SH_TEXTURE_3D,
00046 SH_TEXTURE_CUBE,
00047 };
00048
00052 enum ShCubeDirection {
00053 SH_CUBE_POS_X = 0,
00054 SH_CUBE_NEG_X = 1,
00055 SH_CUBE_POS_Y = 2,
00056 SH_CUBE_NEG_Y = 3,
00057 SH_CUBE_POS_Z = 4,
00058 SH_CUBE_NEG_Z = 5,
00059 };
00060
00065 class
00066
SH_DLLEXPORT ShTextureTraits {
00067
public:
00068
enum Filtering {
00069 SH_FILTER_NONE,
00070 SH_FILTER_MIPMAP
00071 };
00072
00073
enum Wrapping {
00074 SH_WRAP_CLAMP,
00075 SH_WRAP_CLAMP_TO_EDGE,
00076 SH_WRAP_REPEAT
00077 };
00078
enum Clamping {
00079 SH_CLAMPED,
00080 SH_UNCLAMPED
00081 };
00082
00083 ShTextureTraits(
unsigned int interpolation,
00084 Filtering filtering,
00085 Wrapping wrapping,
00086 Clamping clamping)
00087 : m_interpolation(interpolation),
00088 m_filtering(filtering),
00089 m_wrapping(wrapping),
00090 m_clamping(clamping)
00091 {
00092 }
00093
00094
bool operator==(
const ShTextureTraits& other)
const
00095
{
00096
return m_interpolation == other.
m_interpolation
00097 && m_filtering == other.
m_filtering
00098 && m_wrapping == other.
m_wrapping
00099 && m_clamping == other.
m_clamping;
00100 }
00101
00102
bool operator!=(
const ShTextureTraits& other)
const {
return !(*
this == other); }
00103
00104
unsigned int interpolation()
const {
return m_interpolation; }
00105 ShTextureTraits& interpolation(
unsigned int interp) { m_interpolation = interp;
return *
this; }
00106
00107 Filtering filtering()
const {
return m_filtering; }
00108 ShTextureTraits& filtering(Filtering filtering) { m_filtering = filtering;
return *
this; }
00109
00110 Wrapping wrapping()
const {
return m_wrapping; }
00111 ShTextureTraits& wrapping(Wrapping wrapping) { m_wrapping = wrapping;
return *
this; }
00112
00113 Clamping clamping()
const {
return m_clamping; }
00114 ShTextureTraits& clamping(Clamping clamping) { m_clamping = clamping;
return *
this; }
00115
00116
private:
00117
unsigned int m_interpolation;
00118 Filtering m_filtering;
00119 Wrapping m_wrapping;
00120 Clamping m_clamping;
00121 };
00122
00123
class
00124
SH_DLLEXPORT ShTextureNode :
public ShVariableNode {
00125
public:
00126 ShTextureNode(ShTextureDims dims,
00127
int size,
00128
const ShTextureTraits&,
00129
int width,
int height = 0,
int depth = 0);
00130
virtual ~ShTextureNode();
00131
00132
ShTextureDims dims() const;
00133
00134
00135
ShPointer<const
ShMemory> memory(
int n = 0) const;
00136
ShPointer<const
ShMemory> memory(ShCubeDirection dir) const;
00137
ShMemoryPtr memory(
int n = 0);
00138
ShMemoryPtr memory(ShCubeDirection dir);
00139
void memory(
ShMemoryPtr memory,
int n = 0);
00140
void memory(
ShMemoryPtr memory, ShCubeDirection dir);
00141
00142
00143 const ShTextureTraits& traits() const;
00144 ShTextureTraits& traits();
00145
int width() const;
00146
int height() const;
00147
int depth() const;
00148
00149
void setTexSize(
int w);
00150
void setTexSize(
int w,
int h);
00151
void setTexSize(
int w,
int h,
int d);
00152 const
ShVariable& texSizeVar() const;
00153
00154 private:
00155 ShTextureDims m_dims;
00156
00157
ShMemoryPtr* m_memory;
00158
00159 ShTextureTraits m_traits;
00160
int m_width, m_height, m_depth;
00161
00162
ShVariable m_texSizeVar;
00163
00164
00165 ShTextureNode(const ShTextureNode& other);
00166 ShTextureNode& operator=(const ShTextureNode& other);
00167 };
00168
00169 typedef
ShPointer<ShTextureNode>
ShTextureNodePtr;
00170 typedef
ShPointer<const ShTextureNode>
ShTextureNodeCPtr;
00171
00172 }
00173 #endif