WARNING: BREAKING: RENAMED enum values
RENAMED: CubemapLayoutType and NPatchType
This commit is contained in:
parent
81908f7960
commit
408f5aedb8
3 changed files with 30 additions and 30 deletions
|
@ -36,15 +36,15 @@ int main(void)
|
|||
Rectangle dstRecH = { 160.0f, 93.0f, 32.0f, 32.0f };
|
||||
Rectangle dstRecV = { 92.0f, 160.0f, 32.0f, 32.0f };
|
||||
|
||||
// A 9-patch (NPT_9PATCH) changes its sizes in both axis
|
||||
NPatchInfo ninePatchInfo1 = { (Rectangle){ 0.0f, 0.0f, 64.0f, 64.0f }, 12, 40, 12, 12, NPT_9PATCH };
|
||||
NPatchInfo ninePatchInfo2 = { (Rectangle){ 0.0f, 128.0f, 64.0f, 64.0f }, 16, 16, 16, 16, NPT_9PATCH };
|
||||
// A 9-patch (NPATCH_NINE_PATCH) changes its sizes in both axis
|
||||
NPatchInfo ninePatchInfo1 = { (Rectangle){ 0.0f, 0.0f, 64.0f, 64.0f }, 12, 40, 12, 12, NPATCH_NINE_PATCH };
|
||||
NPatchInfo ninePatchInfo2 = { (Rectangle){ 0.0f, 128.0f, 64.0f, 64.0f }, 16, 16, 16, 16, NPATCH_NINE_PATCH };
|
||||
|
||||
// A horizontal 3-patch (NPT_3PATCH_HORIZONTAL) changes its sizes along the x axis only
|
||||
NPatchInfo h3PatchInfo = { (Rectangle){ 0.0f, 64.0f, 64.0f, 64.0f }, 8, 8, 8, 8, NPT_3PATCH_HORIZONTAL };
|
||||
// A horizontal 3-patch (NPATCH_THREE_PATCH_HORIZONTAL) changes its sizes along the x axis only
|
||||
NPatchInfo h3PatchInfo = { (Rectangle){ 0.0f, 64.0f, 64.0f, 64.0f }, 8, 8, 8, 8, NPATCH_THREE_PATCH_HORIZONTAL };
|
||||
|
||||
// A vertical 3-patch (NPT_3PATCH_VERTICAL) changes its sizes along the y axis only
|
||||
NPatchInfo v3PatchInfo = { (Rectangle){ 0.0f, 192.0f, 64.0f, 64.0f }, 6, 6, 6, 6, NPT_3PATCH_VERTICAL };
|
||||
// A vertical 3-patch (NPATCH_THREE_PATCH_VERTICAL) changes its sizes along the y axis only
|
||||
NPatchInfo v3PatchInfo = { (Rectangle){ 0.0f, 192.0f, 64.0f, 64.0f }, 6, 6, 6, 6, NPATCH_THREE_PATCH_VERTICAL };
|
||||
|
||||
SetTargetFPS(60);
|
||||
//---------------------------------------------------------------------------------------
|
||||
|
|
18
src/raylib.h
18
src/raylib.h
|
@ -809,12 +809,12 @@ typedef enum {
|
|||
|
||||
// Cubemap layouts
|
||||
typedef enum {
|
||||
CUBEMAP_AUTO_DETECT = 0, // Automatically detect layout type
|
||||
CUBEMAP_LINE_VERTICAL, // Layout is defined by a vertical line with faces
|
||||
CUBEMAP_LINE_HORIZONTAL, // Layout is defined by an horizontal line with faces
|
||||
CUBEMAP_CROSS_THREE_BY_FOUR, // Layout is defined by a 3x4 cross with cubemap faces
|
||||
CUBEMAP_CROSS_FOUR_BY_THREE, // Layout is defined by a 4x3 cross with cubemap faces
|
||||
CUBEMAP_PANORAMA // Layout is defined by a panorama image (equirectangular map)
|
||||
CUBEMAP_LAYOUT_AUTO_DETECT = 0, // Automatically detect layout type
|
||||
CUBEMAP_LAYOUT_LINE_VERTICAL, // Layout is defined by a vertical line with faces
|
||||
CUBEMAP_LAYOUT_LINE_HORIZONTAL, // Layout is defined by an horizontal line with faces
|
||||
CUBEMAP_LAYOUT_CROSS_THREE_BY_FOUR, // Layout is defined by a 3x4 cross with cubemap faces
|
||||
CUBEMAP_LAYOUT_CROSS_FOUR_BY_THREE, // Layout is defined by a 4x3 cross with cubemap faces
|
||||
CUBEMAP_LAYOUT_PANORAMA // Layout is defined by a panorama image (equirectangular map)
|
||||
} CubemapLayoutType;
|
||||
|
||||
// Font type, defines generation method
|
||||
|
@ -867,9 +867,9 @@ typedef enum {
|
|||
|
||||
// N-patch types
|
||||
typedef enum {
|
||||
NPT_9PATCH = 0, // Npatch defined by 3x3 tiles
|
||||
NPT_3PATCH_VERTICAL, // Npatch defined by 1x3 tiles
|
||||
NPT_3PATCH_HORIZONTAL // Npatch defined by 3x1 tiles
|
||||
NPATCH_NINE_PATCH = 0, // Npatch defined by 3x3 tiles
|
||||
NPATCH_THREE_PATCH_VERTICAL, // Npatch defined by 1x3 tiles
|
||||
NPATCH_THREE_PATCH_HORIZONTAL // Npatch defined by 3x1 tiles
|
||||
} NPatchType;
|
||||
|
||||
// Callbacks to be implemented by users
|
||||
|
|
|
@ -2749,7 +2749,7 @@ TextureCubemap LoadTextureCubemap(Image image, int layoutType)
|
|||
{
|
||||
TextureCubemap cubemap = { 0 };
|
||||
|
||||
if (layoutType == CUBEMAP_AUTO_DETECT) // Try to automatically guess layout type
|
||||
if (layoutType == CUBEMAP_LAYOUT_AUTO_DETECT) // Try to automatically guess layout type
|
||||
{
|
||||
// Check image width/height to determine the type of cubemap provided
|
||||
if (image.width > image.height)
|
||||
|
@ -2767,7 +2767,7 @@ TextureCubemap LoadTextureCubemap(Image image, int layoutType)
|
|||
cubemap.height = cubemap.width;
|
||||
}
|
||||
|
||||
if (layoutType != CUBEMAP_AUTO_DETECT)
|
||||
if (layoutType != CUBEMAP_LAYOUT_AUTO_DETECT)
|
||||
{
|
||||
int size = cubemap.width;
|
||||
|
||||
|
@ -2775,20 +2775,20 @@ TextureCubemap LoadTextureCubemap(Image image, int layoutType)
|
|||
Rectangle faceRecs[6] = { 0 }; // Face source rectangles
|
||||
for (int i = 0; i < 6; i++) faceRecs[i] = (Rectangle){ 0, 0, (float)size, (float)size };
|
||||
|
||||
if (layoutType == CUBEMAP_LINE_VERTICAL)
|
||||
if (layoutType == CUBEMAP_LAYOUT_LINE_VERTICAL)
|
||||
{
|
||||
faces = image;
|
||||
for (int i = 0; i < 6; i++) faceRecs[i].y = (float)size*i;
|
||||
}
|
||||
else if (layoutType == CUBEMAP_PANORAMA)
|
||||
else if (layoutType == CUBEMAP_LAYOUT_PANORAMA)
|
||||
{
|
||||
// TODO: Convert panorama image to square faces...
|
||||
// Ref: https://github.com/denivip/panorama/blob/master/panorama.cpp
|
||||
}
|
||||
else
|
||||
{
|
||||
if (layoutType == CUBEMAP_LINE_HORIZONTAL) for (int i = 0; i < 6; i++) faceRecs[i].x = (float)size*i;
|
||||
else if (layoutType == CUBEMAP_CROSS_THREE_BY_FOUR)
|
||||
if (layoutType == CUBEMAP_LAYOUT_LINE_HORIZONTAL) for (int i = 0; i < 6; i++) faceRecs[i].x = (float)size*i;
|
||||
else if (layoutType == CUBEMAP_LAYOUT_CROSS_THREE_BY_FOUR)
|
||||
{
|
||||
faceRecs[0].x = (float)size; faceRecs[0].y = (float)size;
|
||||
faceRecs[1].x = (float)size; faceRecs[1].y = (float)size*3;
|
||||
|
@ -2797,7 +2797,7 @@ TextureCubemap LoadTextureCubemap(Image image, int layoutType)
|
|||
faceRecs[4].x = 0; faceRecs[4].y = (float)size;
|
||||
faceRecs[5].x = (float)size*2; faceRecs[5].y = (float)size;
|
||||
}
|
||||
else if (layoutType == CUBEMAP_CROSS_FOUR_BY_THREE)
|
||||
else if (layoutType == CUBEMAP_LAYOUT_CROSS_FOUR_BY_THREE)
|
||||
{
|
||||
faceRecs[0].x = (float)size*2; faceRecs[0].y = (float)size;
|
||||
faceRecs[1].x = 0; faceRecs[1].y = (float)size;
|
||||
|
@ -3251,8 +3251,8 @@ void DrawTextureNPatch(Texture2D texture, NPatchInfo nPatchInfo, Rectangle dest,
|
|||
|
||||
if (nPatchInfo.source.width < 0) nPatchInfo.source.x -= nPatchInfo.source.width;
|
||||
if (nPatchInfo.source.height < 0) nPatchInfo.source.y -= nPatchInfo.source.height;
|
||||
if (nPatchInfo.type == NPT_3PATCH_HORIZONTAL) patchHeight = nPatchInfo.source.height;
|
||||
if (nPatchInfo.type == NPT_3PATCH_VERTICAL) patchWidth = nPatchInfo.source.width;
|
||||
if (nPatchInfo.type == NPATCH_THREE_PATCH_HORIZONTAL) patchHeight = nPatchInfo.source.height;
|
||||
if (nPatchInfo.type == NPATCH_THREE_PATCH_VERTICAL) patchWidth = nPatchInfo.source.width;
|
||||
|
||||
bool drawCenter = true;
|
||||
bool drawMiddle = true;
|
||||
|
@ -3262,14 +3262,14 @@ void DrawTextureNPatch(Texture2D texture, NPatchInfo nPatchInfo, Rectangle dest,
|
|||
float bottomBorder = (float)nPatchInfo.bottom;
|
||||
|
||||
// adjust the lateral (left and right) border widths in case patchWidth < texture.width
|
||||
if (patchWidth <= (leftBorder + rightBorder) && nPatchInfo.type != NPT_3PATCH_VERTICAL)
|
||||
if (patchWidth <= (leftBorder + rightBorder) && nPatchInfo.type != NPATCH_THREE_PATCH_VERTICAL)
|
||||
{
|
||||
drawCenter = false;
|
||||
leftBorder = (leftBorder/(leftBorder + rightBorder))*patchWidth;
|
||||
rightBorder = patchWidth - leftBorder;
|
||||
}
|
||||
// adjust the lateral (top and bottom) border heights in case patchHeight < texture.height
|
||||
if (patchHeight <= (topBorder + bottomBorder) && nPatchInfo.type != NPT_3PATCH_HORIZONTAL)
|
||||
if (patchHeight <= (topBorder + bottomBorder) && nPatchInfo.type != NPATCH_THREE_PATCH_HORIZONTAL)
|
||||
{
|
||||
drawMiddle = false;
|
||||
topBorder = (topBorder/(topBorder + bottomBorder))*patchHeight;
|
||||
|
@ -3307,7 +3307,7 @@ void DrawTextureNPatch(Texture2D texture, NPatchInfo nPatchInfo, Rectangle dest,
|
|||
rlColor4ub(tint.r, tint.g, tint.b, tint.a);
|
||||
rlNormal3f(0.0f, 0.0f, 1.0f); // Normal vector pointing towards viewer
|
||||
|
||||
if (nPatchInfo.type == NPT_9PATCH)
|
||||
if (nPatchInfo.type == NPATCH_NINE_PATCH)
|
||||
{
|
||||
// ------------------------------------------------------------
|
||||
// TOP-LEFT QUAD
|
||||
|
@ -3373,7 +3373,7 @@ void DrawTextureNPatch(Texture2D texture, NPatchInfo nPatchInfo, Rectangle dest,
|
|||
rlTexCoord2f(coordD.x, coordC.y); rlVertex2f(vertD.x, vertC.y); // Top-right corner for texture and quad
|
||||
rlTexCoord2f(coordC.x, coordC.y); rlVertex2f(vertC.x, vertC.y); // Top-left corner for texture and quad
|
||||
}
|
||||
else if (nPatchInfo.type == NPT_3PATCH_VERTICAL)
|
||||
else if (nPatchInfo.type == NPATCH_THREE_PATCH_VERTICAL)
|
||||
{
|
||||
// TOP QUAD
|
||||
// -----------------------------------------------------------
|
||||
|
@ -3400,7 +3400,7 @@ void DrawTextureNPatch(Texture2D texture, NPatchInfo nPatchInfo, Rectangle dest,
|
|||
rlTexCoord2f(coordD.x, coordC.y); rlVertex2f(vertD.x, vertC.y); // Top-right corner for texture and quad
|
||||
rlTexCoord2f(coordA.x, coordC.y); rlVertex2f(vertA.x, vertC.y); // Top-left corner for texture and quad
|
||||
}
|
||||
else if (nPatchInfo.type == NPT_3PATCH_HORIZONTAL)
|
||||
else if (nPatchInfo.type == NPATCH_THREE_PATCH_HORIZONTAL)
|
||||
{
|
||||
// LEFT QUAD
|
||||
// -----------------------------------------------------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue