12#include <gx2/context.h>
13#include <gx2/display.h>
16#include <gx2/registers.h>
17#include <gx2/shaders.h>
19#include <gx2/surface.h>
20#include <gx2/sampler.h>
21#include <gx2/texture.h>
25static inline void GX2InitAttribStream(GX2AttribStream *attrib, uint32_t location, uint32_t buffer, uint32_t offset, GX2AttribFormat format)
27 attrib->location = location;
28 attrib->buffer = buffer;
29 attrib->offset = offset;
30 attrib->format = format;
31 attrib->type = GX2_ATTRIB_INDEX_PER_VERTEX;
32 attrib->aluDivisor = 0;
33 attrib->mask = 0x00010203;
34 attrib->endianSwap = GX2_ENDIAN_SWAP_DEFAULT;
39static inline void GX2InitTexture(GX2Texture *texture, uint32_t width, uint32_t height, uint32_t depth, uint32_t mipLevels, GX2SurfaceFormat format, GX2SurfaceDim dim, GX2TileMode tileMode)
41 memset(texture, 0,
sizeof(GX2Texture));
42 texture->surface.dim = dim;
43 texture->surface.width = width;
44 texture->surface.height = height;
45 texture->surface.depth = (depth == 0) ? 1 : depth;
46 texture->surface.mipLevels = (mipLevels == 0) ? 1 : mipLevels;
47 texture->surface.format = format;
48 texture->surface.aa = GX2_AA_MODE1X;
49 texture->surface.use = GX2_SURFACE_USE_TEXTURE;
50 texture->surface.tileMode = tileMode;
51 GX2CalcSurfaceSizeAndAlignment(&texture->surface);
53 texture->viewFirstMip = 0;
54 texture->viewNumMips = texture->surface.mipLevels;
55 texture->viewFirstSlice = 0;
56 texture->viewNumSlices = 1;
57 texture->compMap = 0x00010203;
59 GX2InitTextureRegs(texture);
81 static void draw(int32_t primitive = GX2_PRIMITIVE_MODE_QUADS, uint32_t vtxCount = 4)
83 GX2DrawEx(
static_cast<GX2PrimitiveMode
>(primitive), vtxCount, 0, 1);
static const uint16_t cuVertexAttrSize
Size in bytes of one position vertex (3 floats)
static const uint16_t cuTexCoordAttrSize
Size in bytes of one texture coordinate (2 floats)
static void draw(int32_t primitive=GX2_PRIMITIVE_MODE_QUADS, uint32_t vtxCount=4)
Issues the draw call for the currently bound shaders and attribute buffers.
static const uint16_t cuColorAttrSize
Size in bytes of one vertex color (4 bytes, RGBA)