Search found 9 matches

by gradualgames
Fri May 08, 2020 5:59 pm
Forum: Support and Development
Topic: Simple palette shader giving me all white or all black.
Replies: 4
Views: 6537

Re: Simple palette shader giving me all white or all black.

So I resuscitated my project the last few weeks. I thought I had had this issue fixed, but the syntax of the shader wasn't the last remaining issue as on some machines, I was still getting all black. On other machines, I was getting odd colorization. So with my palette shader above, I generate a 256...
by gradualgames
Wed Mar 20, 2019 7:24 pm
Forum: General
Topic: Reading binary files quickly.
Replies: 21
Views: 15514

Re: Reading binary files quickly.

in Love2D, or any helpful Lua libraries out there that build up a "virtual file" abstraction, perhaps? What I've got works just fine but I figured I'd ask anyway. https://github.com/megagrump/moonblob is faster, more flexible and less cumbersome to use than love.data.pack/unpack for compl...
by gradualgames
Mon Mar 04, 2019 10:16 pm
Forum: General
Topic: Reading binary files quickly.
Replies: 21
Views: 15514

Re: Reading binary files quickly.

I actually almost just dug into the moonblob code to learn how to parse floating point numbers because I think I'm almost through all the types I need to parse in my own mini binary parser. BlobReader:f32 reads 32 bits floating point numbers. BlobReader:f64 reads 64 bits floating point numbers. Her...
by gradualgames
Mon Mar 04, 2019 8:56 pm
Forum: General
Topic: Reading binary files quickly.
Replies: 21
Views: 15514

Re: Reading binary files quickly.

For instance, this file format contains strings which have a uShort header (2 bytes) followed by the characters of the strings. I couldn't infer from the unpack or moonblob documentation if the header for a string was a ushort or a normal 32 bit integer. local reader = BlobReader(data) local len = ...
by gradualgames
Mon Mar 04, 2019 8:17 pm
Forum: General
Topic: Reading binary files quickly.
Replies: 21
Views: 15514

Re: Reading binary files quickly.

Thanks for the responses. I've been looking at the documentation for unpack and moonblob, but it is not clear to me that I could use these without modification. For instance, this file format contains strings which have a uShort header (2 bytes) followed by the characters of the strings. I couldn't ...
by gradualgames
Sun Mar 03, 2019 12:14 am
Forum: General
Topic: Reading binary files quickly.
Replies: 21
Views: 15514

Re: Reading binary files quickly.

then interpret the contents, than continuously perform small file accesses one after the other. It's usually faster to call a few C functions from Lua compared to calling a lot of C function. If you want to iterate every byte of a string, note that string.byte can return multiple parameters: string...
by gradualgames
Sat Mar 02, 2019 10:14 pm
Forum: General
Topic: Reading binary files quickly.
Replies: 21
Views: 15514

Reading binary files quickly.

I've used love.filesystem.read(fileName) to load an entire file's contents into a string. Then I have been using string:byte(start,end) to pluck fields out of the file. I also have tried File:read(numBytes), however I noticed it appears to be dramatically faster to load an entire file into a string,...
by gradualgames
Thu Feb 21, 2019 3:19 am
Forum: Support and Development
Topic: Simple palette shader giving me all white or all black.
Replies: 4
Views: 6537

Re: Simple palette shader giving me all white or all black.

I've already found a solution to my issue; however I have no idea why it fixed it, and would still be interested in learning why. I found this example in the docs: vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords) { vec4 texturecolor = Texel(texture, texture_coords); re...
by gradualgames
Thu Feb 21, 2019 3:04 am
Forum: Support and Development
Topic: Simple palette shader giving me all white or all black.
Replies: 4
Views: 6537

Simple palette shader giving me all white or all black.

My goal is to write a shader which, given any pixel on the screen, uses the red component of the color as an index into a 256 pixel wide, 1 pixel tall texture as a palette lookup table. I want to simulate a 256 color palettized screen mode from the old days, in other words. I was able to get a very ...