first commit

This commit is contained in:
Jose Caban
2025-06-07 01:59:34 -04:00
commit 388ac241f0
3558 changed files with 9116289 additions and 0 deletions

113
CS4451/proj5/Renderer.h Normal file
View File

@@ -0,0 +1,113 @@
#ifndef _RENDERER_H_
#define _RENDERER_H_
#include <vector>
#include <GL/glut.h>
#include <time.h>
#include <iostream>
#include "structs.h"
#include "Subdivision.h"
#define VPD_MIN 200
#define VPD_DEFAULT 800
#define VPD_MAX 1024
#define VIEWDIST_DEFAULT 8.0
#define VIEWDIST_MIN 0.0
#define VIEWDIST_MAX 16.0
class Renderer {
public:
//Members
static inline Renderer* getInstance() {
return & m_instance;
}
std::vector<Point> *points;
std::vector<Triangle> *triangles;
//Used for rotating the thing with the trackball
GLfloat currModelTransform[16];
//Initialization
void init(int *argc, char** argv);
//Accessors
inline int getVPD() {
return vpd;
}
inline float getViewDist() {
return this->viewDist;
}
//Modifiers
inline void multViewDist( float by ) {
if (dist == 79) {
return;
}
dist++;
this->viewDist *= by;
glutPostRedisplay();
}
inline void divViewDist( float by ) {
if (dist == 0) {
return;
}
dist--;
this->viewDist /= by;
glutPostRedisplay();
}
//View Handling
GLvoid window_resize(GLint vpw, GLint vph);
//Utility
void render();
bool animate;
private:
//Members
static Renderer m_instance;
int windowID;
int vpd;
GLuint sceneID;
GLfloat viewDist;
int dist;
//Constructor
inline Renderer() {
points = new std::vector<Point>;
triangles = new std::vector<Triangle>;
vpd = VPD_DEFAULT;
viewDist = VIEWDIST_DEFAULT;
animate = false;
rotAngle1 = rotAngle2 = 0;
dAngle1 = .57;
dAngle2 = .71;
dist = 62;
}
float rotAngle1, rotAngle2;
float dAngle1, dAngle2;
//Initialization
GLint init_glut(int *argc, char** argv);
void generateNormals();
void init_opengl();
//Methods
GLvoid set_material_properties(GLfloat r, GLfloat g, GLfloat b);
GLvoid init_lightsource();
GLuint init_sceneList();
GLvoid create_scene();
};
#endif