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

Last change on this file since 303 was 303, checked in by epyon, 11 years ago
  • program is now handle-based
  • all device constructs are now handle-based and do not dynamically allocate
File size: 2.7 KB
Line 
1// Copyright (C) 2012-2013 ChaosForge / Kornel Kisielewicz
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        class gl_context : public context
20        {
21        protected:
22                gl_context( device* a_device );
23        public:
24                ~gl_context();
25                virtual void bind( texture t, texture_slot slot );
26                virtual void bind( program p );
27                virtual void bind( buffer b );
28                virtual void bind( vertex_array va );
29                virtual void unbind( program p );
30                virtual void unbind( buffer b );
31                virtual void unbind( vertex_array va );
32
33                virtual void update( texture t, void* data );
34                virtual void update( buffer b, const void* data, size_t offset, size_t size );
35
36                virtual void clear( const clear_state& cs );
37                // temporary
38                virtual void draw( primitive prim, const render_state& rs, program p, vertex_array va, size_t count );
39                virtual const ivec4& get_viewport();
40                virtual void set_viewport( const ivec4& viewport );
41                virtual void apply_render_state( const render_state& state );
42                virtual void apply_engine_uniforms( program p, const scene_state& s );
43
44        protected:
45                void force_apply_render_state( const render_state& state );
46                void force_apply_stencil_face( unsigned face, const stencil_test_face& stencil );
47        private:
48                void apply_stencil_test( const stencil_test& stencil );
49                void apply_stencil_face( unsigned face, stencil_test_face& stencil, const stencil_test_face& new_stencil );
50                void apply_scissor_test( const scissor_test& scissor );
51                void apply_depth_test( const depth_test& depth );
52                void apply_depth_mask( bool mask );
53                void apply_depth_range( const depth_range& range );
54                void apply_color_mask( const color_mask& mask );
55                void apply_blending( const blending& blend );
56                void apply_culling( const culling& cull );
57                void apply_polygon_mode( const polygon_mode& mode );
58                void enable( unsigned int what, bool value );
59
60        private:
61                vec4  m_clear_color;
62                float m_clear_depth;
63                int   m_clear_stencil;
64        };
65
66        class sdl_gl_context : public gl_context
67        {
68        public:
69                sdl_gl_context( device* a_device, void* a_sdl_win_handle );
70                ~sdl_gl_context();
71        private:
72                void* m_handle;
73        };
74
75        class native_gl_context : public gl_context
76        {
77        public:
78                native_gl_context( device* a_device, void* a_native_win_handle );
79                void* get_native_handle() { return m_handle; }
80                ~native_gl_context();
81        private:
82                void* m_handle;
83        };
84
85
86} // namespace nv
87
88#endif // NV_CONTEXT_HH
Note: See TracBrowser for help on using the repository browser.