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

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