OldSchool Library
|
This section provides basic guidance on drawing textured and untextured objects, assuming some familiarity with GU (Graphics Utility). Here's a basic example of drawing a textured object and an untextured object: \code void drawSomethingTextured(OSL_IMAGE *img) { // Define the vertices for your shape. Sprites use 2 vertices, triangles use 3, and quads use 4. VERTEX_TYPE *vertices; // Set the provided image as the current texture oslSetTexture(img); // Allocate memory for the vertices vertices = (VERTEX_TYPE*)sceGuGetMemory(NUMBER_OF_VERTICES * sizeof(vertices[0])); // Initialize the vertex data vertices[0].something = ...; // [Additional vertex data setup] // Draw the array of vertices using GU (Graphics Utility) sceGuDrawArray(PRIMITIVETYPE, VERTEX_DESCRIPTION | GU_TRANSFORM_2D, NUMBER_OF_VERTICES, 0, vertices); } void drawSomethingUntextured(OSL_IMAGE *img) { // Define the vertices for your shape. Sprites use 2 vertices, triangles use 3, and quads use 4. VERTEX_TYPE *vertices; // Disable texturing oslDisableTexturing(); // Allocate memory for the vertices vertices = (VERTEX_TYPE*)sceGuGetMemory(NUMBER_OF_VERTICES * sizeof(vertices[0])); // Initialize the vertex data vertices[0].something = ...; // [Additional vertex data setup] // Draw the array of vertices using GU sceGuDrawArray(PRIMITIVETYPE, VERTEX_DESCRIPTION | GU_TRANSFORM_2D, NUMBER_OF_VERTICES, 0, vertices); } \endcode As you can see, drawing with GU is straightforward if you are familiar with it. For those new to GU, it is recommended to review tutorials and examples available on ps2dev.org for a deeper understanding.