Allegro & Game Programing

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Allegro & Game Programing

Post 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();
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Long time no see Jade!

(moved to Misc) ;)
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.. :?
Post Reply