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 

Question about graphics.h TV-out functions

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



Joined: 17 Aug 2006
Posts: 154

PostPosted: Thu Dec 06, 2007 7:18 am    Post subject: Question about graphics.h TV-out functions Reply with quote

Hi! Now I have modified graphics.h file that supports Tv-out,but please guide me how to use it,I see that there are 4 functions regarding TV,please tell me where shall I call them and with which parameters(I want to display video over composite cable,interlaced,upscaled to 480p).I'm talking about these functions:
Code:

void setGraphicsVideoMode(int mode);
void setGraphicsTVAspectRatio(int ar);
void setGraphicsTVOverScan(int left, int top, int right, int bottom);
void setGraphicsScreen(int width, int height, int scale);
Thanks :D
Back to top
View user's profile Send private message
SamuraiX



Joined: 31 Jan 2006
Posts: 76
Location: USA

PostPosted: Thu Dec 06, 2007 11:33 am    Post subject: Reply with quote

It looks like you are using my version of the graphics lib which was based off of Cooleyes' version.

So here it goes:

setGraphicsVideoMode(int mode) sets the output for LCD or TV Out based on the cable type that is inserted or by the User Interface selection that you created.

setGraphicsTVAspectRatio(int ar) will set a global variable that is used for doing on the fly screenHeight manipulation. Meaning you will set your Video Output to 16:9 or 4:3 mode.

setGraphicsTVOverScan(int left, int top, int right, int bottom) is used for setting the image within the TV screen. Now you will notice that when you set the values to Zero, there is a significant amount of overscan and you will want this manipulate your image's size to fit the screen accordingly. This should be controlled by some type of User Interface, so that each person can control their overscan as every TV is different.

setGraphicsScreen(int width, int height, int scale) Now this is a function I created for my application. Basically what this function does is....

Part 1: When the source image is 320x240 the user has the option to scale the image to take up 480x272 (if using the LCD screen) or 720x480 (if using the TV-Out). At the same time if the value for scale is set to 1 it uses bilinear filtering if set to 2 it uses nearest scaling.

Part 2: When the source image is 480x272 the image is left alone and is sent to the LCD screen or scaled to 720x480 automatically if using TV-Out. At the same time if the value for scale is set to 1 it uses bilinear filtering if set to 2 it uses nearest scaling.

I hope this helps. Now just know this.... if you see any functions with s_screen you do not need them as they are only used for my engine called OpenBOR.


Good Luck!
Back to top
View user's profile Send private message Visit poster's website
gambiting



Joined: 17 Aug 2006
Posts: 154

PostPosted: Fri Dec 07, 2007 1:18 am    Post subject: Reply with quote

Hi! Thank you for your response,but I have a lot of problems with it,here are errors I get:

Code:
gambiting@gambiting-desktop:~/psp/shoot4fun_tv$ make
psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -g -G4 -Wall -O2 -D_PSP_FW_VERSION=371   -c -o graphics.o graphics.c
In file included from graphics.c:13:
graphics.h:45: error: expected declaration specifiers or ‘...’ before ‘s_screen’
graphics.c:33: error: expected declaration specifiers or ‘...’ before ‘s_screen’
graphics.c:39: error: expected declaration specifiers or ‘...’ before ‘s_screen’
graphics.c:40: error: expected declaration specifiers or ‘...’ before ‘s_screen’
graphics.c:363: error: expected declaration specifiers or ‘...’ before ‘s_screen’
graphics.c: In function ‘blitScreenToScreen’:
graphics.c:365: error: ‘source’ undeclared (first use in this function)
graphics.c:365: error: (Each undeclared identifier is reported only once
graphics.c:365: error: for each function it appears in.)
graphics.c:365: error: too many arguments to function ‘pBlitScreenToScreen’
graphics.c: At top level:
graphics.c:368: error: expected declaration specifiers or ‘...’ before ‘s_screen’
graphics.c: In function ‘blitScreenToScreenLCD’:
graphics.c:376: error: ‘source’ undeclared (first use in this function)
graphics.c: At top level:
graphics.c:391: error: expected declaration specifiers or ‘...’ before ‘s_screen’
graphics.c: In function ‘blitScreenToScreenTV’:
graphics.c:399: error: ‘source’ undeclared (first use in this function)
make: *** [graphics.o] Error 1
gambiting@gambiting-desktop:~/psp/shoot4fun_tv$


And my makefile:

Code:
TARGET = Shoot4Fun
OBJS = main.o graphics.o image.o pspDveManager.o
YOURLIBS=
INCDIR =
CFLAGS = -g -G4 -Wall -O2
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
PSP_FW_VERSION = 371
LIBDIR =
LDFLAGS =
STDLIBS= -lpspkubridge  -lc -losl -lpng -lz \
      -lpspsdk -lpspctrl -lpspumd -lpsprtc -lpsppower -lpspgu -lpspaudiolib -lpspaudio -lm -losl -lpng -lz -lpspsdk -lpspctrl -lpspumd -lpsprtc -lpsppower -lpspgu -lpspaudiolib -lpspaudio -lm
LIBS=$(STDLIBS)$(YOURLIBS)

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Shoot4Fun

PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
Please help
Back to top
View user's profile Send private message
SamuraiX



Joined: 31 Jan 2006
Posts: 76
Location: USA

PostPosted: Sat Dec 08, 2007 2:35 am    Post subject: Reply with quote

Remove the following code as they are not need outside of my application and then I believe you are all set and ready to go.

Delete Declarations:
Code:
typedef void (*BlitScreenToScreen)(int, int, s_screen*);
void blitScreenToScreenLCD(int width, int height, s_screen* source);
void blitScreenToScreenTV(int width, int height, s_screen* source);
static BlitScreenToScreen pBlitScreenToScreen;



Delete Assignments:
Code:
pBlitScreenToScreen = blitScreenToScreenLCD;
pBlitScreenToScreen = blitScreenToScreenTV;



Delete Functions:
Code:
void blitScreenToScreen(int width, int height, s_screen* source)
{
   pBlitScreenToScreen(width, height, source);
}

void blitScreenToScreenLCD(int width, int height, s_screen* source)
{
   if(!initialized) return;
   sceKernelDcacheWritebackInvalidateAll();
   guStart();
   sceGuClutMode(GU_PSM_8888, 0, 255, 0);
   sceGuClutLoad((32), palette);
   sceGuTexMode(GU_PSM_T8, 0, 0, 0); 
   sceGuTexImage(0, 512, 512, source->width, source->data);
   sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGB);
   sceGuTexFilter(texFilter, texFilter);
   tVertexTexture texture;
   setVertexTexture(&texture, width, height, 16, screenWidth, screenHeight, screenLeft, screenTop);
   do
   {
      getVertexTexture(&texture);
      guDrawSprite(&texture);
   }
   while(texture.output_last == 0);
   sceGuFinish();
    sceGuSync(0, 0);
}

void blitScreenToScreenTV(int width, int height, s_screen* source)
{
   if(!initialized) return;
   sceKernelDcacheWritebackInvalidateAll();
   guStart();
   sceGuClutMode(GU_PSM_8888, 0, 255, 0);
   sceGuClutLoad((32), palette);
   sceGuTexMode(GU_PSM_T8, 0, 0, 0); 
   sceGuTexImage(0, 512, 512, source->width, source->data);
   sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGB);
   sceGuTexFilter(texFilter, texFilter);
   tVertexTexture texture;
   setVertexTexture(&texture, width, height, 16, screenWidth, screenHeight, screenLeft, screenTop);
   do
   {
      getVertexTexture(&texture);
      guDrawSprite(&texture);
   }
   while(texture.output_last == 0);
   sceGuFinish();
    sceGuSync(0, 0);
}
Back to top
View user's profile Send private message Visit poster's website
gambiting



Joined: 17 Aug 2006
Posts: 154

PostPosted: Sat Dec 08, 2007 5:26 am    Post subject: Reply with quote

Ok,again thanks for very good and clear reply,but now I have another(and strange) errors:

Code:
root@gambiting-desktop:/home/gambiting/psp/shoot4fun_tv# make
psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -g -G4 -Wall -O2 -D_PSP_FW_VERSION=371  -L. -L/usr/local/pspdev/psp/sdk/lib   main.o graphics.o pspDveManager.o -lpspkubridge -lpspgu  -lc -losl -lpng -lz -lpspsdk -lpspctrl -lpspumd -lpsprtc -lpsppower -lpspgu -lpspaudiolib -lpspaudio -lm -losl -lpng -lz -lpspsdk -lpspctrl -lpspumd -lpsprtc -lpsppower -lpspgu -lpspaudiolib -lpspaudio -lm  -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -o Shoot4Fun.elf
graphics.o: In function `lw_be':
/usr/local/pspdev/lib/gcc/psp/4.1.0/../../../../psp/include/types.h:74: multiple definition of `lw_be'
main.o:/usr/local/pspdev/lib/gcc/psp/4.1.0/../../../../psp/include/types.h:74: first defined here
graphics.o: In function `lh_be':
/usr/local/pspdev/lib/gcc/psp/4.1.0/../../../../psp/include/types.h:86: multiple definition of `lh_be'
main.o:/usr/local/pspdev/lib/gcc/psp/4.1.0/../../../../psp/include/types.h:86: first defined here
graphics.o: In function `sw_be':
/usr/local/pspdev/lib/gcc/psp/4.1.0/../../../../psp/include/types.h:138: multiple definition of `sw_be'
main.o:/usr/local/pspdev/lib/gcc/psp/4.1.0/../../../../psp/include/types.h:138: first defined here
graphics.o: In function `sh_be':
/usr/local/pspdev/lib/gcc/psp/4.1.0/../../../../psp/include/types.h:145: multiple definition of `sh_be'
main.o:/usr/local/pspdev/lib/gcc/psp/4.1.0/../../../../psp/include/types.h:145: first defined here
graphics.o: In function `blitAlphaImageToScreenTV':
/usr/local/pspdev/lib/gcc/psp/4.1.0/../../../../psp/include/types.h:(.text+0x720): undefined reference to `setVertexTexture'
/usr/local/pspdev/lib/gcc/psp/4.1.0/../../../../psp/include/types.h:(.text+0x728): undefined reference to `getVertexTexture'
graphics.o: In function `blitAlphaImageToScreenLCD':
/usr/local/pspdev/lib/gcc/psp/4.1.0/../../../../psp/include/types.h:(.text+0x8bc): undefined reference to `setVertexTexture'
/usr/local/pspdev/lib/gcc/psp/4.1.0/../../../../psp/include/types.h:(.text+0x8c4): undefined reference to `getVertexTexture'
graphics.o: In function `blitImageToScreenTV':
/usr/local/pspdev/lib/gcc/psp/4.1.0/../../../../psp/include/types.h:(.text+0xa40): undefined reference to `setVertexTexture'
/usr/local/pspdev/lib/gcc/psp/4.1.0/../../../../psp/include/types.h:(.text+0xa48): undefined reference to `getVertexTexture'
graphics.o: In function `blitImageToScreenLCD':
/usr/local/pspdev/lib/gcc/psp/4.1.0/../../../../psp/include/types.h:(.text+0xbc4): undefined reference to `setVertexTexture'
/usr/local/pspdev/lib/gcc/psp/4.1.0/../../../../psp/include/types.h:(.text+0xbcc): undefined reference to `getVertexTexture'
collect2: ld returned 1 exit status
make: *** [Shoot4Fun.elf] Error 1
Do you know anything about it?
Back to top
View user's profile Send private message
SamuraiX



Joined: 31 Jan 2006
Posts: 76
Location: USA

PostPosted: Sun Dec 09, 2007 1:12 am    Post subject: Reply with quote

You need vertex.c/h and you might need image.c/h depending on your application as well from here:

http://openbor.svn.sourceforge.net/viewvc/openbor/psp/
Back to top
View user's profile Send private message Visit poster's website
gambiting



Joined: 17 Aug 2006
Posts: 154

PostPosted: Mon Dec 10, 2007 2:58 am    Post subject: Reply with quote

SamuraiX wrote:
You need vertex.c/h and you might need image.c/h depending on your application as well from here:

http://openbor.svn.sourceforge.net/viewvc/openbor/psp/
I have all of them and it still don't work...
Back to top
View user's profile Send private message
SamuraiX



Joined: 31 Jan 2006
Posts: 76
Location: USA

PostPosted: Mon Dec 10, 2007 5:30 am    Post subject: Reply with quote

You are missing the required objects in your makefile for compilation. Such as.... vertex.o and probably image.o
Back to top
View user's profile Send private message Visit poster's website
gambiting



Joined: 17 Aug 2006
Posts: 154

PostPosted: Sat Dec 15, 2007 8:37 am    Post subject: Reply with quote

I reinstalled my linux distro,and I finally compiled my program,but now I don't know what's wrong.When I switch output to tv it's all disorted.Please tell me if I use all the functions in a good way and order:
Let's say that I have something like that:

Code:

main()
{
initGraphics(1);
setGraphicsVideoMode(1) ;

oslInit(0);   //my whole program is done using OSL so I can't remove it


while(!quit)
{
setGraphicsVideoMode(1) ;
}

}
It may seem strange that I use setGraphicsVideoMode(1) ; inside main program loop,but without it psp doesn't output nothing(I can see my game on psp's screen,but it's very dark,without backlight).Please help?!
Back to top
View user's profile Send private message
SamuraiX



Joined: 31 Jan 2006
Posts: 76
Location: USA

PostPosted: Tue Dec 18, 2007 1:44 am    Post subject: Reply with quote

Hmm, specifying 1 is for composite cable which is not working from what I'm told. However, Component is working.

But I see where it could be not working... So let me update my graphics lib to fix these issues.

** Edit **

Ok I believe it should be working now. However, I don't have my PSP with me to test with. I've checked in my changes to OpenBOR SVN. So have a try with it and let me know.

Lastly, make sure you do a make clean on your project prior to recompiling your project as I made changes to graphics.h as well. You can perform a diff to see what changes were made.


http://openbor.svn.sourceforge.net/viewvc/openbor/psp/
Back to top
View user's profile Send private message Visit poster's website
gambiting



Joined: 17 Aug 2006
Posts: 154

PostPosted: Tue Dec 18, 2007 4:16 am    Post subject: Reply with quote

Hi! I recompiled my program - now it's not distorted,it's just all white.I also start my while loop with initGraphics(1),then I start drawing,I sync frame,and at beginning on the next loop I init graphics again,and so on.Is it all right?
Back to top
View user's profile Send private message
SamuraiX



Joined: 31 Jan 2006
Posts: 76
Location: USA

PostPosted: Tue Dec 18, 2007 5:06 am    Post subject: Reply with quote

Thats not right. You should only init the graphics once (Outside prior to your work/loop). Then blit your images and finally flipscreen (with or without vsync).


Now as far as the white screen, perhaps thats due to the above or my changes not sure yet. Does the image display properly on the PSP Screen? Do you have a component cable to test with? We might have to work together on resolving the Composite Cable issue as I do not own one. But once I leave work I will test again the Component Cable with my latest changes and see if what I just changed didn't effect that as well.
Back to top
View user's profile Send private message Visit poster's website
gambiting



Joined: 17 Aug 2006
Posts: 154

PostPosted: Tue Dec 18, 2007 5:44 am    Post subject: Reply with quote

SamuraiX wrote:
Thats not right. You should only init the graphics once (Outside prior to your work/loop). Then blit your images and finally flipscreen (with or without vsync).


Now as far as the white screen, perhaps thats due to the above or my changes not sure yet. Does the image display properly on the PSP Screen? Do you have a component cable to test with? We might have to work together on resolving the Composite Cable issue as I do not own one. But once I leave work I will test again the Component Cable with my latest changes and see if what I just changed didn't effect that as well.
If I init graphics only once,TV screen flickers once,and there is no display at all,and I can see a very dark image on psp's screen,with no backlight.I have component cable,but I don't have a TV with component input,and I don't know anyone with such tv.If you can check it,please do it.
Back to top
View user's profile Send private message
SamuraiX



Joined: 31 Jan 2006
Posts: 76
Location: USA

PostPosted: Tue Dec 18, 2007 7:05 am    Post subject: Reply with quote

Ok... i think you are mixed up in the modes.


0 = LCD Screen
1 = Composite TV Out
2 = Component (Progressive) TV Out
3 = Component (Interlaced) TV Out


As for the application logic, though I know nothing about your app, you should be following something similar to this.

Code:
void main()
{
   initGraphics(2); // Component Progressive TV-Out

   while(!done)
   {
      // Perform your logic.
      if(alpha) blitAlphaImageToScreen();
      else blitImageToScreen();
      flipScreen();
      sceDisplayWaitVblankStart();
   }
}



If you want send me your source and i will take a look at it.
Back to top
View user's profile Send private message Visit poster's website
gambiting



Joined: 17 Aug 2006
Posts: 154

PostPosted: Tue Dec 18, 2007 7:32 am    Post subject: Reply with quote

Two things:
I use composite cable,not component
I can send you my source,but it's 1500+ lines so reading it may be a problem for you.And as I said,I use OSLib,so for blitting and drawing I use OSL functions,like oslDrawImageXY,so I don't have control over blitAlphaImageToScreen functions - maybe that's the problem?
Back to top
View user's profile Send private message
SamuraiX



Joined: 31 Jan 2006
Posts: 76
Location: USA

PostPosted: Tue Dec 18, 2007 7:43 am    Post subject: Reply with quote

I look at 100 thousand lines of code everyday, so its not a problem....lol But I think I now understand the problem you are having.


Does oslDrawImageXY() use the graphics library's functions such as blitImagetoScreen() and so on....? If not then you will never display the picture correctly as I'll bet money on it that the two are initilized and used differently when compared to each other.

You really only have two options:

1. Use only Graphics lib
2. Implement TV out functionality from Graphics lib to OSLIB.


Thats about all I can do for you.
Back to top
View user's profile Send private message Visit poster's website
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