Quantcast
Channel: beginners - openFrameworks
Viewing all articles
Browse latest Browse all 4929

EXC_BAD_ACCESS with vector

$
0
0

@kotaonaga wrote:

Hi, I am trying to use vector<ofColor>, but I got EXC_BAD_ACCESS. Xcode says Build Succeeded.
How do I use vector<ofColor> with setHsb properly?
Why does this error occur?

This is where EXC_BAD_ACCESS showed up.

This is my code:

ofApp.h:

vector<ofColor> colors;

ofApp.cpp

void ofApp::setup(){
    ofColor color;
    for(int i = 0; i < colors.size(); i++){
        color.setHsb(i * 50, 222, 255);
        colors.push_back(color);
    }
}

void ofApp::draw(){
    ofBackground(250);
    ofSetColor(colors[0]);
    ofDrawCircle(300, 300, 100);
}

Thank you!

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4929

Trending Articles