SDL_FULLSCREEN

Started by
7 comments, last by mrtie_dye 18 years, 9 months ago
I have been working on an SDL project, mostly at work on a Windows2000 computer. Everything compiled and ran quite nicely at work. I uploaded all the files to my webserver, and when I got home today, I downloaded them and compiled them. Well, apprently windows XP does not like Fullscreen mode. The graphics flicker and the display is off center. So, I took out the SDL_FULLSCREEN where I set the video, and it appeared to be working ok. Then, I started pressing the arrow keys to make the little guy run around, and blink! Nothing. It crashed. Has anyone ran into this sort of stuff before? Here is my video init...

    if ( SDL_Init(SDL_INIT_AUDIO|SDL_INIT_VIDEO) < 0 )
    {
        printf("Unable to init SDL: %s\n", SDL_GetError());
        exit(1);
    }
    
    atexit(SDL_Quit);

    screen=SDL_SetVideoMode(800,600,32,SDL_HWSURFACE|SDL_FULLSCREEN);
    
    if ( screen == NULL )
    {
        printf("Unable to set 800x600 video: %s\n", SDL_GetError());
        exit(1);
    }
Thanks for any help you can offer. BTW, it does NOT print "Unable to init SDL:" nor "Unable to set 800x600 video:"
Marriage is the #1 cause of divorce
Advertisement
I highly doubt that it's a problem with that video code, that's pretty much standard. I think it's something with your code else where for the crashes. As for why it's just now happening, there are lots of reasons for that. You can try adding in the flag SDL_DOUBLEBUF for double buffering to see if that takes care of the flickering. Otherwise you will need to check to make sure you are not calling SDL_Flip more than once, are not clearing the screen more than once, and other logic problems like that. I guess make sure you have SDL 1.2.8 and the latest version of your graphics drivers as well [wink]
My SDL apps display off centre in fullscreen mode under win2k. I'd always assumed it was an ATI driver issue, because it seemed to change when I upgraded drivers. It doesn't only happen with SDL/GL, it did it with BFVietnam too. Your post prompted me to do a few more tests though, and it only happens at certain resolutions, and only with certain apps.

Sorry, I know that's not much help.
[size="1"]
I have searched through all of the code, and only found one instance of SDL_Flip being called. I also enabled SDL_DOUBLEBUF, but everything is still flickering. I am using SDL-1.2.8

Here is a report on my graphics card. Don't know if that helps any, but here it is anyway.

INTEL(R) EXTREME GRAPHICS REPORT


Report Date: 06/25/2005
Report Time[hr:mm:ss]: 08:49:45
Driver Version: 6.14.10.4020
Operating System: Windows NT* 5.1.2600 Service Pack 2
Default Language: English
DirectX* Version: 9.0
Physical Memory: 766 MB
Min. Graphics Memory: 1 MB
Max. Graphics Memory: 64 MB
Graphics Memory in use: 4 MB
Processor: x86
Processor Speed: 1694 MHZ
Vendor ID: 0x8086
Device ID: 0x2562
Device Revision: 3


* Output Devices Connected to Graphics Accelerator *

Active Monitors:1

Marriage is the #1 cause of divorce
Well, I have been doing some digging, and I think I have found the problem, but still no way to solve it. The problem occurs when I draw the background. Before, I was loading an image of grass and bliting it to fill up the screen. I decided that since this was causing the problem (if I didn't call the function to draw the grass, everything worked fine) I would load the grass as a CSprite object.

Instead of filling the entire screen, I decided to just try putting the grass in a couple different places, in case there was something wrong with the loop I was using to draw the grass. This is when I stumbled upon something very interesting.

If the grass's y coordinate is above 120 (less than 120), then it draws the grass, no problems. But when the grass dips below 120, it causes the flickering. What could possibly be causing that?

All the bitmaps I use have the same format. The only difference is the size and colors. Now, they are all loaded using the same method. The only difference is the grass is drawn once during the game init, and everything else is drawn everytime the screen updates.

None of this makes any sense. Why would it be doing this? Any help is greatly appreciated.
Marriage is the #1 cause of divorce
Any gluttons for punishment can download the full source here. I have left out comments because to me it makes the code easier to read. I have tried to name things so that their purpose is apparent. If you do happen to download the source and have any questions, feel free to post them here or email me at mrtie_dye@hotmail.com.

Anyway, here is a basic overview of what is going on. At the very base of this program is CSpriteBase. CSpriteBase loads 1 or more images into an array that is later used to create an animation. CSprite has a pointer to a CSpriteBase. So CSprite can display an animation via the frames stored in CSpriteBase. CSprite also has ways of changing it's x,y coordinates and a few other things that would be useful to do with a sprite.

CSpriteBase and CSprite are almost identical to the ones found here except that I have changed the names of almost everything in them, and added some further functionality to suit my needs.

CEnemy, CMenuBar, and CToombStone all inherit from CSprite. CEnemy adds functionality to be able to chase a sprite, and will eventually be able to attack and what not.

CMenuBar is used to display the health and mana of the hero. It has a function to change how much of the image is displayed, so that health or mana can be taken away or added. Sort of like original zelda game where you had 3 hearts, and when you got hit, part of one of the hearts turned black. Yeah, that.

CToombStone doesn't do very much right now. It is just a specialized sprite that the hero and bowSkels can walk behind and in front of.

The final class is CGame. This is where everything happens. It has an init function to initilize all the CSpriteBases and a few other whatnots. It has a gameLoop function that is responsible for moving all the sprites around and drawing them and updating the display. The rest of the funtions just help break up the initilization and gameloop.

Well, that is the crash course. I am working on a website that will go into much more detail, but until I get it finished, I hope this is enough info for you to undertand my code. Thanks for everything.

Mr. Tie Dye
Marriage is the #1 cause of divorce
Well, here is the very beginings of my site. There isn't much there yet, but hopefully, I will have some time to work on it this weekend.
Marriage is the #1 cause of divorce
in CGame::init method, at the end of the method, put these two lines:

SDL_Flip(screen);drawGrass();


this happens because the other surface of the double buffering system is empty - black, hence the horrible flickering.

my eyes hurts very bad now :)
werekarg, you are my hero. That solved the flikcering problem. I still have a few kinks to work out, but having that solved will make everything else mush easier. Thanks so much for your help.
Marriage is the #1 cause of divorce

This topic is closed to new replies.

Advertisement