Changeset 1771
- Timestamp:
- Aug 18, 2012, 5:49:40 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/ticker.cpp
r1718 r1771 363 363 case Entity::DRAWGROUP_BEGIN: 364 364 Scene::GetDefault()->Reset(); 365 Video::Clear( );365 Video::Clear(ClearMask::All); 366 366 break; 367 367 case Entity::DRAWGROUP_HUD: -
trunk/src/video.cpp
r1513 r1771 52 52 static mat4 proj_matrix; 53 53 static ivec2 saved_viewport; 54 #if defined USE_D3D9 54 #if defined USE_D3D9 || defined _XBOX 55 # if defined USE_D3D9 55 56 static IDirect3D9 *d3d_ctx; 56 57 static IDirect3DDevice9 *d3d_dev; 57 static D3DCOLOR clear_color; 58 #elif defined _XBOX 58 # elif defined _XBOX 59 59 static Direct3D *d3d_ctx; 60 60 static D3DDevice *d3d_dev; 61 # endif 61 62 static D3DCOLOR clear_color; 63 static float clear_depth; 62 64 #endif 63 65 }; … … 66 68 ivec2 VideoData::saved_viewport(0, 0); 67 69 68 #if defined USE_D3D9 70 #if defined USE_D3D9 || defined _XBOX 71 # if defined USE_D3D9 69 72 IDirect3D9 *VideoData::d3d_ctx; 70 73 IDirect3DDevice9 *VideoData::d3d_dev; 71 D3DCOLOR VideoData::clear_color; 72 #elif defined _XBOX 74 # elif defined _XBOX 73 75 Direct3D *VideoData::d3d_ctx; 74 76 D3DDevice *VideoData::d3d_dev; 77 # endif 75 78 D3DCOLOR VideoData::clear_color; 79 float VideoData::clear_depth; 76 80 #endif 77 81 … … 108 112 VideoData::saved_viewport = size; 109 113 110 VideoData::clear_color = D3DCOLOR_XRGB(26, 51, 77);111 112 114 d3dpp.BackBufferWidth = size.x; 113 115 d3dpp.BackBufferHeight = size.y; … … 144 146 VideoData::saved_viewport = size; 145 147 146 glClearColor(0.1f, 0.2f, 0.3f, 1.0f);147 glClearDepth(1.0);148 149 148 # if defined HAVE_GL_2X && !defined __APPLE__ 150 149 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); 151 150 # endif 152 151 #endif 152 153 /* Initialise reasonable scene default properties */ 154 SetClearColor(vec4(0.1f, 0.2f, 0.3f, 1.0f)); 155 SetClearDepth(1.f); 153 156 } 154 157 … … 219 222 } 220 223 221 void Video::Clear() 222 { 224 void Video::SetClearDepth(float f) 225 { 226 #if defined USE_D3D9 || defined _XBOX 227 VideoData::clear_depth = f; 228 #else 229 glClearDepth(f); 230 #endif 231 } 232 233 void Video::Clear(ClearMask m) 234 { 235 #if defined USE_D3D9 || defined _XBOX 236 /* Note: D3D9 doesn't appear to support the accumulation buffer. */ 237 int mask = 0; 238 if (m & ClearMask::Color) 239 mask |= D3DCLEAR_TARGET; 240 if (m & ClearMask::Depth) 241 mask |= D3DCLEAR_ZBUFFER; 242 if (m & ClearMask::Stencil) 243 mask |= D3DCLEAR_STENCIL; 244 if (FAILED(VideoData::d3d_dev->Clear(0, NULL, mask, 245 VideoData::clear_color, 246 VideoData::clear_depth, 0))) 247 Abort(); 248 #else 249 /* FIXME: is this necessary here? */ 223 250 ivec2 size = GetSize(); 224 #if defined USE_D3D9 || defined _XBOX225 if (FAILED(VideoData::d3d_dev->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER226 | D3DCLEAR_STENCIL,227 VideoData::clear_color, 1.0f, 0)))228 Abort();229 #else230 251 glViewport(0, 0, size.x, size.y); 231 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 252 253 GLbitfield mask = 0; 254 if (m & ClearMask::Color) 255 mask |= GL_COLOR_BUFFER_BIT; 256 if (m & ClearMask::Depth) 257 mask |= GL_DEPTH_BUFFER_BIT; 258 if (m & ClearMask::Accum) 259 mask |= GL_ACCUM_BUFFER_BIT; 260 if (m & ClearMask::Stencil) 261 mask |= GL_STENCIL_BUFFER_BIT; 262 glClear(mask); 232 263 #endif 233 264 -
trunk/src/video.h
r1325 r1771 23 23 { 24 24 25 struct ClearMask 26 { 27 enum Value 28 { 29 Color = 1 << 0, 30 Depth = 1 << 1, 31 Accum = 1 << 2, 32 Stencil = 1 << 3, 33 34 All = 0xffffffff 35 } 36 m_value; 37 38 inline ClearMask(Value v) { m_value = v; } 39 inline ClearMask(uint64_t i) { m_value = (Value)i; } 40 inline operator Value() { return m_value; } 41 }; 42 25 43 class Video 26 44 { … … 31 49 static void SetDepth(bool set); 32 50 static void SetClearColor(vec4 color); 33 static void Clear(); 51 static void SetClearDepth(float f); 52 static void Clear(ClearMask m); 34 53 static void Capture(uint32_t *buffer); 35 54 static ivec2 GetSize(); -
trunk/tools/neercs/video/render.cpp
r1763 r1771 819 819 /* Clear the back buffer */ 820 820 glEnable(GL_BLEND); 821 glBlendFunc(GL_SRC_COLOR,GL_DST_ALPHA); 822 glClearColor(screen_color.r, screen_color.g, screen_color.b, 1.0f); 823 glClearDepth(1.0f); // set depth buffer 824 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 821 glBlendFunc(GL_SRC_COLOR, GL_DST_ALPHA); 822 823 Video::SetClearColor(vec4(screen_color, 1.f)); 824 Video::SetClearDepth(1.0f); // set depth buffer 825 Video::Clear(ClearMask::Color | ClearMask::Depth); 825 826 826 827 text_render->Blit(border, canvas_size); -
trunk/tutorial/08_fbo.cpp
r1737 r1771 15 15 #include "core.h" 16 16 #include "loldebug.h" 17 #include "lolgl.h"18 17 19 18 using namespace std; … … 78 77 m_fbo = new FrameBuffer(Video::GetSize()); 79 78 m_fbo->Bind(); 80 glClearColor(0.0, 0.0, 0.0, 1.0f);81 glClearDepth(1.0f);82 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);79 Video::SetClearColor(vec4(0.f, 0.f, 0.f, 1.f)); 80 Video::SetClearDepth(1.f); 81 Video::Clear(ClearMask::Color | ClearMask::Depth); 83 82 m_fbo->Unbind(); 84 83 … … 90 89 m_fbo->Bind(); 91 90 /* FIXME: we should just disable depth test in the shader */ 92 glClear(GL_DEPTH_BUFFER_BIT);91 Video::Clear(ClearMask::Depth); 93 92 m_shader->Bind(); 94 93 m_shader->SetUniform(m_uni_flag, 0.f);
Note: See TracChangeset
for help on using the changeset viewer.