- Timestamp:
- 05/28/13 22:19:58 (12 years ago)
- Location:
- trunk/src/gl
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gl/gl_device.cc
r45 r49 67 67 } 68 68 69 texture2d* gl_device::create_texture2d( ivec2 size, texture2d::format aformat, texture2d::datatype adatatype, texture2d_samplersampler, void* data /*= nullptr */ )69 texture2d* gl_device::create_texture2d( ivec2 size, image_format aformat, type adatatype, sampler asampler, void* data /*= nullptr */ ) 70 70 { 71 return new gl_texture2d( size, aformat, adatatype, sampler, data );71 return new gl_texture2d( size, aformat, adatatype, asampler, data ); 72 72 } 73 73 -
trunk/src/gl/gl_enum.cc
r45 r49 134 134 } 135 135 136 unsigned int nv:: texture_format_to_enum( texture2d::format format )136 unsigned int nv::image_format_to_enum( image_format format ) 137 137 { 138 138 switch( format ) 139 139 { 140 case texture2d::RGB : return GL_RGB; 141 case texture2d::RGBA : return GL_RGBA; 142 default : return 0; // TODO: throw! 143 } 144 } 145 146 unsigned int nv::texture_datatype_to_enum( texture2d::datatype datatype ) 147 { 148 switch( datatype ) 149 { 150 case texture2d::UINT : return GL_UNSIGNED_INT; 151 case texture2d::UBYTE : return GL_UNSIGNED_BYTE; 152 case texture2d::FLOAT : return GL_FLOAT; 153 default : return 0; // TODO: throw! 154 } 155 } 156 157 unsigned int nv::texture_filter_to_enum( texture2d_sampler::filter filter ) 140 case RGB : return GL_RGB; 141 case RGBA : return GL_RGBA; 142 default : return 0; // TODO: throw! 143 } 144 } 145 146 unsigned int nv::sampler_filter_to_enum( sampler::filter filter ) 158 147 { 159 148 switch( filter ) 160 149 { 161 case texture2d_sampler::LINEAR : return GL_LINEAR;162 case texture2d_sampler::NEAREST : return GL_NEAREST;163 case texture2d_sampler::NEAREST_MIPMAP_NEAREST : return GL_NEAREST_MIPMAP_NEAREST;164 case texture2d_sampler::LINEAR_MIPMAP_NEAREST : return GL_LINEAR_MIPMAP_NEAREST;165 case texture2d_sampler::NEAREST_MIPMAP_LINEAR : return GL_NEAREST_MIPMAP_LINEAR;166 case texture2d_sampler::LINEAR_MIPMAP_LINEAR : return GL_LINEAR_MIPMAP_LINEAR;167 default : return 0; // TODO: throw! 168 } 169 } 170 171 unsigned int nv:: texture_wrap_to_enum( texture2d_sampler::wrap wrap )150 case sampler::LINEAR : return GL_LINEAR; 151 case sampler::NEAREST : return GL_NEAREST; 152 case sampler::NEAREST_MIPMAP_NEAREST : return GL_NEAREST_MIPMAP_NEAREST; 153 case sampler::LINEAR_MIPMAP_NEAREST : return GL_LINEAR_MIPMAP_NEAREST; 154 case sampler::NEAREST_MIPMAP_LINEAR : return GL_NEAREST_MIPMAP_LINEAR; 155 case sampler::LINEAR_MIPMAP_LINEAR : return GL_LINEAR_MIPMAP_LINEAR; 156 default : return 0; // TODO: throw! 157 } 158 } 159 160 unsigned int nv::sampler_wrap_to_enum( sampler::wrap wrap ) 172 161 { 173 162 switch( wrap ) 174 163 { 175 case texture2d_sampler::CLAMP_TO_EDGE : return GL_CLAMP_TO_EDGE;176 case texture2d_sampler::CLAMP_TO_BORDER : return GL_CLAMP_TO_BORDER;177 case texture2d_sampler::MIRRORED_REPEAT : return GL_MIRRORED_REPEAT;178 case texture2d_sampler::REPEAT : return GL_REPEAT;164 case sampler::CLAMP_TO_EDGE : return GL_CLAMP_TO_EDGE; 165 case sampler::CLAMP_TO_BORDER : return GL_CLAMP_TO_BORDER; 166 case sampler::MIRRORED_REPEAT : return GL_MIRRORED_REPEAT; 167 case sampler::REPEAT : return GL_REPEAT; 179 168 default : return 0; // TODO: throw! 180 169 } -
trunk/src/gl/gl_texture2d.cc
r43 r49 10 10 using namespace nv; 11 11 12 nv::gl_texture2d::gl_texture2d( ivec2 size, format aformat, datatype adatatype, texture2d_samplersampler, void* data /*= nullptr */ )13 : texture2d( size, aformat, adatatype, sampler ), m_name()12 nv::gl_texture2d::gl_texture2d( ivec2 size, image_format aformat, type adatatype, sampler asampler, void* data /*= nullptr */ ) 13 : texture2d( size, aformat, adatatype, asampler ), m_name() 14 14 { 15 15 glBindTexture( GL_TEXTURE_2D, m_name.get_value() ); 16 16 17 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, nv:: texture_filter_to_enum( m_sampler.filter_min ) );18 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, nv:: texture_filter_to_enum( m_sampler.filter_max ) );19 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, nv:: texture_wrap_to_enum( m_sampler.wrap_s) );20 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, nv:: texture_wrap_to_enum( m_sampler.wrap_t) );17 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, nv::sampler_filter_to_enum( m_sampler.filter_min ) ); 18 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, nv::sampler_filter_to_enum( m_sampler.filter_max ) ); 19 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, nv::sampler_wrap_to_enum( m_sampler.wrap_s) ); 20 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, nv::sampler_wrap_to_enum( m_sampler.wrap_t) ); 21 21 22 22 glBindTexture( GL_TEXTURE_2D, 0 ); … … 31 31 { 32 32 glBindTexture( GL_TEXTURE_2D, m_name.get_value() ); 33 glTexImage2D( GL_TEXTURE_2D, 0, nv:: texture_format_to_enum(m_format), m_size.x, m_size.y, 0, nv::texture_format_to_enum(m_format), nv::texture_datatype_to_enum(m_datatype), data );33 glTexImage2D( GL_TEXTURE_2D, 0, nv::image_format_to_enum(m_format), m_size.x, m_size.y, 0, nv::image_format_to_enum(m_format), nv::type_to_gl_enum(m_datatype), data ); 34 34 glBindTexture( GL_TEXTURE_2D, 0 ); 35 35 }
Note: See TracChangeset
for help on using the changeset viewer.