That seems complicated. I mean you probably could try that but I think it would probably take awhile for it to compile. Rather than doing that it would be much better and faster if you just used ffi to wrap libcrypto. That way you can just wrap what you need.Ranguna259 wrote:The problem is I can't find the binaries anywhere, I can't compile the code on windows and I wasn't talking about recompiling love, I wanted to compile the code through luaJIT's FFI, which would load the c code inside Lua.bobbyjones wrote:You don't need to. Just ship the binaries and load them up. You don't have to recompile love for them.
"Questions that don't deserve their own thread" thread
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Party member
- Posts: 730
- Joined: Sat Apr 26, 2014 7:46 pm
Re: "Questions that don't deserve their own thread" thread
- Ranguna259
- Party member
- Posts: 911
- Joined: Tue Jun 18, 2013 10:58 pm
- Location: I'm right next to you
Re: "Questions that don't deserve their own thread" thread
That's what I said, compile luacrypto though FFI, but I don't know how to do that either.
-
- Party member
- Posts: 730
- Joined: Sat Apr 26, 2014 7:46 pm
Re: "Questions that don't deserve their own thread" thread
No meant use ffi to wrap libcrypto which should be available everywhere.
- Ranguna259
- Party member
- Posts: 911
- Joined: Tue Jun 18, 2013 10:58 pm
- Location: I'm right next to you
Re: "Questions that don't deserve their own thread" thread
And how would I do that ?
-
- Party member
- Posts: 730
- Joined: Sat Apr 26, 2014 7:46 pm
Re: "Questions that don't deserve their own thread" thread
Here is an example of an ffi binding. It will result in a faster binding and should be easier because libcrypto is part of openssl so it should be available everywhere. And if it's not it will have binaries for everywhere.
https://github.com/LPGhatguy/luajit-request
Edit: just in case it was unclear (I usually do make unclear posts) the example was not an example of libcrypto but just of ffi bindings in general.
https://github.com/LPGhatguy/luajit-request
Edit: just in case it was unclear (I usually do make unclear posts) the example was not an example of libcrypto but just of ffi bindings in general.
Re: "Questions that don't deserve their own thread" thread
I'm new to writing shaders and having some trouble. I'm using six specific colors in my game, each with a bright and dark version like the CGA palette (e.g. light red is 255/85/85, dark red is 170/0/0, etc.). I'm attempting to implement a "water" shader that returns light cyan (85/255/255) for all light colors and dark cyan (0/170/170) for all dark colors. The code below is returning light cyan even for dark colors and I don't understand why. What am I doing wrong? Any help would be appreciated!
I'd also like the shader to catch light gray (170/170/170) as a light color, but at this point I'd simply like to learn why the above doesn't work.
Code: Select all
vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords) {
vec4 pixel = Texel(texture, texture_coords);
if (pixel.a > 0.0) {
if (pixel.r == 1.0 || pixel.g == 1.0 || pixel.b == 1.0) return vec4(85.0/255.0, 1.0, 1.0, 1.0);
else return vec4(0.0, 170.0/255.0, 170.0/255.0, 1.0);
}
}
- Ranguna259
- Party member
- Posts: 911
- Joined: Tue Jun 18, 2013 10:58 pm
- Location: I'm right next to you
Re: "Questions that don't deserve their own thread" thread
I belive you forgot to open brackets on the second if, try this:
But your code will return vec4(85.0/255.0, 1.0, 1.0, 1.0) for all pixel that have at least one of their rgb values set to 255 and it will return vec4(0.0, 170.0/255.0, 170.0/255.0, 1.0) for all other pixels.
Code: Select all
vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords) {
vec4 pixel = Texel(texture, texture_coords);
if (pixel.a > 0.0) {
if (pixel.r == 1.0 || pixel.g == 1.0 || pixel.b == 1.0) {
return vec4(85.0/255.0, 1.0, 1.0, 1.0);
}
return vec4(0.0, 170.0/255.0, 170.0/255.0, 1.0);
}
}
Re: "Questions that don't deserve their own thread" thread
Something like this might work:
Doing "==" comparison on floating point numbers is always a bit finicky. So I changed it so it checks if the input value is greater than 254.5 instead.
Also code readability is nice. So i'd recommend at least putting if statements and code on separate lines.
Code: Select all
vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords) {
vec4 pixel = Texel(texture, texture_coords);
if (pixel.a > 0.0) {
if (pixel.r > (254.5/255.0) || pixel.g > (254.5/255.0) || pixel.b > (254.5/255.0))
return vec4(85.0/255.0, 1.0, 1.0, 1.0);
else
return vec4(0.0, 170.0/255.0, 170.0/255.0, 1.0);
}
}
Also code readability is nice. So i'd recommend at least putting if statements and code on separate lines.
Artal, A .PSD loader: https://github.com/EvineDev/Artal
Re: "Questions that don't deserve their own thread" thread
Thanks for the suggestions. Unfortunately, neither work. I tried both in my actual game code as well as a separate test file, and both return light cyan when given dark red.
I'm beginning to wonder if it's my machine, but I'm using another shader that works fine.
I figured as much. My original approach was to check if the sum of the RGB channels is greater than 1.5. The highest value dark color (e.g. 170/170/0) sums to 1.333; the lowest value bright color (e.g. 255/85/85) sums to 1.666. But this doesn't work, either. I've attached an example file. The draw color is set to 170/0/0 and the shader code is this:Evine wrote:Doing "==" comparison on floating point numbers is always a bit finicky. So I changed it so it checks if the input value is greater than 254.5 instead.
Code: Select all
vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords) {
vec4 pixel = Texel(texture, texture_coords);
if (pixel.a > 0.0) {
if ((pixel.r + pixel.g + pixel.b) > 1.5)
return vec4(85.0/255.0, 1.0, 1.0, 1.0);
else
return vec4(0.0, 170.0/255.0, 170.0/255.0, 1.0);
}
}
- Attachments
-
- shader_test.love
- (904 Bytes) Downloaded 120 times
Re: "Questions that don't deserve their own thread" thread
Ah now I see the mistake you made. When you're using shaders the color that is set with love.graphics.setColor() and the pixel color of an image is two different arguments passed into the shader. "vec4 color" being the love.graphics.setColor() color and "Image texture" being the image pixels.
Because a primitive shape pixel color can only be vec4(0,0,0,0) or vec4(1,1,1,1) you only need to an if on the color value.
Because a primitive shape pixel color can only be vec4(0,0,0,0) or vec4(1,1,1,1) you only need to an if on the color value.
Code: Select all
vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords) {
vec4 pixel = Texel(texture, texture_coords);
if (pixel.a > 0.0) {
if ((color.r + color.g + color.b) > 1.5)
return vec4(85.0/255.0, 1.0, 1.0, 1.0);
else
return vec4(0.0, 170.0/255.0, 170.0/255.0, 1.0);
}
}
Artal, A .PSD loader: https://github.com/EvineDev/Artal
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 2 guests