Extremely simple task that i can't get to work

Super Beginner here. So all I’m trying to do is declare a variable of type ofRectangle or instantiate an object of type ofRectangle(which way is the correct way to say it?) and draw it. But i can’t do this simple task., Here’s what i have:

in ofApp.h:
ofRectangle player;

in ofApp.cpp:

void ofApp::setup()

void ofApp::update(){


void ofApp::draw()

I believe I’m not creating the object correctly, but I’ve searched everywhere and cannot find how to do it.


you need ofDrawRectangle


How would i go about creating a variable of type ‘ofDrawRectangle’ because

ofDrawRectangle player;

is giving me an error

ofDrawRectangle is a function not a type so you don’t need to declare it just call it with the correct parameters:




being player the ofRectangle varible you had declared originally

Hey thanks for the reply!

So i tried:


but i got an out of scope error for ofDrawRectangle(). So i tried ofRect(player); which worked! But i have a couple questions now, I googled “ofRect” but couldn’t find any documentation on it. Where can i find info on this method? Second question, I’m using v0.8.4, is that why i’m getting the error with ofDrawRectangle?

Thanks again.

You can find the documentation for OF here (it can be better than random a google search, or use this domain for a google site search):


ofDrawRectangle() specifically is here:


The examples included in the download cover a lot of ground and you can use them to see how things work

There is a “rectangleAlignmentAndScaling” example that will give you some good insights

If you are using an IDE like Xcode or Visual studio you can also right click on a method and choose jump to definition (this is the Xcode wording, I forget the exact wording in visual studio). This will show you how the method works. It can also be a great way to learn more about things as you go.

Hey, I’ve seen the documentation for ofDrawRectangle(), but I was asking about the doc for ofRect(), because i was working with codeblocks and ofDrawRectangle() didn’t work, only ofRect() was drawing my rectangles. So, what i’m guessing is ofRect() was depreciated and replaced by ofDrawRectangle()?

Regardless, I moved to Visual Studio and ofDrawRectangle() is working perfectly fine.

Thanks for the help!