hhergeth / CudaTracerLib

A library for ray tracing based rendering algorithms using CUDA
GNU General Public License v3.0
50 stars 9 forks source link

Issue about example for using CudaTracerLib #9

Closed iscaswcm closed 7 years ago

iscaswcm commented 7 years ago

Hi, have a nice day! When comiling example(extract from windows dependencies) how to use CudaTracerLib, some error apperaed: **HostExample.cpp:56:11: error: ‘class CudaTracerLib::Image’ has no member named ‘StartRendering’ outImage.StartRendering(); ^ HostExample.cpp:59:11: error: ‘class CudaTracerLib::Image’ has no member named ‘EndRendering’ outImage.EndRendering();

**_61 -code=sm_61 --relocatable-device-code true ExampleTracer.cu(31): error: identifier "BlockSampleImage" is undefined

ExampleTracer.cu(35): error: function "CudaTracerLib::SequenceSamplerData::operator()" cannot be called with the given argument list object type is: CudaTracerLib::SamplerData

ExampleTracer.cu(49): error: class "CudaTracerLib::IBlockSampler" has no member "getBlockImage"

ExampleTracer.cu(54): error: function "CudaTracerLib::SequenceSamplerData::operator()" cannot be called with the given argument list object type is: CudaTracerLib::SamplerData

4 errors detected in the compilation of "/tmp/tmpxft_00002c11_00000000-7_ExampleTracer.cpp1.ii".****

I download the latest CudaTracerLib source code, I think main reason of errors above is that example code is outdated. I wonder if you can offer me a latest example code to use CudaTracerLib. Thanks a lot.

hhergeth commented 7 years ago

Hey! Thanks for your interest :)

You are absolutely correct, all of these errors were due to me not updating the examples. I have just done this and also updated the windows dependencies. Please download them again.

As you may notice I have removed the ExampleTracer from the example project. This is due to limitations in CUDA 8.0. If you'd like to create your own renderer simply copy those 2 files into the CudaTracerLib/Integrators directory. (Boring technical explanation : Having the tracer in a depending project implies nvcc has to link the kernels to device functions in another project. In CUDA 7.5 this was possible by a hack: add them explicitly to the cuda linker. Sadly this does no longer with 8.0. I might investigate this further but currently the workaround is too simple to justify spending a lot of time on that.)

Please let me know if you have any further questions and of course whether this solved your problem!

iscaswcm commented 7 years ago

Hi, hhergeth! It's very nice of you!I'm downloading it now! Another issue, I advice you add a line like this: set(CUDA_PROPAGATE_HOST_FLAGS OFF) in CMakeLists.txt in order to disable nvcc c++11 warning: cc1: warning: command line option ‘-std=c++11’ is valid for C++/ObjC++ but not for C. When I compiling CudaTracerLib with CUDA 8.0, I write a Makefile , It works. My Makefile: ///////////////////////////////////////////////////////////////////////////// NVCC_FLAGS := $(NVCC_LDFLAGS) $(NVCC_ARCH)

CXX_LDFLAGS := -lstdc++ -lm -lpthread -lgomp -lboost_system -lboost_filesystem -lboost_program_options CXX_FLAGS := -std=c++11 -fopenmp

INCLUDE := -Isrc -Iinclude $(NVCC_INCLUDE)

NVCC := nvcc -std=c++11 $(DEF) CXX := g++ $(DEF)

rwildcard = $(foreach d, $(wildcard $1), $(call rwildcard,$d/,$2)$(filter $(subst ,%,$2),$d))

$(wildcard $1*) -- get all filesnand directories in current directory

SOURCES := $(call rwildcard, src/, .cpp)
OBJS := $(subst src/,build_make/,$(SOURCES:.cpp=.cpp.o)) CU_SOURCES := $(call rwildcard, src/,
.cu) CU_OBJS := $(subst src/,build_make/,$(CU_SOURCES:.cu=.cu.o))

TARGET := build_make/libcudatracer.a

default: $(TARGET)

$(TARGET): $(OBJS) $(CU_OBJS) @$(ECHO) "\033[32;49;6mLinking $@\033[0m" @ar rcs $@ $(OBJS) $(CU_OBJS)

build_make/%.cpp.o: src/%.cpp @mkdir -p $(@D) @$(ECHO) "\033[32;49;1mCompiling $< to $@\033[0m" @$(CXX) $(CXX_FLAGS) $(INCLUDE) -o $@ -c $<

build_make/%.cu.o: src/%.cu @mkdir -p $(@D) @$(ECHO) "\033[32;49;1mCompiling $< to $@\033[0m" @$(NVCC) $(NVCC_FLAGS) $(INCLUDE) -o $@ -c $<

clean:

@$(ECHO) $(SOURCES)

@rm -rf   build_make

///////////////////////////////////////////////////////////////////////////// I wonder if you can give me you email for further discussion, mine is changmaowu@foxmail.com, my name is Changmao Wu, from Lab. of Parallel Software and Computational Sciences, Institute of Software, Chian Academy of Sciences.

iscaswcm commented 7 years ago

Hi, hhergeth! Compiling xample code is OK, however, the result picture is black as following:

![Uploading result.jpg…]()

I think if you can show a example code that can render a picture just like yours: https://github.com/hhergeth/CudaTracerLib/wiki/Example-Renderings

Best wishes for you.