Skip to content
Snippets Groups Projects
Verified Commit 6a3cd6de authored by Tóth Miklós Tibor's avatar Tóth Miklós Tibor :shrug:
Browse files

forog

parent 097b4c2a
No related branches found
No related tags found
No related merge requests found
......@@ -234,8 +234,8 @@ public:
bool shadowIntersect(Ray ray) { // for directional lights
for (Intersectable * object : objects) {
Hit hit = object->intersect(ray);
if (hit.t > 0)
if(hit.t < length(hit.position - ray.start))
if (hit.t < 0)
if(hit.t > length(hit.position - ray.start))
return true;
}
return false;
......@@ -296,10 +296,15 @@ const char *fragmentSource = R"(
class FullScreenTexturedQuad {
unsigned int vao = 0; // vertex array object id and texture id
int wW, wH;
Texture texture;
public:
void loadImage(const std::vector<vec4>& image) {
texture.create(wW, wH, image);
}
FullScreenTexturedQuad(int windowWidth, int windowHeight, std::vector<vec4>& image)
: texture(windowWidth, windowHeight, image)
: wW(windowWidth), wH(windowHeight), texture(windowWidth, windowHeight, image)
{
glGenVertexArrays(1, &vao); // create 1 vertex array object
glBindVertexArray(vao); // make it active
......@@ -330,6 +335,7 @@ void onInitialization() {
scene.build();
std::vector<vec4> image(windowWidth * windowHeight);
long timeStart = glutGet(GLUT_ELAPSED_TIME);
scene.render(image);
long timeEnd = glutGet(GLUT_ELAPSED_TIME);
......@@ -344,6 +350,15 @@ void onInitialization() {
// Window has become invalid: Redraw
void onDisplay() {
std::vector<vec4> image(windowWidth * windowHeight);
long timeStart = glutGet(GLUT_ELAPSED_TIME);
scene.render(image);
long timeEnd = glutGet(GLUT_ELAPSED_TIME);
printf("Rendering time: %d milliseconds\n", (timeEnd - timeStart));
fullScreenTexturedQuad->loadImage(image);
fullScreenTexturedQuad->Draw();
glutSwapBuffers(); // exchange the two buffers
}
......@@ -367,4 +382,6 @@ void onMouseMotion(int pX, int pY) {
// Idle event indicating that some time elapsed: do animation here
void onIdle() {
scene.Animate(.1f);
glutPostRedisplay();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment