Asset manager is now in charge of the loaded assets.
This commit is contained in:
@ -61,8 +61,8 @@ elseif(TARGET_TYPE STREQUAL game)
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Textures
|
# Textures
|
||||||
tool_copy(texture_test
|
tool_texture(texture_test
|
||||||
${ASSETS_SOURCE_DIR}/shared/textures/test_texture.png textures/test_texture.png
|
${ASSETS_SOURCE_DIR}/shared/textures/test_texture.png textures/test_texture
|
||||||
)
|
)
|
||||||
|
|
||||||
# Locales
|
# Locales
|
||||||
|
@ -268,8 +268,7 @@ bool assetManagerItemIsFinished(assetmanageritem_t *item) {
|
|||||||
|
|
||||||
// Font
|
// Font
|
||||||
assetmanageritem_t * assetManagerLoadFont(
|
assetmanageritem_t * assetManagerLoadFont(
|
||||||
assetmanager_t *manager, assetmanagerowner_t owner,
|
assetmanager_t *manager, assetmanagerowner_t owner, char *fileName
|
||||||
font_t *font, char *fileName
|
|
||||||
) {
|
) {
|
||||||
assetmanageritem_t *item;
|
assetmanageritem_t *item;
|
||||||
item = assetManagerItemGet(manager, fileName);
|
item = assetManagerItemGet(manager, fileName);
|
||||||
@ -277,7 +276,6 @@ assetmanageritem_t * assetManagerLoadFont(
|
|||||||
item = assetManagerItemAdd(manager, fileName);
|
item = assetManagerItemAdd(manager, fileName);
|
||||||
item->type = ASSET_MANAGER_TYPE_FONT;
|
item->type = ASSET_MANAGER_TYPE_FONT;
|
||||||
item->data.font.fileName = fileName;
|
item->data.font.fileName = fileName;
|
||||||
item->data.font.font = font;
|
|
||||||
}
|
}
|
||||||
assetManagerItemGetOrAddHolder(item, owner);
|
assetManagerItemGetOrAddHolder(item, owner);
|
||||||
|
|
||||||
@ -290,20 +288,19 @@ bool _assetManagerLoaderFontAsync(assetmanageritem_t *item) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool _assetManagerLoaderFontSync(assetmanageritem_t *item) {
|
bool _assetManagerLoaderFontSync(assetmanageritem_t *item) {
|
||||||
fontInit(item->data.font.font, item->data.font.data);
|
fontInit(&item->data.font.font, item->data.font.data);
|
||||||
free(item->data.font.data);
|
free(item->data.font.data);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _assetManagerLoaderFontDispose(assetmanageritem_t *item) {
|
bool _assetManagerLoaderFontDispose(assetmanageritem_t *item) {
|
||||||
fontDispose(item->data.font.font);
|
fontDispose(&item->data.font.font);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Texture
|
// Texture
|
||||||
assetmanageritem_t * assetManagerLoadTexture(
|
assetmanageritem_t * assetManagerLoadTexture(
|
||||||
assetmanager_t *manager, assetmanagerowner_t owner,
|
assetmanager_t *manager, assetmanagerowner_t owner, char *fileName
|
||||||
texture_t *texture, char *fileName
|
|
||||||
) {
|
) {
|
||||||
assetmanageritem_t *item;
|
assetmanageritem_t *item;
|
||||||
item = assetManagerItemGet(manager, fileName);
|
item = assetManagerItemGet(manager, fileName);
|
||||||
@ -311,7 +308,6 @@ assetmanageritem_t * assetManagerLoadTexture(
|
|||||||
item = assetManagerItemAdd(manager, fileName);
|
item = assetManagerItemAdd(manager, fileName);
|
||||||
item->type = ASSET_MANAGER_TYPE_TEXTURE;
|
item->type = ASSET_MANAGER_TYPE_TEXTURE;
|
||||||
item->data.texture.fileName = fileName;
|
item->data.texture.fileName = fileName;
|
||||||
item->data.texture.texture = texture;
|
|
||||||
}
|
}
|
||||||
assetManagerItemGetOrAddHolder(item, owner);
|
assetManagerItemGetOrAddHolder(item, owner);
|
||||||
|
|
||||||
@ -348,7 +344,7 @@ bool _assetManagerLoaderTextureAsync(assetmanageritem_t *item) {
|
|||||||
bool _assetManagerLoaderTextureSync(assetmanageritem_t *item) {
|
bool _assetManagerLoaderTextureSync(assetmanageritem_t *item) {
|
||||||
// Turn into a texture.
|
// Turn into a texture.
|
||||||
textureInit(
|
textureInit(
|
||||||
item->data.texture.texture,
|
&item->data.texture.texture,
|
||||||
item->data.texture.width,
|
item->data.texture.width,
|
||||||
item->data.texture.height,
|
item->data.texture.height,
|
||||||
item->data.texture.data
|
item->data.texture.data
|
||||||
@ -360,16 +356,16 @@ bool _assetManagerLoaderTextureSync(assetmanageritem_t *item) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool _assetManagerLoaderTextureDispose(assetmanageritem_t *item) {
|
bool _assetManagerLoaderTextureDispose(assetmanageritem_t *item) {
|
||||||
textureDispose(item->data.texture.texture);
|
textureDispose(&item->data.texture.texture);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scaled Texture
|
// Scaled Texture
|
||||||
assetmanageritem_t * assetManagerLoadScaledTexture(
|
assetmanageritem_t * assetManagerLoadScaledTexture(
|
||||||
assetmanager_t *manager, assetmanagerowner_t owner,
|
assetmanager_t *manager, assetmanagerowner_t owner, char *path, char *file
|
||||||
scaledtexture_t *st, char *path, char *file
|
|
||||||
) {
|
) {
|
||||||
assetmanageritem_t *item;
|
assetmanageritem_t *item;
|
||||||
|
scaledtexture_t *st;
|
||||||
char buffer[ASSET_MANAGER_ITEM_NAME_MAX];
|
char buffer[ASSET_MANAGER_ITEM_NAME_MAX];
|
||||||
sprintf(buffer, "%s/%s", path, file);
|
sprintf(buffer, "%s/%s", path, file);
|
||||||
item = assetManagerItemGet(manager, buffer);
|
item = assetManagerItemGet(manager, buffer);
|
||||||
@ -377,8 +373,7 @@ assetmanageritem_t * assetManagerLoadScaledTexture(
|
|||||||
item = assetManagerItemAdd(manager, buffer);
|
item = assetManagerItemAdd(manager, buffer);
|
||||||
|
|
||||||
item->type = ASSET_MANAGER_TYPE_SCALED_TEXTURE;
|
item->type = ASSET_MANAGER_TYPE_SCALED_TEXTURE;
|
||||||
item->data.scaledTexture.scaledTexture = st;
|
st = &item->data.scaledTexture.scaledTexture;
|
||||||
|
|
||||||
st->scaleCount = 0;
|
st->scaleCount = 0;
|
||||||
st->baseWidth = 0;
|
st->baseWidth = 0;
|
||||||
st->baseHeight = 0;
|
st->baseHeight = 0;
|
||||||
@ -397,7 +392,7 @@ bool _assetManagerLoaderScaledTextureAsync(assetmanageritem_t *item) {
|
|||||||
xml_t *child;
|
xml_t *child;
|
||||||
int16_t i, j;
|
int16_t i, j;
|
||||||
scaledtexture_t *st;
|
scaledtexture_t *st;
|
||||||
st = item->data.scaledTexture.scaledTexture;
|
st = &item->data.scaledTexture.scaledTexture;
|
||||||
|
|
||||||
// Begin loading texture XML
|
// Begin loading texture XML
|
||||||
sprintf(buffer, "%s/%s.xml", st->path, st->file);
|
sprintf(buffer, "%s/%s.xml", st->path, st->file);
|
||||||
@ -434,7 +429,7 @@ bool _assetManagerLoaderScaledTextureAsync(assetmanageritem_t *item) {
|
|||||||
// Texture Scale
|
// Texture Scale
|
||||||
assetmanageritem_t * assetManagerLoadTextureScale(
|
assetmanageritem_t * assetManagerLoadTextureScale(
|
||||||
assetmanager_t *manager, assetmanagerowner_t owner,
|
assetmanager_t *manager, assetmanagerowner_t owner,
|
||||||
scaledtexture_t *st, texture_t *text, uint8_t scale
|
scaledtexture_t *st, uint8_t scale
|
||||||
) {
|
) {
|
||||||
assetmanageritem_t *item;
|
assetmanageritem_t *item;
|
||||||
char buffer[ASSET_MANAGER_ITEM_NAME_MAX];
|
char buffer[ASSET_MANAGER_ITEM_NAME_MAX];
|
||||||
@ -444,7 +439,6 @@ assetmanageritem_t * assetManagerLoadTextureScale(
|
|||||||
item = assetManagerItemAdd(manager, buffer);
|
item = assetManagerItemAdd(manager, buffer);
|
||||||
item->type = ASSET_MANAGER_TYPE_SCALE_TEXTURE;
|
item->type = ASSET_MANAGER_TYPE_SCALE_TEXTURE;
|
||||||
item->data.scaleTexture.scale = scale;
|
item->data.scaleTexture.scale = scale;
|
||||||
item->data.scaleTexture.texture = text;
|
|
||||||
item->data.scaleTexture.scaledTexture = st;
|
item->data.scaleTexture.scaledTexture = st;
|
||||||
}
|
}
|
||||||
assetManagerItemGetOrAddHolder(item, owner);
|
assetManagerItemGetOrAddHolder(item, owner);
|
||||||
@ -485,7 +479,7 @@ bool _assetManagerLoaderTextureScaleSync(assetmanageritem_t *item) {
|
|||||||
sts = st->scales + item->data.scaleTexture.scale;
|
sts = st->scales + item->data.scaleTexture.scale;
|
||||||
|
|
||||||
textureInit(
|
textureInit(
|
||||||
item->data.scaleTexture.texture,
|
&item->data.scaleTexture.texture,
|
||||||
sts->width, sts->height,
|
sts->width, sts->height,
|
||||||
item->data.scaleTexture.data
|
item->data.scaleTexture.data
|
||||||
);
|
);
|
||||||
@ -495,14 +489,14 @@ bool _assetManagerLoaderTextureScaleSync(assetmanageritem_t *item) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool _assetManagerLoaderTextureScaleDispose(assetmanageritem_t *item) {
|
bool _assetManagerLoaderTextureScaleDispose(assetmanageritem_t *item) {
|
||||||
textureDispose(item->data.scaleTexture.texture);
|
textureDispose(&item->data.scaleTexture.texture);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shader
|
// Shader
|
||||||
assetmanageritem_t * assetManagerLoadShader(
|
assetmanageritem_t * assetManagerLoadShader(
|
||||||
assetmanager_t *manager, assetmanagerowner_t owner,
|
assetmanager_t *manager, assetmanagerowner_t owner,
|
||||||
shader_t *shader, char *fileVert, char *fileFrag
|
char *fileVert, char *fileFrag
|
||||||
) {
|
) {
|
||||||
assetmanageritem_t *item;
|
assetmanageritem_t *item;
|
||||||
char buffer[ASSET_MANAGER_ITEM_NAME_MAX];
|
char buffer[ASSET_MANAGER_ITEM_NAME_MAX];
|
||||||
@ -511,7 +505,6 @@ assetmanageritem_t * assetManagerLoadShader(
|
|||||||
if(item == NULL) {
|
if(item == NULL) {
|
||||||
item = assetManagerItemAdd(manager, buffer);
|
item = assetManagerItemAdd(manager, buffer);
|
||||||
item->type = ASSET_MANAGER_TYPE_SHADER;
|
item->type = ASSET_MANAGER_TYPE_SHADER;
|
||||||
item->data.shader.shader = shader;
|
|
||||||
item->data.shader.fileVert = fileVert;
|
item->data.shader.fileVert = fileVert;
|
||||||
item->data.shader.fileFrag = fileFrag;
|
item->data.shader.fileFrag = fileFrag;
|
||||||
}
|
}
|
||||||
@ -534,7 +527,7 @@ bool _assetManagerLoaderShaderAsync(assetmanageritem_t *item) {
|
|||||||
|
|
||||||
bool _assetManagerLoaderShaderSync(assetmanageritem_t *item) {
|
bool _assetManagerLoaderShaderSync(assetmanageritem_t *item) {
|
||||||
shaderInit(
|
shaderInit(
|
||||||
item->data.shader.shader,
|
&item->data.shader.shader,
|
||||||
item->data.shader.dataVert,
|
item->data.shader.dataVert,
|
||||||
item->data.shader.dataFrag
|
item->data.shader.dataFrag
|
||||||
);
|
);
|
||||||
@ -544,6 +537,6 @@ bool _assetManagerLoaderShaderSync(assetmanageritem_t *item) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool _assetManagerLoaderShaderDispose(assetmanageritem_t *item) {
|
bool _assetManagerLoaderShaderDispose(assetmanageritem_t *item) {
|
||||||
shaderDispose(item->data.shader.shader);
|
shaderDispose(&item->data.shader.shader);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
@ -38,31 +38,31 @@
|
|||||||
|
|
||||||
// Loader Types
|
// Loader Types
|
||||||
typedef struct {
|
typedef struct {
|
||||||
font_t *font;
|
font_t font;
|
||||||
char *fileName;
|
char *fileName;
|
||||||
char *data;
|
char *data;
|
||||||
} assetmanagerfont_t;
|
} assetmanagerfont_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
texture_t *texture;
|
texture_t texture;
|
||||||
char *fileName;
|
char *fileName;
|
||||||
int32_t width, height;
|
int32_t width, height;
|
||||||
pixel_t *data;
|
pixel_t *data;
|
||||||
} assetmanagertexture_t;
|
} assetmanagertexture_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
scaledtexture_t *scaledTexture;
|
scaledtexture_t scaledTexture;
|
||||||
} assetmanagerscaledtexture_t;
|
} assetmanagerscaledtexture_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
scaledtexture_t *scaledTexture;
|
scaledtexture_t *scaledTexture;
|
||||||
texture_t *texture;
|
texture_t texture;
|
||||||
uint8_t scale;
|
uint8_t scale;
|
||||||
pixel_t *data;
|
pixel_t *data;
|
||||||
} assetmanagerscaletexture_t;
|
} assetmanagerscaletexture_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
shader_t *shader;
|
shader_t shader;
|
||||||
char *fileVert;
|
char *fileVert;
|
||||||
char *fileFrag;
|
char *fileFrag;
|
||||||
char *dataVert;
|
char *dataVert;
|
||||||
@ -205,8 +205,7 @@ bool assetManagerItemIsFinished(assetmanageritem_t *item);
|
|||||||
* @return A pointer to the asset manager item for tracking.
|
* @return A pointer to the asset manager item for tracking.
|
||||||
*/
|
*/
|
||||||
assetmanageritem_t * assetManagerLoadFont(
|
assetmanageritem_t * assetManagerLoadFont(
|
||||||
assetmanager_t *manager, assetmanagerowner_t owner,
|
assetmanager_t *manager, assetmanagerowner_t owner, char *fileName
|
||||||
font_t *font, char *fileName
|
|
||||||
);
|
);
|
||||||
|
|
||||||
bool _assetManagerLoaderFontAsync(assetmanageritem_t *item);
|
bool _assetManagerLoaderFontAsync(assetmanageritem_t *item);
|
||||||
@ -223,8 +222,7 @@ bool _assetManagerLoaderFontDispose(assetmanageritem_t *item);
|
|||||||
* @return A pointer to the asset manager item for tracking.
|
* @return A pointer to the asset manager item for tracking.
|
||||||
*/
|
*/
|
||||||
assetmanageritem_t * assetManagerLoadTexture(
|
assetmanageritem_t * assetManagerLoadTexture(
|
||||||
assetmanager_t *manager, assetmanagerowner_t owner,
|
assetmanager_t *manager, assetmanagerowner_t owner, char *fileName
|
||||||
texture_t *texture, char *fileName
|
|
||||||
);
|
);
|
||||||
|
|
||||||
bool _assetManagerLoaderTextureAsync(assetmanageritem_t *item);
|
bool _assetManagerLoaderTextureAsync(assetmanageritem_t *item);
|
||||||
@ -237,14 +235,12 @@ bool _assetManagerLoaderTextureDispose(assetmanageritem_t *item);
|
|||||||
*
|
*
|
||||||
* @param manager Manager to queue on to.
|
* @param manager Manager to queue on to.
|
||||||
* @param owner Owner ID requesting to load this resource.
|
* @param owner Owner ID requesting to load this resource.
|
||||||
* @param mt Scaled Texture to load in to.
|
|
||||||
* @param path Path of the texture files
|
* @param path Path of the texture files
|
||||||
* @param file File name of the texture sets.
|
* @param file File name of the texture sets.
|
||||||
* @return A pointer to the asset manager item for tracking.
|
* @return A pointer to the asset manager item for tracking.
|
||||||
*/
|
*/
|
||||||
assetmanageritem_t * assetManagerLoadScaledTexture(
|
assetmanageritem_t * assetManagerLoadScaledTexture(
|
||||||
assetmanager_t *manager, assetmanagerowner_t owner,
|
assetmanager_t *manager, assetmanagerowner_t owner, char *path, char *file
|
||||||
scaledtexture_t *st, char *path, char *file
|
|
||||||
);
|
);
|
||||||
|
|
||||||
bool _assetManagerLoaderScaledTextureAsync(assetmanageritem_t *item);
|
bool _assetManagerLoaderScaledTextureAsync(assetmanageritem_t *item);
|
||||||
@ -261,7 +257,7 @@ bool _assetManagerLoaderScaledTextureAsync(assetmanageritem_t *item);
|
|||||||
*/
|
*/
|
||||||
assetmanageritem_t * assetManagerLoadTextureScale(
|
assetmanageritem_t * assetManagerLoadTextureScale(
|
||||||
assetmanager_t *manager, assetmanagerowner_t owner,
|
assetmanager_t *manager, assetmanagerowner_t owner,
|
||||||
scaledtexture_t *st, texture_t *text, uint8_t scale
|
scaledtexture_t *st, uint8_t scale
|
||||||
);
|
);
|
||||||
|
|
||||||
bool _assetManagerLoaderTextureScaleAsync(assetmanageritem_t *item);
|
bool _assetManagerLoaderTextureScaleAsync(assetmanageritem_t *item);
|
||||||
@ -280,7 +276,7 @@ bool _assetManagerLoaderTextureScaleDispose(assetmanageritem_t *item);
|
|||||||
*/
|
*/
|
||||||
assetmanageritem_t * assetManagerLoadShader(
|
assetmanageritem_t * assetManagerLoadShader(
|
||||||
assetmanager_t *manager, assetmanagerowner_t owner,
|
assetmanager_t *manager, assetmanagerowner_t owner,
|
||||||
shader_t *shader, char *fileVert, char *fileFrag
|
char *fileVert, char *fileFrag
|
||||||
);
|
);
|
||||||
|
|
||||||
bool _assetManagerLoaderShaderAsync(assetmanageritem_t *item);
|
bool _assetManagerLoaderShaderAsync(assetmanageritem_t *item);
|
||||||
|
@ -14,32 +14,30 @@ bool sandboxGameInit(sandboxgame_t *game) {
|
|||||||
sceneInit(&game->scene, &game->engine);
|
sceneInit(&game->scene, &game->engine);
|
||||||
|
|
||||||
// Load Shader
|
// Load Shader
|
||||||
assetManagerLoadShader(&game->engine.assetManager, game->scene.assetOwner,
|
game->shader = assetManagerLoadShader(
|
||||||
&game->shader, "shaders/textured.vert", "shaders/textured.frag"
|
&game->engine.assetManager, game->scene.assetOwner,
|
||||||
|
"shaders/textured.vert", "shaders/textured.frag"
|
||||||
);
|
);
|
||||||
assetManagerLoadShader(&game->engine.assetManager, game->scene.assetOwner,
|
game->shader2 = assetManagerLoadShader(
|
||||||
&game->shader2, "shaders/test.vert", "shaders/test.frag"
|
&game->engine.assetManager, game->scene.assetOwner,
|
||||||
|
"shaders/test.vert", "shaders/test.frag"
|
||||||
);
|
);
|
||||||
|
|
||||||
// Load the texture
|
// Load the texture
|
||||||
assetManagerLoadScaledTexture(
|
game->scaledTexture = assetManagerLoadScaledTexture(
|
||||||
&game->engine.assetManager, game->scene.assetOwner,
|
&game->engine.assetManager, game->scene.assetOwner,
|
||||||
&game->st, "poker/characters/sammy", "sprite"
|
"textures", "test_texture"
|
||||||
);
|
);
|
||||||
assetManagerLoadTextureScale(
|
game->textureScale = assetManagerLoadTextureScale(
|
||||||
&game->engine.assetManager, game->scene.assetOwner,
|
&game->engine.assetManager, game->scene.assetOwner,
|
||||||
&game->st, &game->texture, 0
|
&game->scaledTexture->data.scaledTexture.scaledTexture, 0
|
||||||
);
|
|
||||||
|
|
||||||
assetManagerLoadTexture(
|
|
||||||
&game->engine.assetManager, game->scene.assetOwner,
|
|
||||||
&game->texture, "textures/test_texture.png"
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// quadInit(&game->quad, 0, 0,0,0,0, 1,1,1,1);
|
||||||
cubeInit(&game->quad, 1, 1, 1);
|
cubeInit(&game->quad, 1, 1, 1);
|
||||||
|
|
||||||
i = renderPassAdd(&game->scene.renderList, &game->shader);
|
i = renderPassAdd(&game->scene.renderList, &game->shader->data.shader.shader);
|
||||||
i = renderPassAdd(&game->scene.renderList, &game->shader);
|
i = renderPassAdd(&game->scene.renderList, &game->shader->data.shader.shader);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -47,6 +45,7 @@ bool sandboxGameInit(sandboxgame_t *game) {
|
|||||||
void sandboxGameUpdate(sandboxgame_t *game) {
|
void sandboxGameUpdate(sandboxgame_t *game) {
|
||||||
camera_t camera;
|
camera_t camera;
|
||||||
float n;
|
float n;
|
||||||
|
shader_t *shader, *shader2;
|
||||||
|
|
||||||
n = assetManagerProgressGet(&game->engine.assetManager);
|
n = assetManagerProgressGet(&game->engine.assetManager);
|
||||||
if(n < 1.0f) return;
|
if(n < 1.0f) return;
|
||||||
@ -54,13 +53,15 @@ void sandboxGameUpdate(sandboxgame_t *game) {
|
|||||||
sceneRenderStart(&game->scene);
|
sceneRenderStart(&game->scene);
|
||||||
|
|
||||||
// First pass
|
// First pass
|
||||||
shaderuniform_t uniView = shaderGetUniform(&game->shader, "u_View");
|
shader = &game->shader->data.shader.shader;
|
||||||
shaderuniform_t uniProj = shaderGetUniform(&game->shader, "u_Proj");
|
shader2 = &game->shader2->data.shader.shader;
|
||||||
shaderuniform_t uniModel = shaderGetUniform(&game->shader, "u_Modl");
|
shaderuniform_t uniView = shaderGetUniform(shader, "u_View");
|
||||||
shaderuniform_t uniColor = shaderGetUniform(&game->shader, "u_Colr");
|
shaderuniform_t uniProj = shaderGetUniform(shader, "u_Proj");
|
||||||
shaderuniform_t uniTexture = shaderGetUniform(&game->shader, "u_Text");
|
shaderuniform_t uniModel = shaderGetUniform(shader, "u_Modl");
|
||||||
|
shaderuniform_t uniColor = shaderGetUniform(shader, "u_Colr");
|
||||||
|
shaderuniform_t uniTexture = shaderGetUniform(shader, "u_Text");
|
||||||
|
|
||||||
renderpass_t *pass =renderListRenderPass(
|
renderpass_t *pass = renderListRenderPass(
|
||||||
&game->scene.renderList, &game->engine, 0
|
&game->scene.renderList, &game->engine, 0
|
||||||
);
|
);
|
||||||
cameraPerspective(&camera, 45.0f,
|
cameraPerspective(&camera, 45.0f,
|
||||||
@ -70,29 +71,30 @@ void sandboxGameUpdate(sandboxgame_t *game) {
|
|||||||
|
|
||||||
shaderUseCamera(pass->shader, uniView, uniProj, &camera);
|
shaderUseCamera(pass->shader, uniView, uniProj, &camera);
|
||||||
shaderUseColor(pass->shader, uniColor, PIXEL_COLOR_WHITE);
|
shaderUseColor(pass->shader, uniColor, PIXEL_COLOR_WHITE);
|
||||||
shaderUseTexture(pass->shader, uniTexture, &game->texture);
|
shaderUseTexture(pass->shader, uniTexture, &game->textureScale->data.scaleTexture.texture);
|
||||||
shaderUsePosition(pass->shader, uniModel, 0,0,0,
|
shaderUsePosition(pass->shader, uniModel, 0,0,0,
|
||||||
game->engine.time.current/2.0f, game->engine.time.current, 0
|
game->engine.time.current/2.0f, game->engine.time.current, 0
|
||||||
);
|
);
|
||||||
primitiveDraw(&game->quad, 0, -1);
|
primitiveDraw(&game->quad, 0, -1);
|
||||||
|
|
||||||
|
// // Second Pass
|
||||||
pass = renderListRenderPass(&game->scene.renderList, &game->engine, 1);
|
pass = renderListRenderPass(&game->scene.renderList, &game->engine, 1);
|
||||||
shaderUsePosition(pass->shader, uniModel, 0,0,0,
|
shaderUsePosition(pass->shader, uniModel, 0,0,0,
|
||||||
-game->engine.time.current/2.0f, -game->engine.time.current, 0
|
-game->engine.time.current/2.0f, -game->engine.time.current, 0
|
||||||
);
|
);
|
||||||
primitiveDraw(&game->quad, 0, -1);
|
primitiveDraw(&game->quad, 0, -1);
|
||||||
|
|
||||||
|
// Merge Shader
|
||||||
shaderuniform_t uniTextureSet[2];
|
shaderuniform_t uniTextureSet[2];
|
||||||
uniTextureSet[0] = shaderGetUniform(&game->shader2, "u_Text0");
|
uniTextureSet[0] = shaderGetUniform(shader2, "u_Text0");
|
||||||
uniTextureSet[1] = shaderGetUniform(&game->shader2, "u_Text1");
|
uniTextureSet[1] = shaderGetUniform(shader2, "u_Text1");
|
||||||
|
|
||||||
sceneRenderEnd(&game->scene, &game->shader2,
|
sceneRenderEnd(&game->scene, shader2,
|
||||||
shaderGetUniform(&game->shader2, "u_View"),
|
shaderGetUniform(shader2, "u_View"),
|
||||||
shaderGetUniform(&game->shader2, "u_Proj"),
|
shaderGetUniform(shader2, "u_Proj"),
|
||||||
shaderGetUniform(&game->shader2, "u_Modl"),
|
shaderGetUniform(shader2, "u_Modl"),
|
||||||
uniTextureSet,
|
uniTextureSet,
|
||||||
&game->shader, uniView, uniProj, uniModel, uniTexture
|
shader, uniView, uniProj, uniModel, uniTexture
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,11 +26,12 @@
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
engine_t engine;
|
engine_t engine;
|
||||||
scene_t scene;
|
scene_t scene;
|
||||||
shader_t shader;
|
|
||||||
shader_t shader2;
|
|
||||||
texture_t texture;
|
|
||||||
primitive_t quad;
|
primitive_t quad;
|
||||||
scaledtexture_t st;
|
|
||||||
|
assetmanageritem_t *shader;
|
||||||
|
assetmanageritem_t *shader2;
|
||||||
|
assetmanageritem_t *scaledTexture;
|
||||||
|
assetmanageritem_t *textureScale;
|
||||||
} sandboxgame_t;
|
} sandboxgame_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user