Skip to content

Commit

Permalink
fix windows build
Browse files Browse the repository at this point in the history
update gitignore for mingw files
build std::thread stuff only if supported by gcc
fix timer build on mingw
don't use wingl header for now
find and copy missing dlls with wine
fix cmake for mingw

change setters in directionnode. avoid mingw bug

fix qtopengl build

fix mingw warnings
  • Loading branch information
lubosz committed Sep 14, 2012
1 parent 5269d7a commit 17d453b
Show file tree
Hide file tree
Showing 12 changed files with 89 additions and 33 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ include/GL/
test/
liblub.cbp
*.cxx
*.cxx_parameters
*~
*CMakeFiles/
*Makefile
Expand Down
2 changes: 1 addition & 1 deletion apps/editor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ set(EDITOR_MOC_INFILES

qt4_wrap_cpp(EDITOR_MOC_OUTFILES ${EDITOR_MOC_INFILES})
add_executable(liblub-editor ${EDITOR_CPP_FILES} ${EDITOR_MOC_OUTFILES})
target_link_libraries(liblub-editor lubDemos lubEdit QtOpenGL)
target_link_libraries(liblub-editor lubDemos lubEdit)

install(TARGETS liblub-editor DESTINATION "${CMAKE_INSTALL_BINDIR}")
2 changes: 1 addition & 1 deletion apps/planet-editor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ set(EDITOR_MOC_INFILES

qt4_wrap_cpp(EDITOR_MOC_OUTFILES ${EDITOR_MOC_INFILES})
add_executable(liblub-planet-editor ${EDITOR_CPP_FILES} ${EDITOR_MOC_OUTFILES})
target_link_libraries(liblub-planet-editor lubDemos lubEdit QtOpenGL)
target_link_libraries(liblub-planet-editor lubDemos lubEdit)
install(TARGETS liblub-planet-editor DESTINATION "${CMAKE_INSTALL_BINDIR}")
8 changes: 4 additions & 4 deletions demos/raycasting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@ Texture * RaycastingDemo::ballGradient(int size) {

Texture * RaycastingDemo::bulbThreads(int size) {

unsigned threadCount = 8;
unsigned threadSize = size / threadCount;

vector<GLubyte> voxels;
vector<vector<GLubyte>*> voxelParts;

#if defined(_GLIBCXX_HAS_GTHREADS)
unsigned threadCount = 8;
unsigned threadSize = size / threadCount;
std::vector<std::thread> threads;

for(unsigned i = 0; i < threadCount; i++){
Expand All @@ -163,12 +163,12 @@ Texture * RaycastingDemo::bulbThreads(int size) {
for(auto& thread : threads){
thread.join();
}

for (unsigned i = 0; i < threadCount; i++) {
foreach (GLubyte voxel, *voxelParts.at(i)) {
voxels.push_back(voxel);
}
}
#endif

LogDebug << "Sizes" << size*size*size*4 << voxels.size();

Expand Down
24 changes: 24 additions & 0 deletions scripts/mingwDistro
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/python

import subprocess, os

from shutil import copyfile

dlls = []

process = subprocess.Popen(['wine', 'bin/liblub-editor.exe'], shell=False, stderr=subprocess.PIPE)

words = process.communicate()[1].split()
uniqueWords = list(set(words))
for word in uniqueWords:
lineStr = str(word, encoding='utf8')
if ".dll" in lineStr:
if lineStr.endswith(".dll"):
dlls.append(lineStr.replace(".dll", ""))

print (dlls)

for dll in dlls:
locations = os.popen("find /usr/i486-mingw32/ | grep %s | grep dll" % dll).readlines()
dllSource = locations[0].strip()
copyfile(dllSource, 'bin/%s.dll' % dll)
12 changes: 8 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if(WITH_Qt)
endif()

include(${QT_USE_FILE})
find_package(OpenGL)
find_package(OpenGL REQUIRED)
if(NOT OPENGL_FOUND)
message("ERROR: OpenGL not found")
endif(NOT OPENGL_FOUND)
Expand Down Expand Up @@ -49,17 +49,21 @@ set(LIBLUB_MOC_INFILES
qt4_wrap_cpp(LIBLUB_MOC_OUTFILES ${LIBLUB_MOC_INFILES})
add_library(lub ${SOURCES} ${LIBLUB_MOC_OUTFILES})

message(${QT_LIBRARIES})

#libs to link
list(APPEND LIBS
${OPENGL_LIB}
${QT_LIBRARIES}
${Grantlee_CORE_LIBRARIES}
assimp
rt
)

if(LIBLUB_WINDOWS)
list(APPEND LIBS grantlee_core)
else()
list(APPEND LIBS rt)
endif()


if(USE_GLEW)
if(LIBLUB_WINDOWS)
list(APPEND LIBS glew32)
Expand Down
22 changes: 18 additions & 4 deletions src/Procedural/FractalMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ FractalMesh::FractalMesh(const QList<string> & attributes, unsigned resolution,

vector<vector<GLfloat>*> positions;
vector<vector<GLfloat>*> colors;

#if defined(_GLIBCXX_HAS_GTHREADS)
std::vector<std::thread> threads;

for(unsigned i = 0; i < threadCount; ++i){
Expand Down Expand Up @@ -153,7 +153,14 @@ FractalMesh::FractalMesh(const QList<string> & attributes, unsigned resolution,
buffers["color"].insert(buffers["color"].end(), col->begin(), col->end());
delete col;
}

#else
generate_static (0, resolution,
&buffers["position"], &buffers["color"],
resolution, IterationMax, EscapeRadius,
Pixelresolution, PixelHeight,
ZyMax, ZxMin,
C, density);
#endif
// generate(0, resolution, &positions, &colors);


Expand Down Expand Up @@ -287,7 +294,7 @@ void FractalMesh::regenerate() {

// vector<vector<GLfloat>*> positions;
vector<vector<GLfloat>*> colors;

#if defined(_GLIBCXX_HAS_GTHREADS)
std::vector<std::thread> threads;

for(unsigned i = 0; i < threadCount; ++i){
Expand All @@ -308,7 +315,14 @@ void FractalMesh::regenerate() {
for(auto& thread : threads){
thread.join();
}

#else
generate_static_noposition (0, resolution,
&buffers["color"],
resolution, IterationMax, EscapeRadius,
Pixelresolution, PixelHeight,
ZyMax, ZxMin,
C);
#endif
// for(auto* pos : positions){
// buffers["position"].insert(buffers["position"].end(), pos->begin(), pos->end());
// delete pos;
Expand Down
2 changes: 1 addition & 1 deletion src/Renderer/OpenGL.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#ifdef LIBLUB_WINDOWS
# include <GL/wglew.h>
# define glfGetProcAddress wglGetProcAddress
# include "WinGL.h"
//# include "Common/WinGL.h"
#else
# define GLCOREARB_PROTOTYPES 1
# define GL_GLEXT_PROTOTYPES 1
Expand Down
11 changes: 7 additions & 4 deletions src/Scene/DirectionNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,16 @@ void DirectionNode::updateView() {
viewMatrix.lookAt(position, direction() + position, up);
}

void DirectionNode::setParams(qreal fov, qreal near, qreal far) {
void DirectionNode::setFov(const qreal &fov) {
this->fov = fov;
this->nearClip = near;
this->farClip = far;
}

void DirectionNode::setAspect(qreal aspect) {
void DirectionNode::setClipping(const qreal &nearClip, const qreal &farClip) {
this->nearClip = nearClip;
this->farClip = farClip;
}

void DirectionNode::setAspect(const qreal &aspect) {
this->aspect = aspect;
/* Create our projection matrix with a 45 degree field of view
* a width to height ratio of 1 and view from .1 to 100 infront of us */
Expand Down
6 changes: 4 additions & 2 deletions src/Scene/DirectionNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ class DirectionNode : public Node{
QMatrix4x4 getViewNoTranslation();
QMatrix4x4 getProjection() const;

void setAspect(qreal aspect);
void setParams(qreal fov, qreal near, qreal far);
void setAspect(const qreal& aspect);

void setFov(const qreal &fov);
void setClipping(const qreal &nearClip, const qreal &farClip);

void forwardDirection(qreal distance);
void backwardDirection(qreal distance);
Expand Down
2 changes: 1 addition & 1 deletion src/System/Logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void Logger::log(int mode, int color, const string & level,
const string & file, int line) {
const unsigned alignedTextSize = 11;
#if LIBLUB_WINDOWS
cout<<"["<< level << "] "<<file<<":"<<line<<" ";
cout<<"["<< level << "] "<<file<<":"<<line<< getSpaces(alignedTextSize - file.size(), line);
#else
cout<<"\e["<< mode <<";"<< color <<"m[" << level << "]\e[m "
<<"\e[1;34m"<<file<<" \e[0;33m"<<line<<"\e[m"<< getSpaces(alignedTextSize - file.size(), line);
Expand Down
30 changes: 19 additions & 11 deletions src/System/Timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,33 @@ float Timer::getMilliseconds() {
float Timer::getSeconds() {
return float(frameTime.tv_sec) + getMilliseconds()/1000.0;
}

float Timer::getTime() {
timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
return (float(now.tv_sec) + float(now.tv_nsec)/BILLION);
}

#else

void Timer::updateFPS() {

void Timer::startFrame() {
}
void Timer::frameDone() {
}
float Timer::getSeconds() {
return 0;
}
float Timer::getMilliseconds() {
return 0;
}

float Timer::getFPS() {
return 0;
}

float Timer::getSPF() {
return 0;
float Timer::getTime() {
return 0;
}

#endif
Expand All @@ -79,14 +95,6 @@ void Timer::printFPS() {
LogInfo << "FPS" << getFPS() << "," << getMilliseconds() << "ms per Frame";
}

float Timer::getTime() {
#ifndef LIBLUB_WINDOWS
timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
return (float(now.tv_sec) + float(now.tv_nsec)/BILLION);
#endif
}

void Timer::countAverage() {
framesRendered++;
float frameTimeMs = getMilliseconds();
Expand Down

0 comments on commit 17d453b

Please sign in to comment.