Quick little way to spawn in some popcorns. Hit M.
This commit is contained in:
parent
d03afb31e1
commit
748528a31f
3 changed files with 17 additions and 5 deletions
|
|
@ -16,13 +16,13 @@ void framebuffer_size_callback(GLFWwindow *, int width, int height) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void mouse_callback(GLFWwindow *window, double xpos, double ypos) {
|
void mouse_callback(GLFWwindow *window, double xpos, double ypos) {
|
||||||
Camera* camera = static_cast<Camera*>(glfwGetWindowUserPointer(window));
|
Scene* scene = static_cast<Scene*>(glfwGetWindowUserPointer(window));
|
||||||
camera->mouse_move(xpos, ypos);
|
scene->camera.mouse_move(xpos, ypos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void scroll_callback(GLFWwindow *window, double xoffset, double yoffset) {
|
void scroll_callback(GLFWwindow *window, double xoffset, double yoffset) {
|
||||||
Camera* camera = static_cast<Camera*>(glfwGetWindowUserPointer(window));
|
Scene* scene = static_cast<Scene*>(glfwGetWindowUserPointer(window));
|
||||||
camera->mouse_scroll(xoffset, yoffset);
|
scene->camera.mouse_scroll(xoffset, yoffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWwindow* create_window() {
|
GLFWwindow* create_window() {
|
||||||
|
|
@ -65,6 +65,10 @@ void process_input(GLFWwindow *window, Scene& scene) {
|
||||||
scene.camera.right();
|
scene.camera.right();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(glfwGetKey(window, GLFW_KEY_M) == GLFW_PRESS) {
|
||||||
|
scene.spawn("popcorn", scene.camera.position);
|
||||||
|
}
|
||||||
|
|
||||||
if(glfwGetKey(window, GLFW_KEY_L) == GLFW_PRESS) {
|
if(glfwGetKey(window, GLFW_KEY_L) == GLFW_PRESS) {
|
||||||
for(auto& light : scene.light.directional) {
|
for(auto& light : scene.light.directional) {
|
||||||
light.adjust(-0.01f);
|
light.adjust(-0.01f);
|
||||||
|
|
@ -109,7 +113,7 @@ int main() {
|
||||||
auto window = create_window();
|
auto window = create_window();
|
||||||
auto scene = setup();
|
auto scene = setup();
|
||||||
|
|
||||||
glfwSetWindowUserPointer(window, &scene.camera);
|
glfwSetWindowUserPointer(window, &scene);
|
||||||
|
|
||||||
while(!glfwWindowShouldClose(window)) {
|
while(!glfwWindowShouldClose(window)) {
|
||||||
update(window, scene);
|
update(window, scene);
|
||||||
|
|
|
||||||
|
|
@ -57,3 +57,10 @@ void Scene::render(GLFWwindow* window) {
|
||||||
void Scene::cleanup() {
|
void Scene::cleanup() {
|
||||||
shader.cleanup();
|
shader.cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Scene::spawn(const std::string& name, components::Position& position) {
|
||||||
|
things.emplace_back(
|
||||||
|
models.at(name),
|
||||||
|
position,
|
||||||
|
materials.at(name));
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -60,4 +60,5 @@ struct Scene {
|
||||||
void draw_model(Model& scene_model, Material& material, glm::mat4& projection, glm::mat4& view, glm::vec3& position);
|
void draw_model(Model& scene_model, Material& material, glm::mat4& projection, glm::mat4& view, glm::vec3& position);
|
||||||
void render(GLFWwindow* window);
|
void render(GLFWwindow* window);
|
||||||
void cleanup();
|
void cleanup();
|
||||||
|
void spawn(const std::string& name, components::Position& position);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue