Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions linux/README_LINUX_CONFIG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,9 @@ Install FreeGlut2.6+ and GL3:
sudo apt-get install freeglut3-dev

Copy http://www.opengl.org/registry/api/gl3.h to /usr/include/GL3/gl3.h (NOTE this should be necessary with newest version of freeglut!!!)

****
IMPORTANT IF USING AN AMD GRAPHICS CARD!
****
For some reason a bad logging call is made in Program.cpp which causes the program to SEGFAULT if using an AMD graphics card.
Uncomment the line AMD_HACK in scripts/makeStaticLibrary.sh to enable a bypass of this call
2 changes: 1 addition & 1 deletion linux/RendererLinux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void RendererLinux::start() {
FreeGlutGLView::start(this);
}
void RendererLinux::start(std::string name) {
printf("in RendererLinux::start(name)\n");
printf("in RendererLinux::start(%s)\n", name.c_str());
FreeGlutGLView::start(this, name);
}

Expand Down
107 changes: 107 additions & 0 deletions linux/class-examples/week5a_NoiseDisplacement/NoiseSphere.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@

#include "Aluminum/Includes.hpp"

#include "Aluminum/FreeGlutGLView.hpp"
#include "Aluminum/RendererLinux.hpp"
#include "Aluminum/MeshBuffer.hpp"
#include "Aluminum/MeshData.hpp"
#include "Aluminum/MeshUtils.hpp"
#include "Aluminum/Program.hpp"
#include "Aluminum/Texture.hpp"
#include "Aluminum/Behavior.hpp"
#include "Aluminum/Shapes.hpp"
#include "Aluminum/ResourceHandler.hpp"
#include "objload.h"

using namespace aluminum;

class NoiseSphere : public RendererLinux {
public:


vec3 diffuse = vec3(1.0,0.4,0.0);
vec3 specular = vec3(1.0,1.0,1.0);
vec3 ambient = vec3(0.0,0.0,0.3);
mat4 model, view, proj;


Program program;
GLint posLoc=0;
GLint normalLoc=1;

MeshBuffer mb;
MeshData mesh;

Behavior rotateBehavior;
Behavior lightBehavior;

ResourceHandler rh;

void loadProgram(Program &p, const std::string& name) {

p.create();

p.attach(p.loadText(name + ".vsh"), GL_VERTEX_SHADER);
glBindAttribLocation(p.id(), posLoc, "vertexPosition");
glBindAttribLocation(p.id(), normalLoc, "vertexNormal");

p.attach(p.loadText(name + ".fsh"), GL_FRAGMENT_SHADER);

p.link();
}



virtual void onCreate() {

rh.loadProgram(program, "resources/noise", posLoc, normalLoc, -1, -1);

int res = 250;
addSphere(mesh, 1.0, res, res);

mb.init(mesh, posLoc, normalLoc, -1, -1);

proj = glm::perspective(glm::radians(60.0), 1.0, 0.1, 1000.0);
view = glm::lookAt(vec3(0.0,0.0, -4.0), vec3(0,0,0), vec3(0,1,0) );
model = glm::mat4();

glEnable(GL_DEPTH_TEST);
glClearColor(1.0,1.0,1.0,1.0);

rotateBehavior = Behavior(now()).delay(0).length(10000).range(M_PI * 2.0).looping(true).repeats(-1);
}

void updateModel() {

float total = rotateBehavior.tick(now()).total();
model = glm::mat4();
model = glm::rotate(model, total, vec3(0.0f,1.0f,0.0f));
}

float val = 0.0;

void onFrame() {

val += 0.01;

glViewport(0, 0, width, height);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

// updateModel();

program.bind(); {
glUniformMatrix4fv(program.uniform("model"), 1, 0, ptr(model));
glUniformMatrix4fv(program.uniform("view"), 1, 0, ptr(view));
glUniformMatrix4fv(program.uniform("proj"), 1, 0, ptr(proj));

glUniform1f(program.uniform("in_val"), val);

mb.draw();

} program.unbind();
}
};
int main() {
NoiseSphere().start("NoiseSphere");
return 0;
}
Loading