-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
81 lines (65 loc) · 1.86 KB
/
main.cpp
File metadata and controls
81 lines (65 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include "glew.h"
//std include
#include <iostream>
//SFML include
#include <SFML/Window.hpp>
#include <SFML/OpenGL.hpp>
#include <SFML/Graphics.hpp>
//OpenGL include
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#include <GL/freeglut.h>
//loacl includes
#include "world.h"
#define WORLD_WI 800
#define WORLD_HE 600
World* world = new World(WORLD_WI, WORLD_HE);
void build_world()
{
world->build();
world->render_world();
std::cout<<"All work done."<<std::endl;
}
int main()
{
// create the window
sf::RenderWindow window(sf::VideoMode(WORLD_WI, WORLD_HE), "Ray/Path tracing", sf::Style::Default, sf::ContextSettings(32));
window.setVerticalSyncEnabled(true);
// load resources, initialize the OpenGL states, ...
// Build world
build_world();
// run the main loop
bool running = true;
while (running)
{
// handle events
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
{
// end the program
running = false;
}
else if (event.type == sf::Event::Resized)
{
// adjust the viewport when the window is resized
glViewport(0, 0, event.size.width, event.size.height);
}
}
// clear the buffers
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
window.setActive();
// draw...
sf::Texture texture;
texture.create(WORLD_WI,WORLD_HE);
sf::Sprite sprite(texture);
texture.update(world->_pixels);
window.draw(sprite);
// end the current frame (internally swaps the front and back buffers)
window.display();
}
// release resources...
return 0;
}