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

Last change on this file since 301 was 301, checked in by epyon, 11 years ago
  • textures are now handled by lightweight handles
  • textures now need to be manually released via context
  • removed all old texture2d functionality
  • unreleased textures will be auto-released
  • textures are properly tracked via entity system
  • detailed stats and checking now possible
File size: 2.8 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 );
[299]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
[301]35                virtual void update( texture t, void* data );
[299]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
[44]39                virtual void clear( const clear_state& cs );
[45]40                // temporary
[121]41                virtual void draw( primitive prim, const render_state& rs, program* p, vertex_array* va, size_t count );
[44]42                virtual const ivec4& get_viewport();
43                virtual void set_viewport( const ivec4& viewport );
44                virtual void apply_render_state( const render_state& state );
[245]45        protected:
[37]46                void force_apply_render_state( const render_state& state );
[121]47                void force_apply_stencil_face( unsigned face, const stencil_test_face& stencil );
[245]48        private:
[37]49                void apply_stencil_test( const stencil_test& stencil );
[121]50                void apply_stencil_face( unsigned face, stencil_test_face& stencil, const stencil_test_face& new_stencil );
[37]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 );
[233]58                void apply_polygon_mode( const polygon_mode& mode );
[37]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;
[245]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:
[171]73                void* m_handle;
[37]74        };
75
[245]76        class native_gl_context : public gl_context
77        {
78        public:
79                native_gl_context( device* a_device, void* a_native_win_handle );
[295]80                void* get_native_handle() { return m_handle; }
[245]81                ~native_gl_context();
82        private:
83                void* m_handle;
84        };
85
86
[37]87} // namespace nv
88
89#endif // NV_CONTEXT_HH
Note: See TracBrowser for help on using the repository browser.