ofShortPixels doesn't draw pixels correctly

This was originally posted @“biginners”.

http://forum.openframeworks.cc/t/ofshortpixels-doesn’t-draw-pixels-correctly/9527/4

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

Hello.

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

Jin

.h file

  
  
#pragma once  
#include "ofMain.h"  
  
class Dot  {      
public:  
    ofVec2f location;  
  
    Dot(){  
        location.set(0,0);  
    }  
      
    ~Dot(){}  
};  
  
class testApp : public ofBaseApp{      
public:  
    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(){  
    ofSetFrameRate(30);  
    ofSetBackgroundAuto(TRUE);  
    ofBackground(0, 0, 0);  
    w = ofGetWidth();  
    h = ofGetHeight();  
      
    particleTexture.allocate(w,h,GL_RGB);  
    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);  
    _c.clamp();  
      
    return _c;  
}