source: trunk/nv/gl/gl_context.hh @ 326

Last change on this file since 326 was 326, checked in by epyon, 11 years ago
  • window_manager interface added
  • input interface added
  • sdl::window_manager and sdl::input added
  • gl_device/gl_window/gl_context made oblivious to sdl
  • currently some setup is required, application class needed
File size: 3.0 KB
Line 
1// Copyright (C) 2012-2014 ChaosForge Ltd
2// http://chaosforge.org/
3//
4// This file is part of NV Libraries.
5// For conditions of distribution and use, see copyright notice in nv.hh
6/**
7 * @file gl_context.hh
8 * @author Kornel Kisielewicz epyon@chaosforge.org
9 * @brief Context class
10 */
11
12#ifndef NV_GL_CONTEXT_HH
13#define NV_GL_CONTEXT_HH
14
15#include <nv/interface/context.hh>
16
17namespace nv
18{
19        struct gl_framebuffer_info : public framebuffer_info
20        {
21                unsigned glid;
22        };
23
24        class gl_context : public context
25        {
26        public:
27                gl_context( device* a_device, void* a_handle );
28                virtual ~gl_context();
29
30                virtual vertex_array create_vertex_array();
31                virtual framebuffer create_framebuffer();
32                virtual void release( vertex_array va );
33                virtual void release( framebuffer f );
34                virtual const vertex_array_info* get_vertex_array_info( vertex_array va ) const;
35                virtual const framebuffer_info* get_framebuffer_info( framebuffer f ) const;
36
37                virtual void bind( texture t, texture_slot slot );
38
39                virtual void update( texture t, void* data );
40                virtual void update( buffer b, const void* data, size_t offset, size_t size );
41
42                virtual void clear( const clear_state& cs );
43                // temporary
44                virtual void draw( primitive prim, const render_state& rs, program p, vertex_array va, size_t count );
45                virtual const ivec4& get_viewport();
46                virtual void set_viewport( const ivec4& viewport );
47                virtual void apply_render_state( const render_state& state );
48                virtual void apply_engine_uniforms( program p, const scene_state& s );
49                // TODO: remove
50                void* get_native_handle() { return m_handle; }
51
52        protected:
53                void bind( program p );
54//              void bind( buffer b );
55                void bind( vertex_array va );
56                void bind( framebuffer va );
57                void unbind( program p );
58//              void unbind( buffer b );
59                void unbind( vertex_array va );
60                void unbind( framebuffer va );
61
62                void force_apply_render_state( const render_state& state );
63                void force_apply_stencil_face( unsigned face, const stencil_test_face& stencil );
64                // TODO: remove
65                virtual vertex_array_info* get_vertex_array_info_mutable( vertex_array );
66        private:
67                void apply_stencil_test( const stencil_test& stencil );
68                void apply_stencil_face( unsigned face, stencil_test_face& stencil, const stencil_test_face& new_stencil );
69                void apply_scissor_test( const scissor_test& scissor );
70                void apply_depth_test( const depth_test& depth );
71                void apply_depth_mask( bool mask );
72                void apply_depth_range( const depth_range& range );
73                void apply_color_mask( const color_mask& mask );
74                void apply_blending( const blending& blend );
75                void apply_culling( const culling& cull );
76                void apply_polygon_mode( const polygon_mode& mode );
77                void enable( unsigned int what, bool value );
78        private:
79                vec4  m_clear_color;
80                float m_clear_depth;
81                int   m_clear_stencil;
82                void* m_handle;
83
84                entity_store< vertex_array_info, vertex_array >  m_vertex_arrays;
85                entity_store< gl_framebuffer_info, framebuffer > m_framebuffers;
86        };
87
88
89} // namespace nv
90
91#endif // NV_CONTEXT_HH
Note: See TracBrowser for help on using the repository browser.