Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
9214 turbocat 1
/* Here's a simple example of combining SDL and PDCurses functionality.
2
   The top portion of the window is devoted to SDL, with a four-line
3
   (assuming the default 8x16 font) stdscr at the bottom.
4
*/
5
 
6
#include 
7
#include 
8
#include 
9
#include 
10
 
11
/* You could #include pdcsdl.h, or just add the relevant declarations
12
   here: */
13
 
14
PDCEX SDL_Surface *pdc_screen;
15
PDCEX int pdc_yoffset;
16
 
17
int main(int argc, char **argv)
18
{
19
    char inp[60];
20
    int i, j, seed;
21
 
22
    seed = time((time_t *)0);
23
    srand(seed);
24
 
25
    /* Initialize SDL */
26
 
27
    if (SDL_Init(SDL_INIT_VIDEO) < 0)
28
        exit(1);
29
 
30
    atexit(SDL_Quit);
31
 
32
    pdc_screen = SDL_SetVideoMode(640, 480, 0, SDL_SWSURFACE|SDL_ANYFORMAT);
33
 
34
    /* Initialize PDCurses */
35
 
36
    pdc_yoffset = 416;  /* 480 - 4 * 16 */
37
 
38
    initscr();
39
    start_color();
40
    scrollok(stdscr, TRUE);
41
 
42
    PDC_set_title("PDCurses for SDL");
43
 
44
    /* Do some SDL stuff */
45
 
46
    for (i = 640, j = 416; j; i -= 2, j -= 2)
47
    {
48
        SDL_Rect dest;
49
 
50
        dest.x = (640 - i) / 2;
51
        dest.y = (416 - j) / 2;
52
        dest.w = i;
53
        dest.h = j;
54
 
55
        SDL_FillRect(pdc_screen, &dest,
56
                     SDL_MapRGB(pdc_screen->format, rand() % 256,
57
                                rand() % 256, rand() % 256));
58
    }
59
 
60
    SDL_UpdateRect(pdc_screen, 0, 0, 640, 416);
61
 
62
    /* Do some curses stuff */
63
 
64
    init_pair(1, COLOR_WHITE + 8, COLOR_BLUE);
65
    bkgd(COLOR_PAIR(1));
66
 
67
    addstr("This is a demo of ");
68
    attron(A_UNDERLINE);
69
    addstr("PDCurses for SDL");
70
    attroff(A_UNDERLINE);
71
    addstr(".\nYour comments here: ");
72
    getnstr(inp, 59);
73
    addstr("Press any key to exit.");
74
 
75
    getch();
76
    endwin();
77
 
78
    return 0;
79
}