Author Topic: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1  (Read 27604 times)

0 Members and 1 Guest are viewing this topic.

Offline lkj

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 485
  • Rating: +58/-1
    • View Profile
Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
« Reply #30 on: March 03, 2012, 10:03:04 am »
the "directory for the tns file" means the name and directory were the compiled .tns will be. For example this line could be
Code: [Select]
DISTDIR = Example.tns
In the OBJS line you have to write the names of the .c files you want to compile, but with .o instead of .c at the end of each name.
So I could put
DISTDIR = C:/ndless/test1/testprogram.tns
?

I'm sorry that I was wrong and didn't answer :(
It would have to be
DISTDIR = C:/ndless/test1/
but I guess you've figured it out yourself.

Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
« Reply #31 on: March 05, 2012, 03:49:45 pm »
Nope. Never got rand() to compile.

Also, I guess I'll just make my sprites out of shapes for now. :P
« Last Edit: March 05, 2012, 03:49:51 pm by epic7 »

Offline totorigolo

  • LV2 Member (Next: 40)
  • **
  • Posts: 24
  • Rating: +9/-0
    • View Profile
Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
« Reply #32 on: March 06, 2012, 08:14:52 am »
Do you include <nMATHS.h> ? Otherwise show me your code.

In the current configuration of nRGBlib, it's not very useful to have sprites, because you can create as many shapes as you want, it's very light (for example, a box = int16_t x; + int16_t y; + int16_t w; + int16_t h;). This is why I have not yet implemented sprites so far.

Tell me if my English is bad  ;)
« Last Edit: March 06, 2012, 08:15:05 am by totorigolo »
nRGBlib - A portable graphic library for Nspire !

Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
« Reply #33 on: March 09, 2012, 08:36:49 pm »
nMATHS.h doesnt help, heres the code
http://pastebin.com/QfaM34Fc

Also, how do you display integers?

Offline totorigolo

  • LV2 Member (Next: 40)
  • **
  • Posts: 24
  • Rating: +9/-0
    • View Profile
Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
« Reply #34 on: March 10, 2012, 01:09:02 pm »
I have no problem with your code.

I've replaced like this:
Code: [Select]
        //seed=randnum(seed); //my goal is to give yvel a random value -128 to 128
        seed = randMinMax(-128, 128);
and it works pretty fine.

Can you send me your Makefile ?
« Last Edit: March 10, 2012, 01:09:12 pm by totorigolo »
nRGBlib - A portable graphic library for Nspire !

Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
« Reply #35 on: March 10, 2012, 02:51:46 pm »
I'd just need to do
yvel=randMinMax(-128, 128)
do do what i need

Makefile
Code: [Select]
GCC = nspire-gcc
LD = nspire-ld
GCCFLAGS = -Os -nostdlib -I"c:/nRGBlib/sdk/include/"
LDFLAGS = -L "c:/nRGBlib/sdk/lib/"
OBJCOPY := "$(shell (which arm-elf-objcopy arm-none-eabi-objcopy arm-linux-gnueabi-objcopy | head -1) 2>/dev/null)"
ifeq (${OBJCOPY},"")
OBJCOPY := arm-none-eabi-objcopy
endif
OBJS = pong.o
DISTDIR = .
vpath %.tns $(DISTDIR)

all: Pong.tns

%.o: %.c
$(GCC) $(GCCFLAGS) -c $<

%.o: %.S
$(GCC) $(GCCFLAGS) -c $<

Pong.tns: $(OBJS)
$(LD) $(LDFLAGS) $^ -o $(@:.tns=.elf) -lRGB
@mkdir -p $(DISTDIR)
$(OBJCOPY) -O binary $(@:.tns=.elf) $(DISTDIR)/$@

clean:
rm -f *.o *.elf
rm -f $(DISTDIR)/Pong.tns

Offline totorigolo

  • LV2 Member (Next: 40)
  • **
  • Posts: 24
  • Rating: +9/-0
    • View Profile
Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
« Reply #36 on: March 10, 2012, 06:55:02 pm »
Your Makefile seems to be good.

Quote
I'd just need to do
yvel=randMinMax(-128, 128)
do do what i need
I'm not sure to have understood, but if I have well understood, you're right :
Code: [Select]
while (players  == 0)
    {
        //seed++;
        rand();
        if (isKeyPressed(KEY_NSPIRE_CTRL))

        /* ... */

        //seed=randnum(seed); //my goal is to give yvel a random value -128 to 128
        //yvel=seed%257-128;
        yvel=randMinMax(-128, 128);
And I've checked yvel values and they are goods.

Sorry if I'm repeating me, but what is your problem exactly? What is the output of gcc if your code not compile?
nRGBlib - A portable graphic library for Nspire !

Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
« Reply #37 on: March 10, 2012, 10:45:29 pm »
Hm, I'll try it again and I'll show you the error if it fails.

Also, is there a way better than what I currently use to draw things?
My current way is something like:

Loop
{
Draw object
Pause
Do code stuffs
Draw white over object
Update object's coordinates
}

The objects flash a lot with this tho
« Last Edit: March 10, 2012, 11:45:31 pm by epic7 »

Offline totorigolo

  • LV2 Member (Next: 40)
  • **
  • Posts: 24
  • Rating: +9/-0
    • View Profile
Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
« Reply #38 on: March 12, 2012, 02:29:19 pm »
Your way seems good, but I can't help you much better, because I am just a French 15 years old boy who had learned thanks to the SdZ and alone to program :P So, nRGBlib's code is surely not optimized at all, and all suggestions / patch / help (/ ...) is obviously the welcome  ;) (→ https://bitbucket.org/totorigolo/nrgblib/issues?status=new&status=open)

The objects flash a lot with this tho

Indeed, I noticed that the ball is flashing a lot. Maybe, you can use drawBox instead of drawDisc to clear the previous ball, because it should be faster...
To draw circles or discs, I currently use Bresenham's algorithm (http://fr.wikipedia.org/wiki/Algorithme_de_trac%C3%A9_d%27arc_de_cercle_de_Bresenham (or in English http://en.wikipedia.org/wiki/Midpoint_circle_algorithm), thanks Excale for the link :)), and you can see my implementation here (https://bitbucket.org/totorigolo/nrgblib/src/d999e40ef8af/src/nRGBlib/drawDisc.c). Maybe an (more) optimized version exists.

Anyway, thanks you for your feedback :D
« Last Edit: March 12, 2012, 02:29:34 pm by totorigolo »
nRGBlib - A portable graphic library for Nspire !

Offline totorigolo

  • LV2 Member (Next: 40)
  • **
  • Posts: 24
  • Rating: +9/-0
    • View Profile
Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
« Reply #39 on: April 01, 2012, 06:06:24 am »
I am currently adding many new things to nRGBlib, whose images. The system is currently functional, but I have not optimized for the moment only the CX (16bpp), because I absolutely wants to keep compatibility between 16bpp / 4bpp without recompilation, and I'm having some problems with void* pointers ...

So if someone wants to help me in optimizing 4bpp in order to accelerate the next nRGBlib's release.  :)

I also plan to open PNG and JPG (because right now the format is one that I created) by integrating the source code of mViewer (for BMP and PNG) and of Nspire and Movie Player (of tangrs) (for JPG), which are released under GPL v2 and v3.
nRGBlib - A portable graphic library for Nspire !

Offline totorigolo

  • LV2 Member (Next: 40)
  • **
  • Posts: 24
  • Rating: +9/-0
    • View Profile
Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
« Reply #40 on: April 01, 2012, 03:24:42 pm »
Here is an example of nRGBlib's current features.

The map editor is coded in C + + with SFML. It was created thanks to this tutorial.


The sample run slower on 4bpp, because of non-optimization.


----

PS: For epic7, I haven't change your code, but I've just added the double-buffering :
« Last Edit: April 01, 2012, 03:55:24 pm by totorigolo »
nRGBlib - A portable graphic library for Nspire !

Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
« Reply #41 on: April 01, 2012, 03:47:41 pm »
very nice !! :o
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

Offline totorigolo

  • LV2 Member (Next: 40)
  • **
  • Posts: 24
  • Rating: +9/-0
    • View Profile
Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
« Reply #42 on: April 01, 2012, 03:56:24 pm »
Thanks you :D

If you want to play, or create your map, you will have to wait  :P
  • Image transparancy
  • Delete tiles
  • Open PNG / BMP
  • Optimizations on 4bpp
« Last Edit: April 01, 2012, 03:59:26 pm by totorigolo »
nRGBlib - A portable graphic library for Nspire !

Offline totorigolo

  • LV2 Member (Next: 40)
  • **
  • Posts: 24
  • Rating: +9/-0
    • View Profile
Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
« Reply #43 on: April 17, 2012, 06:09:33 pm »
nRGBlib v0.3 has just been released.
The main post has been updated.
A new has been published on TI-Planet : http://tiplanet.org/forum/viewtopic.php?p=123024.
nRGBlib - A portable graphic library for Nspire !

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55941
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
« Reply #44 on: April 17, 2012, 06:14:59 pm »
Awesome, nice to see you still working on this :)