Rockbox Development > Starting Development and Compiling
"out of memory" when making a program with lots of drawpixel() calls
myrockboxacct:
I am trying to make a short "video" for my sansa clip v2.
I have a .c file with tons of rb->lcd_drawpixel() calls. (about 128*64 pixels * hundreds of frames)
The .c file itself is 2 megabytes.
When I type "make" from the build folder, it says "out of memory allocating 547340640 bytes after a total of 496640000 bytes". Please tell me how to fix this.
Someone told me I should use a data file and that I couldn't have so much stuff in a .c or .h file.
Is he right?
How do I make a data file? Can I google that question or is there some special rockbox format for that?
How do I read the data?
Do I have to use this?:
int read(int fildes, void *buf, size_t nbyte);
The read() function attempts to read nbyte bytes from the file associated
with the open file descriptor, fildes, into the buffer pointed to by buf.
I'm a C and Linux beginner. How do I learn these things? Google? I don't understand the function parameters.
--- Code: ---rb->lcd_clear_display();rb->lcd_drawpixel(104,22);rb->lcd_drawpixel(104,23);rb->lcd_drawpixel(104,24);rb->lcd_drawpixel(104,25);
rb->lcd_drawpixel(104,58);rb->lcd_drawpixel(104,59);rb->lcd_drawpixel(104,60);rb->lcd_update();rb->sleep(sleeptime);
/* Then theres a million more of the above*/
--- End code ---
Thanks for helping.
Llorean:
You should really, really take a step back and find a good C tutorial. Learning the language, how programs work, and what a compiler's doing will benefit you a lot in being able to figure things out. While trying to get started by diving in head first is commendable, background material will save you a lot of time and frustration in the long term.
myrockboxacct:
How do I make a data file? Can I google that question or is there some special rockbox way to do that?
How do I read the data? Can I google that question or is there some special rockbox way to do that?
Llorean:
See, that's the thing. It doesn't even look like you're asking the right questions. It looks, based on the code sample, that you'd probably be better off drawing things with a few basic algorithms rather than stating each individual drawpixel. Which would affect how you create the data file (since you'd need to decide the format of the data). How you read said file can mostly be worked out by looking at other programs that load files, of which there are many.
Trying to solve this by asking one question at a time is just going to result in people writing half your program for you, and you not really understanding well what you're doing. If you take the time to stop and learn C, you'll have a skill that's more reusable, and when you do stop by to ask questions they'll much more often be useful ones, and much less often be ones where someone says "I think you're going about this all wrong." Which, I suspect you are, again, based on the code snippet.
nls:
How to deal with files in rockbox is just like standard posix c, you'll find lots of info about it on the net. The format of your data file(s) is up to you. As you probably have figured out, doing what you're doing isn't the right way, drawing graphics isn't what the lcd_drwapixel function is intended for. Take some time looking at the plugin api and you'll see we have other drawing functions that can for example draw bitmaps. These rockbox specific functions you will probably not find much about by googling, the best docs there are is the source code for the functions themselves and other plugins using them.
Navigation
[0] Message Index
[#] Next page
Go to full version