Author Topic: OpenGL Renderer Discussion  (Read 5680 times)

Alhexx

  • *
  • Posts: 1894
    • View Profile
    • http://www.alhexx.com
OpenGL Renderer Discussion
« on: 2002-11-06 19:38:59 »
Since I'm porting Ultima to C++, I'll also try to improve the Renderer Code.

My first question goes out to mirex: Which values have you used for the glPerspective function in your Biturn app? I just need the last 2 values.
Thanx.

I hope we can keep this topic alive for further renderer improvements in our apps. (I also hope that Fice'll take a look at all the question's I'll have :D )

 - Alhexx

mirex

  • *
  • Posts: 1645
    • View Profile
    • http://mirex.mypage.sk
OpenGL Renderer Discussion
« Reply #1 on: 2002-11-07 11:10:45 »
i havent used gluPerspective, i used glFrustum, i didnt wanted to include another header (glu.h) :)

i used glFrustum( -0.08, 0.08,  -0.08, 0.08,  0.1, 50.0 );

dunno if its needed to improve anything ... all things look good enough IMHO.

Alhexx

  • *
  • Posts: 1894
    • View Profile
    • http://www.alhexx.com
OpenGL Renderer Discussion
« Reply #2 on: 2002-11-07 14:21:24 »
Okay, thanx anyway.

Now another question to Ficedula:

I want to keep Ultima's window resizeable. For this, AFAIK, I need the glPerspective and glViewPort functions, right? Well, now I've got the problem that the rendered view is "squished" (b'cause the ratio isn't 1:1). How can I avoid this "squishing" ??

 - Alhexx

ficedula

  • *
  • Posts: 2178
    • View Profile
    • http://www.ficedula.co.uk
OpenGL Renderer Discussion
« Reply #3 on: 2002-11-07 15:35:00 »
You just need to set up the ratio correctly in gluPerspective (the second parameter). Standard usage is to set that to WindowWidth / WindowHeight. If that's not what you're after, then try using a fixed constant.

ShinRa Inc

  • *
  • Posts: 416
  • The Ascension of the Ordinary Man
    • View Profile
    • http://shinrainc.org
OpenGL Renderer Discussion
« Reply #4 on: 2002-11-07 15:43:45 »
Resizable window!?  <3_<3 finally~

::sacrifices fatted politicians to Alhexx::

Alhexx

  • *
  • Posts: 1894
    • View Profile
    • http://www.alhexx.com
OpenGL Renderer Discussion
« Reply #5 on: 2002-11-07 19:49:14 »
Fice: I tried a fixed constants, however, (as far as I remember) it didn't gave my desired result... well, I'll try again...

Shinra: Yupp, resizable. MFC is much more flexbile than VB, so I can program some new funny or/and useful functions... :D

 - Alhexx

mirex

  • *
  • Posts: 1645
    • View Profile
    • http://mirex.mypage.sk
OpenGL Renderer Discussion
« Reply #6 on: 2002-11-08 11:30:46 »
when you resize gl window you can use glViewport( 0, 0, a, a ); where a is size of window. it will be 1:1 but it wont draw on some parts of window, try it out.

ShinRa: uh could you tell me if resizable window in biturn is ok ? (Options/General/Preview in separate window)

Alhexx

  • *
  • Posts: 1894
    • View Profile
    • http://www.alhexx.com
OpenGL Renderer Discussion
« Reply #7 on: 2002-11-08 12:58:07 »
No, I think that the problem is not the glViewport, but the gluPerspective function. I think it simply fails, b'cause it doesn't matter which value I use ... I've gotta try around with those clipping planes, I think they *might* be the reason why it doesn't work *_*

 - Alhexx

 - edit -

I got it. It has to do with the Near and Far Clipping Planes. I always used to set them both to 10.0f
This worked fine, however, the scalinmg was defekt. Now I have set the Near plane to 0.0f, and the stretching's okay. But now I've got another problem: The view is screwed up a bit... some polygon's are not visible ...

Fice: Do you know this problem or should I post a screenshot first?

( *alot* of questions, huh?)

ShinRa Inc

  • *
  • Posts: 416
  • The Ascension of the Ordinary Man
    • View Profile
    • http://shinrainc.org
OpenGL Renderer Discussion
« Reply #8 on: 2002-11-08 16:41:01 »
Resizable preview window in Biturn; Works fine, as far as I can tell.  The only thing is, it has a tendancy to align the model to the far left of the screen after resizing, instead of to the center if you have the window at a non-square size.

Other thing;  How about disabling the Always-on-top setting.  Otherwise, you have to minimize or close the Preview window in order to select a new model to view.

ficedula

  • *
  • Posts: 2178
    • View Profile
    • http://www.ficedula.co.uk
OpenGL Renderer Discussion
« Reply #9 on: 2002-11-08 16:49:20 »
Alhexx: Well, that's quite simple - don't set zNear to zero! You can't ... or rather, you aren't supposed to. zNear and zFar set the distances at which objects become visible and stop being visible. So zFar needs to be however-far-from-the-camera you want to be able to see objects.

zNear is the point at which objects /stop/ being visible. Why can't it be zero? Well, a) it screws up some of the equations ;)  For a justification, try b) If an object is at distance zero, it's almost "inside the camera". Could you see an object than was actually /inside/ the camera? Probably not. You normally set it to something small - eg. 0.1 or 1.

ShinRa Inc

  • *
  • Posts: 416
  • The Ascension of the Ordinary Man
    • View Profile
    • http://shinrainc.org
OpenGL Renderer Discussion
« Reply #10 on: 2002-11-08 18:43:39 »
Speaking of distance stuff....reminds me of a minor Ifalna issue.  You can't zoom out far enough for some of the larger models.  Ultima WEAPON is the best example thereof.

Alhexx

  • *
  • Posts: 1894
    • View Profile
    • http://www.alhexx.com
OpenGL Renderer Discussion
« Reply #11 on: 2002-11-09 11:28:29 »
Fice: Alright. That means that I'll have to move the rendering point (the origin) into that discance right? So I can't keep it at 0,0,0 ... okay



 - Alhexx