source: trunk/src/gl/gl_window.cc @ 90

Last change on this file since 90 was 44, checked in by epyon, 12 years ago
  • context bugfixes, force apply state at creation and apply render state
  • window creates context
  • index buffer
  • vertex arrays (simulation of GL 3 functionality)
  • bugfixes
File size: 1.5 KB
Line 
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_window.hh"
6
7#include "nv/logging.hh"
8#include "nv/lib/gl.hh"
9#include "nv/lib/sdl12.hh"
10
11using namespace nv;
12
13gl_window::gl_window( uint16 width, uint16 height )
14        : m_width( width ), m_height( height ), m_title("NV Engine"), m_screen( nullptr )
15{
16        int flags = SDL_OPENGL;
17       
18        m_screen = SDL_SetVideoMode( width, height, 32, flags );
19       
20        if ( m_screen == 0 )
21        {
22                NV_LOG( LOG_CRITICAL, "Video mode set failed: " << SDL_GetError( ) );
23                return; // TODO: Error report
24        }
25
26        nv::load_gl_library();
27        NV_LOG( LOG_INFO, "OpenGL Vendor       : " << glGetString(GL_VENDOR) );
28        NV_LOG( LOG_INFO, "OpenGL Renderer     : " << glGetString(GL_RENDERER) );
29        NV_LOG( LOG_INFO, "OpenGL Version      : " << glGetString(GL_VERSION) );
30        NV_LOG( LOG_INFO, "OpenGL GLSL Version : " << glGetString(GL_SHADING_LANGUAGE_VERSION) );
31
32        m_context = new gl_context();
33        m_context->set_viewport( nv::ivec4( 0, 0, m_width, m_height ) );
34}
35
36uint16 gl_window::get_width() const
37{
38        return m_width;
39}
40
41uint16 gl_window::get_height() const
42{
43        return m_height;
44}
45
46string gl_window::get_title() const
47{
48        return m_title;
49}
50
51void gl_window::set_title( const string& title )
52{
53        SDL_WM_SetCaption( title.c_str(), title.c_str() );
54        m_title = title;
55}
56
57gl_window::~gl_window()
58{
59        delete m_context;
60}
Note: See TracBrowser for help on using the repository browser.