Skip to content
Snippets Groups Projects
Commit b20a12dc authored by Oliver Bock's avatar Oliver Bock
Browse files

Integrating the new resource management harness

* Resource management files added to Makefile
* Makefile automatically invokes ORC when needed
* The main font is now loaded from a compiled-in font resource
* More resources can be added easily by adding them to resources.orc
parent b8a4d8aa
No related branches found
No related tags found
No related merge requests found
......@@ -7,8 +7,9 @@ CXX ?= g++
LIBS = -L${BOINC_PREFIX}/lib -Bstatic $(shell sdl-config --static-libs) -lfreetype -lftgl -Wl,-Bdynamic -lGL -lGLU
CPPFLAGS = -I/usr/include $(shell sdl-config --cflags) $(shell pkg-config --cflags ftgl)
DEPS = Makefile starsphere.h
OBJS = starlist.o snr_list.o user_text.o pulsar_list.o search_info.o starsphere.o
OBJS = starlist.o snr_list.o user_text.o pulsar_list.o search_info.o starsphere.o ${RESOURCESPEC}.o Resource.o ResourceFactory.o
DEBUGFLAGSCPP = -DDEBUG -pg -ggdb -O0
RESOURCESPEC = resources
# primary role based tagets
default: release
......@@ -46,6 +47,20 @@ pulsar_list.o: $(DEPS) pulsar_list.C
search_info.o: $(DEPS) search_info.C
$(CXX) -g ${CPPFLAGS} -c search_info.C
# resource compiler
ResourceFactory.o: ${RESOURCESPEC}.o Resource.o ResourceFactory.cpp ResourceFactory.h
$(CXX) -g ${CPPFLAGS} -c ResourceFactory.cpp -o ResourceFactory.o
Resource.o: Resource.cpp Resource.h
$(CXX) -g ${CPPFLAGS} -c Resource.cpp -o Resource.o
${RESOURCESPEC}.o: ${RESOURCESPEC}.orc
orc/orc ${RESOURCESPEC}.orc ${RESOURCESPEC}.cpp
$(CXX) -g ${CPPFLAGS} -c ${RESOURCESPEC}.cpp -o ${RESOURCESPEC}.o
# tools
memcheck:
valgrind --tool=memcheck --track-fds=yes --time-stamp=yes --log-file=${PWD}/memcheck.out.%p --leak-check=full ${PWD}/starsphere
......@@ -53,5 +68,5 @@ callgrind:
valgrind --tool=callgrind --track-fds=yes --time-stamp=yes ${PWD}/starsphere
clean:
rm -f ${OBJS} starsphere
rm -f ${RESOURCESPEC}.cpp *.o starsphere
......@@ -31,6 +31,7 @@
#include <SDL.h>
#include "starsphere.h"
#include "ResourceFactory.h"
// ugly globals, will eventually factored out into private members
SDL_Surface *m_DisplaySurface = NULL;
......@@ -252,13 +253,29 @@ int main(int argc, char **argv) {
SDL_WM_SetCaption("Einstein@Home", "Icon");
//SDL_WM_SetIcon(SDL_LoadBMP("icon.png"), NULL);
char fontFile[] = "arial.ttf";
// font = new FTGLBitmapFont(fontFile);
font = new FTGLPixmapFont(fontFile);
// font = new FTGLOutlineFont(fontFile);
// font = new FTGLPolygonFont(fontFile);
// font = new FTGLExtrdFont(fontFile);
// font = new FTGLTextureFont(fontFile);
// prepare resource factory
ResourceFactory factory;
// create font resource instance
const Resource *fontResource = factory.createInstance("FontSansSerif");
if(fontResource == NULL) {
cerr << "Font resource could not be loaded!" << endl;
exit(1);
}
if(fontResource->Data()->size() == 0) {
cerr << "Font resource could not be loaded!" << endl;
exit(1);
}
// create font instance using font resource (base address + size)
// font = new FTGLBitmapFont((&fontResource->Data()->at(0)), fontResource->Data()->size());
font = new FTGLPixmapFont((&fontResource->Data()->at(0)), fontResource->Data()->size());
// font = new FTGLOutlineFont((&fontResource->Data()->at(0)), fontResource->Data()->size());
// font = new FTGLPolygonFont((&fontResource->Data()->at(0)), fontResource->Data()->size());
// font = new FTGLExtrdFont((&fontResource->Data()->at(0)), fontResource->Data()->size());
// font = new FTGLTextureFont((&fontResource->Data()->at(0)), fontResource->Data()->size());
font->CharMap(ft_encoding_unicode);
......@@ -277,6 +294,7 @@ int main(int argc, char **argv) {
eventLoop();
if (font) delete font;
delete fontResource;
return(0);
exit(0);
}
# Resource specification of: Einstein@Home graphics application
FontSansSerif|LiberationSans-Regular.ttf
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment