PDA

View Full Version : SDL_Image



BB Hood
February 16th, 2007, 04:56
Okay, im working on sdl programming for the DC. I want to use SDL_Image so I can do more than just display BMP's with SDL_LoadBMP. The first thing that I noticed is that the lib is included in the Dreamcast Dev Environment R3 but the "SDL_Image.h" is not. What I did was I used a header file that I download for computer programming. Anyway it compiled correctly once I used that but when it got to displaying a .png image on the TV screen(serial upload) it only showed up black. I think it may be because I used a header file that was for programming for the computer. chui compiled the lib in the latest R3 Dev Environment. Has anybody else tried to use SDL_Image?

BB Hood
February 16th, 2007, 18:40
I found it in the making the lib section but I still get a black screen :(.

GPF
February 16th, 2007, 20:45
look in /usr/local/dc/kos1.3/kos-ports/SDL_image-1.2.4/

or the similiar directory structure for R3 should be where the header file exists. add

-I$(KOS_PORTS)/SDL_image-1.2.4
to you CFLAGS in your makefile/project settings etc.

how are you trying to load the file?

from /pc /cd /rd ? sounds like the file isn't being found.

Troy(GPF)

BB Hood
February 17th, 2007, 01:23
Yea, that is what I meant about finding "it". I should be more descriptive. Anyway I am uploading through the serial port of the Dreamcast. So yea, im doing it through the PC. Here is my makefile:


TARGET = testpng.elf
OBJS = charpng.o gfx.o
all: rm-elf $(TARGET)

include $(KOS_BASE)/Makefile.rules

KOS_CFLAGS += -o3 -fstrict-aliasing -fomit-frame-pointer -ffunction-sections
clean:
-rm -f $(TARGET) $(OBJS) romdisk.*

rm-elf:
-rm -f $(TARGET) romdisk.*

$(TARGET): $(OBJS) romdisk.o
$(KOS_CC) $(KOS_CFLAGS) $(KOS_LDFLAGS) -o $(TARGET) $(KOS_START) \
$(OBJS) romdisk.o $(OBJEXTRA) -L$(KOS_BASE)/lib -lSDL -lSDL_image -lpng -ljpeg -lSDL_mixer -lSDL -loggvorbisplay -ltremor -lkallisti -lk++ -lz -lm -lc -lk++ $(KOS_LIBS)

romdisk.img:
$(KOS_GENROMFS) -f romdisk.img -d romdisk -v

romdisk.o: romdisk.img
$(KOS_BASE)/utils/bin2o/bin2o romdisk.img romdisk romdisk.o

run: $(TARGET)
$(KOS_LOADER) $(TARGET)


So because I have -ISDL_image in the (KOS_BASE) section do I need to add it again?

As you can see the title of the lib for me is just "libSDL_image.a" not including the 1.2.4 stuff. I have recompiled the lib 3 times using the .c files I get with R3 and the .c files I get from chui's site(Which turns out to have the name including 1.2.4, I just renamed it to SDL_image). I think for the most part they are both the same just the name of the libs are different. Thanks for the help GPF I really appreciate it. :thumbup:

BlueCrab
February 17th, 2007, 15:10
KOS_CFLAGS += -o3 -fstrict-aliasing -fomit-frame-pointer -ffunction-sections
Optimize level 3 isn't a good idea on the Dreamcast in general. In general you should stick with the KOS default optimization flags, since they're the only ones that KOS and related things have been really tested with. I know in the past even -O2 caused problems on the sh-elf port of gcc, so I wouldn't doubt that changing optimization flags might have affected your code (then again, it might not, there might be some other problem).


$(TARGET): $(OBJS) romdisk.o
$(KOS_CC) $(KOS_CFLAGS) $(KOS_LDFLAGS) -o $(TARGET) $(KOS_START) \
$(OBJS) romdisk.o $(OBJEXTRA) -L$(KOS_BASE)/lib -lSDL -lSDL_image -lpng -ljpeg -lSDL_mixer -lSDL -loggvorbisplay -ltremor -lkallisti -lk++ -lz -lm -lc -lk++ $(KOS_LIBS)
Wow.... that is a jumbled mess of libraries you're linking in there..... I'd reorder it like this, if I were you:

-lSDL_image -lSDL_mixer -lSDL -lpng -ljpeg -ltremor -lz -lm -lk++ $(KOS_LIBS)That SHOULD cover everything, without extra junk going into the linker ($(KOS_LIBS) includes -lkallisti and -lc by default, also, linking -loggvorbisplay and -ltremor both is probably a bad idea.... they're supposed to do the same thing).

Hope that helps...

BB Hood
February 17th, 2007, 15:22
Thanks BlueCrab!

I am new to compiling using "Makefile" and cygwin and I think the Makefile I am using is a template or something. How would I stick with the KOS default optimization flags?

Got to work now so I will try what you game me later and get back to you. Thanks again.

BlueCrab
February 17th, 2007, 15:40
If you get rid of the line that starts with KOS_CFLAGS, you'll restore the default flags for compilation.

BB Hood
February 17th, 2007, 23:45
I changed the makefile by removing the CFLAGS and changing the LIBS according to what you posted and it compiled fine but I still get a black screen. The only thing that shows up is the mouse cursor on the top left corner of the screen.

I will get it to work....someday.