apps/examples/ft80x: Add a few more demos of GPU primitive operations.

This commit is contained in:
Gregory Nutt 2018-02-19 16:32:33 -06:00
parent 64a4622437
commit c755ac0316
3 changed files with 139 additions and 9 deletions

View File

@ -145,6 +145,8 @@ int ft80x_bitmaps(int fd, FAR struct ft80x_dlbuffer_s *buffer);
#endif
int ft80x_points(int fd, FAR struct ft80x_dlbuffer_s *buffer);
int ft80x_lines(int fd, FAR struct ft80x_dlbuffer_s *buffer);
int ft80x_linestrip(int fd, FAR struct ft80x_dlbuffer_s *buffer);
int ft80x_edgestrip_r(int fd, FAR struct ft80x_dlbuffer_s *buffer);
int ft80x_rectangles(int fd, FAR struct ft80x_dlbuffer_s *buffer);
/* Co-processor display examples */

View File

@ -64,23 +64,77 @@ struct ft80x_exampleinfo_s
* Private Data
****************************************************************************/
/* GPU Primitive display examples. Most primitives are used, but not many of
* their various options.
*/
static const struct ft80x_exampleinfo_s g_primitives[] =
{
/* NAME EXAMPLE ENTRY PRIMITIVE */
#ifndef CONFIG_EXAMPLES_FT80X_EXCLUDE_BITMAPS
{ "Bitmaps", ft80x_bitmaps }, /* Bitmap drawing primitive */
{ "Bitmaps", ft80x_bitmaps }, /* BITMAPS Bitmap drawing
* primitive */
#endif
{ "Points", ft80x_points }, /* Point drawing primitive */
{ "Lines", ft80x_lines }, /* Line drawing primitive */
/* Line strip drawing primitive */
/* Edge strip right side drawing primitive */
/* Edge strip left side drawing primitive */
/* Edge strip above drawing primitive */
/* Edge strip below side drawing primitive */
{ "Rectangles", ft80x_rectangles } /* Rectangle drawing primitive */
{ "Points", ft80x_points }, /* POINTS Point drawing
* primitive */
{ "Lines", ft80x_lines }, /* LINES Line drawing */
{ "Line Strip", ft80x_linestrip }, /* LINE_STRIP Line strip drawing
* primitive */
{ "Edge Strip R", ft80x_edgestrip_r }, /* EDGE_STRIP_R Edge strip right
* side drawing
* primitive */
/* EDGE_STRIP_L Edge strip left
* side drawing
* primitive */
/* EDGE_STRIP_A Edge strip above
* side drawing
* primitive */
/* EDGE_STRIP_B Edge strip below
* side drawing
* primitive */
{ "Rectangles", ft80x_rectangles } /* RECTS Rectangle drawing
* primitive */
};
#define NPRIMITIVES (sizeof(g_primitives) / sizeof(ft80x_example_t))
/* Co-processor display examples. Only a small, but interesting, subset
* here co-processor command are exercised and these with only a few of the
* possible options.
*/
/* CMD_TEXT Draw text */
/* CMD_BUTTON Draw a button */
/* CMD_CLOCK Draw an analog
* clock */
/* CMD_GAUGE Draw a gauge */
/* CMD_KEYS Draw a row of
* keys */
/* CMD_PROGRESS Draw a progress
* bar */
/* CMD_SCROLLBAR Draw a scroll bar */
/* CMD_SLIDER Draw a slider */
/* CMD_DIAL Draw a rotary
* dial control */
/* CMD_TOGGLE Draw a toggle
* switch */
/* CMD_NUMBER Draw a decimal
* number */
/* CMD_CALIBRATE Execute the touch
* screen calibration
* routine */
/* CMD_SPINNER Start an animated
* spinner */
/* CMD_SCREENSAVER Start an animated
* screensaver */
/* CMD_SKETCH Start a continuous
* sketch update */
/* CMD_SNAPSHOT Take a snapshot
* of the current
* screen */
/* CMD_LOGO Play device logo
* animation */
/****************************************************************************
* Private Functions
****************************************************************************/

View File

@ -234,6 +234,80 @@ int ft80x_lines(int fd, FAR struct ft80x_dlbuffer_s *buffer)
return OK;
}
/****************************************************************************
* Name: ft80x_linestrip
*
* Description:
* Demonstrate the line strip primitive
*
****************************************************************************/
int ft80x_linestrip(int fd, FAR struct ft80x_dlbuffer_s *buffer)
{
uint32_t cmds[7];
int ret;
/* Format the display list data */
cmds[0] = FT80X_CLEAR_COLOR_RGB(5, 45, 10);
cmds[1] = FT80X_COLOR_RGB(255, 168, 64);
cmds[2] = FT80X_CLEAR(1 ,1 ,1);
cmds[3] = FT80X_BEGIN(FT80X_PRIM_LINE_STRIP);
cmds[4] = FT80X_VERTEX2F(16 * 16, 16 * 16);
cmds[5] = FT80X_VERTEX2F(((FT80X_DISPLAY_WIDTH * 2) /3) * 16,
(FT80X_DISPLAY_HEIGHT * 2 / 3) * 16);
cmds[6] = FT80X_VERTEX2F((FT80X_DISPLAY_WIDTH - 80) * 16,
(FT80X_DISPLAY_HEIGHT - 20) * 16);
/* Create the hardware display list */
ret = ft80x_dl_create(fd, buffer, cmds, 7);
if (ret < 0)
{
ft80x_err("ERROR: ft80x_dl_create failed: %d\n", ret);
return ret;
}
return OK;
}
/****************************************************************************
* Name: ft80x_edgestrip_r
*
* Description:
* Demonstrate the edge strip right primitive
*
****************************************************************************/
int ft80x_edgestrip_r(int fd, FAR struct ft80x_dlbuffer_s *buffer)
{
uint32_t cmds[7];
int ret;
/* Format the display list data */
cmds[0] = FT80X_CLEAR_COLOR_RGB(5, 45, 10);
cmds[1] = FT80X_COLOR_RGB(255, 168, 64);
cmds[2] = FT80X_CLEAR(1 ,1 ,1);
cmds[3] = FT80X_BEGIN(FT80X_PRIM_EDGE_STRIP_R);
cmds[4] = FT80X_VERTEX2F(16 * 16,16 * 16);
cmds[5] = FT80X_VERTEX2F(((FT80X_DISPLAY_WIDTH * 2) / 3 ) * 16,
((FT80X_DISPLAY_HEIGHT * 2) / 3 ) * 16);
cmds[6] = FT80X_VERTEX2F((FT80X_DISPLAY_WIDTH - 80) * 16,
(FT80X_DISPLAY_HEIGHT - 20) * 16);
/* Create the hardware display list */
ret = ft80x_dl_create(fd, buffer, cmds, 7);
if (ret < 0)
{
ft80x_err("ERROR: ft80x_dl_create failed: %d\n", ret);
return ret;
}
return OK;
}
/****************************************************************************
* Name: ft80x_rectangles
*