off screen ofTrueTypeFont

Hi,

I have tested the following code:

  
  
  
ofTrueTypeFont fontText;  
  
// Loading font, etc is just fine  
  
//  
strScrollText = "donec duis eget elementum enim eros et eu fusce gravida in integer ipsum justo lectus leo ligula lorem maecenas magna malesuada massa mattis mauris metus molestie morbi nam nec nibh non nulla odio  ";  
  
float fWidthTxt = fontText.stringWidth(strScrollText);  
  
ofFill();  
ofSetColor(255, 255, 255);  
ofRect(0, ofGetScreenHeight() + 200, fWidthTxt+(ofGetScreenWidth()*2), 30);  
  
ofSetColor(0, 255, 0);  
fontText.drawString( strScrollText, 0, ofGetScreenHeight() + 200);  
glFlush();  
  
imgOffScreen.grabScreen(0, ofGetScreenHeight() + 200, fWidthTxt +(ofGetScreenWidth()*2), 30);  
  
  

What I got within imgOffScreen was just a white rectangle only but no text I drew with “drawString”.

What I want to do is just creating an image from an offscreen text then scroll the image as a horizontal text scroll. I’m just trying to avoid FBO texture because it’s tightly related with hardware specification.

Any tricks/tips/idea for this simple horizontal text scroll?

I think the problem here is that the ofImage grabScreen() only captures what is on the screen – so off screen rendering is not possible.

You can render onscreen, grab the image and then call

  
  
glClearColor(1,1,1,1);  
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);  
  

to clear the screen, but I imagine with a long text this would require breaking it into many parts.

I think the other option (if you must render into a texture) is, as you mentioned, using an FBO .

Thank you chris for the reply.
Yes, I have to avoid FBO because when I tried to use latest version of ofFBOTexture from zach, this error was executed: (I am using OF 006)

  
  
  
// Lines 78 - 83 in ofFBOTexture.cpp (for OF 006)  
  
GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);  
	if(status != GL_FRAMEBUFFER_COMPLETE_EXT)  
	{  
		cout<<"glBufferTexture failed to initialize. Perhaps your graphics card doesnt support the framebuffer extension? If you are running osx prior to system 10.5, that could be the cause"<<endl;  
		std::exit(1);  
	}  
  
  

Theoritically FBO is the only option for me but my application should fit on cheap VGA card. Any suggestions?

My card is NVidia GeForce 6500.

[attachment=0:u8360nif]nvidia.jpg[/attachment:u8360nif]

Wow…I got busy with FBO!

I have just run fbo.exe by Song Ho Ahn from http://www.songho.ca/opengl/gl-fbo.html and it works. My card is just support FBO but why this line (in ofFBOTexture.cpp) is reached:

  
  
  
*  Created by Zach Gage on 3/28/08.  
 *  Copyright 2008 STFJ.NET. All rights reserved.  
  
GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);  
	if(status != GL_FRAMEBUFFER_COMPLETE_EXT)  
	{  
		cout<<"glBufferTexture failed to initialize. Perhaps your graphics card doesnt support the framebuffer extension? If you are running osx prior to system 10.5, that could be the cause"<<endl;  
		std::exit(1);  
	}  
  
  

I mean the the content of variable _status _is not equal to GL_FRAMEBUFFER_COMPLETE_EXT so my OF program just simply ended by std::exit(1)

Is this a bugs in ofFBOTexture.cpp?
Did I just make a mistake because the image I want to grab offscreen is 2400x30 pixels?

[attachment=0:1mek52u5]fbo-nvidia-gf6500.jpg[/attachment:1mek52u5]

Hmm…Ok I got no responses from this forum. BTW, while waiting for you guys for any suggestions or tips I debug ofFBOTexture.cpp from zach in Windows XPSP3/Codeblock/mingw-3.4.5. Here is the strange result:

I put

  
  
status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);  
  

in every line calling any opengl api and watch the content of _status _variable in every debug step. I found a call for opengl api in line 49 causing bad value for _status _variable. All previous calls to opengl api followed by glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) result in good value that is:

GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5

which is defined in GLee.h but the error after calling glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo) is:

GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7

  
  
  
status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);  
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo); // ---> This is the trouble initiator. For my Nvidia GeForce 6500  
  
status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);  
  
  

Then, any calls to glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) result a bad value for status variable.

OK. This is very nice forum. Thx.

Hey, please know that fbo is not part of core OF, which is why you don’t get a whole lot of responses here. No response doesn’t mean folks don’t care about your problems / research. I will look when I have a moment (am traveling now).

Most importantly— relax and have fun here. And / or don’t be a jerk :slight_smile:

Z

Hi zach,

I’m happy with OF and this forum. I think I shouldn’t post it in the beginner section. He…he…he…

Thx zach :smiley:

you just need to replace ofTexture.h and ofTexture.cpp from 006 release.
This helped me.