Changeset 25269
- Timestamp:
- Apr 15, 2021, 8:07:01 PM (3 years ago)
- Location:
- ps/trunk/source
- Files:
-
- 2 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
ps/trunk/source/graphics/Camera.cpp
r25266 r25269 393 393 m_Orientation._41 = 0.0f; m_Orientation._42 = 0.0f; m_Orientation._43 = 0.0f; m_Orientation._44 = 1.0f; 394 394 } 395 396 // Render the camera's frustum397 void CCamera::Render(int intermediates) const398 {399 #if CONFIG2_GLES400 #warning TODO: implement camera frustum for GLES401 #else402 Quad nearPoints;403 Quad farPoints;404 405 GetViewQuad(m_NearPlane, nearPoints);406 GetViewQuad(m_FarPlane, farPoints);407 for(int i = 0; i < 4; i++)408 {409 nearPoints[i] = m_Orientation.Transform(nearPoints[i]);410 farPoints[i] = m_Orientation.Transform(farPoints[i]);411 }412 413 // near plane414 glBegin(GL_POLYGON);415 glVertex3fv(&nearPoints[0].X);416 glVertex3fv(&nearPoints[1].X);417 glVertex3fv(&nearPoints[2].X);418 glVertex3fv(&nearPoints[3].X);419 glEnd();420 421 // far plane422 glBegin(GL_POLYGON);423 glVertex3fv(&farPoints[0].X);424 glVertex3fv(&farPoints[1].X);425 glVertex3fv(&farPoints[2].X);426 glVertex3fv(&farPoints[3].X);427 glEnd();428 429 // connection lines430 glBegin(GL_QUAD_STRIP);431 glVertex3fv(&nearPoints[0].X);432 glVertex3fv(&farPoints[0].X);433 glVertex3fv(&nearPoints[1].X);434 glVertex3fv(&farPoints[1].X);435 glVertex3fv(&nearPoints[2].X);436 glVertex3fv(&farPoints[2].X);437 glVertex3fv(&nearPoints[3].X);438 glVertex3fv(&farPoints[3].X);439 glVertex3fv(&nearPoints[0].X);440 glVertex3fv(&farPoints[0].X);441 glEnd();442 443 // intermediate planes444 CVector3D intermediatePoints[4];445 for(int i = 0; i < intermediates; ++i)446 {447 float t = (i+1.0)/(intermediates+1.0);448 449 for(int j = 0; j < 4; ++j)450 intermediatePoints[j] = nearPoints[j]*t + farPoints[j]*(1.0-t);451 452 glBegin(GL_POLYGON);453 glVertex3fv(&intermediatePoints[0].X);454 glVertex3fv(&intermediatePoints[1].X);455 glVertex3fv(&intermediatePoints[2].X);456 glVertex3fv(&intermediatePoints[3].X);457 glEnd();458 }459 #endif460 } -
ps/trunk/source/graphics/Camera.h
r25159 r25269 109 109 void LookAlong(const CVector3D& camera, CVector3D orientation, CVector3D up); 110 110 111 /**112 * Render: Renders the camera's frustum in world space.113 * The caller should set the color using glColorXy before calling Render.114 *115 * @param intermediates determines how many intermediate distance planes should116 * be hinted at between the near and far planes117 */118 void Render(int intermediates = 0) const;119 120 111 public: 121 112 // This is the orientation matrix. The inverse of this -
ps/trunk/source/maths/BoundingBoxAligned.cpp
r25159 r25269 24 24 #include "BoundingBoxAligned.h" 25 25 26 #include "graphics/ShaderProgram.h"27 #include "lib/ogl.h"28 26 #include "maths/BoundingBoxOriented.h" 29 27 #include "maths/Brush.h" … … 266 264 m_Data[1] += CVector3D(amount, amount, amount); 267 265 } 268 269 ///////////////////////////////////////////////////////////////////////////////270 // Render the bounding box271 void CBoundingBoxAligned::Render(CShaderProgramPtr& shader) const272 {273 std::vector<float> data;274 275 #define ADD_FACE(x, y, z) \276 ADD_PT(0, 0, x, y, z); ADD_PT(1, 0, x, y, z); ADD_PT(1, 1, x, y, z); \277 ADD_PT(1, 1, x, y, z); ADD_PT(0, 1, x, y, z); ADD_PT(0, 0, x, y, z);278 #define ADD_PT(u_, v_, x, y, z) \279 STMT(int u = u_; int v = v_; \280 data.push_back(u); \281 data.push_back(v); \282 data.push_back(m_Data[x].X); \283 data.push_back(m_Data[y].Y); \284 data.push_back(m_Data[z].Z); \285 )286 287 ADD_FACE(u, v, 0);288 ADD_FACE(0, u, v);289 ADD_FACE(u, 0, 1-v);290 ADD_FACE(u, 1-v, 1);291 ADD_FACE(1, u, 1-v);292 ADD_FACE(u, 1, v);293 294 #undef ADD_FACE295 296 shader->TexCoordPointer(GL_TEXTURE0, 2, GL_FLOAT, 5*sizeof(float), &data[0]);297 shader->VertexPointer(3, GL_FLOAT, 5*sizeof(float), &data[2]);298 299 shader->AssertPointersBound();300 glDrawArrays(GL_TRIANGLES, 0, 6*6);301 }302 303 void CBoundingBoxAligned::RenderOutline(CShaderProgramPtr& shader) const304 {305 std::vector<float> data;306 307 #define ADD_FACE(x, y, z) \308 ADD_PT(0, 0, x, y, z); ADD_PT(1, 0, x, y, z); \309 ADD_PT(1, 0, x, y, z); ADD_PT(1, 1, x, y, z); \310 ADD_PT(1, 1, x, y, z); ADD_PT(0, 1, x, y, z); \311 ADD_PT(0, 1, x, y, z); ADD_PT(0, 0, x, y, z);312 #define ADD_PT(u_, v_, x, y, z) \313 STMT(int u = u_; int v = v_; \314 data.push_back(u); \315 data.push_back(v); \316 data.push_back(m_Data[x].X); \317 data.push_back(m_Data[y].Y); \318 data.push_back(m_Data[z].Z); \319 )320 321 ADD_FACE(u, v, 0);322 ADD_FACE(0, u, v);323 ADD_FACE(u, 0, 1-v);324 ADD_FACE(u, 1-v, 1);325 ADD_FACE(1, u, 1-v);326 ADD_FACE(u, 1, v);327 328 #undef ADD_FACE329 330 shader->TexCoordPointer(GL_TEXTURE0, 2, GL_FLOAT, 5*sizeof(float), &data[0]);331 shader->VertexPointer(3, GL_FLOAT, 5*sizeof(float), &data[2]);332 333 shader->AssertPointersBound();334 glDrawArrays(GL_LINES, 0, 6*8);335 } -
ps/trunk/source/maths/BoundingBoxAligned.h
r22372 r25269 1 /* Copyright (C) 20 19Wildfire Games.1 /* Copyright (C) 20 Wildfire Games. 2 2 * This file is part of 0 A.D. 3 3 * … … 148 148 CFrustum ToFrustum() const; 149 149 150 /**151 * Render the surfaces of the bound object as triangles.152 */153 void Render(CShaderProgramPtr& shader) const;154 155 /**156 * Render the outline of the bound object as lines.157 */158 void RenderOutline(CShaderProgramPtr& shader) const;159 160 150 private: 161 151 // Holds the minimal and maximal coordinate points in m_Data[0] and m_Data[1], respectively. -
ps/trunk/source/maths/Brush.cpp
r25159 r25269 16 16 */ 17 17 18 /*19 * Implementation of CBrush, a class representing a convex object20 */21 22 18 #include "precompiled.h" 23 19 24 20 #include "Brush.h" 25 21 26 #include "graphics/ShaderProgram.h"27 22 #include "maths/BoundingBoxAligned.h" 28 23 #include "maths/Frustum.h" 29 #include "lib/ogl.h" 30 31 #include <float.h> 32 24 25 CBrush::CBrush() = default; 33 26 34 27 /////////////////////////////////////////////////////////////////////////////// … … 381 374 ENSURE(prev == &result); 382 375 } 383 std::vector<CVector3D> CBrush::GetVertices() const 376 377 const std::vector<CVector3D>& CBrush::GetVertices() const 384 378 { 385 379 return m_Vertices; 386 380 } 387 381 388 void CBrush::GetFaces(std::vector<std::vector<size_t> 382 void CBrush::GetFaces(std::vector<std::vector<size_t>>& out) const 389 383 { 390 384 // split the back-to-back faces into separate face vectors, so that they're in a … … 416 410 } 417 411 } 418 419 void CBrush::Render(CShaderProgramPtr& shader) const420 {421 std::vector<float> data;422 423 std::vector<std::vector<size_t> > faces;424 GetFaces(faces);425 426 #define ADD_VERT(a) \427 STMT( \428 data.push_back(u); \429 data.push_back(v); \430 data.push_back(m_Vertices[faces[i][a]].X); \431 data.push_back(m_Vertices[faces[i][a]].Y); \432 data.push_back(m_Vertices[faces[i][a]].Z); \433 )434 435 for (size_t i = 0; i < faces.size(); ++i)436 {437 // Triangulate into (0,1,2), (0,2,3), ...438 for (size_t j = 1; j < faces[i].size() - 2; ++j)439 {440 float u = 0;441 float v = 0;442 ADD_VERT(0);443 ADD_VERT(j);444 ADD_VERT(j+1);445 }446 }447 448 #undef ADD_VERT449 450 shader->TexCoordPointer(GL_TEXTURE0, 2, GL_FLOAT, 5*sizeof(float), &data[0]);451 shader->VertexPointer(3, GL_FLOAT, 5*sizeof(float), &data[2]);452 453 shader->AssertPointersBound();454 glDrawArrays(GL_TRIANGLES, 0, data.size() / 5);455 }456 457 void CBrush::RenderOutline(CShaderProgramPtr& shader) const458 {459 std::vector<float> data;460 461 std::vector<std::vector<size_t> > faces;462 GetFaces(faces);463 464 #define ADD_VERT(a) \465 STMT( \466 data.push_back(u); \467 data.push_back(v); \468 data.push_back(m_Vertices[faces[i][a]].X); \469 data.push_back(m_Vertices[faces[i][a]].Y); \470 data.push_back(m_Vertices[faces[i][a]].Z); \471 )472 473 for (size_t i = 0; i < faces.size(); ++i)474 {475 for (size_t j = 0; j < faces[i].size() - 1; ++j)476 {477 float u = 0;478 float v = 0;479 ADD_VERT(j);480 ADD_VERT(j+1);481 }482 }483 484 #undef ADD_VERT485 486 shader->TexCoordPointer(GL_TEXTURE0, 2, GL_FLOAT, 5*sizeof(float), &data[0]);487 shader->VertexPointer(3, GL_FLOAT, 5*sizeof(float), &data[2]);488 489 shader->AssertPointersBound();490 glDrawArrays(GL_LINES, 0, data.size() / 5);491 } -
ps/trunk/source/maths/Brush.h
r24352 r25269 1 /* Copyright (C) 202 0Wildfire Games.1 /* Copyright (C) 202 Wildfire Games. 2 2 * This file is part of 0 A.D. 3 3 * … … 20 20 */ 21 21 22 #ifndef maths_brush_h23 #define maths_brush_h22 #ifndef 23 #define 24 24 25 #include "Vector3D.h" 26 27 #include "graphics/ShaderProgramPtr.h" 25 #include "maths/Vector3D.h" 28 26 29 27 #include <vector> … … 39 37 class CBrush 40 38 { 41 friend class TestBrush;42 43 39 public: 44 CBrush() { }40 CBrush() 45 41 46 42 /** … … 84 80 85 81 /** 86 * Render the surfaces of the brush as triangles. 87 */ 88 void Render(CShaderProgramPtr& shader) const; 89 90 /** 91 * Render the outline of the brush as lines. 92 */ 93 void RenderOutline(CShaderProgramPtr& shader) const; 94 95 private: 96 97 /** 98 * Returns a copy of the vertices in this brush. Intended for testing purposes; you should not need to use 82 * Returns vertices in the brush. Intended for testing purposes; you should not need to use 99 83 * this method directly. 100 84 */ 101 std::vector<CVector3D>GetVertices() const;85 GetVertices() const; 102 86 103 87 /** … … 106 90 * need to use this method directly. 107 91 */ 108 void GetFaces(std::vector<std::vector<size_t> 92 void GetFaces(std::vector<std::vector<size_t>>& out) const; 109 93 110 94 private: … … 127 111 }; 128 112 129 #endif // maths_brush_h113 #endif // -
ps/trunk/source/renderer/ParticleRenderer.cpp
r24652 r25269 25 25 #include "graphics/TextureManager.h" 26 26 #include "ps/Profile.h" 27 27 28 #include "renderer/Renderer.h" 28 29 … … 159 160 160 161 CBoundingBoxAligned bounds = emitter->m_Type->CalculateBounds(emitter->GetPosition(), emitter->GetParticleBounds()); 161 bounds.Render(shader);162 shader); 162 163 } 163 164 } -
ps/trunk/source/renderer/Renderer.cpp
r25261 r25269 22 22 23 23 #include "precompiled.h" 24 25 #include <map>26 #include <set>27 #include <algorithm>28 29 #include <boost/algorithm/string.hpp>30 24 31 25 #include "Renderer.h" … … 59 53 #include "graphics/Texture.h" 60 54 #include "graphics/TextureManager.h" 55 61 56 #include "renderer/HWLightingModelRenderer.h" 62 57 #include "renderer/InstancingModelRenderer.h" … … 77 72 #include "scriptinterface/ScriptInterface.h" 78 73 74 75 76 77 78 79 79 struct SScreenRect 80 80 { … … 299 299 CPostprocManager postprocManager; 300 300 301 302 301 303 CFontManager fontManager; 302 304 … … 1484 1486 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 1485 1487 glColor4ub(255,255,255,64); 1486 m_CullCamera.Render(2);1488 2); 1487 1489 glDisable(GL_BLEND); 1488 1490 1489 1491 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); 1490 1492 glColor3ub(255,255,255); 1491 m_CullCamera.Render(2);1493 2); 1492 1494 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); 1493 1495 … … 1953 1955 } 1954 1956 1957 1958 1959 1960 1961 1955 1962 CFontManager& CRenderer::GetFontManager() 1956 1963 { -
ps/trunk/source/renderer/Renderer.h
r25261 r25269 34 34 #include "renderer/Scene.h" 35 35 36 36 37 class CFontManager; 37 38 class CLightEnv; … … 277 278 CPostprocManager& GetPostprocManager(); 278 279 280 281 279 282 /** 280 283 * GetCapabilities: Return which OpenGL capabilities are available and enabled. -
ps/trunk/source/renderer/ShadowMap.cpp
r25261 r25269 34 34 #include "ps/ConfigDB.h" 35 35 #include "ps/Profile.h" 36 36 37 #include "renderer/Renderer.h" 37 38 #include "renderer/RenderingOptions.h" … … 677 678 678 679 shader->Uniform(str_color, 1.0f, 1.0f, 0.0f, 1.0f); 679 m->ShadowReceiverBound.RenderOutline(shader);680 shader); 680 681 681 682 shader->Uniform(str_color, 0.0f, 1.0f, 0.0f, 1.0f); 682 m->ShadowCasterBound.RenderOutline(shader);683 shader); 683 684 684 685 glEnable(GL_BLEND); 685 686 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 686 687 shader->Uniform(str_color, 0.0f, 0.0f, 1.0f, 0.25f); 687 m->ShadowRenderBound.Render(shader);688 shader); 688 689 glDisable(GL_BLEND); 689 690 690 691 shader->Uniform(str_color, 0.0f, 0.0f, 1.0f, 1.0f); 691 m->ShadowRenderBound.RenderOutline(shader);692 shader); 692 693 693 694 // Render light frustum … … 706 707 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 707 708 shader->Uniform(str_color, 1.0f, 0.0f, 0.0f, 0.25f); 708 frustumBrush.Render(shader);709 shader); 709 710 glDisable(GL_BLEND); 710 711 711 712 shader->Uniform(str_color, 1.0f, 0.0f, 0.0f, 1.0f); 712 frustumBrush.RenderOutline(shader); 713 713 g_Renderer.GetDebugRenderer().DrawBrushOutline(frustumBrush, shader); 714 714 715 715 shaderTech->EndPass(); -
ps/trunk/source/renderer/SilhouetteRenderer.cpp
r25266 r25269 27 27 #include "maths/MathUtil.h" 28 28 #include "ps/Profile.h" 29 29 30 #include "renderer/Renderer.h" 30 31 #include "renderer/Scene.h" … … 456 457 { 457 458 shader->Uniform(str_color, m_DebugBounds[i].color); 458 m_DebugBounds[i].bounds.RenderOutline(shader);459 shader); 459 460 } 460 461
Note:
See TracChangeset
for help on using the changeset viewer.