-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check glut and glew support on travis.
- Loading branch information
Showing
14 changed files
with
295 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_ |