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

Author Topic: Odd sfVideoMode_getFullscreenModes issue  (Read 3669 times)

0 Members and 1 Guest are viewing this topic.

Jebbs

  • Sr. Member
  • ****
  • Posts: 358
  • DSFML Developer
    • View Profile
    • Email
Odd sfVideoMode_getFullscreenModes issue
« on: February 08, 2013, 07:32:05 am »
I'm having an interesting problem when I call sfVideoMode_getFullscreenModes. The number of modes it tells me I have is absurdly high, but only 9 seem to have any valid information. I am using the current version of CSFML, but I am using the library in D though I doubt that would make much of a difference.

Here is an example program I wrote:
void main(string[] args)
{
        sfVideoMode* modes;
        size_t count;
        int size = sfVideoMode.sizeof;

        modes = sfVideoMode_getFullscreenModes(&count);
        writeln("Number of fullscreen modes: ",count);
        writeln();

        for(int i = 0; i<count; i++)
        {
                try
                {
                        sfVideoMode temp = modes[i*size];
                       
                        writeln("VideoMode number ", i+1);
                        writeln(VideoModeAsString(temp));
                        writeln();
                }
                catch
                {

                }
        }
}

string VideoModeAsString(sfVideoMode videoMode)
{
        return "Width: " ~ text(videoMode.width) ~
                   " Height: " ~ text(videoMode.height) ~
                   " Bits per pixel: " ~ text(videoMode.bitsPerPixel);
}
 

If I don't include the try/catch blocks the program throws a runtime error after the 9th video mode. Anyways, here is what the program outputs for me.

Quote
Number of fullscreen modes: 57

VideoMode number 1
Width: 1920 Height: 1080 Bits per pixel: 32

VideoMode number 2
Width: 1280 Height: 720 Bits per pixel: 32

VideoMode number 3
Width: 1366 Height: 768 Bits per pixel: 16

VideoMode number 4
Width: 720 Height: 480 Bits per pixel: 16

VideoMode number 5
Width: 1280 Height: 800 Bits per pixel: 8

VideoMode number 6
Width: 0 Height: 0 Bits per pixel: 0

VideoMode number 7
Width: 0 Height: 0 Bits per pixel: 0

VideoMode number 8
Width: 0 Height: 0 Bits per pixel: 0

VideoMode number 9
Width: 1305645974 Height: 50482155 Bits per pixel: 6357136


I'm not sure what exactly is going on, but  I also want to point out that the very last video mode that I get's written to the console has changing values.  My guess I'll probably be ok if I stop when I get to a {0,0,0} videomode. I don't know if this happens on anyone else's system, but I just thought I would bring this to Laurent's attention.
DSFML - SFML for the D Programming Language.

Jebbs

  • Sr. Member
  • ****
  • Posts: 358
  • DSFML Developer
    • View Profile
    • Email
Re: Odd sfVideoMode_getFullscreenModes issue
« Reply #1 on: February 09, 2013, 06:35:24 am »
Nevermind! I am a complete idiot. I was iterating through the data incorrectly. I forgot that the size of each object was already being taken into account because it was a sfVideoMode*, so [i*size] was unnecessary and went through my memory at an accelerated rate. That was what caused the runtime access error.

Don't mind me!
DSFML - SFML for the D Programming Language.