Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand Mega Surface support #148

Open
wants to merge 32 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
2247f1d
Shrink missized blits
WaywardHeart Oct 19, 2023
43ac2b3
Don't clamp Bitmap::blit
WaywardHeart Oct 19, 2023
086adde
Fix blitting from megatextures
WaywardHeart Oct 23, 2023
44739b8
Change the create Bitmap from surface constructor to always take owne…
WaywardHeart Dec 16, 2023
ed0ef42
Use stretchBlt in drawText
WaywardHeart Oct 31, 2023
8d02148
Adjust the font size by finding the correct dpi
WaywardHeart Oct 22, 2023
1d9806c
Use the first version of the font we find
WaywardHeart Oct 25, 2023
8b4b12b
Test for an invalid rect in drawText
WaywardHeart Oct 26, 2023
b9a1aeb
Don't let drawn text move past the top of the rect
WaywardHeart Oct 22, 2023
e0290eb
Limit squeezing text to a minimum of 50%
WaywardHeart Oct 22, 2023
9e2a4aa
Only draw enough of the text to fill the rect we were given
WaywardHeart Dec 3, 2023
c1b50ba
Match some outline positioning behavior from RGSS and enable transpar…
WaywardHeart Dec 1, 2023
b7ad640
More properly handle src_rects in sprites with negative positions or …
WaywardHeart Jan 6, 2024
35d46e6
Guard against deleted bitmaps
WaywardHeart Dec 29, 2023
9bb6a9b
Add functions for rotating a point or rect
WaywardHeart Jan 8, 2024
ce12247
Change the bush effect on sprites to stay on the bottom after rotations
WaywardHeart Jan 1, 2024
3d1932c
Merge branches 'deletedBitmaps spriteBushRotation waves'
WaywardHeart Jan 10, 2024
b8d6471
Support mega surfaces in stretchBlt, drawText, and textSize
WaywardHeart Dec 3, 2023
6668022
Support mega surfaces in fillRect, gradientFillRect, clearRect, and c…
WaywardHeart Dec 3, 2023
83ee323
Support mega surfaces in getPixel and setPixel
WaywardHeart Dec 3, 2023
57fb65f
Support mega surfaces in replaceRaw
WaywardHeart Dec 3, 2023
ce239f6
Fix wrapRange
WaywardHeart Dec 28, 2023
1c25c9a
Support mega surfaces in hueChange
WaywardHeart Dec 3, 2023
60241f0
Allow creating mega surfaces with Bitmap.new(int, int)
WaywardHeart Dec 4, 2023
57b1130
Allow cloning mega surfaces with Bitmap.new(bitmap, -2) or bitmap.clone
WaywardHeart Dec 8, 2023
f985437
Support mega surfaces in blur
WaywardHeart Dec 4, 2023
705b319
Guard against more exceptions in bitmap-binding.cpp
WaywardHeart Dec 4, 2023
db50c46
Rip out some hi-res debug messages involving surfaces and mega surfaces
WaywardHeart Dec 4, 2023
77fb2d8
Force Lores bitmaps to be mega surfaces if the Hires version is one
WaywardHeart Jan 9, 2024
eb7384c
Use 32 bit pixman regions when necessary
WaywardHeart Dec 5, 2023
657f9d1
Support mega surfaces in Windows, Planes, and Sprites
WaywardHeart Dec 6, 2023
2d0ad61
Fix radial_blur on rectangles
WaywardHeart Jan 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 33 additions & 15 deletions binding/bitmap-binding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@ void bitmapInitProps(Bitmap *b, VALUE self) {
rb_iv_set(self, "font", fontObj);

// Leave property as default nil if hasHires() is false.
if (b->hasHires()) {
b->assumeRubyGC();
wrapProperty(self, b->getHires(), "hires", BitmapType);
}
GFX_GUARD_EXC(
if (b->hasHires()) {
b->assumeRubyGC();
wrapProperty(self, b->getHires(), "hires", BitmapType);
}
);
}

RB_METHOD(bitmapInitialize) {
Expand Down Expand Up @@ -375,9 +377,7 @@ RB_METHOD(bitmapBlur) {

Bitmap *b = getPrivateData<Bitmap>(self);

GFX_LOCK;
b->blur();
GFX_UNLOCK;
GFX_GUARD_EXC(b->blur(););

return Qnil;
}
Expand All @@ -388,9 +388,7 @@ RB_METHOD(bitmapRadialBlur) {
int angle, divisions;
rb_get_args(argc, argv, "ii", &angle, &divisions RB_ARG_END);

GFX_LOCK;
b->radialBlur(angle, divisions);
GFX_UNLOCK;
GFX_GUARD_EXC(b->radialBlur(angle, divisions););

return Qnil;
}
Expand Down Expand Up @@ -470,7 +468,11 @@ RB_METHOD(bitmapGetPlaying){

Bitmap *b = getPrivateData<Bitmap>(self);

return rb_bool_new(b->isPlaying());
VALUE ret;

GFX_GUARD_EXC(ret = rb_bool_new(b->isPlaying()););

return ret;
}

RB_METHOD(bitmapSetPlaying){
Expand Down Expand Up @@ -544,7 +546,11 @@ RB_METHOD(bitmapFrames){

Bitmap *b = getPrivateData<Bitmap>(self);

return INT2NUM(b->numFrames());
int ret;

GFX_GUARD_EXC(ret = b->numFrames(););

return INT2NUM(ret);
}

RB_METHOD(bitmapCurrentFrame){
Expand All @@ -554,7 +560,11 @@ RB_METHOD(bitmapCurrentFrame){

Bitmap *b = getPrivateData<Bitmap>(self);

return INT2NUM(b->currentFrameI());
int ret;

GFX_GUARD_EXC(ret = b->currentFrameI(););

return INT2NUM(ret);
}

RB_METHOD(bitmapAddFrame){
Expand Down Expand Up @@ -611,7 +621,11 @@ RB_METHOD(bitmapNextFrame){

GFX_GUARD_EXC(b->nextFrame(););

return INT2NUM(b->currentFrameI());
int ret;

GFX_GUARD_EXC(ret = b->currentFrameI(););

return INT2NUM(ret);
}

RB_METHOD(bitmapPreviousFrame){
Expand All @@ -623,7 +637,11 @@ RB_METHOD(bitmapPreviousFrame){

GFX_GUARD_EXC(b->previousFrame(););

return INT2NUM(b->currentFrameI());
int ret;

GFX_GUARD_EXC(ret = b->currentFrameI(););

return INT2NUM(ret);
}

RB_METHOD(bitmapSetFPS){
Expand Down
10 changes: 7 additions & 3 deletions shader/sprite.frag
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ uniform lowp vec4 tone;
uniform lowp float opacity;
uniform lowp vec4 color;

uniform float bushDepth;
uniform bool bushY;
uniform bool bushUnder;
uniform float bushSlope;
uniform float bushIntercept;
uniform lowp float bushOpacity;

uniform sampler2D pattern;
Expand Down Expand Up @@ -102,8 +105,9 @@ void main()
}

/* Apply bush alpha by mathematical if */
lowp float underBush = float(v_texCoord.y < bushDepth);
frag.a *= clamp(bushOpacity + underBush, 0.0, 1.0);
bool underBush = (float(bushY) * v_texCoord.y + float(!bushY) * v_texCoord.x) <
(bushSlope * (float(bushY) * v_texCoord.x + float(!bushY) * v_texCoord.y) + bushIntercept);
frag.a *= clamp(bushOpacity + float(underBush == bushUnder), 0.0, 1.0);

gl_FragColor = frag;
}
Loading