mirror of
https://github.com/J-D-K/JKSV.git
synced 2026-04-24 23:37:24 -05:00
offscreen drawing
This commit is contained in:
parent
bc0a99cab9
commit
512889a1a5
2
Makefile
2
Makefile
|
|
@ -38,7 +38,7 @@ INCLUDES := inc
|
|||
EXEFS_SRC := exefs_src
|
||||
APP_TITLE := JKSV
|
||||
APP_AUTHOR := JK
|
||||
APP_VERSION := 01/08/2019
|
||||
APP_VERSION := 04.17.2019
|
||||
ROMFS := romfs
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
|
|
|
|||
62
src/gfx.c
62
src/gfx.c
|
|
@ -40,6 +40,16 @@ static inline uint32_t smooth(const clr px1, const clr px2)
|
|||
return (fA << 24 | fB << 16 | fG << 8 | fR);
|
||||
}
|
||||
|
||||
static inline bool yCheck(const tex *target, int y)
|
||||
{
|
||||
return y < 0 || y >= target->height;
|
||||
}
|
||||
|
||||
static inline bool xCheck(const tex *target, int x)
|
||||
{
|
||||
return x < 0 || x >= target->width;
|
||||
}
|
||||
|
||||
bool graphicsInit(int windowWidth, int windowHeight)
|
||||
{
|
||||
window = nwindowGetDefault();
|
||||
|
|
@ -95,13 +105,13 @@ static void drawGlyph(const FT_Bitmap *bmp, tex *target, int _x, int _y)
|
|||
uint8_t *bmpPtr = bmp->buffer;
|
||||
for(int y = _y; y < _y + bmp->rows; y++)
|
||||
{
|
||||
if(y > target->height || y < 0)
|
||||
if(yCheck(target, y))
|
||||
continue;
|
||||
|
||||
uint32_t *rowPtr = &target->data[y * target->width + _x];
|
||||
for(int x = _x; x < _x + bmp->width; x++, bmpPtr++, rowPtr++)
|
||||
{
|
||||
if(x > target->width || x < 0)
|
||||
if(xCheck(target, x))
|
||||
continue;
|
||||
|
||||
if(*bmpPtr > 0)
|
||||
|
|
@ -303,9 +313,17 @@ void drawRect(tex *target, int x, int y, int w, int h, const clr c)
|
|||
|
||||
for(int tY = y; tY < y + h; tY++)
|
||||
{
|
||||
if(yCheck(target, tY))
|
||||
continue;
|
||||
|
||||
uint32_t *rowPtr = &target->data[tY * target->width + x];
|
||||
for(int tX = x; tX < x + w; tX++, rowPtr++)
|
||||
{
|
||||
if(xCheck(target, tX))
|
||||
continue;
|
||||
|
||||
*rowPtr = clr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -313,9 +331,17 @@ void drawRectAlpha(tex *target, int x, int y, int w, int h, const clr c)
|
|||
{
|
||||
for(int tY = y; tY < y + h; tY++)
|
||||
{
|
||||
if(yCheck(target, tY))
|
||||
continue;
|
||||
|
||||
uint32_t *rowPtr = &target->data[tY * target->width + x];
|
||||
for(int tX = x; tX < x + w; tX++, rowPtr++)
|
||||
{
|
||||
if(xCheck(target, tX))
|
||||
continue;
|
||||
|
||||
*rowPtr = blend(c, clrCreateU32(*rowPtr));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -513,9 +539,15 @@ void texDraw(const tex *t, tex *target, int x, int y)
|
|||
uint32_t *dataPtr = &t->data[0];
|
||||
for(int tY = y; tY < y + t->height; tY++)
|
||||
{
|
||||
if(yCheck(target, tY))
|
||||
continue;
|
||||
|
||||
uint32_t *rowPtr = &target->data[tY * target->width + x];
|
||||
for(int tX = x; tX < x + t->width; tX++, rowPtr++)
|
||||
{
|
||||
if(xCheck(target, tX))
|
||||
continue;
|
||||
|
||||
clr dataClr = clrCreateU32(*dataPtr++);
|
||||
clr fbClr = clrCreateU32(*rowPtr);
|
||||
|
||||
|
|
@ -532,9 +564,17 @@ void texDrawNoAlpha(const tex *t, tex *target, int x, int y)
|
|||
uint32_t *dataPtr = &t->data[0];
|
||||
for(int tY = y; tY < y + t->height; tY++)
|
||||
{
|
||||
if(yCheck(target, tY))
|
||||
continue;
|
||||
|
||||
uint32_t *rowPtr = &target->data[tY * target->width + x];
|
||||
for(int tX = x; tX < x + t->width; tX++)
|
||||
{
|
||||
if(xCheck(target, tX))
|
||||
continue;
|
||||
|
||||
*rowPtr++ = *dataPtr++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -546,9 +586,15 @@ void texDrawSkip(const tex *t, tex *target, int x, int y)
|
|||
uint32_t *dataPtr = &t->data[0];
|
||||
for(int tY = y; tY < y + (t->height / 2); tY++, dataPtr += t->width)
|
||||
{
|
||||
if(yCheck(target, tY))
|
||||
continue;
|
||||
|
||||
uint32_t *rowPtr = &target->data[tY * target->width + x];
|
||||
for(int tX = x; tX < x + (t->width / 2); tX++, rowPtr++)
|
||||
{
|
||||
if(xCheck(target, tX))
|
||||
continue;
|
||||
|
||||
clr px1 = clrCreateU32(*dataPtr++);
|
||||
clr px2 = clrCreateU32(*dataPtr++);
|
||||
clr fbPx = clrCreateU32(*rowPtr);
|
||||
|
|
@ -566,9 +612,15 @@ void texDrawSkipNoAlpha(const tex *t, tex *target, int x, int y)
|
|||
uint32_t *dataPtr = &t->data[0];
|
||||
for(int tY = y; tY < y + (t->height / 2); tY++, dataPtr += t->width)
|
||||
{
|
||||
if(yCheck(target, tY))
|
||||
continue;
|
||||
|
||||
uint32_t *rowPtr = &target->data[tY * target->width + x];
|
||||
for(int tX = x; tX < x + (t->width / 2); tX++, rowPtr++)
|
||||
{
|
||||
if(xCheck(target, tX))
|
||||
continue;
|
||||
|
||||
clr px1 = clrCreateU32(*dataPtr++);
|
||||
clr px2 = clrCreateU32(*dataPtr++);
|
||||
|
||||
|
|
@ -585,9 +637,15 @@ void texDrawInvert(const tex *t, tex *target, int x, int y)
|
|||
uint32_t *dataPtr = &t->data[0];
|
||||
for(int tY = y; tY < y + t->height; tY++)
|
||||
{
|
||||
if(yCheck(target, tY))
|
||||
continue;
|
||||
|
||||
uint32_t *rowPtr = &target->data[tY * target->width + x];
|
||||
for(int tX = x; tX < x + t->width; tX++, rowPtr++)
|
||||
{
|
||||
if(xCheck(target, tX))
|
||||
continue;
|
||||
|
||||
clr dataClr = clrCreateU32(*dataPtr++);
|
||||
clrInvert(&dataClr);
|
||||
clr fbClr = clrCreateU32(*rowPtr);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
#include "util.h"
|
||||
#include "file.h"
|
||||
|
||||
#define VER_STRING "v. 01/08/2019"
|
||||
#define VER_STRING "v. 04.17.2019"
|
||||
|
||||
//background that can be drawn from "/JKSV/back.jpg"
|
||||
//txtSide and fldSide are to fake alpha blending so the framerate doesn't suffer
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user