forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

PSPGL CPP in jsgf version

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Thanhda



Joined: 09 Apr 2005
Posts: 331
Location: Canada

PostPosted: Wed Dec 14, 2005 5:44 am    Post subject: PSPGL CPP in jsgf version Reply with quote

Hey, i was wondering how do you set up a cpp app in jsgf version of pspgl. In holgers version i was able to with no problem. here the patch he gave me.

Code:
$ svn diff
Index: psp-setup.c
===================================================================
--- psp-setup.c (revision 1100)
+++ psp-setup.c (working copy)
@@ -169,7 +169,7 @@
 {
        int id;
        pspKernelSetKernelPC();
-       pspDebugInstallErrorHandler((void *) 0);
+       pspDebugInstallErrorHandler((PspDebugErrorHandler) (void *) 0);
        if ((id = sceKernelCreateThread("update_thread", update_thread, 0x11, 0xFA0, PSP_THREAD_ATTR_USER, 0)) >= 0)
                sceKernelStartThread(id, 0, 0);
 }
Index: eglcube.c
===================================================================
--- eglcube.c   (revision 1082)
+++ eglcube.c   (working copy)
@@ -1,3 +1,6 @@
+
+extern "C" {
+
 #include <pspctrl.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -7,10 +10,11 @@
 #include <GLES/egl.h>
 #include <GLES/gl.h>
 
-
 extern unsigned char logo_start[];
 
+};
 
+
 struct Vertex
 {
        float u, v;
@@ -80,7 +84,7 @@
        #define psp_log(x...) __psp_log(x)
 #else
        #define psp_log(x...) do {} while (0)
-       extern void __psp_log (const char *fmt, ...);
+       extern "C" void __psp_log (const char *fmt, ...);
 #endif
 
 /* enable GLerror logging to "ms0:/pspgl.ge" */
Index: Makefile
===================================================================
--- Makefile    (revision 1049)
+++ Makefile    (working copy)
@@ -1,4 +1,5 @@
 ARCH = psp-
+CPP = $(ARCH)g++
 CC = $(ARCH)gcc
 PSP_INSTALL = ../tools/psp-install
 RM = rm -f
@@ -6,7 +7,7 @@
 PSPPATH := $(shell psp-config --pspsdk-path)
 PSPGL_LFLAGS = -lGLU -lGL -lpspdebug -lpspge -lpspdisplay -lpspctrl -lpspsdk -lm -lc -lpspuser -lpspkernel
 CFLAGS = -g -Wall -O2 -MD -I$(PSPPATH)/include -I..
-LFLAGS = -g -Wall -O2 -DMODULE_NAME="test-egl" psp-setup.c -L$(PSPPATH)/lib -L.. $(PSPGL_LFLAGS)
+LFLAGS = -g -Wall -O2 -DMODULE_NAME="test-egl" psp-setup.c -L$(PSPPATH)/lib -L.. -lstdc++ $(PSPGL_LFLAGS)
 
 TARGET = pspGL-cube
 OBJS = eglcube.o logo.o
@@ -19,7 +20,7 @@
 all: $(TARGET)
 
 .c.o:
-       $(CC) $(CFLAGS) -c $<
+       $(CPP) $(CFLAGS) -c $<
 
 logo.o: logo.raw
        bin2o -i logo.raw logo.o logo



And it compiles like this

Code:
$ make
psp-g++ -g -Wall -O2 -MD -I/usr/local/pspdev/psp/sdk/include -I.. -c eglcube.cpp
bin2o -i logo.raw logo.o logo
psp-gcc eglcube.o logo.o -g -Wall -O2 -DMODULE_NAME="test-egl" psp-setup.c -L/usr/local/pspdev/psp/sdk/lib -L.. -lstdc++ -lGLU -lGL -lpspdebug -lpspge -lpspdisplay -lpspctrl -lpspsdk -lm -lc -lpspuser -lpspkernel -o pspGL-cube


i've tried implementing this into jsgf version, but certain functions where missing. i'm not at home right now so i cant post the errors i got.
_________________
There are 10 types of people in the world: Those who understand binary, and those who don't...
Back to top
View user's profile Send private message Visit poster's website
jsgf



Joined: 12 Jul 2005
Posts: 254

PostPosted: Wed Dec 14, 2005 10:58 am    Post subject: Reply with quote

I haven't done much with PSPGL and C++, but it shouldn't be too hard to make work properly.
Back to top
View user's profile Send private message Visit poster's website
Thanhda



Joined: 09 Apr 2005
Posts: 331
Location: Canada

PostPosted: Wed Dec 14, 2005 12:21 pm    Post subject: Reply with quote

i was wondering, since you seem to have taken over the pspgl development, if you can try yourself to see how it might fit in. i havnt given up trying yet tho, but am currently working on the 3ds loader for your version of pspgl.
_________________
There are 10 types of people in the world: Those who understand binary, and those who don't...
Back to top
View user's profile Send private message Visit poster's website
jsgf



Joined: 12 Jul 2005
Posts: 254

PostPosted: Wed Dec 14, 2005 5:18 pm    Post subject: Reply with quote

Yeah, I'll take a look at it in the next couple of days.

Did you work out your file IO problem?
Back to top
View user's profile Send private message Visit poster's website
Thanhda



Joined: 09 Apr 2005
Posts: 331
Location: Canada

PostPosted: Thu Dec 15, 2005 6:46 am    Post subject: Reply with quote

well i havnt had time to work too much on it. since i'm busy with university and all. but the original errors occured in holgers verion of pspgl. So i'm right now slowly coding one using your version of pspgl. but i'm probably going to finish it up during the weekend.
_________________
There are 10 types of people in the world: Those who understand binary, and those who don't...
Back to top
View user's profile Send private message Visit poster's website
Thanhda



Joined: 09 Apr 2005
Posts: 331
Location: Canada

PostPosted: Sun Jan 01, 2006 6:02 am    Post subject: Reply with quote

Okay, been working on a pspgl cpp for jsf version. Heres what i got so far

Code:
psp-g++ -g -Wall -O2 -MD -MF .deps/glut.d -I.. -I/usr/local/pspdev/psp/sdk/inclu
de -c glut.cpp
glut.cpp:214:3: warning: no newline at end of file
psp-gcc -g -Wall -O2 -MD -MF .deps/psp-setup-glut.d -I.. -I/usr/local/pspdev/psp
/sdk/include -o psp-setup-glut.o -c -DMODULE_NAME="glut" psp-setup.c
psp-gcc -o glut.elf -g -Wall -L.. -stdc++ -L/usr/local/pspdev/psp/sdk/lib glut.o
 psp-setup-glut.o  -lpng -lz -lglut -lGLU -lGL -lm -lc -lpsputility -lpspdebug -
lpspge -lpspdisplay -lpspctrl -lpspsdk -lpsplibc -lpspuser -lpspkernel -lpsprtc
glut.o:(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
make: *** [glut.elf] Error 1
rm psp-setup-glut.o


Not quite sure what the error is. So i'll post my source online. This includes a Make file. so you just just toss it in the pspgl directory.

http://www.geocities.com/tsune_l/test-cpp.zip

This is based off my BMP loader available at
http://forums.ps2dev.org/viewtopic.php?t=4487

the only think i really did was replace

Code:
extern "C" void __pspgl_log (const char *fmt, ...);


in line 10, in glchk.h file. and added extern "C" in the cpp file.

here what i did in the make file

Code:
ARCH = psp-
CPP= $(ARCH)g++
CC = $(ARCH)gcc
AS = $(ARCH)as
SIZE = $(ARCH)size
PSP_INSTALL = ../tools/psp-install
RM = rm -f

PSPPATH := $(shell psp-config --pspsdk-path)
PSPGL_LFLAGS = -lglut -lGLU -lGL -lm -lc -lpsputility -lpspdebug -lpspge -lpspdisplay -lpspctrl -lpspsdk -lpsplibc -lpspuser -lpspkernel -lpsprtc
CFLAGS = -g -Wall -O2 -MD -MF $(DEPDIR)/$(basename $@).d -I.. -I$(PSPPATH)/include
LDFLAGS = -g -Wall -L.. -stdc++ -L$(PSPPATH)/lib

TESTS=glut
#TESTS+=idxtex

BUILDDATE := $(shell date "+%Y/%m/%d %k:%M:%S")
PSP_EBOOT_TITLE = $(TARGET) $(BUILDDATE)
PSP_EBOOT_ICON = firefox.png
PSP_EBOOT_ICON1 = NULL
PSP_EBOOT_UNKPNG = NULL
PSP_EBOOT_PIC1 = NULL
PSP_EBOOT_SND0 = NULL
PSP_EBOOT_PSAR = NULL

DEPDIR = .deps
PSPSDK := $(shell psp-config --pspsdk-path)

all: $(DEPDIR) $(TESTS:%=%.elf)

install: $(TESTS:%=install-%)

-include install-settings

install-%: %.elf
   while [ ! -d $(PSP_MOUNTDIR)/psp/game ]; do mount $(PSP_MOUNTDIR); sleep 1; done
   PSP_MOUNTDIR=$(PSP_MOUNTDIR) \
      $(PSP_INSTALL) $(INSTALLFLAGS) $< \
      --eboot-title="$* $(BUILDDATE)" --eboot-icon="firefox.png"
   umount $(PSP_MOUNTDIR)

DXTTEX:=$(wildcard dxt3/*.dxt3)
DXTOBJ:=$(DXTTEX:%.dxt3=%.o)

glut.elf:glut.o $(DXTOBJ)

psp-setup-%.o: psp-setup.c
   $(CC) $(CFLAGS) -o $@ -c -DMODULE_NAME="$(patsubst psp-setup-%.o,%,$@)" psp-setup.c

%.elf: %.o psp-setup-%.o ../libGL.a ../libGLU.a ../libglut.a
   $(CC) -o $@ $(LDFLAGS) $(filter %.o,$^)  -lpng -lz $(PSPGL_LFLAGS)

%.sys: %-sys.o
   cc -o $@ $^ -lglut -lGL

%.raw: %.png
   convert $< rgba:$@

%-mono.raw: %.png
   convert $< gray:$@

%.o: %.raw
   (sym=`echo $(notdir $*) | tr '-' '_'`; \
    echo -e ".data\n.global $${sym}_start\n$${sym}_start:\n\t.incbin \"$<\"" | $(AS) -o $@)

%.o: %.dxt3
   (sym=`echo $(notdir $*) | tr '-' '_'`; \
    echo -e ".data\n.global $${sym}_start\n.global $${sym}_end\n$${sym}_start:\n\t.incbin \"$<\"\n$${sym}_end:\n" | $(AS) -o $@)

textab.h: $(DXTTEX) Makefile
   (for i in $(DXTTEX); do b=`basename $$i .dxt3`; echo "extern unsigned char $${b}_start[], $${b}_end[];"; done; \
    echo "static const struct { const unsigned char *start, *end; } dxt[] = {"; \
    for i in $(DXTTEX); do b=`basename $$i .dxt3`; echo "     { $${b}_start, $${b}_end },"; done; \
         echo "};" )> $@ || rm -f $@


%.o: $(DEPDIR) %.c
   $(CC) $(CFLAGS) -c $*.c

%.o: $(DEPDIR) %.cpp
   $(CPP) $(CFLAGS) -c $*.cpp

%-sys.o: %.c
   cc -g -DSYS -c -o $@ $<

$(DEPDIR):
   mkdir $(DEPDIR)

clean:
   $(RM) $(DEPDIR)/*.d *.o $(DXTOBJ) *.a *.elf *.sys *~

-include $(wildcard *.d) dummy

_________________
There are 10 types of people in the world: Those who understand binary, and those who don't...
Back to top
View user's profile Send private message Visit poster's website
jimparis



Joined: 10 Jun 2005
Posts: 1179
Location: Boston

PostPosted: Sun Jan 01, 2006 6:32 am    Post subject: Reply with quote

Thanhda wrote:
Code:
psp-gcc -o glut.elf -g -Wall -L.. -stdc++ -L/usr/local/pspdev/psp/sdk/lib glut.o psp-setup-glut.o  -lpng -lz -lglut -lGLU -lGL -lm -lc -lpsputility -lpspdebug -lpspge -lpspdisplay -lpspctrl -lpspsdk -lpsplibc -lpspuser -lpspkernel -lpsprtc
Not quite sure what the error is.
Put -lstdc++ at the end. Or use psp-g++. Also read http://forums.ps2dev.org/viewtopic.php?p=23298#23298.
Back to top
View user's profile Send private message
Thanhda



Joined: 09 Apr 2005
Posts: 331
Location: Canada

PostPosted: Sun Jan 01, 2006 6:53 am    Post subject: Reply with quote

still get an error. i tried that already.

Code:
psp-g++ -g -Wall -O2 -MD -MF .deps/glut.d -I.. -I/usr/local/pspdev/psp/sdk/inclu
de -c glut.cpp
glut.cpp:214:3: warning: no newline at end of file
psp-gcc -g -Wall -O2 -MD -MF .deps/psp-setup-glut.d -I.. -I/usr/local/pspdev/psp
/sdk/include -o psp-setup-glut.o -c -DMODULE_NAME="glut" psp-setup.c
psp-g++ -o glut.elf -g -Wall -L.. -L/usr/local/pspdev/psp/sdk/lib glut.o psp-set
up-glut.o  -lpng -lz -lglut -lGLU -lGL -lm -lc -lpsputility -lpspdebug -lpspge -
lpspdisplay -lpspctrl -lpspsdk -lpsplibc -lpspuser -lpspkernel -lpsprtc -lstdc++

/usr/local/pspdev/lib/gcc/psp/4.0.2/../../../../psp/lib/libc.a(chdir.o): In function `chdir':
../../../../../../newlib/libc/sys/psp/libcglue.c:88: undefined reference to sceIoDopen'
../../../../../../newlib/libc/sys/psp/libcglue.c:93: undefined reference to sceIoDclose'
../../../../../../newlib/libc/sys/psp/libcglue.c:95: undefined reference to `sceIoChdir'
/usr/local/pspdev/lib/gcc/psp/4.0.2/../../../../psp/lib/libc.a(_stat.o): In function `_stat':
../../../../../../newlib/libc/sys/psp/libcglue.c:516: undefined reference to sc
eIoGetstat'
collect2: ld returned 1 exit status
make: *** [glut.elf] Error 1
rm psp-setup-glut.o

_________________
There are 10 types of people in the world: Those who understand binary, and those who don't...
Back to top
View user's profile Send private message Visit poster's website
mrbrown



Joined: 17 Jan 2004
Posts: 1536

PostPosted: Sun Jan 01, 2006 7:48 am    Post subject: Reply with quote

The error is caused by not having the correct library order. Read the post jimparis referred you to or keep fiddling with the order until it works.
Back to top
View user's profile Send private message
Thanhda



Joined: 09 Apr 2005
Posts: 331
Location: Canada

PostPosted: Sun Jan 01, 2006 7:58 am    Post subject: Reply with quote

problem solved. i just placed the -lstdc++ before the -lc and it works. thanks for all the help.

Code:
PSPGL_LFLAGS = -lglut -lGLU -lGL -lstdc++ -lm -lc -lpsputility -lpspdebug -lpspge -lpspdisplay -lpspctrl -lpspsdk -lpsplibc -lpspuser -lpspkernel -lpsprtc

_________________
There are 10 types of people in the world: Those who understand binary, and those who don't...
Back to top
View user's profile Send private message Visit poster's website
Thanhda



Joined: 09 Apr 2005
Posts: 331
Location: Canada

PostPosted: Sun Jan 01, 2006 8:20 am    Post subject: Reply with quote

Okay, Now it compiles just fine, but when i run it. it just goes to a black screen, waits 20 secs, then turns off. does anyone know why it would do this?

Edit Fixed.
changed from this from Makefile
Code:
%.elf: %.o psp-setup-%.o ../libGL.a ../libGLU.a ../libglut.a
   $(CPP) -o $@ $(LDFLAGS) $(filter %.o,$^)  -lpng -lz $(PSPGL_LFLAGS)


to this
Code:
%.elf: %.o psp-setup-%.o ../libGL.a ../libGLU.a ../libglut.a
   $(CC) -o $@ $(LDFLAGS) $(filter %.o,$^)  -lpng -lz $(PSPGL_LFLAGS)


only supose to compile the cpp file using psp-g++. Also removed extern "C" from the glchk.h file. as it only need to be called once in the cpp file.

Here I have posted the code online for people to try it out. Its a port of my bmp loader into cpp.

http://www.geocities.com/tsune_l/test-cpp.zip
_________________
There are 10 types of people in the world: Those who understand binary, and those who don't...
Back to top
View user's profile Send private message Visit poster's website
SiW



Joined: 10 Aug 2005
Posts: 7
Location: Whittemore, Iowa, USA

PostPosted: Thu Jul 13, 2006 4:42 am    Post subject: Reply with quote

Bringing this back up just for reference.

Thanks for posting the code, Thanhda. To build properly with the current version of PSPSDK, you need to link with pspvfpu also. So the line in the Makefile becomes:

Code:
PSPGL_LFLAGS = -lglut -lGLU -lGL -lstdc++ -lm -lc -lpsputility -lpspdebug -lpspge -lpspdisplay -lpspctrl -lpspsdk -lpspvfpu -lpsplibc -lpspuser -lpspkernel -lpsprtc
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group