This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const std::string SimpleParticleShader::VS = "#version 330 core\n" | |
"layout ( location = 0 ) in vec3 vertex_position;" | |
"layout ( location = 4 ) in vec4 position;" | |
"uniform mat4 M_v;" | |
"uniform mat4 M_p;" | |
"uniform float particleSize;" | |
"out float lifetime;" | |
"void main()" | |
"{" | |
" vec4 position_viewspace = M_v * vec4( position.xyz , 1 );" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SimpleEmitter::SimpleEmitter() | |
{ | |
// create 100 particles | |
this->particles.resize( 100 ); | |
for ( uint i = 0 ; i < this->particles.size() ; ++i ) | |
{ | |
// give every particle a random position | |
this->particles[i].position = lstd_random_between( vec3( -1.0f ) , vec3( 1.0f ) ); | |
this->particles[i].lifetime = lstd_random_between( 1.0f , 2.0f ); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void SimpleEmitter::update( const float dt ) | |
{ | |
for ( uint i = 0 ; i < this->particles.size() ; ++i ) | |
{ | |
// subtract from the particles lifetime | |
this->particles[i].lifetime -= dt; | |
// if the lifetime is below 0 respawn the particle | |
if ( this->particles[i].lifetime <= 0.0f ) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void SimpleEmitter::draw() | |
{ | |
glEnableVertexAttribArray( 0 ); | |
glEnableVertexAttribArray( 4 ); | |
// update the position buffer | |
glBindBuffer( GL_ARRAY_BUFFER , this->positionBuffer ); | |
glBufferSubData( GL_ARRAY_BUFFER , 0 , this->particles.size()*4*sizeof(float) , this->positions ); | |
// vertex buffer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include "Z:/cpp/SRC/lgl3/include/lgl3_includes.hpp" | |
#include "Z:/cpp/SRC/lgl3/include/lglShader.hpp" | |
/* | |
emitter | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "SimpleParticles.hpp" | |
/* | |
emitter | |
*/ | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <fstream> | |
#include <iostream> | |
#include <string> | |
#include "timeutil.hpp" | |
#include "util.hpp" | |
class Owl; | |
extern Owl owlInstance; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Owl.hpp" | |
Owl owlInstance; | |
Owl::Owl() | |
{ | |
this->b_init = false; | |
} | |
Owl::~Owl() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class vec3 | |
{ | |
public: | |
float x; | |
float y; | |
float z; | |
vec3( const float x = 0 , const float y = 0 , const float z = 0 ) : x(x) , y(y) , z(z) {} | |
// add another vector to a vector like a += v; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="js/CookieConsentManager.js"></script> | |
<script>CCM_getCookieConsent();</script> |