use "ARCH=arch_name make" restructured project folder, implementations and headers together under sources/
93 lines
2.3 KiB
C++
Executable File
93 lines
2.3 KiB
C++
Executable File
#pragma once
|
|
#include <glm/gtc/matrix_transform.hpp>
|
|
/*
|
|
ON MOBILE, GLES 3.1 WOULD BE REQUIRED (compute shader support)
|
|
*/
|
|
#include <GL/glew.h>
|
|
|
|
#include <string>
|
|
#include <iostream>
|
|
|
|
using namespace std;
|
|
using namespace glm;
|
|
|
|
enum SIM_PRECISION {
|
|
FINE,
|
|
REGULAR,
|
|
ROUGH
|
|
};
|
|
|
|
class CRT_Shader {
|
|
|
|
private:
|
|
static bool CRT_FLIP_Y;
|
|
string resourceRoot = "C:\\Users\\BoBoBoat\\Desktop\\SCUOLA\\CGI\\GL_STUFF\\GL_STUFF\\SOURCES\\EFFECTS\\CRT_SHADER\\";
|
|
const float CRT_PIXEL_LENGTH = 2e-3; //value of 1 gets only red (bad bug)
|
|
static const int CRT_PIXEL_SCALE = 1; //they work together
|
|
const float CRT_DEPTH = 1e0;
|
|
static int CRT_HORIZONTAL_PIXELS;
|
|
static int CRT_VERTICAL_PIXELS;
|
|
static int CRT_WIDTH;
|
|
static int CRT_HEIGHT;
|
|
static int PARTICLE_COUNT;
|
|
static const int GROUP_COUNT = 1024;
|
|
static int PARTICLE_GROUP_COUNT;
|
|
static const unsigned int COLOR_CHANNELS = 4;
|
|
static SIM_PRECISION resolution;
|
|
|
|
mat4 orthoMat;
|
|
vec3 CS_LTN, CS_RBN, CS_LTF, CS_RBF;
|
|
GLuint dt_location;
|
|
|
|
GLuint compute_prog;
|
|
GLuint render_prog;
|
|
GLuint render_vao;
|
|
|
|
GLuint end_position_buffer, start_position_buffer, velocity_buffer, color_buffer, magnets_buffer;
|
|
|
|
float magx;
|
|
float magy;
|
|
|
|
vec4 attractors[8];
|
|
|
|
GLuint velocity_tbo, start_position_tbo, end_position_tbo, color_tbo;
|
|
|
|
|
|
CRT_Shader();
|
|
vec3 scaleToZOne(vec3 vector);
|
|
vec3 crt_emission_angle(int index);
|
|
void createRenderShader();
|
|
void createComputeShader();
|
|
void buffersSetup();
|
|
void VAOsSetup();
|
|
|
|
public:
|
|
static void setup(int w, int h, bool flipY, SIM_PRECISION precision) {
|
|
CRT_FLIP_Y = flipY;
|
|
resolution = precision;
|
|
CRT_WIDTH = w;
|
|
CRT_HEIGHT = h;
|
|
CRT_HORIZONTAL_PIXELS = w / CRT_PIXEL_SCALE;
|
|
CRT_VERTICAL_PIXELS = h / CRT_PIXEL_SCALE;
|
|
PARTICLE_COUNT = CRT_HORIZONTAL_PIXELS * CRT_VERTICAL_PIXELS;
|
|
PARTICLE_GROUP_COUNT = (PARTICLE_COUNT / GROUP_COUNT) + ((PARTICLE_COUNT % GROUP_COUNT) ? 1 : 0);
|
|
cout << "HPIX " << CRT_HORIZONTAL_PIXELS << "\n";
|
|
cout << "VPIX " << CRT_VERTICAL_PIXELS << "\n";
|
|
}
|
|
|
|
static CRT_Shader& get() {
|
|
static CRT_Shader instance;
|
|
return instance;
|
|
}
|
|
|
|
void draw(unsigned int ONE_TICK_MS, unsigned int timePassed);
|
|
void setMagnet(int index, vec4 positionAndMass);
|
|
float getLeftBound();
|
|
float getRightBound();
|
|
float getBottomBound();
|
|
float getTopBound();
|
|
|
|
/*Copies H_PIXELS * V_PIXELS from FrameBuffer to internal VAO */
|
|
void loadColorFromFramebuffer(GLuint FBO);
|
|
};
|