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.
parent
a0eeec21b2
commit
b19f0bb727
|
@ -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
|
||||
|
||||
|
|
16
src/Core.cpp
16
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<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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue