Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ofPixels proposal #7929

Draft
wants to merge 17 commits into
base: master
Choose a base branch
from
12 changes: 7 additions & 5 deletions addons/ofxUnitTests/src/ofxUnitTests.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,17 @@ class ofxUnitTestsApp: public ofBaseApp{
bool do_test_eq(T1 t1, T2 t2, const std::string & v1, const std::string & v2, const std::string & testName, const std::string & msg, const std::string & file, int line){
numTestsTotal++;
if(t1==t2){
ofLogNotice() << testName << " passed";
// ofLogNotice() << testName << " passed";
numTestsPassed++;
return true;
}else{
ofLogError() << testName << " failed " << msg;
ofLogError() << "test_eq(" << v1 << ", " << v2 << ")";
ofLogError() << "value1: " << v1 << " is " << ofToString(t1);
ofLogError() << "value2: " << v2 << " is " << ofToString(t2);
ofLogError() << file << ": " << line;
// ofLogError() << "test_eq(" << v1 << ", " << v2 << ")";
ofLogError() << "expected: " <<ofToString(t2) << " returned: " << ofToString(t1);
ofLogError();
// ofLogError() << "value1: " << v1 << " is " << ofToString(t1);
// ofLogError() << "value2: " << v2 << " is " << ofToString(t2);
// ofLogError() << file << ": " << line;
numTestsFailed++;
return false;
}
Expand Down
14 changes: 7 additions & 7 deletions libs/openFrameworks/graphics/ofBitmapFont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,22 +328,22 @@ static const unsigned char* bmpChar_8x13_Map[] = { bmpChar_8x13_000,bmpChar_8x13
#include "ofTexture.h"
static const float widthTex = 8.0f/256.0f;
static const float heightTex = 14.0f/256.0f;
ofPixels ofBitmapFont::pixels;
ofPixels ofBitmapFont::pixelsBitmapFont;

using std::numeric_limits;
using std::string;

void ofBitmapFont::init(){
if(pixels.isAllocated()) return;
pixels.allocate(16*16, 16*16, OF_PIXELS_GRAY_ALPHA); // letter size:8x14pixels, texture size:16x8letters, gl_r: 1bytes/1pixel
pixels.set(0);
if(pixelsBitmapFont.isAllocated()) return;
pixelsBitmapFont.allocate(16*16, 16*16, OF_PIXELS_GRAY_ALPHA); // letter size:8x14pixels, texture size:16x8letters, gl_r: 1bytes/1pixel
pixelsBitmapFont.set(0);
for (size_t i = 0; i < 256; i++) {
const unsigned char * face = bmpChar_8x13_Map[i];
for (size_t j = 1; j < 15; j++){
for (size_t k = 0; k < 8; k++){
if ( ((face[15-j] << k) & (128)) > 0 ){
pixels[(((i/16))*16*16*16+(i%16)*16 + (j-1)*16*16 + k)*2] = 255;
pixels[(((i/16))*16*16*16+(i%16)*16 + (j-1)*16*16 + k)*2+1] = 255;
pixelsBitmapFont[(((i/16))*16*16*16+(i%16)*16 + (j-1)*16*16 + k)*2] = 255;
pixelsBitmapFont[(((i/16))*16*16*16+(i%16)*16 + (j-1)*16*16 + k)*2+1] = 255;
}
}
}
Expand Down Expand Up @@ -471,7 +471,7 @@ void ofBitmapFont::unloadTexture(){
const ofTexture & ofBitmapFont::getTexture() const{
if(!texture.isAllocated()){
ofBitmapFont::init();
texture.allocate(pixels,false);
texture.allocate(pixelsBitmapFont,false);
texture.setTextureMinMagFilter(GL_LINEAR,GL_NEAREST);
}
return texture;
Expand Down
2 changes: 1 addition & 1 deletion libs/openFrameworks/graphics/ofBitmapFont.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ofBitmapFont{
ofRectangle getBoundingBox(const std::string & text, int x, int y, ofDrawBitmapMode mode = ofGetStyle().drawBitmapMode, bool vFlipped = ofIsVFlipped()) const;
private:
static void init();
static ofPixels pixels;
static ofPixels pixelsBitmapFont;
void unloadTexture();
mutable ofTexture texture;
};
Loading