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.

master
kts 2015-02-24 17:11:52 -08:00
parent a0eeec21b2
commit b19f0bb727
4 changed files with 20 additions and 3 deletions

View File

@ -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 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 VPATH=../../src
BINARY=RtB$(BITS) 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 OBJ_DIR=obj
$(BINARY): $(patsubst %,$(OBJ_DIR)/%,$(OBJ)) $(BINARY): $(patsubst %,$(OBJ_DIR)/%,$(OBJ))
@ -30,6 +30,7 @@ release:
install: $(BINARY) install: $(BINARY)
mkdir -p build/ mkdir -p build/
mkdir -p build/$(LIB_DIR)/ 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)/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 cp -f /usr/$(LIB_DIR)/libSDL2-2.0.so.0.2.1 build/$(LIB_DIR)/libSDL2-2.0.so.0

View File

@ -35,6 +35,7 @@ int Core::initSystem() {
SDL_GetDesktopDisplayMode(0, &display_mode); SDL_GetDesktopDisplayMode(0, &display_mode);
v_width = display_mode.w; v_width = display_mode.w;
v_height = display_mode.h; v_height = display_mode.h;
v_flags = SDL_WINDOW_OPENGL|SDL_WINDOW_RESIZABLE;
// create our window // create our window
v_window = SDL_CreateWindow("Roll them Bones", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, v_width, v_height, v_flags); v_window = SDL_CreateWindow("Roll them Bones", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, v_width, v_height, v_flags);
if (v_window == NULL) { if (v_window == NULL) {
@ -46,6 +47,7 @@ int Core::initSystem() {
// Get our OpenGL context // Get our OpenGL context
v_context = SDL_GL_CreateContext(v_window); v_context = SDL_GL_CreateContext(v_window);
if (v_context == NULL) { if (v_context == NULL) {
std::cerr << SDL_GetError();
LOG(LOG_ERROR) << "SDL_GL_CreateContext: " << SDL_GetError(); LOG(LOG_ERROR) << "SDL_GL_CreateContext: " << SDL_GetError();
return 1; return 1;
} }
@ -167,6 +169,20 @@ void Core::doProcess() {
while (SDL_PollEvent(&event)) { while (SDL_PollEvent(&event)) {
if (event.type == SDL_QUIT) { if (event.type == SDL_QUIT) {
flags &= ~IS_RUNNING; 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<RenderCamera*>::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(); doRender();

View File

@ -28,7 +28,7 @@ class Core {
GLint v_fbo; // window framebuffer object GLint v_fbo; // window framebuffer object
int v_width; // width of our display int v_width; // width of our display
int v_height; // height 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 RenderScene *scene; // our current render scene
// Audio *audio_service; // Audio *audio_service;
// Net *net_service; // Net *net_service;

View File

@ -21,12 +21,12 @@ class RenderView {
Mesh *getMesh(); Mesh *getMesh();
int setProgram(Program *program); int setProgram(Program *program);
Program *getProgram(); Program *getProgram();
int setView(int width, int height);
protected: protected:
GLuint fbo; // The fbo that RenderScene will draw to GLuint fbo; // The fbo that RenderScene will draw to
private: private:
int createView(int width, int height); int createView(int width, int height);
int destroyView(); int destroyView();
int setView(int width, int height);
GLuint fbo_depth; // The fbo depth buffer GLuint fbo_depth; // The fbo depth buffer
GLuint fbo_tex; // The texture of the fbo GLuint fbo_tex; // The texture of the fbo
int w, h; // width and height of this view (also of fbo) int w, h; // width and height of this view (also of fbo)