ported the University CGI demo from WINDOWS + GLUT + GLEW + GLU + OpenGL 4 to LINUX WAYLAND + EGL + GLES 2 with minimal cuts
This commit is contained in:
24
GL_STUFF/HEADERS/CURVES/Bezier.hpp
Executable file
24
GL_STUFF/HEADERS/CURVES/Bezier.hpp
Executable file
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
#include "./Curve.hpp"
|
||||
|
||||
class Bezier : public Curve {
|
||||
private:
|
||||
unsigned int order;
|
||||
protected:
|
||||
float evaluateBasisFunction(float at, int number, int order, float intervalLeft, float intervalRight);
|
||||
public:
|
||||
Bezier(unsigned int order, vector<glm::vec3> *points, vector<float> *intervals);
|
||||
glm::vec3 evaluate(float at);
|
||||
glm::vec3 derivate(float at);
|
||||
};
|
||||
|
||||
|
||||
|
||||
class Bezier3Segments : public Bezier {
|
||||
public:
|
||||
Bezier3Segments( vector<glm::vec3>* points, vector<float>* intervals);
|
||||
glm::vec3 evaluate(float at);
|
||||
glm::vec3 derivate(float at);
|
||||
float getLeftBound();
|
||||
float getRightBound();
|
||||
};
|
||||
22
GL_STUFF/HEADERS/CURVES/Curve.hpp
Executable file
22
GL_STUFF/HEADERS/CURVES/Curve.hpp
Executable file
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include <glm/glm.hpp>
|
||||
using namespace std;
|
||||
|
||||
class Curve {
|
||||
protected:
|
||||
vector<glm::vec3> *controlPoints;
|
||||
vector<float> *intervalBoundaries;
|
||||
|
||||
public:
|
||||
Curve(vector<glm::vec3> *points, vector<float> *boundaries);
|
||||
vector<glm::vec3>* getControlPoints();
|
||||
void setControlPoints(vector<glm::vec3>* points);
|
||||
vector<float>* getIntervalBoundaries();
|
||||
void setIntervalBoundaries(vector<float>* boundaries);
|
||||
virtual float getLeftBound();
|
||||
virtual float getRightBound();
|
||||
virtual glm::vec3 evaluate(float at) = 0;
|
||||
virtual glm::vec3 derivate(float at) = 0;
|
||||
|
||||
};
|
||||
35
GL_STUFF/HEADERS/CURVES/CurveIterator.hpp
Executable file
35
GL_STUFF/HEADERS/CURVES/CurveIterator.hpp
Executable file
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
#include "./Curve.hpp"
|
||||
|
||||
enum class CurveIterationMode
|
||||
{
|
||||
BASIC,
|
||||
LENGTH
|
||||
};
|
||||
|
||||
class CurveIterator {
|
||||
private:
|
||||
Curve *curve;
|
||||
unsigned int steps;
|
||||
CurveIterationMode iterationMode;
|
||||
float estimatedLength;
|
||||
int basicStepCounter;
|
||||
float lengthStepCounter;
|
||||
float leftBound;
|
||||
float rightBound;
|
||||
float lastIncrement;
|
||||
|
||||
void resetIterator();
|
||||
void computeLength();
|
||||
|
||||
public:
|
||||
CurveIterator(Curve *curve, unsigned int steps, CurveIterationMode basicOrLength);
|
||||
void nextStep();
|
||||
float getStep();
|
||||
void setProgress(float at);
|
||||
glm::vec3 evaluation();
|
||||
glm::vec3 derivation();
|
||||
|
||||
Curve* getCurve();
|
||||
|
||||
};
|
||||
35
GL_STUFF/HEADERS/CURVES/CurvesLoader.hpp
Executable file
35
GL_STUFF/HEADERS/CURVES/CurvesLoader.hpp
Executable file
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <regex>
|
||||
#include <iostream>
|
||||
#include "./Curve.hpp"
|
||||
#include "Bezier.hpp"
|
||||
#include "NURBS.hpp"
|
||||
|
||||
class CurvesLoader {
|
||||
static string currentCurveType;
|
||||
static vector<glm::vec3>* pointsBuffer;
|
||||
|
||||
static vector<NURBS*> NURBSes;
|
||||
static vector<Bezier3Segments*> beziers;
|
||||
|
||||
static unsigned int NURBSOrder;
|
||||
static NURBSType NURBS_TYPE;
|
||||
static vector<float>* NURBSWeights;
|
||||
|
||||
static char lineHeader[128];
|
||||
static char* res;
|
||||
static FILE* file;
|
||||
|
||||
static std::smatch pieces;
|
||||
static void beginCurve(string str, std::smatch pieces, std::regex regex);
|
||||
static NURBS* BasicNURBS();
|
||||
static NURBS* ClampedNURBS();
|
||||
static NURBS* CyclicNURBS();
|
||||
static void closeNURBS();
|
||||
static void closeBezier();
|
||||
static void closePendingCurve();
|
||||
static void parseVertexData(string str);
|
||||
public:
|
||||
static bool loadCurves(std::string path, vector<Curve*>& curves);
|
||||
};
|
||||
21
GL_STUFF/HEADERS/CURVES/Hermite.hpp
Executable file
21
GL_STUFF/HEADERS/CURVES/Hermite.hpp
Executable file
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
#include "./Curve.hpp"
|
||||
|
||||
enum class HermiteModes {
|
||||
Basic,
|
||||
Direct,
|
||||
Cardinal,
|
||||
TBC
|
||||
};
|
||||
|
||||
class Hermite : public Curve {
|
||||
private:
|
||||
vector<glm::vec3> derivatives;
|
||||
glm::vec3 evaluateCubic(float t, float t1, float t2, glm::vec3 y1, glm::vec3 y2, glm::vec3 dy1, glm::vec3 dy2);
|
||||
|
||||
public:
|
||||
void computeDerivatives(HermiteModes mode, vector<glm::vec3> auxData);
|
||||
Hermite(vector<glm::vec3> *points, vector<float> *intervals);
|
||||
glm::vec3 evaluate(float at);
|
||||
glm::vec3 derivate(float at);
|
||||
};
|
||||
28
GL_STUFF/HEADERS/CURVES/NURBS.hpp
Executable file
28
GL_STUFF/HEADERS/CURVES/NURBS.hpp
Executable file
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
#include "./Curve.hpp"
|
||||
|
||||
enum class NURBSType {
|
||||
BASIC,
|
||||
CLAMPED,
|
||||
CYCLIC
|
||||
};
|
||||
|
||||
class NURBS : public Curve {
|
||||
private:
|
||||
unsigned int order;
|
||||
vector<float>* weights;
|
||||
vector<unsigned int>* multiplicities;
|
||||
vector<float>* derivativeBoundaries;
|
||||
vector<glm::vec3>* derivativePoints;
|
||||
vector<float>* derivativeWeghts;
|
||||
glm::vec3 deBoor( float at, int index);
|
||||
void preliminaryChecks();
|
||||
public:
|
||||
NURBS( unsigned int order, vector<glm::vec3>* points, vector<float>* weights, vector<float>* boundaries, vector<unsigned int>* multiplicities);
|
||||
unsigned int getOrder();
|
||||
vector<float>* getWeights();
|
||||
glm::vec3 evaluate(float at);
|
||||
glm::vec3 derivate(float at);
|
||||
float getLeftBound();
|
||||
float getRightBound();
|
||||
};
|
||||
92
GL_STUFF/HEADERS/EFFECTS/CRT_shader.h
Executable file
92
GL_STUFF/HEADERS/EFFECTS/CRT_shader.h
Executable file
@@ -0,0 +1,92 @@
|
||||
#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);
|
||||
};
|
||||
18
GL_STUFF/HEADERS/EFFECTS/PseudoContext.h
Executable file
18
GL_STUFF/HEADERS/EFFECTS/PseudoContext.h
Executable file
@@ -0,0 +1,18 @@
|
||||
#ifndef PSEUDOCONTEXT
|
||||
#define PSEUDOCONTEXT
|
||||
|
||||
#include <vector>
|
||||
|
||||
class PseudoContext {
|
||||
protected:
|
||||
//viewport
|
||||
int width, height;
|
||||
int top, left;
|
||||
|
||||
public:
|
||||
PseudoContext(int left, int top, int width, int height);
|
||||
virtual void draw() = 0;
|
||||
std::vector<int> getBounds();
|
||||
|
||||
};
|
||||
#endif
|
||||
22
GL_STUFF/HEADERS/EFFECTS/ReelManager.h
Executable file
22
GL_STUFF/HEADERS/EFFECTS/ReelManager.h
Executable file
@@ -0,0 +1,22 @@
|
||||
#ifndef REELMANAGER_H
|
||||
#define REELMANAGER_H
|
||||
/*
|
||||
#include <GL/glew.h>
|
||||
*/
|
||||
#include <GLES2/gl2.h>
|
||||
#include <vector>
|
||||
|
||||
class ReelManager {
|
||||
private:
|
||||
unsigned int TEXTURE_NUM;
|
||||
unsigned int currentIndex = 0;
|
||||
GLuint* textures;
|
||||
GLuint FBO;
|
||||
public:
|
||||
ReelManager(unsigned int textureNumber, unsigned int width, unsigned int height);
|
||||
GLuint getFBO();
|
||||
void clearTexture();
|
||||
void nextTexture();
|
||||
std::vector<GLuint> getTextures();
|
||||
};
|
||||
#endif
|
||||
26
GL_STUFF/HEADERS/EFFECTS/Scene.h
Executable file
26
GL_STUFF/HEADERS/EFFECTS/Scene.h
Executable file
@@ -0,0 +1,26 @@
|
||||
#ifndef SCENE_H
|
||||
#define SCENE_H
|
||||
|
||||
/*
|
||||
#include <GL/glew.h>
|
||||
*/
|
||||
#include <GLES2/gl2.h>
|
||||
#include "PseudoContext.h"
|
||||
|
||||
|
||||
class Scene : public PseudoContext{
|
||||
|
||||
private:
|
||||
//aux
|
||||
GLuint FBO;
|
||||
GLuint depthRBO;
|
||||
GLuint outputTexture; /*FBO for communications with other bois*/
|
||||
|
||||
public:
|
||||
Scene(int left, int top, int width, int height);
|
||||
void setOutTexture(GLuint outTexture);
|
||||
void draw();
|
||||
void keyPress(unsigned char key, int x, int y);
|
||||
GLuint getFrameBuffer();
|
||||
};
|
||||
#endif
|
||||
31
GL_STUFF/HEADERS/EFFECTS/Screen.h
Executable file
31
GL_STUFF/HEADERS/EFFECTS/Screen.h
Executable file
@@ -0,0 +1,31 @@
|
||||
#ifndef SCREEN_H
|
||||
#define SCREEN_H
|
||||
|
||||
#include "../SCENE/Model3D.hpp"
|
||||
#include "PseudoContext.h"
|
||||
|
||||
class Screen: public PseudoContext {
|
||||
|
||||
private:
|
||||
|
||||
//aux
|
||||
GLuint inputTexture = 0;
|
||||
GLuint quadVAO, vertVBO;
|
||||
GLuint program2;
|
||||
GLuint shaderTexId;
|
||||
GLfloat quadVerts[18] = {
|
||||
-1.0f, -1.0f, -1.0f,
|
||||
1.0f, -1.0f, -1.0f,
|
||||
-1.0f, 1.0f, -1.0f,
|
||||
-1.0f, 1.0f, -1.0f,
|
||||
1.0f, -1.0f, -1.0f,
|
||||
1.0f, 1.0f, -1.0f
|
||||
};
|
||||
|
||||
public:
|
||||
Screen(int left, int top, int width, int height);
|
||||
void setInputTexture(GLuint inputTexture);
|
||||
void draw();
|
||||
};
|
||||
|
||||
#endif
|
||||
38
GL_STUFF/HEADERS/EFFECTS/TexMerger.h
Executable file
38
GL_STUFF/HEADERS/EFFECTS/TexMerger.h
Executable file
@@ -0,0 +1,38 @@
|
||||
#ifndef TEXMERGER_H
|
||||
#define TEXMERGER_H
|
||||
/*
|
||||
#include <GL/glew.h>
|
||||
*/
|
||||
#include <GLES2/gl2.h>
|
||||
#include <vector>
|
||||
|
||||
|
||||
class TexMerger {
|
||||
private:
|
||||
GLuint program;
|
||||
GLuint* mergeBuffers;
|
||||
std::vector<bool> usageMap;
|
||||
GLuint FBO;
|
||||
GLuint quadVAO, vertVBO;
|
||||
GLuint shaderTex1Id, shaderTex2Id;
|
||||
int bufCount;
|
||||
GLuint reserveBuffer();
|
||||
bool isBuffer(GLuint number);
|
||||
void freeBuffer(GLuint number);
|
||||
GLfloat quadVerts[18] = {
|
||||
-1.0f, -1.0f, -1.0f,
|
||||
1.0f, -1.0f, -1.0f,
|
||||
-1.0f, 1.0f, -1.0f,
|
||||
-1.0f, 1.0f, -1.0f,
|
||||
1.0f, -1.0f, -1.0f,
|
||||
1.0f, 1.0f, -1.0f
|
||||
};
|
||||
|
||||
|
||||
public:
|
||||
TexMerger(GLuint texCount, unsigned int texWidth, unsigned int texHeight);
|
||||
GLuint merge(std::vector<GLuint> inTextures, int startIndex, int endIndex);
|
||||
};
|
||||
#endif // !TEXMERGER_H
|
||||
|
||||
|
||||
40
GL_STUFF/HEADERS/SCENE/Camera.hpp
Executable file
40
GL_STUFF/HEADERS/SCENE/Camera.hpp
Executable file
@@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
class Camera {
|
||||
|
||||
public:
|
||||
glm::vec3 cameraPos;
|
||||
glm::vec3 cameraFront;
|
||||
glm::vec3 cameraUp;
|
||||
|
||||
Camera();
|
||||
Camera( glm::vec3 position, glm::vec3 front, glm::vec3 up);
|
||||
glm::mat4 getViewMat();
|
||||
glm::vec3 getPosition();
|
||||
//exp
|
||||
void alignTo( glm::vec3 direction);
|
||||
void setPosition( glm::vec3 pos);
|
||||
};
|
||||
|
||||
class CameraController {
|
||||
|
||||
private:
|
||||
Camera *camera;
|
||||
float cameraSpeed = 0.5f;
|
||||
bool mouseUnlocked = true;
|
||||
float lastX;
|
||||
float lastY;
|
||||
float PHI = 0.0;
|
||||
float THETA = 270.0;
|
||||
unsigned int windowLeft;
|
||||
unsigned int windowTop;
|
||||
unsigned int windowWidth;
|
||||
unsigned int windowHeight;
|
||||
|
||||
public:
|
||||
CameraController(Camera *cam);
|
||||
Camera* getCamera();
|
||||
void setWindowData(int left, int width, int top, int height);
|
||||
void mouseMotion(int cursorX, int cursorY);
|
||||
void keyPress(unsigned char key);
|
||||
};
|
||||
21
GL_STUFF/HEADERS/SCENE/Instance3D.h
Executable file
21
GL_STUFF/HEADERS/SCENE/Instance3D.h
Executable file
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
#include <glm/glm.hpp>
|
||||
/*
|
||||
#include <GL/glew.h>
|
||||
*/
|
||||
#include <GLES2/gl2.h>
|
||||
#include "./Model3D.hpp"
|
||||
#include "../SCENE/ObjectInstance.hpp"
|
||||
|
||||
class Instance3D : public WorldInstanceable {
|
||||
|
||||
private:
|
||||
Model3D* mesh;
|
||||
|
||||
public:
|
||||
Instance3D(Model3D* mesh, vec3 position);
|
||||
Instance3D(Model3D* mesh, vec3 position, vec3 scale);
|
||||
Instance3D(Model3D* mesh, vec3 position, vec3 axis, float angle);
|
||||
Instance3D(Model3D* mesh, vec3 position, vec3 scale, vec3 axis, float angle);
|
||||
Model3D* getModel();
|
||||
};
|
||||
3
GL_STUFF/HEADERS/SCENE/InstancesLoader.h
Executable file
3
GL_STUFF/HEADERS/SCENE/InstancesLoader.h
Executable file
@@ -0,0 +1,3 @@
|
||||
#include "../SCENE/Instance3D.h"
|
||||
|
||||
bool loadInstances(std::string path, vector<Instance3D*>& instances, bool smoothNormals);
|
||||
29
GL_STUFF/HEADERS/SCENE/Model3D.hpp
Executable file
29
GL_STUFF/HEADERS/SCENE/Model3D.hpp
Executable file
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include <GLES2/gl2.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
using namespace std; //for vector
|
||||
using namespace glm; //vec3 and friends
|
||||
|
||||
class Model3D {
|
||||
|
||||
private:
|
||||
int nVertices;
|
||||
GLuint vao;
|
||||
vec3 boundingBoxLBN;
|
||||
vec3 boundingBoxRTF;
|
||||
vector<vec3> loadVertexData(const char* modelPath, bool smoothNormals);
|
||||
void computeBoundingBox(vector<vec3> points);
|
||||
|
||||
public:
|
||||
Model3D(const char* modelPath, bool smoothNormals);
|
||||
GLuint getVAO();
|
||||
int getTrisCount();
|
||||
void draw();
|
||||
vec3 getLBN();
|
||||
vec3 getRTF();
|
||||
};
|
||||
30
GL_STUFF/HEADERS/SCENE/ObjectInstance.hpp
Executable file
30
GL_STUFF/HEADERS/SCENE/ObjectInstance.hpp
Executable file
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
#include <glm/glm.hpp>
|
||||
#include <GLES2/gl2.h>
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
|
||||
class WorldInstanceable {
|
||||
|
||||
private:
|
||||
glm::vec3 localFront, localUp;
|
||||
void setup(glm::vec3 position);
|
||||
|
||||
public:
|
||||
glm::mat4 scaleMat;
|
||||
glm::mat4 rotation;
|
||||
glm::vec3 position;
|
||||
WorldInstanceable(glm::vec3 position);
|
||||
WorldInstanceable(glm::vec3 position, glm::vec3 scale);
|
||||
WorldInstanceable(glm::vec3 position, glm::vec3 axis, float angle);
|
||||
WorldInstanceable(glm::vec3 position, glm::vec3 scale, glm::vec3 axis, float angle);
|
||||
void setPosition(glm::vec3 position);
|
||||
void rotate(glm::vec3 axis, float angle);
|
||||
void scale(float factor);
|
||||
void scale(glm::vec3 factors);
|
||||
glm::mat4 getLocalTransform();
|
||||
glm::mat4 getGlobalTransform();
|
||||
void alignTo(glm::vec3 direction);
|
||||
|
||||
};
|
||||
26
GL_STUFF/HEADERS/SCENE/ShadingHelper.h
Executable file
26
GL_STUFF/HEADERS/SCENE/ShadingHelper.h
Executable file
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
#include <glm/glm.hpp>
|
||||
/*
|
||||
#include <GL/glew.h>
|
||||
*/
|
||||
#include <GLES2/gl2.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
class ShadingHelper {
|
||||
GLuint program;
|
||||
public:
|
||||
ShadingHelper(GLuint program);
|
||||
void useProgram();
|
||||
GLuint getProgram();
|
||||
void bindTexture2D(GLuint texUnitIndex, GLuint texture, std::string uniform);
|
||||
void bindViewUniforms(glm::mat4 projection, glm::mat4 view);
|
||||
void bindLightUniforms(glm::vec3 lightPos, glm::vec3 lightCol, glm::vec3 eyePos);
|
||||
void bindModelUniforms(glm::mat4 locRotScl, glm::mat4 rotScl);
|
||||
};
|
||||
|
||||
class TextureHelper {
|
||||
public:
|
||||
GLuint texture;
|
||||
std::string uniformName;
|
||||
};
|
||||
20
GL_STUFF/HEADERS/SCENE/objloader.hpp
Executable file
20
GL_STUFF/HEADERS/SCENE/objloader.hpp
Executable file
@@ -0,0 +1,20 @@
|
||||
#ifndef OBJLOADER_H
|
||||
#define OBJLOADER_H
|
||||
|
||||
bool loadOBJ(
|
||||
const char* path,
|
||||
std::vector<glm::vec3>& out_vertices,
|
||||
std::vector<glm::vec2>& out_uvs,
|
||||
std::vector<glm::vec3>& out_normals,
|
||||
bool smoothNormals
|
||||
);
|
||||
|
||||
bool loadAssImp(
|
||||
const char* path,
|
||||
std::vector<unsigned short>& indices,
|
||||
std::vector<glm::vec3>& vertices,
|
||||
std::vector<glm::vec2>& uvs,
|
||||
std::vector<glm::vec3>& normals
|
||||
);
|
||||
|
||||
#endif
|
||||
12
GL_STUFF/HEADERS/UTILS/ClockIterator.hpp
Executable file
12
GL_STUFF/HEADERS/UTILS/ClockIterator.hpp
Executable file
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
class ClockIterator {
|
||||
private:
|
||||
unsigned int max;
|
||||
unsigned int counter;
|
||||
public:
|
||||
ClockIterator(unsigned int loopMillis);
|
||||
unsigned int step(unsigned int millis);
|
||||
float getPercentage();
|
||||
unsigned int getPosition();
|
||||
void reset();
|
||||
};
|
||||
3
GL_STUFF/HEADERS/UTILS/OnlyOnce.hpp
Executable file
3
GL_STUFF/HEADERS/UTILS/OnlyOnce.hpp
Executable file
@@ -0,0 +1,3 @@
|
||||
#include <GLES2/gl2.h>
|
||||
|
||||
GLuint loadImg(const char* path);
|
||||
21
GL_STUFF/HEADERS/UTILS/ResourceCache.h
Executable file
21
GL_STUFF/HEADERS/UTILS/ResourceCache.h
Executable file
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include "../UTILS/OnlyOnce.hpp"
|
||||
using namespace std;
|
||||
|
||||
class ResourceCache {
|
||||
|
||||
private:
|
||||
ResourceCache ();
|
||||
map<string, GLuint> images;
|
||||
map<string, GLuint> shaders;
|
||||
public:
|
||||
static ResourceCache& get() {
|
||||
static ResourceCache instance;
|
||||
return instance;
|
||||
}
|
||||
GLuint getImage(string path);
|
||||
GLuint getShader(string vertPath, string fragPath);
|
||||
};
|
||||
12
GL_STUFF/HEADERS/UTILS/ShaderMaker.h
Executable file
12
GL_STUFF/HEADERS/UTILS/ShaderMaker.h
Executable file
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
#include <GLES2/gl2.h>
|
||||
|
||||
class ShaderMaker
|
||||
{
|
||||
public:
|
||||
static GLuint createProgram(char* vertexfilename, char *fragmentfilename);
|
||||
static char* readShaderSource(const char* shaderFile);
|
||||
|
||||
private:
|
||||
ShaderMaker() { }
|
||||
};
|
||||
7462
GL_STUFF/HEADERS/UTILS/stb_image.h
Executable file
7462
GL_STUFF/HEADERS/UTILS/stb_image.h
Executable file
File diff suppressed because it is too large
Load Diff
2598
GL_STUFF/HEADERS/UTILS/stb_image_resize.h
Executable file
2598
GL_STUFF/HEADERS/UTILS/stb_image_resize.h
Executable file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user