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

Simple Question About ofMeshVbo

$
0
0

@jhx4979 wrote:

I'm trying to use ofMeshVbo to draw some particles, but I can only draw one particle. I can't find where is the problem.
here is the ofApp.cpp
#include "ofApp.h"`

       //--------------------------------------------------------------
    void ofApp::setup(){
        ofSetVerticalSync(true);
        pointShader.load("shader");

        vboMesh.setMode(OF_PRIMITIVE_POINTS);
        float r = ofGetHeight() / 2;
        for (int i = 0; i<100; i++) {
            vboMesh.addVertex(ofVec3f(ofRandomf() * r, ofRandomf() * r, ofRandomf() * r));
        }

        ofBackgroundGradient(ofColor::white, ofColor::black);

        gui.setup();
        gui.add(fps.setup("fps: ", ofToString(ofGetFrameRate())));
    }

    //--------------------------------------------------------------
    void ofApp::update(){
        fps = ofToString(ofGetFrameRate());
    }

    //--------------------------------------------------------------
    void ofApp::draw(){

        gui.draw();
        camera.begin();
        pointShader.begin();
        glPointSize(50.0f);
        vboMesh.draw();
        pointShader.end();
        camera.end();
    }

and my shaders:
#version 330

uniform mat4 modelViewProjectionMatrix;

in vec3 position;

void main(){
    gl_Position = modelViewProjectionMatrix * vec4(position, 1.0f);
}

#version 330

out vec4 outputColor;

void main()
{
    outputColor = vec4(0.0f, 1.0f, 0.0f, 1.0f);
}

Thanks a lot.

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4929

Trending Articles