You are not logged in.

#1 2011-01-11 00:09:10

EvilTroopa
Member

Wide screen framebuffer

Hi !
I'm currently working on a 3D game which looks ok for now on a 4:3 config.
I'm having a hard time understanding how to display anything nice on a PAL wide screen.
I thought, from looking on a few posts here, that widescreen was implemented into GRRLIB, but my output buffer always stays at 640x480 and I don't know how to change that.

I've been trying to look at rmode with different configurations :
PAL 50 - 4:3
rmode->viWidth = 672
rmode->viHeight = 528
rmode->fbWidth = 640
rmode->fbxHeight = 528

PAL 60 (480i) - 4:3
rmode->viWidth = 672
rmode->viHeight = 480
rmode->fbWidth = 640
rmode->fbxHeight = 480

PAL 60 (480i) - 16:9
rmode->viWidth = 678
rmode->viHeight = 480
rmode->fbWidth = 640
rmode->fbxHeight = 480

PAL 60 (480p with YUV cable) - 16:9
rmode->viWidth = 678
rmode->viHeight = 480
rmode->fbWidth = 640
rmode->fbxHeight = 480


I thought 16:9 screen would allow a bigger buffer width, it doesn't. Can't it grow to like 720px wide ?
I read somewhere (don't really remember where) that there was a hardware video buffer that was limited to 640x480 and that's why we can't get anything wider.
I also read that for wider buffers, it could be done with two-pass frame buffer copy, each being smaller than 640x480. But I guess it's a "pro" thing that may not be possible with our homebrew libs.
I know this can be avoided by using a different camera ratio, so the image once stretched will seem ok on widescreens, but I have no idea how to do it.

So if anyone understands better and can give me some clues about what's going on with the frame buffer size, I would be grateful big_smile

Last edited by EvilTroopa (2011-01-11 00:09:54)

Offline

 

#2 2011-01-12 00:44:14

EvilTroopa
Member

Re: Wide screen framebuffer

OK, like last time, I'm going to anwser myself...

First thing, it is not possible to change the buffer size.
To display something in widescreen mode you have to change the guOrtho or guPerspective to use a different ratio W/H. it will then be rendered in the 640x480 buffer, and then streched back to the TV. And it looks OK.

So I made a few changes in GRRLIB, if you're interested.
First I created 2 global variables called GRRLIB_ScreenWidth and GRRLIB_ScreenHeight, to access it from anywhere in my program (just like rmode before).

So in GRRLIB.h around line 180

Code:

GRR_EXTERN  GXRModeObj  *rmode;
GRR_EXTERN  void        *xfb[2]  GRR_INITS(NULL, NULL);
GRR_EXTERN  u32         fb       GRR_INIT(0);
GRR_EXTERN    u16            GRRLIB_ScreenWidth;        //That's new
GRR_EXTERN    u16            GRRLIB_ScreenHeight;        //That's new

In GRRLIB_core.c, line 75

Code:

    GRRLIB_ScreenHeight = rmode->xfbHeight;
    GRRLIB_ScreenWidth = rmode->fbWidth;
    
    // 16:9 and 4:3 Screen Adjustment
    if (CONF_GetAspectRatio() == CONF_ASPECT_16_9) {
        rmode->viWidth = 678;
        rmode->viXOrigin = (VI_MAX_WIDTH_NTSC - 678)/2;  // This probably needs to consider PAL
        GRRLIB_ScreenWidth = 16.0f*((f32)rmode->xfbHeight)/9.0f;
    } else {    // 4:3
        mode->viWidth = 672;
        rmode->viXOrigin = (VI_MAX_WIDTH_NTSC - 672)/2;
    }

then around line 150

Code:

    guOrtho(perspective, 0, GRRLIB_ScreenHeight, 0, GRRLIB_ScreenWidth, 0, 1000.0f);

Then in GRRLIB_3D.c :
In function GRRLIB_3dMode(...)

Code:

    guPerspective(m, fov, (f32)GRRLIB_ScreenWidth/(f32)GRRLIB_ScreenHeight, minDist, maxDist);

In function GRRLIB_2dMode()

Code:

    guOrtho(m, 0, GRRLIB_ScreenHeight, 0, GRRLIB_ScreenWidth, 0, 1000.0f);

I haven't checked everything yet. There's probably a few 2D functions that require the screen size. Feel free to complete any modifications that would help solving the wide screen problem.

Also, I've been looking at the ScreenShot function. As it takes image data from the EFB, which is limited to 640x480, it can't be used to created a 853x480 png image. Not with the actual PNGU lib that is. Maybe if someone could come with a nice scaling algorithm...

Last edited by EvilTroopa (2011-01-12 00:44:41)

Offline

 

#3 2011-01-12 07:34:35

owen
Member

Re: Wide screen framebuffer

What happens if you just leave it in widescreen all the time?  do you have to hardcoding 678 into the program?

Last edited by owen (2011-01-12 07:36:34)

Offline

 

#4 2011-01-12 16:56:23

EvilTroopa
Member

Re: Wide screen framebuffer

What happens if you just leave it in widescreen all the time?

If you leave widescreen on a 4:3 screen, the image is compressed on the X axis, as it has 853x480 scaled to 640x480.

do you have to hardcoding 678 into the program?

Actually, I took these values from different forum posts. A guy clamed that it helped to cover most screen overscans, but I haven't noticed anything special on my tv's.
I have tested with 640 and it works perfectly fine.

Offline

 

#5 2011-01-13 14:30:07

owen
Member

Re: Wide screen framebuffer

I see, yes, that would be a problem.  I imagine this would be most critical if you doing a 2d game or a game that has some kinda of HUD.

What about games that that have a black bar letter box?  I think that that may be a easier route.  It would make your game widescreen ALL THE TIME.  except it would piss off people with standard TVs.  I hate letterboxs but If the game is good I forget about the black lines eventually.

Offline

 

#6 2011-01-13 21:52:48

EvilTroopa
Member

Re: Wide screen framebuffer

Why would you have letterbox ? Unless you have some sort of puzzlegame that fits in the screen, you're allowed to show more from the left and right with my solution.
I'd rather have the interface thought to work on both modes than add some aweful black (or whatever color) on the top and bottom.
But hey, you do what you want, my code may not answer all problems.
I'll try to do a few screenshots to show you how I use it wink

Offline

 

#7 2011-01-14 20:36:37

owen
Member

Re: Wide screen framebuffer

From my experience with FZeroGx widescreen settings, the game seems to use totally different sprites if its set to widescreen mode.  I assume that its because of the change in aspect ratio makes its hard for them to reuse them.  Working with the black bars would make the aspect ratio consistent between modes.  At least thats how it seems to me.

I hope they implement it in the next version of GRRLIB because I don't like changing library code.

Offline

 

#8 2011-01-19 22:12:15

EvilTroopa
Member

Re: Wide screen framebuffer

I'm going to try to release a new version of NanoMechas using WideScreen mode to see how it looks.
But the first tries with 3D look fine to me. I'll add some 2D sprites to see if it works too.

Offline

 

#9 2011-09-29 23:36:37

BoondokLife
Member

Re: Wide screen framebuffer

Hey EvilTroopa, Were you able to make any more headway into this? I am just starting to play around with Wii programming, but noticed the image stretching mentioned.

I really will only be using this in 2D for the couple of apps I am making.

Offline

 

#10 2011-10-01 13:33:42

EvilTroopa
Member

Re: Wide screen framebuffer

Hey BoondokLife !
I haven't made anything on Wii for a while now (huge changes in my life big_smile), but I will eventually come back to Wii dev soon.

To answer shortly, yes you can make a 2D widescreen games. I talked to NoNameNo (or was it Crayon ?) a few months back and he told me he would add the widescreen code I wrote to GRRLIB but I don't know if he had time to do that.

If you simply add the code I wrote above in your files and compile GRRLIB again, you should have widescreen if your Wii is set to widescreen, and 4/3 if it's not.

I'll be back soon with a more details.

See ya! smile

Last edited by EvilTroopa (2011-10-01 13:34:43)

Offline

 

Board footer

Powered by FluxBB