Page 11 of 91

Re: "Questions that don't deserve their own thread" thread

Posted: Wed Aug 27, 2014 8:18 pm
by Cryogenical
It did nothing but change the size of my window. Still had borders.

Re: "Questions that don't deserve their own thread" thread

Posted: Wed Aug 27, 2014 9:33 pm
by Jasoco
Cryogenical wrote:It did nothing but change the size of my window. Still had borders.
Are you trying to remove the border or make the window resizable? Because they're two separate things. Just add "borderless = true" to that table. Go to the Wiki and look up love.window.setMode(). There's a lot of settings in there to play with.

Re: "Questions that don't deserve their own thread" thread

Posted: Wed Aug 27, 2014 9:46 pm
by Zilarrezko
Cryogenical wrote:It did nothing but change the size of my window. Still had borders.
What system do you have? Because I know windows 8 won't get rid of borders unless you make it borderless and make it not resizeable.

Sorry I probably forgot to put in borderless.

Code: Select all

local resizeable = false
local borderless = false

function love.keypressed(key, unicode)
      if key == "5" then
           resizeable = not resizeable
           borderless = not borderless
           love.window.setMode(1080, 720, {resizable = resizeable, borderless = borderless})
      end
end
See if that works, sorry.

Re: "Questions that don't deserve their own thread" thread

Posted: Thu Aug 28, 2014 5:30 pm
by Cryogenical
Closer, but the window was still resizeable.
I am running on windows 8 sadly.

I fixed it by either changing the local variable for resizeable to true, or just getting rid of the function of resizeable = not resizeable.

Thank you guys though! Helps a lot.

Re: "Questions that don't deserve their own thread" thread

Posted: Fri Aug 29, 2014 7:49 am
by rmcode
Somehow my brain can't process why this

Code: Select all

return content and content:isPassable() or true;
doesn't work like this:

Code: Select all

        if content then
            return content:isPassable();
        else
            return true;
        end

Re: "Questions that don't deserve their own thread" thread

Posted: Fri Aug 29, 2014 9:31 am
by Robin
Because

Code: Select all

a and b or c
is the same as

Code: Select all

(a and b) or c
which returns c if either a or b is falsy, otherwise it returns b.

What you want is

Code: Select all

return not content or content:isPassable()

Re: "Questions that don't deserve their own thread" thread

Posted: Fri Aug 29, 2014 10:40 am
by rmcode
Ah ... so the statement would return true, if isPassable() returns false. That's where the mistake was. I thought it would directly return the result of isPassable() if there was content and return true if there wasn't.

Thanks for the explanation.

Re: "Questions that don't deserve their own thread" thread

Posted: Wed Sep 03, 2014 6:46 am
by Whatthefuck
How do I use getPointer with FFI on an ImageData object to change a certain pixel in it? Is the ImageData array two dimensional, and what variable names do the pixel colors use?

Re: "Questions that don't deserve their own thread" thread

Posted: Wed Sep 03, 2014 7:51 am
by slime
If you use this (all you need to do is require the file) then you'll get the performance of LuaJIT's FFI when calling ImageData methods, without having to worry about whether your C pointer / array arithmetic is correct.

Re: "Questions that don't deserve their own thread" thread

Posted: Wed Sep 03, 2014 9:13 am
by rmcode
I wrote a shader yesterday, which allows me to cycle through different colour palettes. Since I am pretty new to shaders I used a pretty brute-force approach:

Code: Select all

vec4 effect( vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords )
{
    vec4 tex = Texel(texture, texture_coords);

    if (tex.r == 0 && tex.g == 0 && tex.b == 0) {                   // Black
        tex.r = PALETTE[0][0];
        tex.g = PALETTE[0][1];
        tex.b = PALETTE[0][2];
    } else if (tex.r == 1.0 && tex.g == 1.0 && tex.b == 1.0) {      // White
        tex.r = PALETTE[1][0];
        tex.g = PALETTE[1][1];
        tex.b = PALETTE[1][2];
    } else if (tex.r >= 0.5 && tex.g >= 0.5 && tex.b >= 0.5) {      // Light Gray
        tex.r = PALETTE[2][0];
        tex.g = PALETTE[2][1];
        tex.b = PALETTE[2][2];
    } else if (tex.r >= 0.2 && tex.g >= 0.2 && tex.b >= 0.2) {      // Dark Gray
        tex.r = PALETTE[3][0];
        tex.g = PALETTE[3][1];
        tex.b = PALETTE[3][2];
    }

    // This will make every pixel of the sprite opaque.
    // tex.a = color.a;

    return tex;
}
It works fine for the colour cycling part, but not for transparent images. When I set love.graphics.setColor(255, 255, 255, 0), it still shows the sprite at 100 % opacity. I know I have to do something with the alpha, but I'm not sure what :S