Advertisement
GeeckoDev

glib2d.h - PC

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