From f965f6daa99cc8d11f732f00002535fdd2e66d65 Mon Sep 17 00:00:00 2001 From: KT Date: Tue, 9 Nov 2021 12:58:15 -0600 Subject: Publish a5 --- dev/a5-artrender/artrender_app.h | 102 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 dev/a5-artrender/artrender_app.h (limited to 'dev/a5-artrender/artrender_app.h') diff --git a/dev/a5-artrender/artrender_app.h b/dev/a5-artrender/artrender_app.h new file mode 100644 index 0000000..3005c4b --- /dev/null +++ b/dev/a5-artrender/artrender_app.h @@ -0,0 +1,102 @@ +/** CSci-4611 Assignment 5: Art Render + */ + +#ifndef ART_RENDER_APP_H_ +#define ART_RENDER_APP_H_ + +#include +using namespace mingfx; + +#include "edge_mesh.h" + +#include +#include + + +/** Main application class for the ArtRender project.*/ +class ArtRenderApp : public GraphicsApp { +public: + + ArtRenderApp(); + virtual ~ArtRenderApp(); + + /// Rereads the shader programs file their txt files and recompiles them + void OnReloadBtnPressed(); + + /// Switches to gouraud shading + void OnGouraudBtnPressed(); + + /// Switches to phong shading + void OnPhongBtnPressed(); + + /// Switches to an artsy, toon rendering style + void OnArtsyBtnPressed(); + + /// Callbacks used for UniCam camera controls + void OnLeftMouseDown(const Point2& pos); + void OnLeftMouseDrag(const Point2& pos, const Vector2& delta); + void OnLeftMouseUp(const Point2& pos); + void UpdateSimulation(double dt); + + /// The GUI is setup here + void InitNanoGUI(); + + /// Models and shaders are loaded here, note these cannot be loaded within + /// the constructor because the OpenGL context is not yet created at the + /// time the constructor is called. + void InitOpenGL(); + + /// Rendering using shaders goes here. + void DrawUsingOpenGL(); + +private: + + void LoadShadersAndTextures(); + + // 0 = gouraud, 1 = phong, 2 = artsy + int shader_style_; + + // 0 for the first model loaded, ... + int current_model_; + + // filenames, also used as the caption for the buttons + std::vector model_files_; + // triangle mesh stored for each model file + std::vector meshes_; + // the "edge mesh" computed from the triangle mesh for each file + std::vector edge_meshes_; + + // position for the light source used in the shaders + Point3 light_pos_; + + // per-vertex gouraud shading + ShaderProgram gouraud_shaderprog_; + + // standard per-pixel phong shading + ShaderProgram phong_shaderprog_; + + // toon shading + ShaderProgram artsy_shaderprog_; + // textures to use for calculating lighting cutoffs inside the toon shader + Texture2D diffuse_ramp_; + Texture2D specular_ramp_; + + // special program to use for drawing silhouette edges with the edge mesh + ShaderProgram outline_shaderprog_; + + + + // Unicam stores/sets the view matrix based on mouse interaction since it + // is in charge of moving around the camera. + UniCam uni_cam_; + Matrix4 proj_matrix_; + + // QuickShapes is just used to draw a little yellow sphere at the position + // of the light. + QuickShapes quick_shapes_; + + // A list of paths to search for data files (images and shaders) + std::vector search_path_; +}; + +#endif \ No newline at end of file -- cgit v1.2.3