Changeset 2762
- Timestamp:
- Jun 22, 2013, 5:31:19 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core.h
r2761 r2762 86 86 87 87 88 /* XXX: workaround for X11 headers that try to #define None */ 88 /* XXX: workaround for X11 headers that try to #define these */ 89 #undef Always 90 #define Always Always 89 91 #undef None 90 92 #define None None -
trunk/src/gpu/rendercontext.cpp
r2761 r2762 58 58 TrackedState<float> m_clear_depth; 59 59 TrackedState<bool> m_alpha_blend; 60 TrackedState<BlendF actor> m_blend_src;61 TrackedState<BlendF actor> m_blend_dst;60 TrackedState<BlendFunc> m_blend_src; 61 TrackedState<BlendFunc> m_blend_dst; 62 62 TrackedState<bool> m_alpha_test; 63 TrackedState< bool> m_depth_test;63 TrackedState<DepthFunc> m_depth_func; 64 64 TrackedState<CullMode> m_face_culling; 65 65 }; … … 93 93 g_renderer->SetAlphaTest(m_data->m_alpha_test.GetValue()); 94 94 95 if (m_data->m_depth_ test.HasChanged())96 g_renderer->SetDepth Test(m_data->m_depth_test.GetValue());95 if (m_data->m_depth_func.HasChanged()) 96 g_renderer->SetDepthFunc(m_data->m_depth_func.GetValue()); 97 97 98 98 if (m_data->m_face_culling.HasChanged()) … … 126 126 } 127 127 128 void RenderContext::SetBlendFunc(BlendF actor src, BlendFactordst)128 void RenderContext::SetBlendFunc(BlendFunc src, BlendFunc dst) 129 129 { 130 130 if (!m_data->m_blend_src.HasChanged()) … … 144 144 } 145 145 146 void RenderContext::SetDepth Test(bool set)146 void RenderContext::SetDepthFunc(DepthFunc func) 147 147 { 148 if (!m_data->m_depth_ test.HasChanged())149 m_data->m_depth_ test.TrackValue(g_renderer->GetDepthTest());148 if (!m_data->m_depth_func.HasChanged()) 149 m_data->m_depth_func.TrackValue(g_renderer->GetDepthFunc()); 150 150 151 g_renderer->SetDepth Test(set);151 g_renderer->SetDepthFunc(func); 152 152 } 153 153 -
trunk/src/gpu/renderer.cpp
r2761 r2762 56 56 vec4 m_clear_color; 57 57 float m_clear_depth; 58 BlendFactor m_blend_src, m_blend_dst; 58 BlendFunc m_blend_src, m_blend_dst; 59 DepthFunc m_depth_func; 59 60 CullMode m_face_culling; 60 bool m_alpha_blend, m_alpha_test , m_depth_test;61 bool m_alpha_blend, m_alpha_test; 61 62 62 63 #if defined USE_D3D9 … … 102 103 SetAlphaTest(false); 103 104 104 m_data->m_blend_src = BlendF actor::Zero;105 m_data->m_blend_dst = BlendF actor::Zero;106 SetBlendFunc(BlendF actor::SrcAlpha, BlendFactor::OneMinusSrcAlpha);107 108 m_data->m_depth_ test = false;109 SetDepth Test(true);110 111 m_data->m_face_culling = CullMode:: None;112 SetFaceCulling(CullMode::C CW);105 m_data->m_blend_src = BlendFunc::Zero; 106 m_data->m_blend_dst = BlendFunc::Zero; 107 SetBlendFunc(BlendFunc::SrcAlpha, BlendFunc::OneMinusSrcAlpha); 108 109 m_data->m_depth_func = DepthFunc::Disabled; 110 SetDepthFunc(DepthFunc::LessOrEqual); 111 112 m_data->m_face_culling = CullMode::Disabled; 113 SetFaceCulling(CullMode::CounterClockwise); 113 114 114 115 /* Add some rendering states that we don't export to the user */ … … 199 200 */ 200 201 201 void Renderer::SetBlendFunc(BlendF actor src, BlendFactordst)202 void Renderer::SetBlendFunc(BlendFunc src, BlendFunc dst) 202 203 { 203 204 if (m_data->m_blend_src == src && m_data->m_blend_dst == dst) … … 206 207 #if defined USE_D3D9 || defined _XBOX 207 208 enum D3DBLEND s1[2] = { D3DBLEND_ONE, D3DBLEND_ZERO }; 208 BlendF actors2[2] = { src, dst };209 BlendFunc s2[2] = { src, dst }; 209 210 210 211 for (int i = 0; i < 2; ++i) … … 212 213 switch (s2[i]) 213 214 { 214 case BlendF actor::Zero:215 case BlendFunc::Zero: 215 216 s1[i] = D3DBLEND_ZERO; break; 216 case BlendF actor::One:217 case BlendFunc::One: 217 218 s1[i] = D3DBLEND_ONE; break; 218 case BlendF actor::SrcColor:219 case BlendFunc::SrcColor: 219 220 s1[i] = D3DBLEND_SRCCOLOR; break; 220 case BlendF actor::OneMinusSrcColor:221 case BlendFunc::OneMinusSrcColor: 221 222 s1[i] = D3DBLEND_INVSRCCOLOR; break; 222 case BlendF actor::DstColor:223 case BlendFunc::DstColor: 223 224 s1[i] = D3DBLEND_DESTCOLOR; break; 224 case BlendF actor::OneMinusDstColor:225 case BlendFunc::OneMinusDstColor: 225 226 s1[i] = D3DBLEND_INVDESTCOLOR; break; 226 case BlendF actor::SrcAlpha:227 case BlendFunc::SrcAlpha: 227 228 s1[i] = D3DBLEND_SRCALPHA; break; 228 case BlendF actor::OneMinusSrcAlpha:229 case BlendFunc::OneMinusSrcAlpha: 229 230 s1[i] = D3DBLEND_INVSRCALPHA; break; 230 case BlendF actor::DstAlpha:231 case BlendFunc::DstAlpha: 231 232 s1[i] = D3DBLEND_DESTALPHA; break; 232 case BlendF actor::OneMinusDstAlpha:233 case BlendFunc::OneMinusDstAlpha: 233 234 s1[i] = D3DBLEND_INVDESTALPHA; break; 234 235 /* FiXME: these can be supported using D3DPBLENDCAPS_BLENDFACTOR */ 235 case BlendF actor::ConstantColor:236 assert(0, "BlendF actor::ConstantColor not supported");236 case BlendFunc::ConstantColor: 237 assert(0, "BlendFunc::ConstantColor not supported"); 237 238 break; 238 case BlendF actor::OneMinusConstantColor:239 assert(0, "BlendF actor::OneMinusConstantColor not supported");239 case BlendFunc::OneMinusConstantColor: 240 assert(0, "BlendFunc::OneMinusConstantColor not supported"); 240 241 break; 241 case BlendF actor::ConstantAlpha:242 assert(0, "BlendF actor::ConstantAlpha not supported");242 case BlendFunc::ConstantAlpha: 243 assert(0, "BlendFunc::ConstantAlpha not supported"); 243 244 break; 244 case BlendF actor::OneMinusConstantAlpha:245 assert(0, "BlendF actor::OneMinusConstantAlpha not supported");245 case BlendFunc::OneMinusConstantAlpha: 246 assert(0, "BlendFunc::OneMinusConstantAlpha not supported"); 246 247 break; 247 248 } … … 252 253 #else 253 254 GLenum s1[2] = { GL_ONE, GL_ZERO }; 254 BlendF actors2[2] = { src, dst };255 BlendFunc s2[2] = { src, dst }; 255 256 256 257 for (int i = 0; i < 2; ++i) … … 258 259 switch (s2[i]) 259 260 { 260 case BlendF actor::Zero:261 case BlendFunc::Zero: 261 262 s1[i] = GL_ZERO; break; 262 case BlendF actor::One:263 case BlendFunc::One: 263 264 s1[i] = GL_ONE; break; 264 case BlendF actor::SrcColor:265 case BlendFunc::SrcColor: 265 266 s1[i] = GL_SRC_COLOR; break; 266 case BlendF actor::OneMinusSrcColor:267 case BlendFunc::OneMinusSrcColor: 267 268 s1[i] = GL_ONE_MINUS_SRC_COLOR; break; 268 case BlendF actor::DstColor:269 case BlendFunc::DstColor: 269 270 s1[i] = GL_DST_COLOR; break; 270 case BlendF actor::OneMinusDstColor:271 case BlendFunc::OneMinusDstColor: 271 272 s1[i] = GL_ONE_MINUS_DST_COLOR; break; 272 case BlendF actor::SrcAlpha:273 case BlendFunc::SrcAlpha: 273 274 s1[i] = GL_SRC_ALPHA; break; 274 case BlendF actor::OneMinusSrcAlpha:275 case BlendFunc::OneMinusSrcAlpha: 275 276 s1[i] = GL_ONE_MINUS_SRC_ALPHA; break; 276 case BlendF actor::DstAlpha:277 case BlendFunc::DstAlpha: 277 278 s1[i] = GL_DST_ALPHA; break; 278 case BlendF actor::OneMinusDstAlpha:279 case BlendFunc::OneMinusDstAlpha: 279 280 s1[i] = GL_ONE_MINUS_DST_ALPHA; break; 280 case BlendF actor::ConstantColor:281 case BlendFunc::ConstantColor: 281 282 s1[i] = GL_CONSTANT_COLOR; break; 282 case BlendF actor::OneMinusConstantColor:283 case BlendFunc::OneMinusConstantColor: 283 284 s1[i] = GL_ONE_MINUS_CONSTANT_COLOR; break; 284 case BlendF actor::ConstantAlpha:285 case BlendFunc::ConstantAlpha: 285 286 s1[i] = GL_CONSTANT_ALPHA; break; 286 case BlendF actor::OneMinusConstantAlpha:287 case BlendFunc::OneMinusConstantAlpha: 287 288 s1[i] = GL_ONE_MINUS_CONSTANT_ALPHA; break; 288 289 } … … 296 297 } 297 298 298 BlendF actorRenderer::GetBlendFuncSrc() const299 BlendFunc Renderer::GetBlendFuncSrc() const 299 300 { 300 301 return m_data->m_blend_src; 301 302 } 302 303 303 BlendF actorRenderer::GetBlendFuncDst() const304 BlendFunc Renderer::GetBlendFuncDst() const 304 305 { 305 306 return m_data->m_blend_dst; … … 336 337 */ 337 338 338 void Renderer::SetDepth Test(bool set)339 { 340 if (m_data->m_depth_ test == set)339 void Renderer::SetDepthFunc(DepthFunc func) 340 { 341 if (m_data->m_depth_func == func) 341 342 return; 342 343 343 344 #if defined USE_D3D9 || defined _XBOX 344 # define STR0(x) #x 345 # define STR(x) STR0(x) 346 # pragma message(__FILE__ "(" STR(__LINE__) "): warning: Renderer::SetDepthTest() not implemented") 347 #else 348 if (set) 345 switch (func) 346 { 347 case DepthFunc::Disabled: 348 break; /* Nothing to do */ 349 case DepthFunc::Never: 350 m_data->m_d3d_dev->SetRenderState(D3DRS_ZFUNC, D3DCMP_NEVER); 351 break; 352 case DepthFunc::Less: 353 m_data->m_d3d_dev->SetRenderState(D3DRS_ZFUNC, D3DCMP_LESS); 354 break; 355 case DepthFunc::Equal: 356 m_data->m_d3d_dev->SetRenderState(D3DRS_ZFUNC, D3DCMP_EQUAL); 357 break; 358 case DepthFunc::LessOrEqual: 359 m_data->m_d3d_dev->SetRenderState(D3DRS_ZFUNC, D3DCMP_LESSEQUAL); 360 break; 361 case DepthFunc::Greater: 362 m_data->m_d3d_dev->SetRenderState(D3DRS_ZFUNC, D3DCMP_GREATER); 363 break; 364 case DepthFunc::NotEqual: 365 m_data->m_d3d_dev->SetRenderState(D3DRS_ZFUNC, D3DCMP_NOTEQUAL); 366 break; 367 case DepthFunc::GreaterOrEqual: 368 m_data->m_d3d_dev->SetRenderState(D3DRS_ZFUNC, D3DCMP_GREATEREQUAL); 369 break; 370 case DepthFunc::Always: 371 m_data->m_d3d_dev->SetRenderState(D3DRS_ZFUNC, D3DCMP_ALWAYS); 372 break; 373 } 374 375 if (func == DepthFunc::Disabled) 376 m_data->m_d3d_dev->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE); 377 else 378 m_data->m_d3d_dev->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE); 379 #else 380 switch (func) 381 { 382 case DepthFunc::Disabled: 383 break; /* Nothing to do */ 384 case DepthFunc::Never: 385 glDepthFunc(GL_NEVER); break; 386 case DepthFunc::Less: 387 glDepthFunc(GL_LESS); break; 388 case DepthFunc::Equal: 389 glDepthFunc(GL_EQUAL); break; 390 case DepthFunc::LessOrEqual: 391 glDepthFunc(GL_LEQUAL); break; 392 case DepthFunc::Greater: 393 glDepthFunc(GL_GREATER); break; 394 case DepthFunc::NotEqual: 395 glDepthFunc(GL_NOTEQUAL); break; 396 case DepthFunc::GreaterOrEqual: 397 glDepthFunc(GL_GEQUAL); break; 398 case DepthFunc::Always: 399 glDepthFunc(GL_ALWAYS); break; 400 } 401 402 if (func == DepthFunc::Disabled) 403 glDisable(GL_DEPTH_TEST); 404 else 349 405 glEnable(GL_DEPTH_TEST); 350 else 351 glDisable(GL_DEPTH_TEST); 352 #endif 353 354 m_data->m_depth_test = set; 355 } 356 357 bool Renderer::GetDepthTest() const 358 { 359 return m_data->m_depth_test; 406 #endif 407 408 m_data->m_depth_func = func; 409 } 410 411 DepthFunc Renderer::GetDepthFunc() const 412 { 413 return m_data->m_depth_func; 360 414 } 361 415 … … 372 426 switch (mode) 373 427 { 374 case CullMode:: None:428 case CullMode::Disabled: 375 429 m_data->m_d3d_dev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); 376 430 break; 377 case CullMode::C W:431 case CullMode::Clockwise: 378 432 m_data->m_d3d_dev->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW); 379 433 break; 380 case CullMode::C CW:434 case CullMode::CounterClockwise: 381 435 m_data->m_d3d_dev->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW); 382 436 break; … … 385 439 switch (mode) 386 440 { 387 case CullMode:: None:441 case CullMode::Disabled: 388 442 glDisable(GL_CULL_FACE); 389 443 break; 390 case CullMode::C W:444 case CullMode::Clockwise: 391 445 glEnable(GL_CULL_FACE); 392 446 glFrontFace(GL_CW); 393 447 break; 394 case CullMode::C CW:448 case CullMode::CounterClockwise: 395 449 glEnable(GL_CULL_FACE); 396 450 glFrontFace(GL_CCW); -
trunk/src/lol/gpu/rendercontext.h
r2761 r2762 31 31 void SetClearDepth(float depth); 32 32 void SetAlphaBlend(bool set); 33 void SetBlendFunc(BlendF actor src, BlendFactordst);33 void SetBlendFunc(BlendFunc src, BlendFunc dst); 34 34 void SetAlphaTest(bool set); 35 void SetDepth Test(bool set);35 void SetDepthFunc(DepthFunc func); 36 36 void SetFaceCulling(CullMode mode); 37 37 -
trunk/src/lol/gpu/renderer.h
r2761 r2762 23 23 24 24 /* A safe enum to indicate the blending factors. */ 25 struct BlendF actor25 struct BlendFunc 26 26 { 27 27 enum Value … … 44 44 m_value; 45 45 46 inline BlendF actor() : m_value(Zero) {}47 inline BlendF actor(Value v) : m_value(v) {}46 inline BlendFunc() : m_value(Zero) {} 47 inline BlendFunc(Value v) : m_value(v) {} 48 48 inline operator Value() { return m_value; } 49 49 }; … … 54 54 enum Value 55 55 { 56 None,57 C W,58 C CW,56 Disabled, 57 Clockwise, 58 CounterClockwise, 59 59 } 60 60 m_value; 61 61 62 inline CullMode() : m_value( None) {}62 inline CullMode() : m_value(Disabled) {} 63 63 inline CullMode(Value v) : m_value(v) {} 64 inline operator Value() { return m_value; } 65 }; 66 67 /* A safe enum to indicate the depth test mode. */ 68 struct DepthFunc 69 { 70 enum Value 71 { 72 Disabled, 73 Never, 74 Less, 75 Equal, 76 LessOrEqual, 77 Greater, 78 NotEqual, 79 GreaterOrEqual, 80 Always, 81 } 82 m_value; 83 84 inline DepthFunc() : m_value(Disabled) {} 85 inline DepthFunc(Value v) : m_value(v) {} 64 86 inline operator Value() { return m_value; } 65 87 }; … … 84 106 bool GetAlphaBlend() const; 85 107 86 void SetBlendFunc(BlendF actor src, BlendFactordst);87 BlendF actorGetBlendFuncSrc() const;88 BlendF actorGetBlendFuncDst() const;108 void SetBlendFunc(BlendFunc src, BlendFunc dst); 109 BlendFunc GetBlendFuncSrc() const; 110 BlendFunc GetBlendFuncDst() const; 89 111 90 112 void SetAlphaTest(bool set); 91 113 bool GetAlphaTest() const; 92 114 93 void SetDepth Test(bool set);94 bool GetDepthTest() const;115 void SetDepthFunc(DepthFunc func); 116 DepthFunc GetDepthFunc() const; 95 117 96 118 void SetFaceCulling(CullMode mode); -
trunk/src/scene.cpp
r2760 r2762 193 193 { 194 194 RenderContext rc; 195 rc.SetDepth Test(true);195 rc.SetDepthFunc(DepthFunc::LessOrEqual); 196 196 rc.SetAlphaBlend(true); 197 rc.SetBlendFunc(BlendF actor::SrcAlpha, BlendFactor::OneMinusSrcAlpha);197 rc.SetBlendFunc(BlendFunc::SrcAlpha, BlendFunc::OneMinusSrcAlpha); 198 198 199 199 #if defined USE_D3D9 || defined _XBOX 200 200 #else 201 glDepthFunc(GL_LEQUAL);202 201 #if defined HAVE_GL_2X && !defined __APPLE__ 203 202 glEnable(GL_ALPHA_TEST); -
trunk/tools/neercs/video/render.cpp
r2760 r2762 1454 1454 RenderContext rc; 1455 1455 rc.SetAlphaBlend(true); 1456 rc.SetBlendFunc(BlendF actor::SrcColor, BlendFactor::DstAlpha);1456 rc.SetBlendFunc(BlendFunc::SrcColor, BlendFunc::DstAlpha); 1457 1457 1458 1458 glEnable(GL_TEXTURE_2D); … … 1481 1481 RenderContext rc; 1482 1482 rc.SetAlphaBlend(false); 1483 rc.SetDepth Test(false);1483 rc.SetDepthFunc(DepthFunc::Disabled); 1484 1484 1485 1485 glEnableClientState(GL_VERTEX_ARRAY); -
trunk/tools/neercs/video/text-render.cpp
r2752 r2762 146 146 { 147 147 RenderContext rc; 148 rc.SetDepth Test(false);148 rc.SetDepthFunc(DepthFunc::Disabled); 149 149 150 150 glViewport(0, 0, m_fbo_size.x, m_fbo_size.y); -
trunk/tutorial/08_fbo.cpp
r2753 r2762 91 91 /* FIXME: we should just disable depth test in the shader */ 92 92 RenderContext rc; 93 rc.SetDepth Test(false);93 rc.SetDepthFunc(DepthFunc::Disabled); 94 94 95 95 m_fbo->Bind();
Note: See TracChangeset
for help on using the changeset viewer.