Easy GL2D

Got something cool to help make the toolchains better? Post it here.

Should libgl2d be integrated into libnds? http://devkitpro.org/viewtopic.php?p=6893#p6893

Yes, integrate it immediately if not sooner.
41
40%
No, let's have this as a separate library and work towards middleware.
20
20%
Let's do both - integrate it as is and build an abstraction layer on top.
17
17%
I'm good with whatever is decided.
24
24%
 
Total votes: 102

relminator
Posts: 84
Joined: Sun Apr 11, 2010 10:43 am

Re: Easy GL2D

Post by relminator » Fri Feb 18, 2011 3:24 am

Yo, Enay. I have just updated the lib. See if it fixes some of the issues you posted.

Better Docs too.

;*)

ENAY
Posts: 15
Joined: Mon Aug 16, 2010 7:29 am
Location: Japan

Re: Easy GL2D

Post by ENAY » Fri Feb 18, 2011 3:46 am

Thanks man. I will take a look now. :)

ENAY
Posts: 15
Joined: Mon Aug 16, 2010 7:29 am
Location: Japan

Re: Easy GL2D

Post by ENAY » Fri Feb 18, 2011 4:23 am

[snip]
Last edited by ENAY on Fri Feb 18, 2011 5:05 am, edited 1 time in total.

Discostew
Posts: 103
Joined: Sun Mar 08, 2009 7:24 pm

Re: Easy GL2D

Post by Discostew » Fri Feb 18, 2011 4:40 am

ENAY wrote: Compiling the 'sprites' example gives me the error:-

Code: Select all

gl2d.c:(.text+0x16da): undefined reference to 'glColorTableEXT'
I hope this helps. For now I will revert back to the previous version of your library.
Have you updated to the newest version of libnds?

ENAY
Posts: 15
Joined: Mon Aug 16, 2010 7:29 am
Location: Japan

Re: Easy GL2D

Post by ENAY » Fri Feb 18, 2011 4:41 am

Aaaah, no. That might explain everything ;)

[edit]Updated!

Looks like the GL2D library has changed a bit to do with pallettes so I need to modify my source code.

By the way Relminator I've also just reminded myself of something, in the features list you mention that this library supports 'alpha' but yet there are no parameters (as it seems) in your functions to enable to do so.

Keep up the good work :)

relminator
Posts: 84
Joined: Sun Apr 11, 2010 10:43 am

Re: Easy GL2D

Post by relminator » Fri Feb 18, 2011 8:40 am

ENAY wrote:Aaaah, no. That might explain everything ;)

[edit]Updated!

Looks like the GL2D library has changed a bit to do with pallettes so I need to modify my source code.

By the way Relminator I've also just reminded myself of something, in the features list you mention that this library supports 'alpha' but yet there are no parameters (as it seems) in your functions to enable to do so.

Keep up the good work :)
Yeah, palettes are now bounded to the textures. Easier to use BTW.

Alpha support is via the textures you upload yourself. GL2D has nothing to do with it.

ENAY
Posts: 15
Joined: Mon Aug 16, 2010 7:29 am
Location: Japan

Re: Easy GL2D

Post by ENAY » Fri Feb 18, 2011 9:40 am

Well I am still having problems compiling. I get a lot of errors when it tries to create the .elf file.

Code: Select all

linking jss-ds.elf
c:/devkitPro/libnds/lib\libgl2d.a(gl2d.o): In function `glScreen2D':
gl2d.c:(.text+0x1b2): undefined reference to `glInit_C'
gl2d.c:(.text+0x518): undefined reference to `glGlobalData'
gl2d.c:(.text+0x6a2): undefined reference to `glMaterialf'
gl2d.c:(.text+0x6aa): undefined reference to `glMaterialf'
gl2d.c:(.text+0x6b2): undefined reference to `glMaterialf'
gl2d.c:(.text+0x6ba): undefined reference to `glMaterialf'
c:/devkitPro/libnds/lib\libgl2d.a(gl2d.o): In function `glPutPixel':
gl2d.c:(.text+0x7c0): undefined reference to `glBindTexture'
c:/devkitPro/libnds/lib\libgl2d.a(gl2d.o): In function `glLine':
gl2d.c:(.text+0x81e): undefined reference to `glBindTexture'
c:/devkitPro/libnds/lib\libgl2d.a(gl2d.o): In function `glBox':
gl2d.c:(.text+0x896): undefined reference to `glBindTexture'
c:/devkitPro/libnds/lib\libgl2d.a(gl2d.o): In function `glBoxFilled':
gl2d.c:(.text+0x942): undefined reference to `glBindTexture'
c:/devkitPro/libnds/lib\libgl2d.a(gl2d.o): In function `glBoxFilledGradient':
gl2d.c:(.text+0x9ca): undefined reference to `glBindTexture'
c:/devkitPro/libnds/lib\libgl2d.a(gl2d.o):gl2d.c:(.text+0xa66): more undefined references to `glBindTexture' follow
c:/devkitPro/libnds/lib\libgl2d.a(gl2d.o): In function `glLoadSpriteSet':
gl2d.c:(.text+0x1600): undefined reference to `glGenTextures'
gl2d.c:(.text+0x1608): undefined reference to `glBindTexture'
gl2d.c:(.text+0x1624): undefined reference to `glTexImage2D'
gl2d.c:(.text+0x163a): undefined reference to `glColorTableEXT'
c:/devkitPro/libnds/lib\libgl2d.a(gl2d.o): In function `glLoadTileSet':
gl2d.c:(.text+0x16a0): undefined reference to `glGenTextures'
gl2d.c:(.text+0x16a8): undefined reference to `glBindTexture'
gl2d.c:(.text+0x16c4): undefined reference to `glTexImage2D'
gl2d.c:(.text+0x16da): undefined reference to `glColorTableEXT'
collect2: ld returned 1 exit status
make[1]: *** [/c/work/devkitpro-stuff/jss-ds/jss-ds.elf] Error 1
rm gfx.s
"make": *** [build] Error 2

> Process Exit Code: 2
> Time Taken: 00:19
Not sure where the problem lies, I noticed the source code in all of the examples has changed too so I have gone through every line of the source code and also compared the make files to see if anything else was changed. Perhaps I need to start a new project in devkitpro?




Ah yes, the Alpha support thing, I was getting confused between Alpha and Transparency. Indeed the command I was looking for was, for example:-

"glPolyFmt(POLY_ALPHA(31) | POLY_CULL_NONE | POLY_ID(5));"

to have a percentage of drawing transparency.

Anyway, back to fault searching.

WinterMute
Site Admin
Posts: 1845
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: Easy GL2D

Post by WinterMute » Fri Feb 18, 2011 1:14 pm

Looks like you're probably linking in the wrong order, libgl2d uses functions from libnds so it needs to be specified first in the LIBS line - i.e.

Code: Select all

LIBS	:=	-lgl2d -lnds9
This brings up an interesting point though. As it stands now this library would probably serve users better if it was integrated into libnds rather than maintained separately. On the other hand I've already seen this working as a cross platform library on OSX, Windows and linux so it could potentially make for a nice piece of middleware if it were abstracted a bit more and included features for user input and audio output. The other way to go is to integrate this into libnds as it is now and build an abstraction layer on top of it later.

Anyone have any thoughts? I'll add a poll and a link to this post in the thread in a bit. I may go with the result of the vote or make an executive decision based on the general discussion.
Help keep devkitPro toolchains free, Donate today

Personal Blog

ENAY
Posts: 15
Joined: Mon Aug 16, 2010 7:29 am
Location: Japan

Re: Easy GL2D

Post by ENAY » Fri Feb 18, 2011 2:18 pm

Thanks Wintermute, :D

That indeed worked, odd how before it worked with the parameters in reverse, I am using max mod library but that was always last. Anyway, thanks for that, it compiles ok now. It seems I always get beaten by the simplest of things.

Well, I think this library is really good. Although I've only been tinkering with the DS for a few weeks this library has really taken out a lot of low level programming and made things really easy to understand. I have had about 50 or so sprites rendering on both screens with backgrounds simultaneously without slowdown (slow in emulators though)
For 2D games I think this is ideal, you could easily make any kind of 2D game using this library on the DS.

If I had a suggestion, it would be that the library needs some sort of unload function, as currently there isn't really any way to know where your pointer is in memory. At some point I am probably going to want to swap around images in memory to transition to other graphics. Get rid of one image and replace it with another. Still not sure how I am going to do this but if there is a bit more automatic memory management (of course very difficult if you are using lots of different types of images) that would be great. To be safe I have simply made a 256x1024 image all tiled with everything I could possibly need. I have also opened up all the banks for memory.

Code: Select all

// Set  Bank A to texture (128 kb)
	vramSetBankA( VRAM_A_TEXTURE );
	vramSetBankB( VRAM_B_TEXTURE );
	vramSetBankC( VRAM_C_TEXTURE );
	vramSetBankD( VRAM_D_TEXTURE );
	
	vramSetBankE(VRAM_E_TEX_PALETTE);
For now 512kb is more than enough for me. But yes, if there is a way to easily load images in and out of memory I would love to see that, even if it's just a limitation that you can only load in another image of the same type and colour depth that you first created, then I would be more than happy.

Not sure if this library needs more features for input or output. Better to leave it as a dedicated gfx library since loading sounds and detecting input is a lot simpler than loading and displaying graphics. Well that's just me anyway. But right now (aside from learning how to save and load files on a cartridge) I have pretty much everything I could possibly need.

relminator
Posts: 84
Joined: Sun Apr 11, 2010 10:43 am

Re: Easy GL2D

Post by relminator » Fri Feb 18, 2011 2:45 pm

Enay: LibNDS 1.5.0 can do dynamic textures.


Just glDeleteTexture() when you want to unload it. Then do a glLoad[Sprite/Tile]set() after that to load another texture.

Should work as long as you have enough VRAM allocated for textures.

BTW, pls. vote on the poll WM added.

edit: Could we have a look-see of your current game? ;*)

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest