Changeset 463 for trunk/src/gl/gl_device.cc
- Timestamp:
- 08/28/15 18:28:34 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gl/gl_device.cc
r461 r463 17 17 gl_device::gl_device() 18 18 { 19 m_shader_header.append( "#version 120\n " );19 m_shader_header.append( "#version 120\n#extension GL_EXT_texture_array : require\n" ); 20 20 for ( auto& i : get_uniform_factory() ) 21 21 m_shader_header.append( "uniform "+datatype_to_glsl_type( i.second->get_datatype() )+" "+ i.first +";\n" ); … … 95 95 nv::texture nv::gl_device::create_texture( texture_type type, ivec2 size, image_format aformat, sampler asampler, const void* data /*= nullptr */ ) 96 96 { 97 NV_ASSERT_ALWAYS( type != TEXTURE_3D && type != TEXTURE_2D_ARRAY, "2D texture type expected!" ); 97 98 unsigned glid = 0; 98 99 unsigned gl_type = texture_type_to_enum( type ); 100 101 bool is_depth = aformat.format == DEPTH16 || aformat.format == DEPTH24 || aformat.format == DEPTH32; 102 99 103 glGenTextures( 1, &glid ); 100 104 … … 117 121 glTexParameteri( gl_type, GL_TEXTURE_WRAP_S, GLint( nv::sampler_wrap_to_enum( asampler.wrap_s) ) ); 118 122 glTexParameteri( gl_type, GL_TEXTURE_WRAP_T, GLint( nv::sampler_wrap_to_enum( asampler.wrap_t) ) ); 123 124 if ( is_depth ) 125 { 126 #define GL_TEXTURE_DEPTH_SIZE 0x884A 127 #define GL_DEPTH_TEXTURE_MODE 0x884B 128 #define GL_TEXTURE_COMPARE_MODE 0x884C 129 #define GL_TEXTURE_COMPARE_FUNC 0x884D 130 #define GL_COMPARE_R_TO_TEXTURE 0x884E 131 132 #define GL_INTENSITY 0x8049 133 #define GL_LUMINANCE 0x1909 134 // glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE ); 135 // glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL ); 136 // glTexParameteri( GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_LUMINANCE ); 137 // glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, 0 ); 138 // glTexParameteri( GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_INTENSITY ); 139 } 140 141 // #define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE 142 // #define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF 143 // 144 // float aniso = 0.0f; 145 // glGetFloatv( GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &aniso ); 146 // NV_LOG_INFO( "Anisotropy at ", aniso, " (", int( aniso ), " ) " ); 147 // glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, aniso ); 119 148 120 149 glTexImage2D( gl_type, 0, GLint( nv::image_format_to_internal_enum(aformat.format) ), size.x, size.y, 0, nv::image_format_to_enum(aformat.format), nv::datatype_to_gl_enum(aformat.type), data ); … … 127 156 info->format = aformat; 128 157 info->tsampler = asampler; 129 info->size = size;158 info->size = ivec3( size.x, size.y, 1 ); 130 159 info->glid = glid; 131 160 return result; 132 161 } 162 163 nv::texture nv::gl_device::create_texture( texture_type type, ivec3 size, image_format aformat, sampler asampler, const void* data /*= nullptr */ ) 164 { 165 NV_ASSERT_ALWAYS( type == TEXTURE_3D || type == TEXTURE_2D_ARRAY, "3D texture type expected!" ); 166 unsigned glid = 0; 167 unsigned gl_type = texture_type_to_enum( type ); 168 169 bool is_depth = aformat.format == DEPTH16 || aformat.format == DEPTH24 || aformat.format == DEPTH32; 170 171 glGenTextures( 1, &glid ); 172 glBindTexture( gl_type, glid ); 173 174 if ( asampler.filter_max != sampler::NEAREST ) 175 { 176 asampler.filter_max = sampler::LINEAR; 177 } 178 179 glTexParameteri( gl_type, GL_TEXTURE_MIN_FILTER, GLint( nv::sampler_filter_to_enum( asampler.filter_min ) ) ); 180 glTexParameteri( gl_type, GL_TEXTURE_MAG_FILTER, GLint( nv::sampler_filter_to_enum( asampler.filter_max ) ) ); 181 glTexParameteri( gl_type, GL_TEXTURE_WRAP_S, GLint( nv::sampler_wrap_to_enum( asampler.wrap_s ) ) ); 182 glTexParameteri( gl_type, GL_TEXTURE_WRAP_T, GLint( nv::sampler_wrap_to_enum( asampler.wrap_t ) ) ); 183 184 //glTexStorage3D( GL_TEXTURE_2D_ARRAY, mipLevelCount, GL_RGBA8, width, height, layerCount ); 185 glTexImage3D( gl_type, 0, GLint( nv::image_format_to_internal_enum( aformat.format ) ), size.x, size.y, size.z, 0, nv::image_format_to_enum( aformat.format ), nv::datatype_to_gl_enum( aformat.type ), data ); 186 glBindTexture( gl_type, 0 ); 187 188 texture result = m_textures.create(); 189 gl_texture_info* info = m_textures.get( result ); 190 info->type = type; 191 info->format = aformat; 192 info->tsampler = asampler; 193 info->size = size; 194 info->glid = glid; 195 return result; 196 } 197 198 133 199 134 200 void nv::gl_device::release( texture t )
Note: See TracChangeset
for help on using the changeset viewer.