mirror of
https://github.com/yawut/SDL.git
synced 2026-03-21 17:34:36 -05:00
render/wiiu: Use vec* for u_texSize and u_viewSize
This commit is contained in:
parent
eba4263f00
commit
fcb1d21683
|
|
@ -127,9 +127,9 @@ int WIIU_SDL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
GX2SetPixelSampler(&tdata->sampler, 0);
|
||||
GX2RSetAttributeBuffer(a_position, 0, a_position->elemSize, 0);
|
||||
GX2RSetAttributeBuffer(a_texCoord, 1, a_texCoord->elemSize, 0);
|
||||
GX2SetVertexUniformReg(wiiuTextureShader.vertexShader->uniformVars[0].offset, 4, (uint32_t *)data->u_viewSize);
|
||||
GX2SetVertexUniformReg(wiiuTextureShader.vertexShader->uniformVars[1].offset, 4, (uint32_t *)tdata->u_texSize);
|
||||
GX2SetPixelUniformReg(wiiuTextureShader.pixelShader->uniformVars[0].offset, 4, (uint32_t*)&u_mod);
|
||||
GX2SetVertexUniformReg(wiiuTextureShader.vertexShader->uniformVars[0].offset, 4, (uint32_t *)&data->u_viewSize);
|
||||
GX2SetVertexUniformReg(wiiuTextureShader.vertexShader->uniformVars[1].offset, 4, (uint32_t *)&tdata->u_texSize);
|
||||
GX2SetPixelUniformReg(wiiuTextureShader.pixelShader->uniformVars[0].offset, 4, (uint32_t *)&u_mod);
|
||||
WIIU_SDL_SetGX2BlendMode(texture->blendMode);
|
||||
GX2DrawEx(GX2_PRIMITIVE_MODE_QUADS, 4, 0, 1);
|
||||
|
||||
|
|
@ -239,9 +239,9 @@ int WIIU_SDL_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
GX2SetPixelSampler(&tdata->sampler, 0);
|
||||
GX2RSetAttributeBuffer(a_position, 0, a_position->elemSize, 0);
|
||||
GX2RSetAttributeBuffer(a_texCoord, 1, a_texCoord->elemSize, 0);
|
||||
GX2SetVertexUniformReg(wiiuTextureShader.vertexShader->uniformVars[0].offset, 4, (uint32_t *)data->u_viewSize);
|
||||
GX2SetVertexUniformReg(wiiuTextureShader.vertexShader->uniformVars[1].offset, 4, (uint32_t *)tdata->u_texSize);
|
||||
GX2SetPixelUniformReg(wiiuTextureShader.pixelShader->uniformVars[0].offset, 4, (uint32_t*)&u_mod);
|
||||
GX2SetVertexUniformReg(wiiuTextureShader.vertexShader->uniformVars[0].offset, 4, (uint32_t *)&data->u_viewSize);
|
||||
GX2SetVertexUniformReg(wiiuTextureShader.vertexShader->uniformVars[1].offset, 4, (uint32_t *)&tdata->u_texSize);
|
||||
GX2SetPixelUniformReg(wiiuTextureShader.pixelShader->uniformVars[0].offset, 4, (uint32_t *)&u_mod);
|
||||
WIIU_SDL_SetGX2BlendMode(texture->blendMode);
|
||||
GX2DrawEx(GX2_PRIMITIVE_MODE_QUADS, 4, 0, 1);
|
||||
|
||||
|
|
@ -286,8 +286,8 @@ int WIIU_SDL_RenderDrawPoints(SDL_Renderer * renderer, const SDL_FPoint * points
|
|||
GX2SetContextState(data->ctx);
|
||||
wiiuSetColorShader();
|
||||
GX2RSetAttributeBuffer(a_position, 0, a_position->elemSize, 0);
|
||||
GX2SetVertexUniformReg(wiiuColorShader.vertexShader->uniformVars[0].offset, 4, (uint32_t *)data->u_viewSize);
|
||||
GX2SetPixelUniformReg(wiiuColorShader.pixelShader->uniformVars[0].offset, 4, (uint32_t*)&u_colour);
|
||||
GX2SetVertexUniformReg(wiiuColorShader.vertexShader->uniformVars[0].offset, 4, (uint32_t *)&data->u_viewSize);
|
||||
GX2SetPixelUniformReg(wiiuColorShader.pixelShader->uniformVars[0].offset, 4, (uint32_t *)&u_colour);
|
||||
WIIU_SDL_SetGX2BlendMode(renderer->blendMode);
|
||||
GX2DrawEx(GX2_PRIMITIVE_MODE_POINTS, count, 0, 1);
|
||||
|
||||
|
|
@ -333,8 +333,8 @@ int WIIU_SDL_RenderDrawLines(SDL_Renderer * renderer, const SDL_FPoint * points,
|
|||
GX2SetContextState(data->ctx);
|
||||
wiiuSetColorShader();
|
||||
GX2RSetAttributeBuffer(a_position, 0, a_position->elemSize, 0);
|
||||
GX2SetVertexUniformReg(wiiuColorShader.vertexShader->uniformVars[0].offset, 4, (uint32_t *)data->u_viewSize);
|
||||
GX2SetPixelUniformReg(wiiuColorShader.pixelShader->uniformVars[0].offset, 4, (uint32_t*)&u_colour);
|
||||
GX2SetVertexUniformReg(wiiuColorShader.vertexShader->uniformVars[0].offset, 4, (uint32_t *)&data->u_viewSize);
|
||||
GX2SetPixelUniformReg(wiiuColorShader.pixelShader->uniformVars[0].offset, 4, (uint32_t *)&u_colour);
|
||||
WIIU_SDL_SetGX2BlendMode(renderer->blendMode);
|
||||
GX2DrawEx(GX2_PRIMITIVE_MODE_LINE_STRIP, count, 0, 1);
|
||||
|
||||
|
|
@ -394,8 +394,8 @@ int WIIU_SDL_RenderFillRects(SDL_Renderer * renderer, const SDL_FRect * rects, i
|
|||
GX2SetContextState(data->ctx);
|
||||
wiiuSetColorShader();
|
||||
GX2RSetAttributeBuffer(a_position, 0, a_position->elemSize, 0);
|
||||
GX2SetVertexUniformReg(wiiuColorShader.vertexShader->uniformVars[0].offset, 4, (uint32_t *)data->u_viewSize);
|
||||
GX2SetPixelUniformReg(wiiuColorShader.pixelShader->uniformVars[0].offset, 4, (uint32_t*)&u_colour);
|
||||
GX2SetVertexUniformReg(wiiuColorShader.vertexShader->uniformVars[0].offset, 4, (uint32_t *)&data->u_viewSize);
|
||||
GX2SetPixelUniformReg(wiiuColorShader.pixelShader->uniformVars[0].offset, 4, (uint32_t *)&u_colour);
|
||||
WIIU_SDL_SetGX2BlendMode(renderer->blendMode);
|
||||
GX2DrawEx(GX2_PRIMITIVE_MODE_QUADS, 4 * count, 0, 1);
|
||||
|
||||
|
|
|
|||
|
|
@ -144,8 +144,10 @@ int WIIU_SDL_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
}
|
||||
|
||||
// Update u_viewSize
|
||||
data->u_viewSize[0] = target->surface.width;
|
||||
data->u_viewSize[1] = target->surface.height;
|
||||
data->u_viewSize = (WIIUVec4) {
|
||||
.x = (float)target->surface.width,
|
||||
.y = (float)target->surface.height,
|
||||
};
|
||||
|
||||
// Update context state
|
||||
GX2SetContextState(data->ctx);
|
||||
|
|
|
|||
|
|
@ -31,6 +31,24 @@
|
|||
#include <gx2/sampler.h>
|
||||
#include <gx2r/buffer.h>
|
||||
|
||||
typedef struct {
|
||||
union { float x, r; };
|
||||
union { float y, g; };
|
||||
} WIIUVec2;
|
||||
|
||||
typedef struct {
|
||||
union { float x, r; };
|
||||
union { float y, g; };
|
||||
union { float z, b; };
|
||||
} WIIUVec3;
|
||||
|
||||
typedef struct {
|
||||
union { float x, r; };
|
||||
union { float y, g; };
|
||||
union { float z, b; };
|
||||
union { float w, a; };
|
||||
} WIIUVec4;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void *next;
|
||||
|
|
@ -38,20 +56,18 @@ typedef struct
|
|||
} WIIU_RenderAllocData;
|
||||
|
||||
//Driver internal data structures
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
GX2ContextState *ctx;
|
||||
WIIU_RenderAllocData *listfree;
|
||||
float u_viewSize[4];
|
||||
WIIUVec4 u_viewSize;
|
||||
SDL_Texture windowTex;
|
||||
} WIIU_RenderData;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
GX2Sampler sampler;
|
||||
GX2Texture texture;
|
||||
GX2ColorBuffer cbuf;
|
||||
float u_texSize[4];
|
||||
WIIUVec4 u_texSize;
|
||||
} WIIU_TextureData;
|
||||
|
||||
static inline GX2RBuffer* WIIU_AllocRenderData(WIIU_RenderData *r, GX2RBuffer buffer) {
|
||||
|
|
@ -131,22 +147,6 @@ static inline Uint32 TextureNextPow2(Uint32 w) {
|
|||
return n;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
union { float x, r; };
|
||||
union { float y, g; };
|
||||
} WIIUVec2;
|
||||
typedef struct {
|
||||
union { float x, r; };
|
||||
union { float y, g; };
|
||||
union { float z, b; };
|
||||
} WIIUVec3;
|
||||
typedef struct {
|
||||
union { float x, r; };
|
||||
union { float y, g; };
|
||||
union { float z, b; };
|
||||
union { float w, a; };
|
||||
} WIIUVec4;
|
||||
|
||||
typedef struct WIIUPixFmt {
|
||||
GX2SurfaceFormat fmt;
|
||||
uint32_t compMap;
|
||||
|
|
|
|||
|
|
@ -17,14 +17,14 @@
|
|||
#define SCREEN_WIDTH 1280
|
||||
#define SCREEN_HEIGHT 720
|
||||
|
||||
static const float u_viewSize[4] = {(float)SCREEN_WIDTH, (float)SCREEN_HEIGHT};
|
||||
static const WIIUVec4 u_viewSize = {.x = (float)SCREEN_WIDTH, .y = (float)SCREEN_HEIGHT};
|
||||
|
||||
static void render_scene(SDL_Renderer * renderer) {
|
||||
WIIU_RenderData *data = (WIIU_RenderData *) renderer->driverdata;
|
||||
WIIU_TextureData *tdata = (WIIU_TextureData *) data->windowTex.driverdata;
|
||||
|
||||
float tex_w = tdata->u_texSize[0];
|
||||
float tex_h = tdata->u_texSize[1];
|
||||
float tex_w = tdata->u_texSize.x;
|
||||
float tex_h = tdata->u_texSize.y;
|
||||
int win_x, win_y, win_w, win_h;
|
||||
GX2RBuffer *a_position, *a_texCoord;
|
||||
WIIUVec2 *a_position_vals, *a_texCoord_vals;
|
||||
|
|
@ -85,8 +85,8 @@ static void render_scene(SDL_Renderer * renderer) {
|
|||
WHBGfxClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
wiiuSetTextureShader();
|
||||
|
||||
GX2SetVertexUniformReg(wiiuTextureShader.vertexShader->uniformVars[0].offset, 4, (uint32_t *)u_viewSize);
|
||||
GX2SetVertexUniformReg(wiiuTextureShader.vertexShader->uniformVars[1].offset, 4, (uint32_t *)tdata->u_texSize);
|
||||
GX2SetVertexUniformReg(wiiuTextureShader.vertexShader->uniformVars[0].offset, 4, (uint32_t *)&u_viewSize);
|
||||
GX2SetVertexUniformReg(wiiuTextureShader.vertexShader->uniformVars[1].offset, 4, (uint32_t *)&tdata->u_texSize);
|
||||
GX2SetPixelUniformReg(wiiuTextureShader.pixelShader->uniformVars[0].offset, 4, (uint32_t*)u_mod);
|
||||
|
||||
GX2RSetAttributeBuffer(a_position, 0, a_position->elemSize, 0);
|
||||
|
|
|
|||
|
|
@ -102,8 +102,10 @@ int WIIU_SDL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
tdata->u_texSize[0] = texture->w;
|
||||
tdata->u_texSize[1] = texture->h;
|
||||
tdata->u_texSize = (WIIUVec4) {
|
||||
.x = texture->w,
|
||||
.y = texture->h,
|
||||
};
|
||||
|
||||
texture->driverdata = tdata;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user