Ignore:
Timestamp:
08/07/14 12:11:16 (11 years ago)
Author:
epyon
Message:
  • textures are now handled by lightweight handles
  • textures now need to be manually released via context
  • removed all old texture2d functionality
  • unreleased textures will be auto-released
  • textures are properly tracked via entity system
  • detailed stats and checking now possible
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gl/gl_context.cc

    r300 r301  
    88#include "nv/lib/gl.hh"
    99#include "nv/lib/sdl.hh"
    10 #include "nv/gl/gl_texture2d.hh"
     10#include "nv/gl/gl_device.hh"
    1111#include "nv/gl/gl_program.hh"
    1212#include "nv/gl/gl_vertex_buffer.hh"
     
    1414using namespace nv;
    1515
    16 void gl_context::bind( texture2d* texture, texture_slot slot )
    17 {
    18         GLuint id = static_cast< gl_texture2d* >( texture )->glid;
    19         glActiveTexture( GL_TEXTURE0 + static_cast< GLenum >( slot ) );
    20         glBindTexture( GL_TEXTURE_2D, id );
     16void gl_context::bind( texture t, texture_slot slot )
     17{
     18        const gl_texture_info* info = static_cast< const gl_texture_info* >( m_device->get_texture_info( t ) );
     19        if ( info )
     20        {
     21                glActiveTexture( GL_TEXTURE0 + static_cast< GLenum >( slot ) );
     22                glBindTexture( GL_TEXTURE_2D, info->glid );
     23        }
    2124}
    2225
     
    9497}
    9598
    96 void gl_context::update( texture2d* texture, void* data )
    97 {
    98         GLuint id = static_cast< gl_texture2d* >( texture )->glid;
    99         image_format format = texture->get_format();
    100         ivec2        size   = texture->get_size();
    101 
    102         glBindTexture( GL_TEXTURE_2D, id );
    103         glTexImage2D( GL_TEXTURE_2D, 0, (GLint)nv::image_format_to_enum(format.format), size.x, size.y, 0, nv::image_format_to_enum(format.format), nv::datatype_to_gl_enum(format.type), data );
     99void nv::gl_context::update( texture t, void* data )
     100{
     101        const gl_texture_info* info = static_cast< const gl_texture_info* >( m_device->get_texture_info( t ) );
     102        if ( info )
     103        {
     104                image_format format = info->format;
     105                ivec2        size   = info->size;
     106
     107                glBindTexture( GL_TEXTURE_2D, info->glid );
     108                glTexImage2D( GL_TEXTURE_2D, 0, (GLint)nv::image_format_to_enum(format.format), size.x, size.y, 0, nv::image_format_to_enum(format.format), nv::datatype_to_gl_enum(format.type), data );
     109        }
    104110}
    105111
Note: See TracChangeset for help on using the changeset viewer.