source: trunk/src/gl/gl_device.cc @ 42

Last change on this file since 42 was 42, checked in by epyon, 12 years ago
  • vertex_buffer interface and implementation
File size: 1.5 KB
RevLine 
[38]1// Copyright (C) 2012-2013 Kornel Kisielewicz
2// This file is part of NV Libraries.
3// For conditions of distribution and use, see copyright notice in nv.hh
4
5#include "nv/gl/gl_device.hh"
6
7#include "nv/gl/gl_window.hh"
8#include "nv/gl/gl_program.hh"
[42]9#include "nv/gl/gl_vertex_buffer.hh"
[38]10#include "nv/logging.hh"
11#include "nv/lib/sdl12.hh"
12
13using namespace nv;
14
15window* gl_device::create_window( uint16 width, uint16 height )
16{
17        return new gl_window( width, height );
18}
19
20gl_device::gl_device()
21{
22        nv::load_sdl_library();
23        m_info = NULL;
24
25        if ( SDL_Init( SDL_INIT_VIDEO ) < 0 )
26        {
27                NV_LOG( LOG_CRITICAL, "Video initialization failed: " << SDL_GetError( ) );
28                return; // TODO: Error report
29        }
30
31        m_info = SDL_GetVideoInfo( );
32
33        if ( !m_info )
34        {
35                NV_LOG( LOG_CRITICAL, "Video query failed: " << SDL_GetError( ) );
36                return; // TODO: Error report
37        }
38
39//      bpp = m_info->vfmt->BitsPerPixel;
40
41        SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 );
42        SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 );
43        SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 );
44        SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
45        SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
46}
47
48program* gl_device::create_program( const string& vs_source, const string& fs_source )
49{
50        return new gl_program( vs_source, fs_source );
51}
52
[42]53vertex_buffer* gl_device::create_vertex_buffer( buffer_hint hint, int size, void* source /*= nullptr */ )
54{
55        return new gl_vertex_buffer( hint, size, source );
56}
[38]57
58gl_device::~gl_device()
59{
60        SDL_Quit();
61}
[42]62
Note: See TracBrowser for help on using the repository browser.