Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - PaloDeQueso

Pages: [1]
1
Graphics / SFML2 Rendering Text to GLTexture
« on: February 22, 2011, 04:34:06 pm »
What I am trying to accomplish is rendering text to a GLTexture to be used however I wish. What I would like to do, is create a single RenderImage to render any text into. Then somehow generate an OpenGL Texture ID from that.

So I have a "TextManager" in my engine...
I just started rewriting it from the SFML1.6 version so it's still very short and very simple and basically does nothing, hah. So I'll just post my code for it.

Declaration
Code: [Select]

class TextManager{
public:
TextManager(void);
void AddFont(std::string name, std::string font_path);
unsigned int DrawTextToTexture(std::string text, unsigned int font_size = 30, std::string font_name = "default");
private:
std::map<std::string, sf::Font *> fonts;
sf::RenderImage *render_image;
};


Definition
Code: [Select]

TextManager::TextManager(void){
AddFont("default", "Common/Fonts/Vera.ttf");
render_image = new sf::RenderImage();
// Do I Need This Next Line?!?
render_image->GetImage().CreateTexture(120, 38);
}

void TextManager::AddFont(std::string name, std::string font_path){
if (fonts.count(name) < 1){
sf::Font *font = new sf::Font();
font->LoadFromFile(font_path);
fonts[name] = font;
}
}

unsigned int TextManager::DrawTextToTexture(std::string text, unsigned int font_size, std::string font_name){
if (fonts.count(font_name) > 0){
sf::Text sf_text(text.c_str(), *fonts[font_name], text.size());
sf_text.SetCharacterSize(font_size);
sf_text.SetPosition(0.0f, 0.0f);
render_image->Draw(sf_text);
// WHAT DO I DO AFTER I DRAW IT?
      // Would I have to create a GL Texture every frame and release it? That seems crazy.
}
}


I have comments in there showing my dilemmas
Basically:
- When I create the RenderImage do I have to create a texture?
    - If so... can it resize itself to what I'm drawing inside of it?
- I have a texture manager which creates gl textures from sf::Images but that doesn't get done every frame, so I'm confused as to how to handle this code specifically.

One idea I had was to manage sf::Texts as well, and keep them in an associative array by IDs so they can be easily referenced and updated, and they would each have their own RenderImage, however I'd like to avoid this in favor or a simpler approach if I can.

Thoughts?
Thanks in advance!

2
Graphics / SFML 2 and FBOs?
« on: February 21, 2011, 10:41:30 pm »
I recently decided to update to SFML2 because of the RenderImage feature so I can finally render text to images once again. (Something I've missed from my SDL days) But as soon as I did, my FBOs are always rendering blank. NOTE: I didn't try to change anything, I just turned off all text features that I had before and recompiled my Engine with SFML2. Suddenly my deferred renderer is completely broken. Anyone else experience any issues with SFML 2 and FBOs?

3
General / Single Linker Error Left VS 2010
« on: December 20, 2010, 04:56:34 pm »
I'm mainly a linux developer, but recently wanted to make sure my "cross-platform" project was actually cross-platform. So I compiled my project under MinGW just fine, but realized I might want to connect to mysql for some stuff just to experiment, but the library and dll are only compiled for visual studio. Seeing how I might want to let others work on my project to sometime and that visual studio is seemingly the standard dev studio for windows, it should compile there anyway.

I'm using visual c++ express 10. I've compiled SFML 1.6 using it and are using the release dynamic libraries... I have defined SFML_DYNAMIC in the preprocessor directives for the project and have one lasting linker error...

error LNK2001: unresolved external symbol "private: static unsigned int * sf::Font::ourDefaultCharset" (?ourDefaultCharset@Font@sf@@0PAIA)

I'm pretty stumped on this last one, any ideas?

Here are the libraries I'm linking in order...
(glew32s glut32 glu32 opengl32 sfml-system sfml-audio sfml-network sfml-window sfml-graphics assimp BulletDynamics BulletCollision LinearMath)

I believe all should be in place... perhaps there's just some features that don't exist in the windows build of SFML like this Default Charset... I'm as of yet unsure.

Thanks in advance for any help!

Pages: [1]