openframeworks / openframeworks/openFrameworks

ofTexture::readToPixels(...) calls ofGetImageTypeFromGLType(), which fails in many cases.

Open
#5,669 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C++
Stars
10.4k
Forks
2.6k
Avg merge
1d 21h
Merged PRs (30d)
9

Description

Hi, I'm trying to copy font's texture to ofImage.
I found this post about how to copy ofTexture to ofImage
https://forum.openframeworks.cc/t/oftexture-to-ofimage/4451/6

So I tried this based on @polyclick's suggestion

void ofApp::setup(){

    font.load("font.ttf", 50);
    ofPixels pixels;
    font.getFontTexture().readToPixels(pixels);
    image.setFromPixels(pixels); 
}

But when I run it, I see these errors on the console.

[ error ] ofPixels: image type not supported
[ error ] ofPixels: format doesn't support channels
[ error ] ofGLUtils: ofGetGLFormatFromPixelFormat(): unknown OF pixel format-1, returning GL_LUMINANCE

a8b1bf20fbf481ef9f7f4f74e486c8f9a9ea3f12

How can I properly copy font Texture to ofImage?
I use OF 0.9.8 on OSX.
Thank you so much in advance!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the font texture copy shown in the issue with OF 0.9.8 on OSX, then trace ofTexture::readToPixels(...) through ofGetImageTypeFromGLType() and the reported ofPixels/ofGLUtils errors. Done means the font texture can be copied into ofImage without the unsupported image type, channel, or pixel-format errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.