Skip to content

Commit

Permalink
Check glut and glew support on travis.
Browse files Browse the repository at this point in the history
  • Loading branch information
tatsy committed Apr 26, 2015
1 parent 5a6ca41 commit 41702da
Show file tree
Hide file tree
Showing 14 changed files with 295 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,25 @@ before_install:
- sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 90
- sudo update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-4.9 90
install:
# install freeglut and glew
- sudo apt-get -qq install freeglut3 freeglut3-dev libglew-dev libglew1.10

# install GTest
- sudo apt-get install libgtest-dev
- "cd /usr/src/gtest && sudo cmake . && sudo cmake --build . && sudo mv libg* /usr/local/lib; cd -"
- export GTEST_LIBRARY=/usr/local/lib/libgtest.a
- export GTEST_MAIN_LIBRARY=/usr/local/lib/libgtest_main.a
- export GTEST_INCLUDE_DIRS=/usr/include

# install lcov
- wget http://ftp.de.debian.org/debian/pool/main/l/lcov/lcov_1.11.orig.tar.gz
- tar xf lcov_1.11.orig.tar.gz
- sudo make -C lcov-1.11/ install
- gem install coveralls-lcov
- lcov --version
- g++ --version

# build spica
- cmake .
- cmake --build .
before_script:
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ spica
#### Results


#### ToDo

* kd-tree implementation

## License

* MIT license 2015, Tatsuya Yatagawa (tatsy).
Expand Down
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ add_subdirectory(renderer)
add_subdirectory(geometry)
add_subdirectory(utils)
add_subdirectory(scenes)
add_subdirectory(structure)
add_subdirectory(viewer)

set(SOURCES ${SOURCES})
set(HEADERS ${HEADERS} ../include/spica.h)
Expand Down
11 changes: 11 additions & 0 deletions src/structure/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
set(SOURCES
${SOURCES}
${CMAKE_CURRENT_LIST_DIR}/kd_tree.cc
${CMAKE_CURRENT_LIST_DIR}/bbox.cc
PARENT_SCOPE)

set(HEADERS
${HEADERS}
${CMAKE_CURRENT_LIST_DIR}/kd_tree.h
${CMAKE_CURRENT_LIST_DIR}/bbox.h
PARENT_SCOPE)
41 changes: 41 additions & 0 deletions src/structure/bbox.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#define SPICA_BBOX_EXPORT
#include "bbox.h"

namespace spica {

BBox::BBox()
: _posMin()
, _posMax()
{
}

BBox::BBox(double minX, double minY, double minZ, double maxX, double maxY, double maxZ)
: _posMin(minX, minY, minZ)
, _posMax(maxX, maxY, maxZ)
{
}

BBox::BBox(const Vector3& posMin, const Vector3& posMax)
: _posMin(posMin)
, _posMax(posMax)
{
}

BBox::BBox(const BBox& box)
: _posMin(box._posMin)
, _posMax(box._posMax)
{
}

BBox::~BBox()
{
}

BBox& BBox::operator=(const BBox& box) {
this->_posMin = box._posMin;
this->_posMax = box._posMax;
return *this;
}

} // namespace spica

39 changes: 39 additions & 0 deletions src/structure/bbox.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#ifndef _SPICA_BBOX_H_
#define _SPICA_BBOX_H_

#if defined(_WIN32) || defined(__WIN32__)
#ifndef SPICA_BBOX_EXPORT
#define SPICA_BBOX_DLL __declspec(dllexport)
#else
#define SPICA_BBOX_DLL __declspec(dllimport)
#endif
#else
#define SPICA_BBOX_DLL
#endif

#include "../utils/vector3.h"

namespace spica {

// ----------------------------------------
// Axis-aligned bounding box
// ----------------------------------------
class SPICA_BBOX_DLL BBox {
private:
Vector3 _posMin; // Position of minimum corner
Vector3 _posMax; // Position of maximum corner

public:
BBox();
explicit BBox(double minX, double minY, double minZ, double maxX, double maxY, double maxZ);
explicit BBox(const Vector3& posMin, const Vector3& posMax);
BBox(const BBox& box);

~BBox();

BBox& operator=(const BBox& box);
};

} // namespace spica

#endif // _SPICA_BBOX_H_
Empty file added src/structure/kd_tree.cc
Empty file.
19 changes: 19 additions & 0 deletions src/structure/kd_tree.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef _SPICA_KD_TREE_H_
#define _SPICA_KD_TREE_H_

namespace spica {

class KdTree {

struct KdTreeNode {
int startID;
int endID;
KdTreeNode* left;
KdTreeNode* right;
};

};

}

#endif // _SPICA_KD_TREE_H_
39 changes: 39 additions & 0 deletions src/viewer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
option(BUILD_VIEWER "BUILD_VIEWER" OFF)

if (${BUILD_VIEWER} STREQUAL "ON")

if (MSVC)
set(CMAKE_PREFIX_PATH "C:/Qt/5.4/msvc2013_64_opengl/" CACHE STRING "CMAKE_PREFIX_PATH")
endif()

find_package(Qt5Widgets REQUIRED)
find_package(Qt5OpenGL REQUIRED)
find_package(OpenGL REQUIRED)

set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

link_directories(${CMAKE_LIBRARY_OUTPUT_DIRECTORY})

add_executable(scene_viewer main.cc
scene_viewer.cc
scene_viewer.h
qgl_render_widget.cc
qgl_render_widget.h)

qt5_use_modules(scene_viewer Widgets OpenGL)

target_link_libraries(scene_viewer "${LIB_PREFIX}spica_renderer${LIB_SUFFIX}")
target_link_libraries(scene_viewer ${QT_LIBRARIES} ${OPENGL_LIBRARIES})

set(QT_LIB_LIST Qt5Widgets Qt5Core Qt5Gui)

if (MSVC)
foreach (qtlib ${QT_LIB_LIST})
add_custom_command(TARGET scene_viewer POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
ARGS ${CMAKE_PREFIX_PATH}bin/${qtlib}${BUILD_TYPE_SUFFIX}.dll ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
endforeach(qtlib)
endif()

endif()
19 changes: 19 additions & 0 deletions src/viewer/main.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <QtWidgets/qapplication.h>

#include "../scenes/cornell_box.h"
#include "scene_viewer.h"
using namespace spica;

int main(int argc, char** argv) {
QApplication app(argc, argv);

Scene scene;
Camera camera;
cornellBox(scene, camera, 640, 480);

SceneViewer viewer;
viewer.show();
viewer.setScene(scene, camera);

return app.exec();
}
33 changes: 33 additions & 0 deletions src/viewer/qgl_render_widget.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include "qgl_render_widget.h"

#include <gl/glut.h>
#include <gl/glew.h>

namespace spica {

QGLRenderWidget::QGLRenderWidget(QWidget *parent)
: QGLWidget(parent)
{
}

QGLRenderWidget::~QGLRenderWidget()
{
}

void QGLRenderWidget::setScene(const Scene& scene, const Camera& camera) {
printf("%d %d\n", camera.imageW(), camera.imageH());
this->resize(camera.imageW(), camera.imageH());
}

void QGLRenderWidget::initializeGL() {
qglClearColor(Qt::black);
}

void QGLRenderWidget::resizeGL(int width, int height) {
glViewport(0, 0, width, height);
}

void QGLRenderWidget::paintGL() {
}

} // namespace spica
29 changes: 29 additions & 0 deletions src/viewer/qgl_render_widget.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#ifndef _SPICA_QGL_RENDER_WIDGET_H_
#define _SPICA_QGL_RENDER_WIDGET_H_

#include <QtOpenGL/qgl.h>

#include "../renderer/scene.h"
#include "../renderer/camera.h"

namespace spica {

class QGLRenderWidget : public QGLWidget {
Q_OBJECT

public:
explicit QGLRenderWidget(QWidget *parent = 0);
~QGLRenderWidget();

void setScene(const Scene& scene, const Camera& camera);

protected:
void initializeGL();
void resizeGL(int width, int height);
void paintGL();

};

}

#endif // _SPICA_QGL_RENDER_WIDGET_H_
25 changes: 25 additions & 0 deletions src/viewer/scene_viewer.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "scene_viewer.h"

namespace spica {

SceneViewer::SceneViewer(QWidget *parent)
: QMainWindow(parent)
, qglWidget(0)
{
qglWidget = new QGLRenderWidget(this);
qglWidget->show();

this->setCentralWidget(qglWidget);
}

SceneViewer::~SceneViewer()
{
delete qglWidget;
}

void SceneViewer::setScene(const Scene& scene, const Camera& camera) {
this->resize(camera.imageW(), camera.imageH());
qglWidget->setScene(scene, camera);
}

} // namespace spica
26 changes: 26 additions & 0 deletions src/viewer/scene_viewer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifndef _SPICA_SCENE_VIEWER_H_
#define _SPICA_SCENE_VIEWER_H_

#include <qmainwindow.h>
#include <qboxlayout.h>

#include "qgl_render_widget.h"
#include "../renderer/camera.h"
#include "../renderer/scene.h"

namespace spica {

class SceneViewer : public QMainWindow {
public:
explicit SceneViewer(QWidget *parent = 0);
~SceneViewer();

void setScene(const Scene& scene, const Camera& camera);

protected:
QGLRenderWidget* qglWidget;
};

}

#endif // _SPICA_SCENE_VIEWER_H_

0 comments on commit 41702da

Please sign in to comment.