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

OpenGL ES 2.0 points sprites shader

$
0
0

@Dorald wrote:

Hi all .
I'm trying to port "pointsAsTexturesExample" on iOS but I can't set the texture color .

Vertex Shader:

attribute vec4 position;
uniform mat4 modelViewProjectionMatrix;

attribute vec4 aColor;
varying vec4 vColor;

void main(){
    gl_PointSize = 28.0;
    gl_Position = modelViewProjectionMatrix * position;
    vColor = aColor;
}

Fragment Shader:

#ifdef GL_ES
precision lowp float;
#endif

uniform sampler2D tex;

varying vec4 vColor;

void main() {

    gl_FragColor = texture2D( tex, gl_PointCoord) * vColor;
}

Draw code :

    glDepthMask(GL_FALSE);

    ofSetColor(255, 100, 90);

    ofEnableBlendMode(OF_BLENDMODE_ADD);
    ofEnablePointSprites();

    shader.begin();
    camera.begin();

    texture.bind();
    vbo.draw(GL_POINTS, 0, (int)points.size());
    texture.unbind();

    camera.end();
    shader.end();

    ofDisablePointSprites();
    ofDisableBlendMode();
    // check to see if the points are
    // sizing to the right size
    ofEnableAlphaBlending();
    camera.begin();
    for (unsigned int i=0; i<points.size(); i++) {
        ofSetColor(255, 80);
        ofVec3f mid = points[i];
        mid.normalize();
        mid *= 300;
        ofDrawLine(points[i], mid);
    }
    camera.end();
    glDepthMask(GL_TRUE);

What I'm doing wrong here !?
Thanks in advance.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4929

Trending Articles