Ignore:
Timestamp:
07/18/13 00:50:12 (12 years ago)
Author:
epyon
Message:
  • sdl - full 2.0 version implemented in the same header
  • sdl - nova fully runs on SDL 2.0 *also*
File:
1 edited

Legend:

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

    r157 r171  
    77#include "nv/gl/gl_enum.hh"
    88#include "nv/lib/gl.hh"
     9#include "nv/lib/sdl.hh"
    910
    1011using namespace nv;
     
    349350
    350351
    351 gl_context::gl_context( device* a_device )
    352         : context( a_device )
    353 {
     352gl_context::gl_context( device* a_device, void* a_win_handle )
     353        : context( a_device ), m_handle( nullptr )
     354{
     355#if NV_SDL_VERSION == NV_SDL_20
     356        m_handle = SDL_GL_CreateContext( static_cast<SDL_Window*>( a_win_handle ) );
     357
     358        if ( m_handle == 0 )
     359        {
     360                NV_LOG( LOG_CRITICAL, "GL Context creation failed: " << SDL_GetError( ) );
     361                return; // TODO: Error report
     362        }
     363#else
     364        NV_UNUSED( a_win_handle );
     365#endif
     366
     367        nv::load_gl_library();
     368        NV_LOG( LOG_INFO, "OpenGL Vendor       : " << glGetString(GL_VENDOR) );
     369        NV_LOG( LOG_INFO, "OpenGL Renderer     : " << glGetString(GL_RENDERER) );
     370        NV_LOG( LOG_INFO, "OpenGL Version      : " << glGetString(GL_VERSION) );
     371        NV_LOG( LOG_INFO, "OpenGL GLSL Version : " << glGetString(GL_SHADING_LANGUAGE_VERSION) );
     372#if NV_SDL_VERSION == NV_SDL_20
     373//      SDL_GL_SetSwapInterval(1);
     374#endif
     375
    354376        // TODO: do we really need this?
    355377        glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
     378
    356379        force_apply_render_state( m_render_state );
    357380}
     381
     382
     383nv::gl_context::~gl_context()
     384{
     385#if NV_SDL_VERSION == NV_SDL_20
     386        SDL_GL_DeleteContext(static_cast<SDL_GLContext>( m_handle ) );
     387#endif
     388}
     389
    358390
    359391void gl_context::draw( primitive prim, const render_state& rs, program* p, vertex_array* va, size_t count )
Note: See TracChangeset for help on using the changeset viewer.