Changeset 45 for trunk


Ignore:
Timestamp:
05/28/13 17:55:52 (12 years ago)
Author:
epyon
Message:
  • temporary draw for context (and implementation)
  • cleaned up warnings
  • general cleanups
Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/nv/gl/gl_context.hh

    r44 r45  
    2222                gl_context();
    2323                virtual void clear( const clear_state& cs );
     24                // temporary
     25                virtual void draw( primitive prim, const render_state& rs, program* p, vertex_array* va, int count );
    2426                virtual const ivec4& get_viewport();
    2527                virtual void set_viewport( const ivec4& viewport );
  • trunk/nv/gl/gl_device.hh

    r44 r45  
    2626                virtual index_buffer* create_index_buffer( buffer_hint hint, int size, void* source = nullptr );
    2727                virtual vertex_array* create_vertex_array();
     28                virtual texture2d* create_texture2d( ivec2 size, texture2d::format aformat, texture2d::datatype adatatype, texture2d_sampler sampler, void* data = nullptr );
    2829                virtual ~gl_device();
    2930        private:
  • trunk/nv/gl/gl_enum.hh

    r43 r45  
    1717#include <nv/interface/vertex_buffer.hh>
    1818#include <nv/interface/texture2d.hh>
     19#include <nv/interface/context.hh>
    1920#include <nv/types.hh>
    2021
     
    3536        unsigned int texture_filter_to_enum( texture2d_sampler::filter filter );
    3637        unsigned int texture_wrap_to_enum( texture2d_sampler::wrap wrap );
     38        unsigned int primitive_to_enum( primitive p );
    3739
    3840        unsigned int type_to_gl_enum( type type );
  • trunk/nv/interface/context.hh

    r44 r45  
    1414
    1515#include <nv/common.hh>
     16#include <nv/interface/program.hh>
     17#include <nv/interface/vertex_buffer.hh>
    1618#include <nv/interface/clear_state.hh>
    1719#include <nv/interface/render_state.hh>
     
    1921namespace nv
    2022{
     23        enum primitive
     24        {
     25                POINTS,
     26                LINES,
     27                LINE_LOOP,
     28                LINE_STRIP,
     29                TRIANGLES,
     30                TRIANGLE_STRIP,
     31                TRIANGLE_FAN
     32        };
     33
    2134        class context
    2235        {
    2336        public:
    2437                virtual void clear( const clear_state& cs ) = 0;
     38                // temporary
     39                virtual void draw( primitive prim, const render_state& rs, program* p, vertex_array* va, int count ) = 0;
    2540                virtual void apply_render_state( const render_state& state ) = 0;
    2641                virtual const ivec4& get_viewport() = 0;
  • trunk/nv/interface/device.hh

    r44 r45  
    1616#include <nv/string.hh>
    1717#include <nv/interface/vertex_buffer.hh>
     18#include <nv/interface/texture2d.hh>
    1819
    1920namespace nv
     
    3031                virtual index_buffer* create_index_buffer( buffer_hint hint, int size, void* source = nullptr ) = 0;
    3132                virtual vertex_array* create_vertex_array() = 0;
     33                virtual texture2d* create_texture2d( ivec2 size, texture2d::format aformat, texture2d::datatype adatatype, texture2d_sampler sampler, void* data = nullptr ) = 0;
    3234        };
    3335
  • trunk/src/gl/gl_context.cc

    r44 r45  
    353353        force_apply_render_state( m_render_state );
    354354}
     355
     356void gl_context::draw( primitive prim, const render_state& rs, program* p, vertex_array* va, int count )
     357{
     358        apply_render_state( rs );
     359        p->bind();
     360        va->bind();
     361        glDrawArrays( primitive_to_enum(prim), 0, count);
     362        va->unbind();
     363        p->unbind();
     364}
  • trunk/src/gl/gl_device.cc

    r44 r45  
    88#include "nv/gl/gl_program.hh"
    99#include "nv/gl/gl_vertex_buffer.hh"
     10#include "nv/gl/gl_texture2d.hh"
    1011#include "nv/logging.hh"
    1112#include "nv/lib/sdl12.hh"
     
    6667}
    6768
     69texture2d* gl_device::create_texture2d( ivec2 size, texture2d::format aformat, texture2d::datatype adatatype, texture2d_sampler sampler, void* data /*= nullptr */ )
     70{
     71        return new gl_texture2d( size, aformat, adatatype, sampler, data );
     72}
     73
    6874gl_device::~gl_device()
    6975{
    7076        SDL_Quit();
    7177}
    72 
  • trunk/src/gl/gl_enum.cc

    r44 r45  
    181181}
    182182
     183unsigned int nv::primitive_to_enum( primitive p )
     184{
     185        switch( p )
     186        {
     187        case POINTS         : return GL_POINTS;
     188        case LINES          : return GL_LINES;
     189        case LINE_LOOP      : return GL_LINE_LOOP;
     190        case LINE_STRIP     : return GL_LINE_STRIP;
     191        case TRIANGLES      : return GL_TRIANGLES;
     192        case TRIANGLE_STRIP : return GL_TRIANGLE_STRIP;
     193        case TRIANGLE_FAN   : return GL_TRIANGLE_FAN;
     194        default : return 0; // TODO: throw!
     195        }
     196}
    183197
    184198unsigned int nv::type_to_gl_enum( type type )
  • trunk/src/gl/texture_font.cc

    r28 r45  
    5555
    5656    FT_Size_Metrics metrics = ((FT_Face)(m_rface))->size->metrics;
    57     m_ascender = (metrics.ascender >> 6) / 100.0;
    58     m_descender = (metrics.descender >> 6) / 100.0;
    59     m_height = (metrics.height >> 6) / 100.0;
    60     m_linegap = m_height - m_ascender + m_descender;
     57    m_ascender  = (float)(metrics.ascender >> 6) / 100.0f;
     58    m_descender = (float)(metrics.descender >> 6) / 100.0f;
     59    m_height    = (float)(metrics.height >> 6) / 100.0f;
     60    m_linegap   = m_height - m_ascender + m_descender;
    6161}
    6262
  • trunk/src/resource_manager.cc

    r7 r45  
    2424        if ( i != m_id_map.end() )
    2525        {
    26                 return m_data[ i->second ];
     26                return m_data[ (unsigned int)i->second ];
    2727        }
    2828        return resource::ptr();
Note: See TracChangeset for help on using the changeset viewer.