I did some more testing. After updating Radeon driver, Test2 works, however, Test3 now does something else wrong for the graphics, plus it now takes about 40 seconds for each frame. Keep in mind, the RenderTexture rendering is not in the loop, the rendering is done before, and the loop just draws the sprite holding the RenderTesture.
Fortunately I was just testing, I'm using as shown in Test2, however, it may make it impossible for me to generate repeated textures using my computer.
The actual reason I use the RenderTexture is because I am generating all my graphics with the computer, rendering Shapes, Text, and define Shapes. My plan was to generate complex Images, rendering in the start-up, then Sprite the Images in the loop, much faster.
My first attempt was to make a RenderImage class, based on RenderTarget, and Image, using SFML 1.6, (because SFML 2.0 was no released yet). The RenderTarget class claims "Base class for all render targets (window, image, ...) More...", however, the RenderWindow was the only one, not the Image referred to. Making a derived class did not work for me. Then I heard the new version takes the rendering off the screen, that when I gave up on the RenderImage on SFML1.6 and that about when you heard from what happened.
If someone can help me with the RenderImage class, here is the code I made. It ran like a normal Image, but I couldn't make it render anything. Understanding the depth required to make it work is beyond my skill. It's SFML 1.6 version, however, I agree it's best to use the newest, it may need modification.
Warning: I added a few things mostly unnecessary to make it work, it didn't.
header...
#pragma once
#include <SFML/Graphics/Image.hpp>
#include <SFML/Graphics/RenderTarget.hpp>
namespace sf
{
//incomplete types, declared to be used for creating pointers to classes defined elsewhere.
class Drawable;
//class RenderWindow;
class RenderImage :
public Image,
public RenderTarget
{
public:
RenderImage(void);//default
RenderImage(const RenderImage& Copy);//copy
RenderImage(const Image& Copy);//copy from normal image
RenderImage(unsigned int Width, unsigned int Height, const Color& Col = Color(0, 0, 0, 255));//create blank image
RenderImage(unsigned int Width, unsigned int Height, const Uint8* Data);//create using pixel data
~RenderImage(void);
bool Create(unsigned int Width, unsigned int Height, Color Col = Color(0, 0, 0, 255));
unsigned int GetWidth() const;
unsigned int GetHeight() const;
private:
virtual void OnCreate();
virtual bool Activate(bool Active);
};
}//namesapce sf
cpp file...
#include "RenderImage.h"
namespace sf
{
//default
RenderImage::RenderImage(void)
{
//Image();
Initialize();
}
//copy
RenderImage::RenderImage(const RenderImage& Copy):
Image(Copy)
{
Initialize();
}
//copy from normal image
RenderImage::RenderImage(const Image& Copy):
Image(Copy)
{
Initialize();
}
//create blank image
RenderImage::RenderImage(unsigned int Width, unsigned int Height, const Color& Col):
Image(Width, Height, Col)
{
//Image(Width, Height, Col);
//Create(Width, Height, Col);
Initialize();
}
//create image from pixel data
RenderImage::RenderImage(unsigned int Width, unsigned int Height, const Uint8* Data):
Image(Width, Height, Data)
{
Initialize();
}
RenderImage::~RenderImage(void)
{
//~Image();
}
bool RenderImage::Create(unsigned int Width, unsigned int Height, Color Col)
{
bool Im_bool = Image::Create(Width, Height, Col);
Initialize();
return Im_bool;
}
bool RenderImage::Activate(bool Active)
{
// For performances and consistency reasons, we only handle activation
if (Active)
//return SetActive();
return true;//image does not have a window.SetActive(), no window!
else
return true;
}
//bool setActive(bool Active)
//{
// return
//}
unsigned int RenderImage::GetWidth() const
{
//return RenderTarget::GetWidth();
return Image::GetWidth();
}
unsigned int RenderImage::GetHeight() const
{
//return RenderTarget::GetHeight();
return Image::GetHeight();
}
void RenderImage::OnCreate()
{
// We can now initialize the render target part
RenderTarget::Initialize();
}
}//namesapce sf
I hope someone can help.
If important, this may need a different thread.