0

我有一个绘制地球的程序,它使用以下代码读取纹理文件:

Images::RGBImage surfaceImage;
surfaceImage=Images::readImageFile("",Vrui::openFile("/home/rodrtu/Desktop/SolarSystem/land_shallow_topo_2048.png"));`

我设置它的方式只适用于我的桌面,但我希望其他人能够访问我的程序文件和图片,并能够让程序在他们的计算机上运行。我应该使用什么而不是使用"/home/rodrtu/Desktop/SolarSystem/land_shallow_topo_2048.png"

如果我将一个文件夹添加到与我的 .cpp 文件相同的位置,我应该对我的 makefile 进行更改吗?这是我的makefile

VRUI_MAKEDIR := /opt/local/Vrui-2.6/share/make
ifdef DEBUG
  VRUI_MAKEDIR := $(VRUI_MAKEDIR)/debug
endif

INSTALLDIR := $(shell pwd)

# Set resource directory: I added this images folder to the same place as my 
# .cpp file, but it still doesn't work
RESOURCEDIR = images

########################################################################
########################################################################

# Include definitions for the system environment and system-provided
# packages
include $(VRUI_MAKEDIR)/SystemDefinitions
include $(VRUI_MAKEDIR)/Packages.System
include $(VRUI_MAKEDIR)/Configuration.Vrui
include $(VRUI_MAKEDIR)/Packages.Vrui

# Set installation directory structure:
BININSTALLDIR = $(INSTALLDIR)/$(EXEDIR)
RESOURCEINSTALLDIR = $(INSTALLDIR)/$(RESOURCEDIR)

########################################################################
########################################################################

PACKAGES = MYVRUI

########################################################################
########################################################################

ALL = $(EXEDIR)/NewPlanet   

.PHONY: all
all: $(ALL)

########################################################################
#'make clean'
########################################################################

.PHONY: extraclean
extraclean:

.PHONY: extrasqueakyclean
extrasqueakyclean:

# Include basic makefile
include $(VRUI_MAKEDIR)/BasicMakefile

########################################################################
########################################################################


$(EXEDIR)/NewPlanet: $(OBJDIR)/NewPlanet.o $(OBJDIR)/drawShape.o 
4

2 回答 2

0

您应该使用 Beta 建议的相对路径。将“数据”文件夹放在与可执行文件相同的文件夹中,然后使用: Vrui::openFile("./data/land_shallow_topo_2048.png")

于 2013-05-20T21:28:20.317 回答
0

文件打开应该与程序目录相关,因此您可以在源目录中为图片创建一个子目录。但是,请务必让用户知道将这些图片放在哪里,

g-dev@g$ mkdir dat
g-dev@g$ mv pic.jpg dat/pic.jpg

然后在源代码中:

::readImageFile("", Vrui::openFile("pic.jpg")

在 CMake 中添加目录:

include_directories ("${PROJECT_SOURCE_DIR/dat}")

在VS中添加目录:

这里

(确保您使用提供的 MSVS 宏作为文件路径$(ProjectDir)$(SolutionDir)

于 2013-05-20T21:29:07.693 回答