Page 1 of 1

Allegro & Game Programing

Posted: Tue Nov 01, 2005 7:57 pm
by Jade
Hey, I've just started working with allegro http://www.talula.demon.co.uk/allegro/ and every time I run the get_screen_resolution() I get a core dump on the program. Not sure why as everything else seems to be working. Any ideas? I've included the C code below. Any or all suggestions would be appreicated.

Code: Select all

/*************
/* Name: GetInfo.c
/* Date: 01/11/05
/* Description: Returns information about the system operating system using allegro
***************/

#include <stdio.h>
#include <conio.h>
#include "allegro.h"

/************
/* Name: YesNo
/* Parameters: int value
/* Purpose: returns string Yes or No if value is true or false
************/
char *YesNo(int value)
{
    if (value)
        return "Yes";
    else
        return "No";
}

/************
/* Name: OSName
/* Parameters: int number
/* Purpose: returns the string value to the correct operating system
************/
char *OSName(int number)
{
    switch(number)
    {
    case OSTYPE_UNKNOWN: return "Unknown or MS-DOS";
    case OSTYPE_WIN3: return "Windows";
    case OSTYPE_WIN95: return "Windows 95";
    case OSTYPE_WIN98: return "Windows 98";
    case OSTYPE_WINME: return "Windows ME";
    case OSTYPE_WINNT: return "Windows NT";
    case OSTYPE_WIN2000: return "Windows 2000";
    case OSTYPE_WINXP: return "Windows XP";
    case OSTYPE_OS2: return "OS/2";
    case OSTYPE_WARP: return "OS/2 Warp 3";
    case OSTYPE_DOSEMU: return "Linux DOSEMU";
    case OSTYPE_OPENDOS: return "Caldera OpenDOS";
    case OSTYPE_LINUX: return "Linux";
    case OSTYPE_FREEBSD: return "FreeBSD";
    case OSTYPE_QNX: return "QNX";
    case OSTYPE_UNIX: return "Unix Variant";
    case OSTYPE_BEOS: return "BEOS";
    case OSTYPE_MACOS: return "MacOS";
    }
}

int main()
{
    /*local variables*/
    int width, height;
    width = height = 0;
    get_desktop_resolution(&width, &height); /*The program runs if I comment out this line... */
    
    allegro_init();
    printf("Allegro version = %s\n", allegro_id);
    printf("Operating System = %s version %i.%i\n", OSName(os_type), os_version, os_revision);
    printf("Allows For Multitasking = %s\n", YesNo(os_multitasking));
    printf("Desktop Resolution = %i x %i\n", width, height);
    printf("Color Depth = %i bits\n", desktop_color_depth());
    
    
    printf("\nPress any key...\n");
    getch();
    return 0;
}
END_OF_MAIN();

Posted: Tue Nov 01, 2005 8:10 pm
by feyd
Long time no see Jade!

(moved to Misc) ;)

Posted: Tue Nov 01, 2005 8:15 pm
by Jade
Heh, yeah I know. Been busy in college. Boring stuff. Oopsie about the post in the wrong place, what would we do without you Feyd?

Posted: Tue Nov 01, 2005 9:57 pm
by feyd
the code example I'm seeing has allegro_init() happening before the call to get_desktop_resolution() .. that's the only thing I can see without downloading and running it.. :?