summaryrefslogtreecommitdiff
path: root/apps/graphics/traveler/include
diff options
context:
space:
mode:
Diffstat (limited to 'apps/graphics/traveler/include')
-rw-r--r--apps/graphics/traveler/include/trv_color.h2
-rw-r--r--apps/graphics/traveler/include/trv_debug.h8
-rw-r--r--apps/graphics/traveler/include/trv_graphics.h77
-rw-r--r--apps/graphics/traveler/include/trv_main.h2
-rw-r--r--apps/graphics/traveler/include/trv_mem.h52
-rw-r--r--apps/graphics/traveler/include/trv_raycntl.h8
-rw-r--r--apps/graphics/traveler/include/trv_types.h7
-rw-r--r--apps/graphics/traveler/include/trv_world.h10
8 files changed, 132 insertions, 34 deletions
diff --git a/apps/graphics/traveler/include/trv_color.h b/apps/graphics/traveler/include/trv_color.h
index 04e9d1523..0a2cf78bb 100644
--- a/apps/graphics/traveler/include/trv_color.h
+++ b/apps/graphics/traveler/include/trv_color.h
@@ -71,7 +71,7 @@ struct trv_color_lum_s
****************************************************************************/
bool trv_color_allocate(FAR struct trv_palette_s *pinfo);
-void trv_color_endmapping(void);
+void trv_color_free(FAR struct trv_palette_s *pinfo);
trv_pixel_t trv_color_rgb2pixel(FAR struct trv_color_rgb_s *pixel);
void trv_color_pixel2lum(trv_pixel_t pixel, FAR struct trv_color_lum_s *lum);
trv_pixel_t trv_color_lum2pixel(FAR struct trv_color_lum_s *lum);
diff --git a/apps/graphics/traveler/include/trv_debug.h b/apps/graphics/traveler/include/trv_debug.h
index d54b1eb13..08b4c2d3b 100644
--- a/apps/graphics/traveler/include/trv_debug.h
+++ b/apps/graphics/traveler/include/trv_debug.h
@@ -93,13 +93,13 @@
printf(EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
# else
-# define vdbg(x...)
+# define trv_vdebug(x...)
# endif
# else
-# define dbg(x...)
-# define vdbg(x...)
+# define trv_debug(x...)
+# define trv_vdebug(x...)
# endif
#else
@@ -132,7 +132,7 @@
* arguments, then this additional interface will be built.
*/
-#ifndef CONFIG_CPP_HAVE_VARARGS && (CONFIG_GRAPHICS_TRAVELER_DEBUG_LEVEL > 0)
+#if !defined(CONFIG_CPP_HAVE_VARARGS) && CONFIG_GRAPHICS_TRAVELER_DEBUG_LEVEL > 0
int trv_debug(FAR const char *format, ...);
#endif
diff --git a/apps/graphics/traveler/include/trv_graphics.h b/apps/graphics/traveler/include/trv_graphics.h
index 5364c8bc7..69790e627 100644
--- a/apps/graphics/traveler/include/trv_graphics.h
+++ b/apps/graphics/traveler/include/trv_graphics.h
@@ -42,41 +42,88 @@
#include "trv_types.h"
+#include <nuttx/video/fb.h>
+#ifdef CONFIG_NX
+# include <nuttx/nx/nx.h>
+#endif
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#if defined(CONFIG_GRAPHICS_TRAVELER_RGB16_565)
+# define TRV_BPP 16
+# define TRV_COLOR_FMT FB_FMT_RGB16_565
+#elif defined(CONFIG_GRAPHICS_TRAVELER_RGB32_888)
+# define TRV_BPP 32
+# define TRV_COLOR_FMT FB_FMT_RGB32
+#else
+# error No color format defined
+#endif
+
+#define MAX_REND_WIDTH 480
+#define MAX_REND_HEIGHT 240
+
/****************************************************************************
* Public Types
****************************************************************************/
+#if TRV_BPP == 16
+typedef uint16_t dev_pixel_t; /* Width of one hardware pixel */
+#elif TRV_BPP == 32
+typedef uint32_t dev_pixel_t; /* Width of one hardware pixel */
+#endif
+
struct trv_palette_s
{
int ncolors; /* Number of colors in the look-up table */
- FAR nxgl_mxpixel_t *lut; /* Color lookup table */
+ FAR dev_pixel_t *lut; /* Color lookup table */
};
struct trv_graphics_info_s
{
- nxgl_coord_t width; /* Image width */
- nxgl_coord_t height; /* Image height */
+#ifdef CONFIG_NX
+ NXHANDLE hnx; /* The connection handle */
+ NXHANDLE bgwnd; /* Background window handle */
+#else
+ trv_coord_t stride; /* Length of a line in bytes */
+#endif
+ trv_coord_t hwwidth; /* Display width (pixels) */
+ trv_coord_t hwheight; /* Display height (rows) */
+ trv_coord_t swwidth; /* Software render width (pixels) */
+ trv_coord_t swheight; /* Software render height height (rows) */
+ uint8_t vscale; /* Log2 vertical image scale factor */
+ uint8_t hscale; /* Log2 horizontal image scale factor */
struct trv_palette_s palette; /* Color palette */
- FAR nxgl_mxpixel_t *buffer; /* Hardware framebuffer */
+ FAR dev_pixel_t *hwbuffer; /* Hardware frame buffer */
+ FAR trv_pixel_t *swbuffer; /* Software render buffer */
};
-struct trv_framebuffer_s
-{
- nxgl_coord_t width; /* Image width */
- nxgl_coord_t height; /* Image height */
- FAR trv_pixel_t *buffer; /* Software render buffer */
-};
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+#ifdef CONFIG_NX
+extern FAR const struct nx_callback_s *g_trv_nxcallback;
+extern sem_t g_trv_nxevent;
+extern volatile bool g_trv_nxresolution;
+#ifdef CONFIG_NX_MULTIUSER
+extern volatile bool g_trv_nxrconnected;
+#endif
+#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
-int trv_graphics_initialize(uint16_t width, uint16_t height,
- uint8_t scale_factor,
- FAR struct trv_graphics_info_s *ginfo);
-void trv_graphics_terminate(void);
+int trv_graphics_initialize(FAR struct trv_graphics_info_s *ginfo);
+void trv_graphics_terminate(FAR struct trv_graphics_info_s *ginfo);
trv_pixel_t trv_graphics_index2pixel(int index);
-void trv_display_update(struct trv_framebuffer_s *fb);
+void trv_display_update(struct trv_graphics_info_s *fb);
trv_pixel_t *trv_get_renderbuffer(uint16_t width, uint16_t height);
+#ifdef CONFIG_NX_MULTIUSER
+FAR void *trv_nxlistener(FAR void *arg)
+#endif
+
#endif /* __APPS_GRAPHICS_TRAVELER_INCLUDE_TRV_GRAPHICS_H */
diff --git a/apps/graphics/traveler/include/trv_main.h b/apps/graphics/traveler/include/trv_main.h
index 08d16ef2b..62c5ad61f 100644
--- a/apps/graphics/traveler/include/trv_main.h
+++ b/apps/graphics/traveler/include/trv_main.h
@@ -56,6 +56,6 @@ extern bool g_trv_terminate;
* Public Function Prototypes
****************************************************************************/
-void trv_abort(FAR char *format, ...);
+void trv_abort(FAR char *format, ...) noreturn_function;
#endif /* __APPS_GRAPHICS_TRAVELER_INCLUDE_TRV_MAIN_H */
diff --git a/apps/graphics/traveler/include/trv_mem.h b/apps/graphics/traveler/include/trv_mem.h
new file mode 100644
index 000000000..5ae3866cf
--- /dev/null
+++ b/apps/graphics/traveler/include/trv_mem.h
@@ -0,0 +1,52 @@
+/****************************************************************************
+ * apps/graphics/traveler/include/trv_mem.h
+ *
+ * Copyright (C) 2014 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gnutt@nuttx.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+#ifndef __APPS_GRAPHICS_TRAVELER_INCLUDE_TRV_MEM_H
+#define __APPS_GRAPHICS_TRAVELER_INCLUDE_TRV_MEM_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include "trv_types.h"
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+FAR void *trv_malloc(size_t size);
+void trv_free(FAR void *memory);
+
+#endif /* __APPS_GRAPHICS_TRAVELER_INCLUDE_TRV_MEM_H */
diff --git a/apps/graphics/traveler/include/trv_raycntl.h b/apps/graphics/traveler/include/trv_raycntl.h
index 01cbed191..ffcf2b6d3 100644
--- a/apps/graphics/traveler/include/trv_raycntl.h
+++ b/apps/graphics/traveler/include/trv_raycntl.h
@@ -41,6 +41,7 @@
****************************************************************************/
#include "trv_types.h"
+#include "trv_graphics.h"
/****************************************************************************
* Pre-processor Definitions
@@ -54,10 +55,7 @@
* Public Function Prototypes
****************************************************************************/
-extern uint8_t *trv_raycaster_initialize(uint16_t screen_width,
- uint16_t screen_height,
- uint8_t scale_factor,
- FAR uint8_t *screen_buffer);
-extern void trv_raycaster(FAR struct trv_camera_s *player);
+void trv_raycaster(FAR struct trv_camera_s *player,
+ FAR struct trv_graphics_info_s *ginfo);
#endif /* __APPS_GRAPHICS_TRAVELER_INCLUDE_TRV_RAYCNTL_H */
diff --git a/apps/graphics/traveler/include/trv_types.h b/apps/graphics/traveler/include/trv_types.h
index 6fbf61071..2eb9f2618 100644
--- a/apps/graphics/traveler/include/trv_types.h
+++ b/apps/graphics/traveler/include/trv_types.h
@@ -41,12 +41,12 @@
****************************************************************************/
#include <nuttx/config.h>
+#include <nuttx/compiler.h>
+#include <sys/types.h>
#include <stdint.h>
#include <stdbool.h>
-#include <nuttx/nx/nxglib.h>
-
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@@ -63,7 +63,8 @@
* Public Types
****************************************************************************/
-typedef uint8_t trv_pixel_t;
+typedef uint8_t trv_pixel_t; /* Width of one pixel in rendering phase */
+typedef int16_t trv_coord_t; /* Contains one display coordinate */
/****************************************************************************
* Public Function Prototypes
diff --git a/apps/graphics/traveler/include/trv_world.h b/apps/graphics/traveler/include/trv_world.h
index b590e2f87..939ec1820 100644
--- a/apps/graphics/traveler/include/trv_world.h
+++ b/apps/graphics/traveler/include/trv_world.h
@@ -52,11 +52,11 @@
struct trv_camera_s
{
- nxgl_coord_t x; /* Camera X position */
- nxgl_coord_t y; /* Camera Y position */
- nxgl_coord_t z; /* Camera Z position */
- int16_t yaw; /* Camera yaw orientation */
- int16_t pitch; /* Camera pitch orientation */
+ trv_coord_t x; /* Camera X position */
+ trv_coord_t y; /* Camera Y position */
+ trv_coord_t z; /* Camera Z position */
+ int16_t yaw; /* Camera yaw orientation */
+ int16_t pitch; /* Camera pitch orientation */
};
/****************************************************************************