ofShortPixels doesn't draw pixels correctly

This was originally posted @“biginners”.


Joshua noble suggested me to file it as a bug on jithub but I’ve never been there.

So I’m posting here.

Hope this is OK.

/////////////////original messages


I have question about ofShortPixels and ofShortColor.

If you execute the code below , it’ll draw at half way screen height even though I did set aDot at (0. screen height / 4)

And another weird thing is it draws 20 pixels instead of 10 pixels which I set for loop for 10 times.

It only draws correctly with ofPixels and ofColor.

It doesn’t work with ofFloatPixels and ofFloatColor.

Please help me out.

I need to have RGB value over 255 so I can check if those values are over 255.

Thanks in advanced


.h file

#pragma once  
#include "ofMain.h"  
class Dot  {      
    ofVec2f location;  
class testApp : public ofBaseApp{      
    void setup();  
    void update();  
    void draw();  
    int w,h;  
    ofTexture particleTexture;  
    ofShortPixels * rgbPixels;  
    ofShortColor&  paint(ofShortColor &);  
    Dot aDot;  

.cpp file

#include "testApp.h"  
void testApp::setup(){  
    ofBackground(0, 0, 0);  
    w = ofGetWidth();  
    h = ofGetHeight();  
    rgbPixels = new ofShortPixels;  
    rgbPixels->allocate(w, h, 3);  
    aDot.location.set(0, h/4);  
void testApp::update(){  
    ofShortColor pixelColor;  
    ofShortColor newPixelColor;  
    for(int i = 0; i<10; i++){  
        pixelColor = rgbPixels->getColor(aDot.location.x+i, aDot.location.y);  
        newPixelColor = paint(pixelColor);  
        rgbPixels->setColor(aDot.location.x+i, aDot.location.y,newPixelColor);  
    particleTexture.loadData(* rgbPixels);  
void testApp::draw(){  
    particleTexture.draw(0, 0, w, h);  
ofShortColor &  testApp::paint(ofShortColor & _c){  
    _c.r += 10;  
    _c.g += 2;  
    _c.b += 3;  
    _c.set(_c.r, _c.g, _c.b);  
    return _c;