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

Last change on this file since 473 was 473, checked in by epyon, 10 years ago
  • rtti updates
  • device/context initial uniform buffer support
  • fixes
File size: 3.8 KB
Line 
1// Copyright (C) 2012-2015 ChaosForge Ltd
2// http://chaosforge.org/
3//
4// This file is part of Nova libraries.
5// For conditions of distribution and use, see copying.txt file in root folder.
6
7/**
8 * @file gl_context.hh
9 * @author Kornel Kisielewicz epyon@chaosforge.org
10 * @brief Context class
11 */
12
13#ifndef NV_GL_CONTEXT_HH
14#define NV_GL_CONTEXT_HH
15
16#include <nv/interface/context.hh>
17
18namespace nv
19{
20        struct gl_framebuffer_info : public framebuffer_info
21        {
22                unsigned glid;
23                unsigned depth_rb_glid;
24        };
25
26        class gl_context : public context
27        {
28        public:
29                gl_context( device* a_device, void* a_handle );
30                virtual ~gl_context();
31
32                virtual vertex_array create_vertex_array();
33                virtual framebuffer create_framebuffer();
34                virtual void release( vertex_array va );
35                virtual void release( framebuffer f );
36                virtual const vertex_array_info* get_vertex_array_info( vertex_array va ) const;
37                virtual const framebuffer_info* get_framebuffer_info( framebuffer f ) const;
38
39                virtual void set_draw_buffers( uint32 count, const output_slot* slots );
40                virtual void set_draw_buffer( output_slot slot );
41                virtual void set_read_buffer( output_slot slot );
42                virtual void blit( framebuffer f, clear_state::buffers_type mask, ivec2 src1, ivec2 src2, ivec2 dst1, ivec2 dst2 );
43
44                virtual void attach( framebuffer f, output_slot slot, texture t );
45                virtual void attach( framebuffer f, texture depth, int layer = -1 );
46                virtual void attach( framebuffer f, ivec2 size );
47                virtual bool check( framebuffer_slot ft );
48                virtual void bind( framebuffer f, framebuffer_slot ft = FRAMEBUFFER );
49                virtual void bind( texture t, texture_slot slot );
50                virtual void bind( buffer b, uint32 index, size_t offset = 0, size_t size = 0 );
51
52                virtual void update( texture t, const void* data );
53                virtual void update( buffer b, const void* data, size_t offset, size_t size );
54                virtual void update( buffer b, uint32 index, const void* data, size_t offset, size_t size );
55
56                virtual void clear( const clear_state& cs );
57                // temporary
58                virtual void draw( primitive prim, const render_state& rs, program p, vertex_array va, size_t count, size_t first = 0 );
59                virtual const ivec4& get_viewport();
60                virtual void set_viewport( const ivec4& viewport );
61                virtual void apply_render_state( const render_state& state );
62                virtual void apply_engine_uniforms( program p, const scene_state& s );
63                // TODO: remove
64                void* get_native_handle() { return m_handle; }
65
66        protected:
67                void bind( program p );
68//              void bind( buffer b );
69                void bind( vertex_array va );
70                void unbind( program p );
71//              void unbind( buffer b );
72                void unbind( vertex_array va );
73                void unbind( framebuffer va );
74
75                void force_apply_render_state( const render_state& state );
76                void force_apply_stencil_face( unsigned face, const stencil_test_face& stencil );
77                // TODO: remove
78                virtual vertex_array_info* get_vertex_array_info_mutable( vertex_array );
79        private:
80                void apply_stencil_test( const stencil_test& stencil );
81                void apply_stencil_face( unsigned face, stencil_test_face& stencil, const stencil_test_face& new_stencil );
82                void apply_scissor_test( const scissor_test& scissor );
83                void apply_depth_test( const depth_test& depth );
84                void apply_depth_mask( bool mask );
85                void apply_depth_range( const depth_range& range );
86                void apply_color_mask( const color_mask& mask );
87                void apply_blending( const blending& blend );
88                void apply_culling( const culling& cull );
89                void apply_polygon_mode( const polygon_mode& mode );
90                void enable( unsigned int what, bool value );
91        private:
92                vec4  m_clear_color;
93                float m_clear_depth;
94                int   m_clear_stencil;
95                void* m_handle;
96
97                handle_store< vertex_array_info, vertex_array >  m_vertex_arrays;
98                handle_store< gl_framebuffer_info, framebuffer > m_framebuffers;
99        };
100
101
102} // namespace nv
103
104#endif // NV_CONTEXT_HH
Note: See TracBrowser for help on using the repository browser.