SFML community forums
Help => Graphics => Topic started by: TheDistur on June 04, 2011, 07:20:26 pm
-
I am able to call Create on a RenderImage in the main() function of a program. If I call it in a member function of a class, my main window, a RenderWindow draws nothing. The program seems to continue running. What am I missing here?
-
The error is at line 42.
Seriously, show your code ;)
-
Okay here's a minimum example of the trouble I am having.
#include <SFML/Graphics.hpp>
#include "include/MyObject.h"
int main()
{
sf::RenderWindow MyRenderWindow(sf::VideoMode(640, 320, 32), "Title");
MyObject MyObjectInstance;
MyObjectInstance.CreateRenderImage();
while (MyRenderWindow.IsOpened())
{
sf::Event Event;
while (MyRenderWindow.PollEvent(Event))
{
if (Event.Type == sf::Event::Closed)
MyRenderWindow.Close();
}
MyRenderWindow.Clear();
MyRenderWindow.Display();
}
return EXIT_SUCCESS;
}
MyObject.cpp
#include "MyObject.h"
MyObject::MyObject()
{
}
MyObject::~MyObject()
{
}
void MyObject::CreateRenderImage(void)
{
sf::RenderImage MyRenderImage;
MyRenderImage.Create(30, 30); // MyRenderWindow stops drawing. Code after this would execute though.
}
-
MyRenderImage only exists in the scope of the member function. You have to declare it as a member variable if you want to keep it.
This is basic C++ or any other programming language, my suggestion is that you study that trough a book or tutorial. Before or along side SFML doesn't matter.
-
MyRenderImage only exists in the scope of the member function. You have to declare it as a member variable if you want to keep it.
This is basic C++ or any other programming language, my suggestion is that you study that trough a book or tutorial. Before or along side SFML doesn't matter.
That's not the issue. The code is a minimum example to show the issue I am having. Please run the code and watch what happens when Create is called.
-
Thanks for the minimal code. I'll try to test it as soon as possible.
-
What exactly is your code supposed to show? It should be a black window, so what else do you see after you create/destroy the render image?
-
This is what I'm seeing.
(http://dl.dropbox.com/u/3448237/broken.jpg)
If there's anything else you need, let me know.
-
Thanks.
What's your graphics card? Is it a crappy Intel integrated chipset?
-
Guess so, GMA 950 in my netbook.
-
sf::RenderImage has a lot of problems with this chipset. I'm afraid I won't be able to fix them for SFML 2.0.
-
Oh, thanks for having a look at my problem anyway.