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

Show Posts

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.


Messages - jimboTL60

Pages: [1]
1
Window / Drawing a GUI
« on: September 24, 2009, 04:59:55 am »
That's good to now, thank you very much! I was afraid it would be too slow but if you say it is the common way, I'll just do that.

Why will it be faster in SFML2 to draw a GUI?

Also, is it better to use vsync?

2
Window / Double buffering and screen flickering
« on: September 23, 2009, 12:32:17 am »
I built a graphic interface. In the main loop, if a control has to be updated, it is drawed on the RenderWindow then displayed. But I do not use Clear(), because the program would have to draw all the controls over again, which would considerably slow down the program. The problem is that without clearing the screen, it flickers between the two buffers used by SFML. I'm looking for the best solution not to compromise speed. I wouldn't care if it were not for the real time audio that has to be calculated at the same time.

I guess I could indeed capture the last frame and redisplay it, but wouldn't that mean doubling the framerate?

3
Graphics / Global stuff
« on: July 09, 2009, 12:36:51 pm »
Ok, here's what I learned about the problem:

These sf objects I declare as Globals contain dynamically allocated memory, because they use Vectors for pixels, which is a good thing.

But Globals are stored in the Data segment while the Heap segment contains the dynamically allocated variables.

I think that might cause the crash when my Global objects are initialized and the constructors called.

It's hard to be certain about how exactly it occurs, but using globals seems a pretty bad idea anyways, especially with dynamic memory allocation.

Here's an article:
http://bytes.com/topic/c/insights/737451-case-against-global-variables

I think I've spent enough time on this, I might move on with my project ;)

Thanks anyway!

4
Graphics / sf Variable declaration outside the main
« on: July 09, 2009, 09:28:07 am »
Quote from: "Laurent"
Quote
What about the debug SFML libraries?

What do you mean?


I mean what are they, how do I use them.

5
Graphics / Crashes
« on: July 09, 2009, 03:00:53 am »
I already said it, it ends at a certain point, in a call to the sf objects, and Windows tells me it crashed. And I don't have this problem with OpenAl.

Code: [Select]
// If I declare this inside the main it never crashes, array or not
// Dynamic allocation sometimes works, sometimes not.
sf::Image IMG_PianoB[3][3];
sf::Image IMG_PianoN[3];
sf::Sprite SPR_PianoB[3][3], SPR_PianoN[3];

int main()
{

[...]
// Exemple of dynamic allocation
sf::RenderWindow * Interface;
Interface = new sf::RenderWindow;

// CHARGEMENT DES IMAGES ET ALLOCATION DANS DES SPRITES
//// Piano
if (!IMG_PianoB[0][0].LoadFromFile("IMAGES/PianoB0A.tga"))
    return EXIT_FAILURE;
if (!IMG_PianoB[0][1].LoadFromFile("IMAGES/PianoB1A.tga"))
    return EXIT_FAILURE;
if (!IMG_PianoB[0][2].LoadFromFile("IMAGES/PianoB2A.tga"))
    return EXIT_FAILURE;
if (!IMG_PianoB[1][0].LoadFromFile("IMAGES/PianoB0B.tga"))
    return EXIT_FAILURE;
if (!IMG_PianoB[1][1].LoadFromFile("IMAGES/PianoB1B.tga"))
    return EXIT_FAILURE;
if (!IMG_PianoB[1][2].LoadFromFile("IMAGES/PianoB2B.tga"))
    return EXIT_FAILURE;
if (!IMG_PianoN[0].LoadFromFile("IMAGES/PianoN0.tga"))
    return EXIT_FAILURE;
if (!IMG_PianoN[1].LoadFromFile("IMAGES/PianoN1.tga"))
    return EXIT_FAILURE;
if (!IMG_PianoN[2].LoadFromFile("IMAGES/PianoN2.tga"))
    return EXIT_FAILURE;

// This tends to crash when Images are declared outside the main
    SPR_PianoB[0][0].SetImage(IMG_PianoB[0][0]);
    SPR_PianoB[0][1].SetImage(IMG_PianoB[0][1]);
    SPR_PianoB[0][2].SetImage(IMG_PianoB[0][2]);
    SPR_PianoB[1][0].SetImage(IMG_PianoB[1][0]);
    SPR_PianoB[1][1].SetImage(IMG_PianoB[1][1]);
    SPR_PianoB[1][2].SetImage(IMG_PianoB[1][2]);
    SPR_PianoN[0].SetImage(IMG_PianoN[0]);
    SPR_PianoN[1].SetImage(IMG_PianoN[1]);
    SPR_PianoN[2].SetImage(IMG_PianoN[2]);

// Same here if Interface is declared outside, random results
    (*Interface).Create(VideoModes[0], "QUANTON AUDIO", sf::Style::Fullscreen);
    (*Interface).Clear();
    (*Interface).Draw(SPR_PianoB[0][0]);
    (*Interface).Display();

[...]

EXIT RETURN_SUCCESS;
}


I really don't know what else I could tell you.

Edit: And I know exactly where in my code it stops because I usually add
std::cout << "What it's about to do" << std::endl;

6
Graphics / Debugging
« on: July 08, 2009, 12:27:29 pm »
I use what comes with CodeBlocks. I guess there's some tutorial somewhere. Looks like what we used with VB in high school. What about the debug SFML libraries?

7
Graphics / Transparency
« on: July 08, 2009, 12:19:24 pm »
Well, now that I now TARGAs, I guess I'll never use bitmaps again  :cry: I wonder why Vista can't give me a preview of these files though... it sucks.

8
Graphics / sf Variable declaration outside the main
« on: July 08, 2009, 11:56:07 am »
Quote
If you can, you should try the sfml2 branch from the SVN repository.


Alright, I just downloaded it. I'll update the appropriate file tomorrow.

Quote
Sure it does, if you use the debug SFML libraries. And it does many more things automatically (show the context, the call stack, put conditional breakpoints, ...). You should really try "new-school" debugging


Well, from what you tell me, new-school debugging implies debugging SFML ...  :roll:  anyways, how do I proceed?

Quote
Well, the error message is important. And if you run the debugger you can report many more informations about the crash.


There's no error message. It just crashes. And it does because my sf objects are declared outside of the main, when I try to access their functions, like sprite.SetImage or window.Create. Sometimes it works, sometimes it doesn't, sometimes partially. It's like lotto, and it's a symptom of bad memory allocation [by the sfml classes].

My only solution for now is to share objects by passing them to my functions by reference, but it's no garantee. God I miss my good old FBgfx ... never let me down.  :wink: [/quote]

9
Graphics / Transparency
« on: July 08, 2009, 11:28:32 am »
Well, you shouldn't listen to everybody, since most of them are dumb cowards.

Why is BMP the worst format? I'd say it's pretty much deprecated, but sometimes useful. They are bit maps ... the purpose is obvious. And the header is so simple...

I use Tiffs for professional exportation (when psd isn't supported), it's more flexible. PNGs are for web exchange. Gifs are lightweight and can be animated. JPGs are the best for photo compression. And, well, now I use Targats to get support for the alpha channel. Yet, it would have been so simple to implement alpha management for the bitmaps.

10
Graphics / Global declarations
« on: July 08, 2009, 09:08:40 am »
I'm using SFML version 1.5. I don't use the debugger since I've always debugged my code oldschool, with console prints, thinking and research. Does a debugger tell where in SFML it crashed? Because in my program I know exactly where.

My code: pratically the same as the examples; change the names and declare the vars before the main. That's all. I tried to declare them dynamically using new, not much of a success. (Actually, it worked a few times then started crashing back again... probably a [dynamic] memory allocation problem)

The crash: well a crash is a crash ... it hangs and Windows "tries" to understand why. Then I copy-paste the declarations into the main and it works again. As I said in the preceding post, no probs with Images yet, just sprites and windows, but if I declare the Images outside, the sprites don't like them.

11
Graphics / Alpha channels
« on: July 08, 2009, 08:48:06 am »
Yes they do,

"An alpha channel (for transparency) may be stored in a separate file, where it is similar to a grayscale image, or in a fourth channel that converts 24-bit images to 32 bits per pixel." -Wiki

And that's what Photoshop allows, yet it doesn't allow alpha channels in PNG files.

Edit: Actually it allows you to export PNGs for Web with transparency, if you have a transparent background, but that's not the same at all. I'm using CS2, so I can't say if it changed in CS3...

12
Graphics / sf Variable declaration outside the main
« on: July 08, 2009, 03:02:28 am »
Hi,

When I declare my image and sprite variables outside of the main function, any access to the sprites crashes the program, but it works fine if the variables are declared inside the main. Why is it that way and what if I really need global stuff?

This doesn't affect myimage.LoadFromFile(myfilename). I also can declare my sf::Event variables outside without problem.

Edit: I get the same crashing problem with rendering windows declared outside the main.

13
Graphics / File formats
« on: July 08, 2009, 02:49:35 am »
I just tried the PNG format, but Photoshop didn't allow me to export the alpha channel. It works with the TGA. What I don't understand is why I can't use BMPs for transparency with SFML. I mean, I can export the alpha channel, and load the image, and display it, but SFML doesn't care about its alpha channel. There's nothing new with 32-bits BMPs, so maybe someone should fix this.

Pages: [1]
anything