first commit
This commit is contained in:
122
CS4451/proj4/Renderer.h
Normal file
122
CS4451/proj4/Renderer.h
Normal file
@@ -0,0 +1,122 @@
|
||||
#ifndef _RENDERER_H_
|
||||
#define _RENDERER_H_
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <GL/glut.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "structs.h"
|
||||
#include "defs.h"
|
||||
#include "Input.h"
|
||||
|
||||
#include <time.h> //For FPS
|
||||
|
||||
using namespace std;
|
||||
|
||||
class Renderer {
|
||||
public:
|
||||
|
||||
static Renderer* getInstance();
|
||||
|
||||
vector<Sphere*> *spheres;
|
||||
vector<Triangle*> *triangles;
|
||||
vector<Light*> *lights;
|
||||
|
||||
Point viewport;
|
||||
Point h;
|
||||
Point v;
|
||||
Point l;
|
||||
|
||||
m_float ambient;
|
||||
|
||||
GLvoid window_resize(GLint vpw, GLint vph);
|
||||
void render(void);
|
||||
void renderWithShadows(void);
|
||||
|
||||
inline void init(int *argc, char** argv) {
|
||||
this->wid = init_glut(argc,argv);
|
||||
init_opengl();
|
||||
init_scene();
|
||||
this->calculateDistance();
|
||||
lastClock = clock();
|
||||
fps = 0;
|
||||
}
|
||||
|
||||
void init_scene();
|
||||
|
||||
m_float* getViewAngle() {
|
||||
return &viewAngle;
|
||||
}
|
||||
|
||||
bool drawShadows;
|
||||
bool primitivesOnly;
|
||||
|
||||
bool backFaceCull;
|
||||
|
||||
inline m_int getVPD() { return this->vpd; }
|
||||
|
||||
Point distanceToCenter;
|
||||
|
||||
private:
|
||||
|
||||
static Renderer instance;
|
||||
MaterialAttributes m_shadow_attrib;
|
||||
|
||||
GLUquadricObj* lightCenter;
|
||||
|
||||
Renderer();
|
||||
~Renderer();
|
||||
|
||||
float frontClippingPlane;
|
||||
float rearClippingPlane;
|
||||
|
||||
m_int vpd;
|
||||
m_int wid;
|
||||
|
||||
m_float viewAngle;
|
||||
|
||||
m_uint triangleScene;
|
||||
|
||||
clock_t fps;
|
||||
clock_t lastClock;
|
||||
|
||||
|
||||
void init_opengl();
|
||||
m_int init_glut(m_int *argc, char** argv);
|
||||
|
||||
void apply_attributes(MaterialAttributes attrib, float alpha);
|
||||
inline void apply_attributes(MaterialAttributes attrib) {
|
||||
apply_attributes(attrib,1.0f);
|
||||
}
|
||||
|
||||
GLvoid init_lightsource( GLvoid );
|
||||
|
||||
bool checkTriNormal(Point normal, Point lightCenter);
|
||||
bool checkTriangle(Triangle* triangle, Point lightCenter);
|
||||
void calculateNormal(Point *dest, Triangle* triangle);
|
||||
|
||||
m_uint calculateShadowVolumes();
|
||||
|
||||
void fixVertexDirection(Triangle* t);
|
||||
|
||||
void drawPrimitives(bool withLight);
|
||||
|
||||
void getVector(Point* dest, Point* to, Point* from);
|
||||
|
||||
void calculateDistance();
|
||||
|
||||
inline Point centerOfTriangle(Triangle* t) {
|
||||
Point p;
|
||||
p.x = ( t->a1.x + t->a2.x + t->a3.x ) / 3.;
|
||||
p.y = ( t->a1.y + t->a2.y + t->a3.y ) / 3.;
|
||||
p.z = ( t->a1.z + t->a2.z + t->a3.z ) / 3.;
|
||||
return p;
|
||||
}
|
||||
|
||||
void generateTriangleShadows();
|
||||
void generateSphereShadows();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user