Orange Part Two – Load the OBJ

So in Part One we got our OpenGL app up and running (with no OpenGL, wait for it..) and some basic drag and drop of a single file. I’m not going to get into multiple files but later on it might be cool to be able to drop on an .obj and .png and have the whole thing kapow with the model right there… But not yet.

Most of this tutorial series is taken from the OpenGLAppExample provided with the Introjucer, I’m pretty much learning this stuff as I go through it – I don’t yet actually know any OpenGL, but I also don’t expect anyone to read this.

On to business

JUCE doesn’t itself include an .obj loader but the OpenGLAppExample does, so I’m going to be using that. You can find it in the source for that example – WavefrontObjParser.h – we’ll need to include that header in MainComponent.cpp and stick a private variable in there.

// private member variables
String debugMessage;
WavefrontObjFile mesh;

Loading this file is very simple, mesh has a load method which takes a File which is created from an absolute path like the ones we get from filesDropped. I’m really starting to like this.

void filesDropped(const StringArray& files, int x, int y) override
File file(files[0]);

if (mesh.load(file).wasOk())
debugMessage.append(files[0], files[0].length());
debugMessage.append("loaded \n", 1);
debugMessage.append(files[0], files[0].length());
debugMessage.append("failed to load \n", 1);


Note my debug messages changed slightly to support multi-lines, this was a simple change in the paint method.

g.drawMultiLineText(debugMessage, 20, 20, getWidth());

Seems to have worked, now to dig around in the example and draw something on screen.

Brief interlude….

10 mins..

20 mins..

I need to learn some OpenGL. =(


10 JUCE Tutorials in 10 Days

So I’ve signed up to attend the JUCE Summit 2015 but I know absolutely nothing about JUCE. It’s Monday night now, the conference starts in 12 days, with 2 of those being taken up by async Brighton meets and subsequent after-drinks that leaves 10 semi-free evenings to get to grips with the framework. I’m not including weekends, I’m on a screen free weekend mission right now.

They won’t be in-depth, they probably won’t be good, but they may be useful to someone (really, me!) I’ve set the one simple requirement that they must solve a real world need, so no Hello World!s.

I’ll update this post to index and track progress.

  1. Orange – Part one of a series aiming to create a simple OBJ file viewer