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
RevLine 
[37]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        {
[245]21        protected:
22                gl_context( device* a_device );
[37]23        public:
[171]24                ~gl_context();
[301]25                virtual void bind( texture t, texture_slot slot );
[303]26                virtual void bind( program p );
[302]27                virtual void bind( buffer b );
28                virtual void bind( vertex_array va );
[303]29                virtual void unbind( program p );
[302]30                virtual void unbind( buffer b );
31                virtual void unbind( vertex_array va );
[299]32
[301]33                virtual void update( texture t, void* data );
[302]34                virtual void update( buffer b, const void* data, size_t offset, size_t size );
[299]35
[44]36                virtual void clear( const clear_state& cs );
[45]37                // temporary
[303]38                virtual void draw( primitive prim, const render_state& rs, program p, vertex_array va, size_t count );
[44]39                virtual const ivec4& get_viewport();
40                virtual void set_viewport( const ivec4& viewport );
41                virtual void apply_render_state( const render_state& state );
[303]42                virtual void apply_engine_uniforms( program p, const scene_state& s );
43
[245]44        protected:
[37]45                void force_apply_render_state( const render_state& state );
[121]46                void force_apply_stencil_face( unsigned face, const stencil_test_face& stencil );
[245]47        private:
[37]48                void apply_stencil_test( const stencil_test& stencil );
[121]49                void apply_stencil_face( unsigned face, stencil_test_face& stencil, const stencil_test_face& new_stencil );
[37]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 );
[233]57                void apply_polygon_mode( const polygon_mode& mode );
[37]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;
[245]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:
[171]72                void* m_handle;
[37]73        };
74
[245]75        class native_gl_context : public gl_context
76        {
77        public:
78                native_gl_context( device* a_device, void* a_native_win_handle );
[295]79                void* get_native_handle() { return m_handle; }
[245]80                ~native_gl_context();
81        private:
82                void* m_handle;
83        };
84
85
[37]86} // namespace nv
87
88#endif // NV_CONTEXT_HH
Note: See TracBrowser for help on using the repository browser.