17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-17 06:19:19 +02:00
Files
maszyna/rendering/openglparticles.cppm
maj00r b8f040e6fd propagate template headers transitively, import Console where used
AnimModel.cpp reaches cParser through the simulation core, not a direct
import, so the previous pass missed it; the propagation now follows the
whole import closure. Train.cpp, drivermode.cpp and Globals.cpp call
Console:: inside _WIN32 guards without importing eu07.console - invisible
on Linux, where those blocks are skipped.
2026-09-10 01:41:24 +02:00

74 lines
2.0 KiB
C++

module;
#include <array>
#include <chrono>
#include <deque>
#include <limits>
#include <mutex>
#include <ostream>
#include <sstream>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <utility>
#include <cstddef>
#include <cstdint>
#include <vector>
#include "glad/glad.h"
export module eu07.rendering.openglparticles;
import eu07.glm;
import eu07.rendering.openglcamera;
export {
/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
2.0. If a copy of the MPL was not
distributed with this file, You can
obtain one at
http://mozilla.org/MPL/2.0/.
*/
// particle data visualizer
class opengl_particles {
public:
// constructors
opengl_particles() = default;
// destructor
~opengl_particles() {
if( m_buffer != -1 ) {
::glDeleteBuffers( 1, &m_buffer ); } }
// methods
void
update( opengl_camera const &Camera );
std::size_t
render( GLint const Textureunit );
private:
// types
struct particle_vertex {
glm::vec3 position; // 3d space
std::uint8_t color[ 4 ]; // rgba, unsigned byte format
glm::vec2 texture; // uv space
float padding[ 2 ]; // experimental, some gfx hardware allegedly works better with 32-bit aligned data blocks
};
/*
using sourcedistance_pair = std::pair<smoke_source *, float>;
using source_sequence = std::vector<sourcedistance_pair>;
*/
using particlevertex_sequence = std::vector<particle_vertex>;
// methods
// members
/*
source_sequence m_sources; // list of particle sources visible in current render pass, with their respective distances to the camera
*/
particlevertex_sequence m_particlevertices; // geometry data of visible particles, generated on the cpu end
GLuint m_buffer{ (GLuint)-1 }; // id of the buffer holding geometry data on the opengl end
std::size_t m_buffercapacity{ 0 }; // total capacity of the last established buffer
};
//---------------------------------------------------------------------------
} // export