Skip to content

Commit

Permalink
Texture + Lights intro
Browse files Browse the repository at this point in the history
  • Loading branch information
carolinadcf committed Oct 4, 2021
1 parent bfd2491 commit deff746
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 3 deletions.
7 changes: 6 additions & 1 deletion data/shaders/normal.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ varying vec3 v_normal;
varying vec2 v_uv;
varying vec4 v_color;

uniform sampler2D u_texture;

void main()
{
gl_FragColor = vec4(v_normal,1.0);


vec4 albedo = texture2D(u_texture, v_uv);
gl_FragColor = albedo;
}
Binary file added framework.iobj
Binary file not shown.
Binary file added framework.ipdb
Binary file not shown.
Binary file added framework.pdb
Binary file not shown.
13 changes: 12 additions & 1 deletion src/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,24 @@ Application::Application(int window_width, int window_height, SDL_Window* window
camera->setPerspective(45.f,window_width/(float)window_height,0.1f,10000.f); //set the projection, we want to be perspective

{
// HELMET MODEL
StandardMaterial* mat = new StandardMaterial();
Texture* albedo = Texture::Get("data/models/helmet/albedo.png");
mat->texture = albedo;
SceneNode* node = new SceneNode("Visible node");
node->mesh = Mesh::Get("data/meshes/sphere.obj.mbin");
node->mesh = Mesh::Get("data/models/helmet/helmet.obj.mbin");
//node->model.scale(5, 5, 5);
node->material = mat;
mat->shader = Shader::Get("data/shaders/basic.vs", "data/shaders/normal.fs");
node_list.push_back(node);

// LIGHT
Light* light = new Light("first light");
light->ambient = Vector3(1.0, 0.0, 0.0);
light->specular = Vector3(1.0, 1.0, 1.0);
light->difuse = Vector3(1.0, 1.0, 1.0);
light->position = Vector3(-10.0 , 10.0, 10.0);

}

//hide the cursor
Expand Down
1 change: 1 addition & 0 deletions src/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class Application
static Application* instance;

std::vector< SceneNode* > node_list;
std::vector< Light* > light_list;

//window
SDL_Window* window;
Expand Down
5 changes: 5 additions & 0 deletions src/scenenode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,8 @@ void SceneNode::renderInMenu()
ImGui::TreePop();
}
}

Light::Light(std::string name)
{
this->name = name;
}
15 changes: 14 additions & 1 deletion src/scenenode.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,20 @@
#include "camera.h"
#include "material.h"

class Light;
class Light {
public:

Light(std::string name);
~Light();

Vector3 ambient;
Vector3 difuse;
Vector3 specular;
Vector3 position;

std::string name;

};

class SceneNode {
public:
Expand Down

0 comments on commit deff746

Please sign in to comment.