From b19f0bb72700412a943f1190a7f296888d0fff79 Mon Sep 17 00:00:00 2001 From: kts Date: Tue, 24 Feb 2015 17:11:52 -0800 Subject: [PATCH] Updated Linux build, forgot to set v_flags to opengl/resizable. Core now calls updateProjection for each camera and setView for each camera's RenderView on window resize. This functionality will be moved elsewhere, as we do not necessarily want to resize the view or the camera to the entire window. --- build/linux/Makefile | 3 ++- src/Core.cpp | 16 ++++++++++++++++ src/Core.hpp | 2 +- src/RenderView.hpp | 2 +- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/build/linux/Makefile b/build/linux/Makefile index 08e58d7..17c331d 100644 --- a/build/linux/Makefile +++ b/build/linux/Makefile @@ -14,7 +14,7 @@ CXXFLAGS+=$(DEBUG) -Wall `sdl2-config --cflags` -c LDFLAGS+= -Wall -L../../../sdl/$(LIB_DIR) -Wl,-rpath=$(LIB_DIR)/ -lSDL2 -lpthread -Wl,--no-undefined -lm -ldl -pthread -lrt -Wl,-Bstatic -lGLEW -Wl,-Bdynamic -lGL VPATH=../../src BINARY=RtB$(BITS) -OBJ=main.o Log.o Mat4.o Vec.o RenderScene.o RenderSet.o RenderObject.o RenderCamera.o RenderView.o +OBJ=main.o Core.o fio.o checksum.o Log.o Quat.o Mat4.o Vec.o Mesh.o Program.o RenderScene.o RenderSet.o RenderObject.o RenderCamera.o RenderView.o OBJ_DIR=obj $(BINARY): $(patsubst %,$(OBJ_DIR)/%,$(OBJ)) @@ -30,6 +30,7 @@ release: install: $(BINARY) mkdir -p build/ mkdir -p build/$(LIB_DIR)/ + cp -rfv ../../data build/ cp -f /usr/$(LIB_DIR)/libpng14.so.14.12.0 build/$(LIB_DIR)/libpng14.so.14 cp -f /usr/$(LIB_DIR)/libSDL2-2.0.so.0.2.1 build/$(LIB_DIR)/libSDL2-2.0.so.0 diff --git a/src/Core.cpp b/src/Core.cpp index 729c9bb..51616f9 100644 --- a/src/Core.cpp +++ b/src/Core.cpp @@ -35,6 +35,7 @@ int Core::initSystem() { SDL_GetDesktopDisplayMode(0, &display_mode); v_width = display_mode.w; v_height = display_mode.h; + v_flags = SDL_WINDOW_OPENGL|SDL_WINDOW_RESIZABLE; // create our window v_window = SDL_CreateWindow("Roll them Bones", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, v_width, v_height, v_flags); if (v_window == NULL) { @@ -46,6 +47,7 @@ int Core::initSystem() { // Get our OpenGL context v_context = SDL_GL_CreateContext(v_window); if (v_context == NULL) { + std::cerr << SDL_GetError(); LOG(LOG_ERROR) << "SDL_GL_CreateContext: " << SDL_GetError(); return 1; } @@ -167,6 +169,20 @@ void Core::doProcess() { while (SDL_PollEvent(&event)) { if (event.type == SDL_QUIT) { flags &= ~IS_RUNNING; + } else if (event.type == SDL_WINDOWEVENT) { + if (event.window.event == SDL_WINDOWEVENT_RESIZED) { + v_width = event.window.data1; + v_height = event.window.data2; + RenderCamera *r_camera; + RenderView *r_view; + std::vector::iterator camera_it, camera_end; + for (camera_it = scene->getCameras()->begin(), camera_end = scene->getCameras()->end(); camera_it != camera_end; ++camera_it) { + r_camera = *camera_it; + if ((r_view = r_camera->getRenderView()) == NULL) continue; + r_camera->updateProjection(v_width, v_height); + r_view->setView(v_width, v_height); + } + } } } doRender(); diff --git a/src/Core.hpp b/src/Core.hpp index 18c9822..fe2e099 100644 --- a/src/Core.hpp +++ b/src/Core.hpp @@ -28,7 +28,7 @@ class Core { GLint v_fbo; // window framebuffer object int v_width; // width of our display int v_height; // height of our display - int v_flags; // video flags + int v_flags; // video flags RenderScene *scene; // our current render scene // Audio *audio_service; // Net *net_service; diff --git a/src/RenderView.hpp b/src/RenderView.hpp index b007fed..bceb9fe 100644 --- a/src/RenderView.hpp +++ b/src/RenderView.hpp @@ -21,12 +21,12 @@ class RenderView { Mesh *getMesh(); int setProgram(Program *program); Program *getProgram(); + int setView(int width, int height); protected: GLuint fbo; // The fbo that RenderScene will draw to private: int createView(int width, int height); int destroyView(); - int setView(int width, int height); GLuint fbo_depth; // The fbo depth buffer GLuint fbo_tex; // The texture of the fbo int w, h; // width and height of this view (also of fbo)