mvdevs / jk2mv

JK2MV - improved, modernized JK2 client and server
https://jk2mv.org
GNU General Public License v2.0
108 stars 33 forks source link

Widescreen/Eyefinity Support #49

Closed TriForceX closed 6 years ago

TriForceX commented 8 years ago

We've talked a bit about this in the forums, but i want to leave here too.

Basically this fix is for the 2D render (not the 3D), actually the current code just stretch all 2D from 640x480. Both games has this problem (jk2 and jk3),i discussed this with some guys attemped to fix this... huds are easy to fix (editing all cgs.widthRatioCoef), but there are some texts or fonts which would require modified renderer... same with the jk2 menus i think.

Current: http://i.imgur.com/OraXC70.jpg?1 Fixed: http://i.imgur.com/ju9LqD9.jpg?1 Changes: http://i.imgur.com/t0CNBdA.jpg?1

ouned commented 8 years ago

the whole menu depends on the fixed 2D resolution items are actually placed by specifying x and y thus, to actually fix it you would have to rewrite the whole menu code and menu files

TriForceX commented 8 years ago

yeah i know, but we can start step by step, for example start with the HUD in-game. please add an enhancement label

ouned commented 8 years ago

isn't the hud in cgame?

TriForceX commented 8 years ago

Lol true, that was an a bad example, but somethings need to be changed on the engine, for example the console is working fine and isnt streched, but the shader of background is streched. I will check what things can be done in the engine.

TriForceX commented 7 years ago

i found a way to fix this, i divide in two steps, internal game (before join a server) and clientside game (after join a server), so maybe i can make a new branch with this, starting with the internal game first.

Before: https://i.imgur.com/nV6iGsq.png After: https://i.imgur.com/Aje9K3b.png

ouned commented 7 years ago

Looks nice can we see what you did somewhere?

aufau commented 7 years ago

Well to update the issue:

First of all I opt for new mvapi calls with some "ratio" argument rather than a global setting. This is because some things like menu are very hard if not impossible to fix in a generic way and mods may opt to aspect-ratio correct only some items (eg hardcoded HUD).

At minimum we need:

Alternatively we could add more MVAPI calls for ease-of-use like trap_MVAPI_R_DrawStretchPic, or instead of new DrawRotatePic(2), add a single DrawTransformPic taking full 2D linear transformation matrix as an argument (not very user-friendly I guess but extends image manipulation possibilities greatly).

I think I'm leaning towards minimal solution right now.

ouned commented 7 years ago

sounds cool

TriForceX commented 7 years ago

@aufau nice to hear that, i have some done in another branch, but locally (not published yet), maybe i can upload in somewhere? or start a new branch in this repo? (im using jk2mv)

aufau commented 7 years ago

Go ahead. In your jk2mv github fork please.

aufau commented 7 years ago

I've just pushed MVAPI_SETVIRTUALSCREEN syscall. It allows you to change "virtual screen dimensions" (default 640x480) used by trap_R_DrawStretchPic(), trap_R_DrawRotatePic(), trap_R_DrawRotatePic2(), trap_R_Font_DrawString(), trap_R_Font_StrlenPixels() and trap_R_Font_HeightPixels(), separately for UI and CGame modules and per syscall.

This allows you to comfortably make your mod draw hud without stretching, eg by using virtual screen width adjusted for your monitor and leaving virtual screen height at 480. Then all you've got to do is to change shaders adjusted to the right side (ie replace all 640 occurencies with new virtual screen width).

You can examine a working CGame implementation here: https://github.com/aufau/SaberMod/commits/widescreen

If you'd like to comment on it, please do until it hits official API. Then I'm going to close the issue.

TriForceX commented 7 years ago

@aufau i will take a look on that, thanks

aufau commented 6 years ago

Ok it's out and I'm closing the issue. You can check out widescreen HUD implementation using this MVAPI on sabermod development server with 1.4 client or in our screenshots gallery: https://jk2mv.org/data/_uploaded/image/widescreen-mod.jpg

TriForceX commented 6 years ago

@aufau Thank you very much, I regret the delay, I have not been able to review this since I recently had an operation in my left eye (clear of cornea) and I have been in recovery. the screenshots look amazing, I hope to review it soon. thanks for your help!

aufau commented 6 years ago

Well the patches are quite tiresome (a lot of trivial changes) because I didn't take "approximation" approach but rather did everything precisely. There is a lot of commits but most of them do the same thing: replace constant SCREEN_WIDTH with dynamically calculated screenWidth. Wish you get better soon. Cheers :-)