Advertisement
GeeckoDev

glib2d.h term

Mar 19th, 2012
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 22.54 KB | None | 0 0
  1. /** \mainpage gLib2D Documentation
  2.  *
  3.  * \section intro Introduction
  4.  *
  5.  * gLib2D by Geecko - A simple, fast, light-weight 2D graphics library. \n\n
  6.  * This library has been designed to replace the old graphics.c library
  7.  * and to simplify the use of pspgu.\n
  8.  * The goals : keep it simple, keep it small, keep it fast.
  9.  *
  10.  * \section limits Known limitations
  11.  *
  12.  * - Draw & display buffers can't actually be used as real textures. Just a way
  13.  *   to get the vram pointer.
  14.  * - No support for multiples contexts (e.g. sharing coordinates beetween
  15.  *   textures using some gBegin calls at a time).
  16.  * - Manipulating textures (clear, get pixel info...) is not possible.
  17.  * - When some 512*512 rotated, colorized and scaled textures are rendered
  18.  *   at a time, the framerate *could* go under 60 fps.
  19.  *
  20.  * \section install Installation
  21.  *
  22.  * - Simply put glib2d.c and glib2d.h in your source directory. \n
  23.  * - Then add glib2d.o and link "-lpng -ljpeg -lz -lpspgu -lm -lpspvram"
  24.  *   in your Makefile.
  25.  * - You're done !
  26.  *
  27.  * \section copyright License
  28.  *
  29.  * This work is licensed under the Creative Commons BY-SA 3.0 License. \n
  30.  * See http://creativecommons.org/licenses/by-sa/3.0/ or the LICENSE file
  31.  * for more details. \n
  32.  * You can support the library by marking your homebrew with
  33.  * "Using gLib2D by Geecko".
  34.  *
  35.  * \section contact Contact
  36.  *
  37.  * Please report bugs or submit ideas at : \n geecko.dev@free.fr \n\n
  38.  * Get the full documentation on : \n http://geecko.dev.free.fr \n\n
  39.  * Also stay tuned on... \n
  40.  * https://github.com/GeeckoDev (contributors would be a plus!) \n
  41.  * http://twitter.com/GeeckoDev
  42.  */
  43.  
  44.  
  45. /**
  46.  * \file glib2d.h
  47.  * \brief gLib2D Header
  48.  * \version Beta 5
  49.  */
  50.  
  51. #ifndef GLIB2D_H
  52. #define GLIB2D_H
  53.  
  54. #ifdef __cplusplus
  55. extern "C" {
  56. #endif
  57.  
  58. #include <stdbool.h>
  59.  
  60. /**
  61.  * \def USE_PNG
  62.  * \brief Choose if the PNG support is enabled.
  63.  *
  64.  * Otherwise, this part will be not compiled to gain some space.
  65.  * Enable this to get PNG support, disable to avoid compilation errors
  66.  * when libpng is not linked in the Makefile.
  67.  */
  68. /**
  69.  * \def USE_JPEG
  70.  * \brief Choose if the JPEG support is enabled.
  71.  *
  72.  * Otherwise, this part will be not compiled to gain some space.
  73.  * Enable this to get JPEG support, disable to avoid compilation errors
  74.  * when libjpeg is not linked in the Makefile.
  75.  */
  76. /**
  77.  * \def USE_VFPU
  78.  * \brief Choose if the VFPU support is enabled.
  79.  *
  80.  * Otherwise, this part will be not compiled to use the standard math library.
  81.  * Enable this to greatly improve performance with 2d rotations. You SHOULD use
  82.  * PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU) to avoid crashes.
  83.  */
  84. #define USE_PNG
  85. #define USE_JPEG
  86. //#define USE_VFPU
  87.  
  88. /**
  89.  * \def G2D_SCR_W
  90.  * \brief Screen width constant, in pixels.
  91.  */
  92. /**
  93.  * \def G2D_SCR_H
  94.  * \brief Screen height constant, in pixels.
  95.  */
  96. /**
  97.  * \def G2D_VOID
  98.  * \brief Generic constant, equals to 0 (do nothing).
  99.  */
  100. #define G2D_SCR_W (480)
  101. #define G2D_SCR_H (272)
  102. #define G2D_VOID 0
  103.  
  104. /**
  105.  * \def G2D_RGBA(r,g,b,a)
  106.  * \brief Create a g2dColor.
  107.  *
  108.  * This macro creates a g2dColor from 4 values, red, green, blue and alpha.
  109.  * Input range is from 0 to 255.
  110.  */
  111. #define G2D_RGBA(r,g,b,a) ((r)|((g)<<8)|((b)<<16)|((a)<<24))
  112.  
  113. /**
  114.  * \def G2D_GET_R(color)
  115.  * \brief Get red channel value from a g2dColor.
  116.  */
  117. /**
  118.  * \def G2D_GET_G(color)
  119.  * \brief Get green channel value from a g2dColor.
  120.  */
  121. /**
  122.  * \def G2D_GET_B(color)
  123.  * \brief Get blue channel value from a g2dColor.
  124.  */
  125. /**
  126.  * \def G2D_GET_A(color)
  127.  * \brief Get alpha channel value from a g2dColor.
  128.  */
  129. #define G2D_GET_R(color) (((color)    ) & 0xFF)
  130. #define G2D_GET_G(color) (((color)>>8 ) & 0xFF)
  131. #define G2D_GET_B(color) (((color)>>16) & 0xFF)
  132. #define G2D_GET_A(color) (((color)>>24) & 0xFF)
  133.  
  134. /**
  135.  * \def G2D_MODULATE(color,luminance,alpha)
  136.  * \brief g2dColor modulation.
  137.  *
  138.  * This macro modulates the luminance & alpha of a g2dColor.
  139.  * Input range is from 0 to 255.
  140.  */
  141. #define G2D_MODULATE(color,luminance,alpha) \
  142. G2D_RGBA((int)(luminance)*G2D_GET_R(color)/255, \
  143.          (int)(luminance)*G2D_GET_G(color)/255, \
  144.          (int)(luminance)*G2D_GET_B(color)/255, \
  145.          (int)(alpha    )*G2D_GET_A(color)/255)
  146.  
  147. /**
  148.  * \enum g2dColors
  149.  * \brief Colors enumeration.
  150.  *
  151.  * Primary, secondary, tertiary and grayscale colors are defined.
  152.  */
  153. enum g2dColors
  154. {
  155.   // Primary colors
  156.   RED          = 0xFF0000FF,
  157.   GREEN        = 0xFF00FF00,
  158.   BLUE         = 0xFFFF0000,
  159.   // Secondary colors
  160.   CYAN         = 0xFFFFFF00,
  161.   MAGENTA      = 0xFFFF00FF,
  162.   YELLOW       = 0xFF00FFFF,
  163.   // Tertiary colors
  164.   AZURE        = 0xFFFF7F00,
  165.   VIOLET       = 0xFFFF007F,
  166.   ROSE         = 0xFF7F00FF,
  167.   ORANGE       = 0xFF007FFF,
  168.   CHARTREUSE   = 0xFF00FF7F,
  169.   SPRING_GREEN = 0xFF7FFF00,
  170.   // Grayscale
  171.   WHITE        = 0xFFFFFFFF,
  172.   LITEGRAY     = 0xFFBFBFBF,
  173.   GRAY         = 0xFF7F7F7F,
  174.   DARKGRAY     = 0xFF3F3F3F,
  175.   BLACK        = 0xFF000000
  176. };
  177.  
  178. /**
  179.  * \enum g2dCoord_Mode
  180.  * \brief Coordinates modes enumeration.
  181.  *
  182.  * Choose where the coordinates correspond in the object.
  183.  * Can only be used with g2dSetCoordMode.
  184.  */
  185. /**
  186.  * \enum g2dLine_Mode
  187.  * \brief Line modes enumeration.
  188.  *
  189.  * Change line draw properties.
  190.  * Can only be used with g2dBeginLines.
  191.  */
  192. /**
  193.  * \enum g2dFlip_Mode
  194.  * \brief Flip modes enumeration.
  195.  *
  196.  * Change flip properties.
  197.  * Can only be used with g2dFlip.
  198.  */
  199. /**
  200.  * \enum g2dTex_Mode
  201.  * \brief Texture modes enumeration.
  202.  *
  203.  * Change texture properties.
  204.  * Can only be used with g2dTexLoad.
  205.  */
  206. typedef enum
  207. {
  208.   G2D_UP_LEFT,
  209.   G2D_UP_RIGHT,
  210.   G2D_DOWN_RIGHT,
  211.   G2D_DOWN_LEFT,
  212.   G2D_CENTER
  213. } g2dCoord_Mode;
  214. typedef enum
  215. {
  216.   G2D_STRIP = 1 /**< Make a line strip. */
  217. } g2dLine_Mode;
  218. typedef enum
  219. {
  220.   G2D_VSYNC = 1 /**< Limit the FPS to 60 (synchronized with the screen).
  221.                      Better image quality and less power consumption. */
  222. } g2dFlip_Mode;
  223. typedef enum
  224. {
  225.   G2D_SWIZZLE = 1 /**< Recommended. Use it to get *more* rendering speed. */
  226. } g2dTex_Mode;
  227.  
  228. /**
  229.  * \var g2dAlpha
  230.  * \brief Alpha type.
  231.  */
  232. /**
  233.  * \var g2dColor
  234.  * \brief Color type.
  235.  */
  236. typedef int g2dAlpha;
  237. typedef unsigned int g2dColor;
  238.  
  239. /**
  240.  * \struct g2dImage
  241.  * \brief Image structure.
  242.  */
  243. typedef struct
  244. {
  245.   int tw;         /**< Real texture width. A power of two. */
  246.   int th;         /**< Real texture height. A power of two. */
  247.   int w;          /**< Texture width, as seen when drawing. */
  248.   int h;          /**< Texture height, as seen when drawing. */
  249.   float ratio;    /**< Width/height ratio. */
  250.   bool swizzled;  /**< Is the texture swizzled ? */
  251.   bool can_blend; /**< Can the texture blend ? */
  252.   g2dColor* data; /**< Pointer to raw data. */
  253. } g2dImage;
  254.  
  255. /**
  256.  * \var g2d_draw_buffer
  257.  * \brief The current draw buffer as a texture.
  258.  */
  259. /**
  260.  * \var g2d_disp_buffer
  261.  * \brief The current display buffer as a texture.
  262.  */
  263. extern g2dImage g2d_draw_buffer;
  264. extern g2dImage g2d_disp_buffer;
  265.  
  266. /**
  267.  * \brief Initializes the library.
  268.  *
  269.  * This function will create a GU context and setup the display buffers.
  270.  * Automatically called by the other functions.
  271.  */
  272. void g2dInit();
  273.  
  274. /**
  275.  * \brief Shutdowns the library.
  276.  *
  277.  * This function will destroy the GU context.
  278.  */
  279. void g2dTerm();
  280.  
  281. /**
  282.  * \brief Clears screen & depth buffer.
  283.  * @param color Screen clear color
  284.  *
  285.  * This function clears the screen, and clears the zbuffer if depth coordinate
  286.  * is used in the loop. Will automatically init the GU if needed.
  287.  */
  288. void g2dClear(g2dColor color);
  289.  
  290. /**
  291.  * \brief Clears depth buffer.
  292.  *
  293.  * This function clears the zbuffer to zero (z range 0-65535).
  294.  * Will automatically init the GU if needed.
  295.  */
  296. void g2dClearZ();
  297.  
  298. /**
  299.  * \brief Begins rectangles rendering.
  300.  * @param tex Pointer to a texture, pass NULL to get a colored rectangle.
  301.  *
  302.  * This function begins object rendering. Resets all properties.
  303.  * One g2dAdd() call per object.
  304.  * Only one texture can be used, but multiple objects can be rendered at a time.
  305.  * g2dBegin*() / g2dEnd() couple can be called multiple times in the loop,
  306.  * to render multiple textures.
  307.  */
  308. void g2dBeginRects(g2dImage* tex);
  309.  
  310. /**
  311.  * \brief Begins lines rendering.
  312.  * @param line_mode A g2dLine_Mode constant.
  313.  *
  314.  * This function begins object rendering. Calls g2dReset().
  315.  * Two g2dAdd() calls per object.
  316.  * Pass G2D_LINE_STRIP to make a line strip (two calls, then one per object).
  317.  */
  318. void g2dBeginLines(g2dLine_Mode mode);
  319.  
  320. /**
  321.  * \brief Begins quads rendering.
  322.  * @param tex Pointer to a texture, pass NULL to get a colored quad.
  323.  *
  324.  * This function begins object rendering. Resets all properties.
  325.  * Four g2dAdd() calls per object, first for the up left corner, then clockwise.
  326.  * Only one texture can be used, but multiple objects can be rendered at a time.
  327.  * g2dBegin*() / g2dEnd() couple can be called multiple times in the loop,
  328.  * to render multiple textures.
  329.  */
  330. void g2dBeginQuads(g2dImage* tex);
  331.  
  332. /**
  333.  * \brief Begins points rendering.
  334.  *
  335.  * This function begins object rendering. Resets all properties.
  336.  * One g2dAdd() call per object.
  337.  */
  338. void g2dBeginPoints();
  339.  
  340. /**
  341.  * \brief Ends object rendering.
  342.  *
  343.  * This function ends object rendering. Must be called after g2dBegin*() to add
  344.  * objects to the display list. Automatically adapts pspgu functionnalities
  345.  * to get the best performance possible.
  346.  */
  347. void g2dEnd();
  348.  
  349. /**
  350.  * \brief Resets current transformation and attribution.
  351.  *
  352.  * This function must be called during object rendering.
  353.  * Calls g2dResetCoord(), g2dResetRotation(), g2dResetScale(),
  354.  * g2dResetColor(), g2dResetAlpha(), g2dResetCrop() and g2dResetTex().
  355.  */
  356. void g2dReset();
  357.  
  358. /**
  359.  * \brief Flips the screen.
  360.  * @param flip_mode A g2dFlip_Mode constant.
  361.  *
  362.  * This function must be called at the end of the loop.
  363.  * Renders the whole display list to the draw buffer.
  364.  * Inverts framebuffers to display the whole thing.
  365.  */
  366. void g2dFlip(g2dFlip_Mode mode);
  367.  
  368. /**
  369.  * \brief Pushes the current transformation & attribution to a new object.
  370.  *
  371.  * This function must be called during object rendering.
  372.  */
  373. void g2dAdd();
  374.  
  375. /**
  376.  * \brief Saves the current transformation to stack.
  377.  *
  378.  * This function must be called during object rendering.
  379.  * The stack is 64 saves high.
  380.  * Use it like the OpenGL one.
  381.  */
  382. void g2dPush();
  383.  
  384. /**
  385.  * \brief Restore the current transformation from stack.
  386.  *
  387.  * This function must be called during object rendering.
  388.  * The stack is 64 saves high.
  389.  * Use it like the OpenGL one.
  390.  */
  391. void g2dPop();
  392.  
  393. /**
  394.  * \brief Frees an image & set its pointer to NULL.
  395.  * @param tex Pointer to the variable which contains the image pointer.
  396.  *
  397.  * This function is used to gain memory when an image is useless.
  398.  * Must pass the pointer to the variable which contains the pointer,
  399.  * to set it to NULL (passing NULL to a g2dBegin* function is safe).
  400.  */
  401. void g2dTexFree(g2dImage** tex);
  402.  
  403. /**
  404.  * \brief Loads an image.
  405.  * @param path Path to the file.
  406.  * @param tex_mode A g2dTex_Mode constant.
  407.  * @returns Pointer to the image.
  408.  *
  409.  * This function loads an image file. There is support for PNG & JPEG files
  410.  * (if USE_PNG and USE_JPEG are defined). Swizzling is enabled only for 16*16+
  411.  * textures (useless on small textures), pass G2D_SWIZZLE to enable it.
  412.  * Image support up to 512*512 only (hardware limitation).
  413.  */
  414. g2dImage* g2dTexLoad(char path[], g2dTex_Mode mode);
  415.  
  416. /**
  417.  * \brief Resets the current coordinates.
  418.  *
  419.  * This function must be called during object rendering.
  420.  * Sets g2dSetCoordMode() to G2D_UP_LEFT and g2dSetCoordXYZ() to (0,0,0).
  421.  */
  422. void g2dResetCoord();
  423.  
  424. /**
  425.  * \brief Set coordinate mode.
  426.  * @param coord_mode A gCoord_Mode.
  427.  *
  428.  * This function must be called during object rendering.
  429.  * Defines where the coordinates correspond in the object.
  430.  */
  431. void g2dSetCoordMode(g2dCoord_Mode mode);
  432.  
  433. /**
  434.  * \brief Gets the current position.
  435.  * @param x Pointer to save the current x (in pixels).
  436.  * @param y Pointer to save the current y (in pixels).
  437.  * @param z Pointer to save the current z (in pixels).
  438.  *
  439.  * This function must be called during object rendering.
  440.  * Parameters are pointers to float, not int !
  441.  * Pass NULL if not needed.
  442.  */
  443. void g2dGetCoordXYZ(float* x, float* y, float* z);
  444.  
  445. /**
  446.  * \brief Sets the new position.
  447.  * @param x New x, in pixels.
  448.  * @param y New y, in pixels.
  449.  *
  450.  * This function must be called during object rendering.
  451.  */
  452. void g2dSetCoordXY(float x, float y);
  453.  
  454. /**
  455.  * \brief Sets the new position, with depth support.
  456.  * @param x New x, in pixels.
  457.  * @param y New y, in pixels.
  458.  * @param z New z, in pixels. (front 0-65535 back)
  459.  *
  460.  * This function must be called during object rendering.
  461.  */
  462. void g2dSetCoordXYZ(float x, float y, float z);
  463.  
  464. /**
  465.  * \brief Sets the new position, relative to the current.
  466.  * @param x New x increment, in pixels.
  467.  * @param y New y increment, in pixels.
  468.  *
  469.  * This function must be called during object rendering.
  470.  */
  471. void g2dSetCoordXYRelative(float x, float y);
  472.  
  473. /**
  474.  * \brief Sets the new position, with depth support, relative to the current.
  475.  * @param x New x increment, in pixels.
  476.  * @param y New y increment, in pixels.
  477.  * @param z New z increment, in pixels.
  478.  *
  479.  * This function must be called during object rendering.
  480.  */
  481. void g2dSetCoordXYZRelative(float x, float y, float z);
  482.  
  483. /**
  484.  * \brief Use integer coordinates.
  485.  * @param use false to desactivate (better look, by default),
  486.               true to activate (can be useful when you have glitches).
  487.  *
  488.  * This function must be called during object rendering.
  489.  */
  490. void g2dSetCoordInteger(bool use);
  491.  
  492. /**
  493.  * \brief Resets the global scale.
  494.  *
  495.  * This function resets the global scale to 1.f.
  496.  * Translations and scales are multiplied by this factor.
  497.  */
  498. void g2dResetGlobalScale();
  499.  
  500. /**
  501.  * \brief Resets the current scale.
  502.  *
  503.  * This function must be called during object rendering.
  504.  * Sets the scale to the current image size or (10,10).
  505.  */
  506. void g2dResetScale();
  507.  
  508. /**
  509.  * \brief Gets the global scale.
  510.  * @param scale Pointer to save the global scale (factor).
  511.  *
  512.  * Pass NULL if not needed.
  513.  */
  514. void g2dGetGlobalScale(float* scale);
  515.  
  516. /**
  517.  * \brief Gets the current scale.
  518.  * @param w Pointer to save the current width (in pixels).
  519.  * @param h Pointer to save the current height (in pixels).
  520.  *
  521.  * This function must be called during object rendering.
  522.  * Parameters are pointers to float, not int !
  523.  * Pass NULL if not needed.
  524.  */
  525. void g2dGetScaleWH(float* w, float* h);
  526.  
  527. /**
  528.  * \brief Sets the global scale.
  529.  *
  530.  * Translations and scales are multiplied by this factor.
  531.  */
  532. void g2dSetGlobalScale(float scale);
  533.  
  534. /**
  535.  * \brief Sets the new scale.
  536.  * @param w Width scale factor.
  537.  * @param h Height scale factor.
  538.  *
  539.  * This function must be called during object rendering.
  540.  * g2dResetScale() is called, then width & height scale are
  541.  * multiplied by these values.
  542.  * Negative values can be passed to invert the image.
  543.  */
  544. void g2dSetScale(float w, float h);
  545.  
  546. /**
  547.  * \brief Sets the new scale, in pixels.
  548.  * @param w New width, in pixels.
  549.  * @param h New height, in pixels.
  550.  *
  551.  * This function must be called during object rendering.
  552.  * Negative values can be passed to invert the image.
  553.  */
  554. void g2dSetScaleWH(float w, float h);
  555.  
  556. /**
  557.  * \brief Sets the new scale, relative to the current.
  558.  * @param w Width scale factor.
  559.  * @param h Height scale factor.
  560.  *
  561.  * This function must be called during object rendering.
  562.  * Current width & height scale are multiplied by these values.
  563.  * Negative values can be passed to invert the image.
  564.  */
  565. void g2dSetScaleRelative(float w, float h);
  566.  
  567. /**
  568.  * \brief Sets the new scale, in pixels, relative to the current.
  569.  * @param w New width to increment, in pixels.
  570.  * @param h New height to increment, in pixels.
  571.  *
  572.  * This function must be called during object rendering.
  573.  * Negative values can be passed to invert the image.
  574.  */
  575. void g2dSetScaleWHRelative(float w, float h);
  576.  
  577. /**
  578.  * \brief Resets the current color.
  579.  *
  580.  * This function must be called during object rendering.
  581.  * Sets g2dSetColor() to WHITE.
  582.  */
  583. void g2dResetColor();
  584.  
  585. /**
  586.  * \brief Resets the current alpha.
  587.  *
  588.  * This function must be called during object rendering.
  589.  * Sets g2dSetAlpha() to 255.
  590.  */
  591. void g2dResetAlpha();
  592.  
  593. /**
  594.  * \brief Gets the current alpha.
  595.  * @param alpha Pointer to save the current alpha (0-255).
  596.  *
  597.  * This function must be called during object rendering.
  598.  * Pass NULL if not needed.
  599.  */
  600. void g2dGetAlpha(g2dAlpha* alpha);
  601.  
  602. /**
  603.  * \brief Sets the new color.
  604.  * @param color The new color.
  605.  *
  606.  * This function must be called during object rendering.
  607.  * Can be used to colorize any object.
  608.  */
  609. void g2dSetColor(g2dColor color);
  610.  
  611. /**
  612.  * \brief Sets the new alpha.
  613.  * @param alpha The new alpha (0-255).
  614.  *
  615.  * This function must be called during object rendering.
  616.  * Can be used to make any object transparent.
  617.  */
  618. void g2dSetAlpha(g2dAlpha alpha);
  619.  
  620. /**
  621.  * \brief Sets the new alpha, relative to the current alpha.
  622.  * @param alpha The new alpha increment.
  623.  *
  624.  * This function must be called during object rendering.
  625.  * Can be used to make any object transparent.
  626.  */
  627. void g2dSetAlphaRelative(int alpha);
  628.  
  629. /**
  630.  * \brief Resets the current rotation.
  631.  *
  632.  * This function must be called during object rendering.
  633.  * Sets g2dSetRotation() to 0°.
  634.  */
  635. void g2dResetRotation();
  636.  
  637. /**
  638.  * \brief Gets the current rotation, in radians.
  639.  * @param radians Pointer to save the current rotation.
  640.  *
  641.  * This function must be called during object rendering.
  642.  * Pass NULL if not needed.
  643.  */
  644. void g2dGetRotationRad(float* radians);
  645.  
  646. /**
  647.  * \brief Gets the current rotation, in degrees.
  648.  * @param degrees Pointer to save the current rotation.
  649.  *
  650.  * This function must be called during object rendering.
  651.  * Pass NULL if not needed.
  652.  */
  653. void g2dGetRotation(float* degrees);
  654.  
  655. /**
  656.  * \brief Sets the new rotation, in radians.
  657.  * @param radians The new angle.
  658.  *
  659.  * This function must be called during object rendering.
  660.  * The rotation center is the actual coordinates.
  661.  */
  662. void g2dSetRotationRad(float radians);
  663.  
  664. /**
  665.  * \brief Sets the new rotation, in degrees.
  666.  * @param degrees The new angle.
  667.  *
  668.  * This function must be called during object rendering.
  669.  * The rotation center is the actual coordinates.
  670.  */
  671. void g2dSetRotation(float degrees);
  672.  
  673. /**
  674.  * \brief Sets the new rotation, relative to the current, in radians.
  675.  * @param radians The new angle increment.
  676.  *
  677.  * This function must be called during object rendering.
  678.  * The rotation center is the actual coordinates.
  679.  */
  680. void g2dSetRotationRadRelative(float radians);
  681.  
  682. /**
  683.  * \brief Sets the new rotation, relative to the current, in degrees.
  684.  * @param degrees The new angle increment.
  685.  *
  686.  * This function must be called during object rendering.
  687.  * The rotation center is the actual coordinates.
  688.  */
  689. void g2dSetRotationRelative(float degrees);
  690.  
  691. /**
  692.  * \brief Resets the current crop.
  693.  *
  694.  * This function must be called during object rendering.
  695.  * Sets g2dSetCropXY() to (0;0) and g2dSetCropWH() to (tex->w,tex->h).
  696.  */
  697. void g2dResetCrop();
  698.  
  699. /**
  700.  * \brief Gets the current crop position.
  701.  * @param x Pointer to save the current crop x.
  702.  * @param y Pointer to save the current crop y.
  703.  *
  704.  * This function must be called during object rendering.
  705.  * Pass NULL if not needed.
  706.  */
  707. void g2dGetCropXY(int* x, int* y);
  708.  
  709. /**
  710.  * \brief Gets the current crop scale.
  711.  * @param w Pointer to save the current crop width.
  712.  * @param h Pointer to save the current crop height.
  713.  *
  714.  * This function must be called during object rendering.
  715.  * Pass NULL if not needed.
  716.  */
  717. void g2dGetCropWH(int* w, int* h);
  718.  
  719. /**
  720.  * \brief Sets the new crop position.
  721.  * @param x New x, in pixels.
  722.  * @param y New y, in pixels.
  723.  *
  724.  * This function must be called during object rendering. Defines crop position.
  725.  * If the rectangle is larger or next to the image, texture will be repeated
  726.  * when g2dSetTexRepeat is enabled. Useful for a tileset.
  727.  */
  728. void g2dSetCropXY(int x, int y);
  729.  
  730. /**
  731.  * \brief Sets the new crop size.
  732.  * @param w New width, in pixels.
  733.  * @param h New height, in pixels.
  734.  *
  735.  * This function must be called during object rendering. Defines crop size.
  736.  * If the rectangle is larger or next to the image, texture will be repeated
  737.  * when g2dSetTexRepeat is enabled. Useful for a tileset.
  738.  */
  739. void g2dSetCropWH(int w, int h);
  740.  
  741. /**
  742.  * \brief Sets the new crop position, relative to the current.
  743.  * @param x New x increment, in pixels.
  744.  * @param y New y increment, in pixels.
  745.  *
  746.  * This function must be called during object rendering. Defines crop position.
  747.  * If the rectangle is larger or next to the image, texture will be repeated
  748.  * when g2dSetTexRepeat is enabled. Useful for a tileset.
  749.  */
  750. void g2dSetCropXYRelative(int x, int y);
  751.  
  752. /**
  753.  * \brief Sets the new crop size, relative to the current.
  754.  * @param w New width increment, in pixels.
  755.  * @param h New height increment, in pixels.
  756.  *
  757.  * This function must be called during object rendering. Defines crop size.
  758.  * If the rectangle is larger or next to the image, texture will be repeated
  759.  * when g2dSetTexRepeat is enabled. Useful for a tileset.
  760.  */
  761. void g2dSetCropWHRelative(int w, int h);
  762.  
  763. /**
  764.  * \brief Resets texture properties.
  765.  *
  766.  * This function must be called during object rendering.
  767.  */
  768. void g2dResetTex();
  769.  
  770. /**
  771.  * \brief Set texture wrap.
  772.  * @param use true to repeat, false to clamp (by default).
  773.  *
  774.  * This function must be called during object rendering.
  775.  */
  776. void g2dSetTexRepeat(bool use);
  777.  
  778. /**
  779.  * \brief Use alpha blending with the texture.
  780.  * @param use true to activate (better look, by default),
  781.               false to desactivate (better performance).
  782.  *
  783.  * This function must be called during object rendering.
  784.  * Automaticaly disabled when g2dImage::can_blend is set to false.
  785.  */
  786. void g2dSetTexBlend(bool use);
  787.  
  788. /**
  789.  * \brief Use the bilinear filter with the texture.
  790.  * @param use true to activate (better look, by default).
  791.               false to desactivate (better performance).
  792.  *
  793.  * This function must be called during object rendering.
  794.  * Only useful when scaling.
  795.  */
  796. void g2dSetTexLinear(bool use);
  797.  
  798. /**
  799.  * \brief Resets the draw zone to the entire screen.
  800.  *
  801.  * This function can be called everywhere in the loop.
  802.  */
  803. void g2dResetScissor();
  804.  
  805. /**
  806.  * \brief Sets the draw zone.
  807.  * @param x New x position.
  808.  * @param y New y position.
  809.  * @param w New width.
  810.  * @param h New height.
  811.  *
  812.  * This function can be called everywhere in the loop.
  813.  * Pixel draw will be skipped outside this rectangle.
  814.  */
  815. void g2dSetScissor(int x, int y, int w, int h);
  816.  
  817. #ifdef __cplusplus
  818. }
  819. #endif
  820.  
  821. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement