Skip to content
Permalink
Browse files

updated nxdraw.c from fbff

  • Loading branch information...
ghaerr committed Jun 13, 2019
1 parent e959bb8 commit f7781e801f7bbfb58bcdd31d723b3cd1f58becb8
Showing with 44 additions and 12 deletions.
  1. +2 −0 ChangeLog
  2. +7 −1 draw.h
  3. +1 −1 fbpdf.c
  4. +34 −10 nxdraw.c
@@ -1,2 +1,4 @@
13 Jun 2019
* updated nxdraw.c from fbff
8 Jun 2019
* initial port to Nano-X, revised sources and fb_ api for simpler multiple platform support
8 draw.h
@@ -1,5 +1,6 @@
/* main functions */
int fb_init(char *title, int w, int h);
int fb_init(void);
int fb_open(char *title, int w, int h, int flags);
void fb_free(void);
unsigned fb_mode(void);
void *fb_mem(int r);
@@ -10,6 +11,11 @@ void fb_update(void);

typedef unsigned int fbval_t; /* framebuffer depth */

/* fb_open flags*/
#define NOFRAME 0
#define BORDER 1
#define APPFRAME 2

/* fb_mode() interpretation */
#define FBM_BPP(m) (((m) >> 16) & 0x0f)
#define FBM_COLORS(m) ((m) & 0x0fff)
@@ -345,7 +345,7 @@ int main(int argc, char *argv[])
break;
}
}
if (fb_init(PROGNAME, 800, 600))
if (fb_init() || fb_open(PROGNAME, 800, 600, APPFRAME))
return 1;
srows = fb_rows();
scols = fb_cols();
@@ -55,27 +55,51 @@ static void init_colors(void)
bl = 0;
}

int fb_init(char *title, int w, int h)
int fb_init(void)
{
GR_SCREEN_INFO si;
if (GrOpen() < 0)
return 1;

bytespp = 4;
init_colors();

if (!w || !h) {
GR_SCREEN_INFO si;
GrGetScreenInfo(&si);
WIDTH = si.cols;
HEIGHT = si.rows;
} else {
/* get width/height for fb_cols/fb_rows before fb_open*/
GrGetScreenInfo(&si);
WIDTH = si.cols;
HEIGHT = si.rows;
STRIDE = WIDTH * bytespp;

return 0;
}

int fb_open(char *title, int w, int h, int flags)
{
GR_WM_PROPS props;

/* reset window size from fullscreen if given*/
if (w && h) {
WIDTH = w;
HEIGHT = h;
STRIDE = WIDTH * bytespp;
}
STRIDE = WIDTH * bytespp;

wid = GrNewBufferedWindow(GR_WM_PROPS_BUFFER_MMAP|GR_WM_PROPS_BUFFER_BGRA, title, GR_ROOT_WINDOW_ID,
0, 0, WIDTH, HEIGHT, 0);
switch (flags) {
case NOFRAME:
props = GR_WM_PROPS_CLOSEBOX; /* will generate no frame, closebox, or border*/
break;
case BORDER:
props = GR_WM_PROPS_BORDER;
break;
case APPFRAME:
props = GR_WM_PROPS_APPWINDOW;
break;
default:
return 1;
}
props |= GR_WM_PROPS_BUFFER_MMAP | GR_WM_PROPS_BUFFER_BGRA | GR_WM_PROPS_NORESIZE;

wid = GrNewBufferedWindow(props, title, GR_ROOT_WINDOW_ID, 0, 0, WIDTH, HEIGHT, 0);
fb = GrOpenClientFramebuffer(wid);
if (!fb) {
GrDestroyWindow(wid);

0 comments on commit f7781e8

Please sign in to comment.
You can’t perform that action at this time.