SFML community forums
Help => Window => Topic started by: unbel on June 30, 2009, 12:18:56 am
-
I'm using DEVIL to manage images on my program.
It seems i can't make a screenshot of my opengl window using DEVIL, while i can do it finely with SDL (instead of SFML)..
The image created with my function is all black, i can't see anything.
No error is returned.
What about ilutGLScreen() and SFML?
bool ImagesDevIL::screenshot(const char *c){
ILuint temp, devilError;
ilGenImages(1, &temp);
ilBindImage(temp);
if (!ilutGLScreen()) cerr << "error ilutGLScreen";
ilSaveImage(c);
devilError = ilGetError();
if (devilError != IL_NO_ERROR) {
cerr << "Devil Error: " << iluErrorString(devilError) << endl;
return false;
}
ilDeleteImages(1, &temp);
return true;
}
-
When do you call it? And why don't you use SFML to achieve this?
-
When do you call it?
I call it in the main loop.
And why don't you use SFML to achieve this?
Do you want ignoring the problem with DevIL? :)
Wll, I tried now, with sf::RenderWindow instead of sf::Window.
I used:
sf::Image my = app.Capure();
my.SaveToFile("myfile.png");
The image saved is all white...
-
Which version of SFML are you using? Can you show your main loop?
Do you want ignoring the problem with DevIL?
No, but I prefer debugging SFML instead of other libraries ;)
-
Which version of SFML are you using? Can you show your main loop?
I'm using the last, 1.5.
#include <SFML/Window.hpp>
#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>
class OGLContext {
private:
sf::RenderWindow _app;
public:
void initialize (const char *title, int bpp = 32, int w = 800, int h = 600, bool resize = false, bool full = false)
}
void OGLContext::initialize (
const char *title, int bpp, int w, int h, bool resize, bool full)
{
unsigned long style = sf::Style::Close;
if (resize) style |= sf::Style::Resize;
else if (full) style |= sf::Style::Fullscreen;
_app.Create(sf::VideoMode::VideoMode(w, h, bpp), title, style, sf::WindowSettings::WindowSettings(24, 8, 2));
}
void RenderScene(){
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
//......
// call _app.Display()
app->update();
}
int main(int argc, char *argv[] )
{
app = new OGLContext("OpenGL with SFML", 1024, 768, 32);
// loading other things
// i'm newbie with opengl, i use this options
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);
glDepthFunc(GL_LEQUAL);
glClearDepth(1.0);
glShadeModel(GL_SMOOTH);
glDisable( GL_DITHER );
glEnable(GL_COLOR_MATERIAL);
glEnable( GL_MULTISAMPLE);
glEnable(GL_POINT_SMOOTH);
glEnable(GL_POLYGON_SMOOTH);
glEnable(GL_LINE_SMOOTH);
glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
// more...
while (app->isOpened()){
// The _app.Display() is inside this render function
RenderScene();
if (app->isPressKey(sf::Key::Num0)){
app->screenshot("screen_shot.png");
}
}
}
-
Is the application running fine, apart from this screenshot issue?
Do you call _app.GetEvent somewhere?
-
Is the application running fine, apart from this screenshot issue?
Do you call _app.GetEvent somewhere?
Yes, it run ok, and i handle the input..
The file is created, but is all white, or violet.
-
Can you give a complete example so that I can compile and try it directly?
-
Can you give a complete example so that I can compile and try it directly?
http://rapidshare.com/files/251494580/src.rar.html
-
Thanks :)
-
It works fine for me (Windows XP, Visual C++ 9, both SFML 1.5 and SFML 2.0). What is your configuration?
By the way, you're doing a few weird things:
_input = (sf::Input*) &(_app.GetInput());
You'd better declare a const sf::Input* rather than using this ugly cast.
delete _input;
Nobody told you to delete the window's input object ;) (it crashes)
sf::VideoMode::VideoMode(w, h, bpp)
You're calling a constructor rather than instanciating the class. Surprisingly it works, but anyway it should be written like this:
sf::VideoMode(w, h, bpp)
And don't include all these unnecessary headers, only SFML/Graphics.hpp is needed in your code. Including too many files can increase the compilation time a lot.
-
It works fine for me (Windows XP, Visual C++ 9, both SFML 1.5 and SFML 2.0). What is your configuration?
Winsows XP pro, eclipse\mingw (gcc v3.45) SFML v1.5
I call gcc with these libs : -lopengl32 -glu32 -lsfml-audio -lsfml-graphic -lsfml-window -lsfml-system
By the way, you're doing a few weird things:
_input = (sf::Input*) &(_app.GetInput());
You'd better declare a const sf::Input* rather than using this ugly cast.
delete _input;
Nobody told you to delete the window's input object ;) (it crashes)
sf::VideoMode::VideoMode(w, h, bpp)
You're calling a constructor rather than instanciating the class. Surprisingly it works, but anyway it should be written like this:
sf::VideoMode(w, h, bpp)
And don't include all these unnecessary headers, only SFML/Graphics.hpp is needed in your code. Including too many files can increase the compilation time a lot.
:shock:
Thanks!