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

Author Topic: DEVIL and SFML, ilutGLScreen()  (Read 6410 times)

0 Members and 1 Guest are viewing this topic.

unbel

  • Newbie
  • *
  • Posts: 8
    • View Profile
DEVIL and SFML, ilutGLScreen()
« 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?

Code: [Select]
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;
}

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
DEVIL and SFML, ilutGLScreen()
« Reply #1 on: June 30, 2009, 07:53:56 am »
When do you call it? And why don't you use SFML to achieve this?
Laurent Gomila - SFML developer

unbel

  • Newbie
  • *
  • Posts: 8
    • View Profile
DEVIL and SFML, ilutGLScreen()
« Reply #2 on: June 30, 2009, 09:04:26 pm »
Quote from: "Laurent"
When do you call it?

I call it in the main loop.

Quote from: "Laurent"
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:

Code: [Select]
sf::Image my = app.Capure();
my.SaveToFile("myfile.png");

The image saved is all white...

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
DEVIL and SFML, ilutGLScreen()
« Reply #3 on: June 30, 2009, 09:58:48 pm »
Which version of SFML are you using? Can you show your main loop?

Quote
Do you want ignoring the problem with DevIL?

No, but I prefer debugging SFML instead of other libraries ;)
Laurent Gomila - SFML developer

unbel

  • Newbie
  • *
  • Posts: 8
    • View Profile
DEVIL and SFML, ilutGLScreen()
« Reply #4 on: June 30, 2009, 11:14:53 pm »
Quote from: "Laurent"
Which version of SFML are you using? Can you show your main loop?

I'm using the last, 1.5.

Code: [Select]


#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");
        }
    }
}


Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
DEVIL and SFML, ilutGLScreen()
« Reply #5 on: July 01, 2009, 08:38:06 am »
Is the application running fine, apart from this screenshot issue?
Do you call _app.GetEvent somewhere?
Laurent Gomila - SFML developer

unbel

  • Newbie
  • *
  • Posts: 8
    • View Profile
DEVIL and SFML, ilutGLScreen()
« Reply #6 on: July 01, 2009, 09:14:13 pm »
Quote from: "Laurent"
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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
DEVIL and SFML, ilutGLScreen()
« Reply #7 on: July 01, 2009, 11:16:43 pm »
Can you give a complete example so that I can compile and try it directly?
Laurent Gomila - SFML developer

unbel

  • Newbie
  • *
  • Posts: 8
    • View Profile
DEVIL and SFML, ilutGLScreen()
« Reply #8 on: July 03, 2009, 06:14:35 pm »
Quote from: "Laurent"
Can you give a complete example so that I can compile and try it directly?


http://rapidshare.com/files/251494580/src.rar.html

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
DEVIL and SFML, ilutGLScreen()
« Reply #9 on: July 03, 2009, 07:16:58 pm »
Thanks :)
Laurent Gomila - SFML developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
DEVIL and SFML, ilutGLScreen()
« Reply #10 on: July 03, 2009, 07:39:30 pm »
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:
Code: [Select]
_input = (sf::Input*) &(_app.GetInput());
You'd better declare a const sf::Input* rather than using this ugly cast.
Code: [Select]
delete _input;
Nobody told you to delete the window's input object ;) (it crashes)
Code: [Select]
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:
Code: [Select]
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.
Laurent Gomila - SFML developer

unbel

  • Newbie
  • *
  • Posts: 8
    • View Profile
DEVIL and SFML, ilutGLScreen()
« Reply #11 on: July 04, 2009, 02:12:08 am »
Quote from: "Laurent"
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

Quote from: "Laurent"

By the way, you're doing a few weird things:
Code: [Select]
_input = (sf::Input*) &(_app.GetInput());
You'd better declare a const sf::Input* rather than using this ugly cast.
Code: [Select]
delete _input;
Nobody told you to delete the window's input object ;) (it crashes)
Code: [Select]
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:
Code: [Select]
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!

 

anything