OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [mw/] [src/] [demos/] [nanox/] [demo4.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 673 markom
/*
2
 * Demonstration program for Nano-X blitting
3
 */
4
#include <stdio.h>
5
#include <stdlib.h>
6
#include "nano-X.h"
7
#include "device.h"
8
 
9
static  GR_GC_ID        gc1;            /* graphics context for text */
10
static  GR_SCREEN_INFO  si;             /* information about screen */
11
 
12
#define GRAY14          MWRGB( 17, 17, 17 )
13
#define GRAY13          MWRGB( 34, 34, 34 )
14
#define GRAY12          MWRGB( 51, 51, 51 )
15
#define GRAY11          MWRGB( 68, 68, 68 )
16
#define GRAY10          MWRGB( 85, 85, 85 )
17
#define GRAY9           MWRGB( 102, 102, 102 )
18
#define GRAY8           MWRGB( 119, 119, 119 )
19
#define GRAY7           MWRGB( 136, 136, 136 )
20
#define GRAY6           MWRGB( 153, 153, 153 )
21
#define GRAY5           MWRGB( 170, 170, 170 )
22
#define GRAY4           MWRGB( 187, 187, 187 )
23
#define GRAY3           MWRGB( 204, 204, 204 )
24
#define GRAY2           MWRGB( 221, 221, 221 )
25
#define GRAY1           MWRGB( 238, 238, 238 )
26
 
27
int
28
main(int argc,char **argv)
29
{
30
        GR_EVENT        event;          /* current event */
31
 
32
        if (GrOpen() < 0) {
33
                fprintf(stderr, "cannot open graphics\n");
34
                exit(1);
35
        }
36
 
37
        GrGetScreenInfo(&si);
38
 
39
        gc1 = GrNewGC();
40
 
41
        GrSetGCForeground(gc1, WHITE);
42
        /*GrFillRect(GR_ROOT_WINDOW_ID, gc, 0, 0, 240, 320);*/
43
 
44
        GrLine(GR_ROOT_WINDOW_ID, gc1, 4, 4, 634, 4);
45
        GrLine(GR_ROOT_WINDOW_ID, gc1, 4, 4, 4, 474);
46
        GrLine(GR_ROOT_WINDOW_ID, gc1, 634, 4, 634, 474);
47
        GrLine(GR_ROOT_WINDOW_ID, gc1, 4, 474, 634, 474);
48
 
49
        /*GrJPEG(GR_ROOT_WINDOW_ID, gc, 0, 0, 400, 400, "/home/mart/nov9_pic1.jpg");*/
50
 
51
/* Bitblit function */
52
{
53
        PSD     mempsd;
54
        int     linelen, size;
55
        void *  pixels;
56
 
57
        mempsd = scrdev.AllocateMemGC(&scrdev);
58
        GdCalcMemGCAlloc(mempsd, 50, 100, 0, 0, &size, &linelen);
59
        pixels = malloc(size);
60
        mempsd->flags |= PSF_ADDRMALLOC;
61
        mempsd->MapMemGC(mempsd, 50, 100, scrdev.planes, scrdev.bpp,
62
                linelen, size, pixels);
63
 
64
        /* Draw some stuff on offscreen */
65
        GdSetForeground(GdFindColor(GREEN));
66
        GdFillRect(mempsd, 0, 0, 50, 100);
67
        GdSetForeground(GdFindColor(RED));
68
        GdFillRect(mempsd, 5, 20, 40, 60);
69
 
70
        /* blit */
71
        GdBlit(&scrdev, 10, 10, 50, 100, mempsd, 0, 0, 0);
72
}
73
/*      GrSetGCForeground(gc, BLACK);
74
        GrPoint(GR_ROOT_WINDOW_ID, gc, 0, 0);
75
 
76
        GrSetGCForeground(gc, GRAY10);
77
        GrFillRect(GR_ROOT_WINDOW_ID, gc, 1, 1, 478, 638);
78
*/
79
        while (1) {
80
                GrGetNextEvent(&event);
81
                if(event.type == GR_EVENT_TYPE_CLOSE_REQ) break;
82
        }
83
 
84
        GrClose();
85
 
86
        return 0;
87
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.