241
Graphics / sf::RenderImage::Create extremely slow
« on: May 14, 2011, 11:04:13 pm »
It actually gave me 2.52619 secs when I tried that.
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.
int main()
{
system("pause");
sf::RenderImage rimage;
rimage.Create(128, 128);
system("pause");
return 0;
}
// Check to see if must create a new texture (texture already in place has no dimensions)
if(pImg->GetWidth() == 0)
{
pImg->Create(128, 128, false);
pImg->Clear(sf::Color(0, 0, 0, 0));
}
#include <SFML\Window.hpp>
#include <SFML\OpenGL.hpp>
#include <SFML\Graphics.hpp>
#include <string>
int main(int argc, char* args[])
{
sf::RenderWindow appWindow;
sf::Renderer appRenderer(appWindow);
// Create a settings description struct
sf::ContextSettings settings;
// Settings for app window
settings.AntialiasingLevel = 4;
// Create the app window
appWindow.Create(sf::VideoMode(800, 600, 32), "SFML Text", sf::Style::Close, settings);
// Enable Smooth Shading
glShadeModel(GL_SMOOTH);
// Black Background
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
// Depth Buffer Setup
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
// Really Nice Perspective Calculations
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
// Resize perspective to fit screen aspect ratio
glViewport(0, 0, 800, 600);
// Enable alpha rendering (transparency) in textures
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// Enable alpha blending
glEnable(GL_BLEND);
// Enable texture mapping
glEnable(GL_TEXTURE_2D);
// Enable backface culling
glEnable(GL_CULL_FACE);
if(glGetError() != GL_NO_ERROR)
abort();
// Additional settings
appWindow.SetFramerateLimit(60);
appWindow.EnableVerticalSync(true);
const sf::Input &inpt(appWindow.GetInput());
sf::Text t;
t.SetFont(sf::Font::GetDefaultFont());
t.SetString("bla bla bla");
sf::Event e;
bool quit = false;
while(!quit)
{
while(appWindow.GetEvent(e))
{
// Window closed
if (e.Type == sf::Event::Closed)
quit = true;
}
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor4f(0.3f, 0.5f, 0.3f, 1.0f);
glBegin(GL_QUADS);
glVertex2f(10.0f, 0.0f);
glVertex2f(10.0f, 10.0f);
glVertex2f(0.0f, 10.0f);
glVertex2f(0.0f, 0.0f);
glEnd();
appRenderer.SaveGLStates();
appWindow.Draw(t);
appRenderer.RestoreGLStates();
appWindow.Display();
}
appWindow.Close();
return EXIT_SUCCESS;
}
appWindow.Draw(t);
call.// Render text
text.SetFont(sf::Font::GetDefaultFont());
text.SetString("bla bla bla");
text.SetColor(sf::Color(18, 128, 34));
text.SetStyle(sf::Text::Regular);
appRenderer.SaveGLStates();
appWindow.Draw(text);
appRenderer.RestoreGLStates();
BlurEffect.SetTexture("texture", sf::Shader::CurrentTexture);
BlurEffect.SetCurrentTexture("texture");
The application was unable to start correctly (0xc000007b). Click
OK to close the application.