1 /* -*- Mode: C; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the Mozilla Public License Version 2.0.
7 // See license.mkd for licensing and copyright information.
8 // -------------------------------------------------------------------------*/
11 * Graphics drawing operations.
16 #ifndef SQUIRRELJME_GFX_H
17 #define SQUIRRELJME_GFX_H
20 #include "sjme/gfxConst.h"
24 #ifndef SJME_CXX_IS_EXTERNED
25 #define SJME_CXX_IS_EXTERNED
26 #define SJME_CXX_SQUIRRELJME_GFX_H
28 #endif /* #ifdef SJME_CXX_IS_EXTERNED */
29 #endif /* #ifdef __cplusplus */
31 /*--------------------------------------------------------------------------*/
34 * Frame buffer related storage and information within SquirrelJME, this must
35 * be compatible with @c PencilShelf in SquirrelJME.
39 typedef struct sjme_gfx_framebuffer sjme_gfx_framebuffer
;
42 * Stores the state of a renderer within the framebuffer.
46 typedef struct sjme_gfx_graphics sjme_gfx_graphics
;
49 * Obtains a graphics drawing instance of the framebuffer.
51 * @param framebuffer The framebuffer to get the graphics from.
52 * @param inOutGraphics The output graphics to initialize into.
53 * @param pixelFormat The @c sjme_gfx_pixelFormat used for the draw.
54 * @param bufferWidth The buffer width, this is the scanline width of the
56 * @param bufferHeight The buffer height.
57 * @param buffer The target buffer to draw to, this is cast to the correct
59 * @param offset The offset to the start of the buffer.
60 * @param palette The color palette, may be @c NULL.
61 * @param surfaceX Starting surface X coordinate.
62 * @param surfaceY Starting surface Y coordinate.
63 * @param surfaceWidth Surface width.
64 * @param surfaceHeight Surface height.
65 * @return Returns @c SJME_JNI_TRUE on success.
68 typedef sjme_jboolean (*sjme_gfx_getGraphics
)(
69 sjme_attrInNotNull sjme_gfx_framebuffer
* framebuffer
,
70 sjme_attrInOutNotNull sjme_gfx_graphics
* inOutGraphics
,
71 sjme_attrInRange(0, SJME_NUM_GFX_PIXEL_FORMATS
)
72 sjme_gfx_pixelFormat pixelFormat
,
73 sjme_attrInPositiveNonZero sjme_jint bufferWidth
,
74 sjme_attrInPositiveNonZero sjme_jint bufferHeight
,
75 sjme_attrInNotNull sjme_pointer buffer
,
76 sjme_attrInPositive sjme_jint offset
,
77 sjme_attrInNullable sjme_pointer palette
,
78 sjme_attrInValue sjme_jint surfaceX
,
79 sjme_attrInValue sjme_jint surfaceY
,
80 sjme_attrInPositiveNonZero sjme_jint surfaceWidth
,
81 sjme_attrInPositiveNonZero sjme_jint surfaceHeight
);
84 * Functions for drawing in a given graphics accordingly.
88 typedef struct sjme_gfx_pencilFunctions
92 } sjme_gfx_pencilFunctions
;
94 struct sjme_gfx_graphics
96 /** The framebuffer this state draws into */
97 sjme_gfx_framebuffer
* framebuffer
;
99 /** The pixel format used. */
100 sjme_gfx_pixelFormat pixelFormat
;
102 /** Pencil functions for this graphics. */
103 sjme_gfx_pencilFunctions pencilFunctions
;
106 struct sjme_gfx_framebuffer
108 /** The pointer to the framebuffer data, may be @c NULL if opaque. */
111 /** The width of the framebuffer in pixels. */
114 /** The height of the framebuffer in pixels. */
117 /** The scanline length of the framebuffer in pixels. */
120 /** The true scanline length of the framebuffer in bytes. */
121 sjme_jint pitchBytes
;
123 /** Function to get a graphics drawing instance for this framebuffer. */
124 sjme_gfx_getGraphics getGraphics
;
126 /** If the framebuffer is allocated extra here, this has room for it. */
127 sjme_jubyte rawReservedBuffer
[sjme_flexibleArrayCount
];
130 /*--------------------------------------------------------------------------*/
134 #ifdef SJME_CXX_SQUIRRELJME_GFX_H
136 #undef SJME_CXX_SQUIRRELJME_GFX_H
137 #undef SJME_CXX_IS_EXTERNED
138 #endif /* #ifdef SJME_CXX_SQUIRRELJME_GFX_H */
139 #endif /* #ifdef __cplusplus */
141 #endif /* SQUIRRELJME_GFX_H */