Jump to content
  • Advertisement
Sign in to follow this  
adnankhan

OpenGL openGL Wrapper FPS Problem

This topic is 5196 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I posted a messege before but no good reply. I have found something which solved my problem but with a huge overhead can any body help me as I am a new to openGL Problem: I am writting an OpenGL Wrapper which Displays FPS on different games but the problem is that it does not Display the FPS in the correct place in MOHAA(Medal of Honour Allied Assult) and Heavy Metal : Fakk 2 caz the game's ViewPort at that time is in a specific rectangle (which I assum as the whole Screen), Actually I want the Whole Screen as ViewPort so that I can Display FPS on the corners of the enitre Game Screen. This code solved the problem but the over head is between 50% to 75% which is too much, can anyone tell me with an alternative to this code HGLRC horg,hrc; HDC h; horg = wglGetCurrentContext(); h = wglGetCurrentDC(); hrc = wglCreateContext(h); wglMakeCurrent(h, hrc); // My function which draws the FPS drawFPS(x,y,float); // After displaying FPS I resume to the old Context // and delete the one I created. wglMakeCurrent(h, horg); wglDeleteContext( hrc ); Thnx in Advance...

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by r
well, why don't you use the original context?


I dont use the original context caz it does not allow me to write on a particular region of the screen even when I change the ViewPort to the entire Screen.

Say If the Current Viewport in the game is (10,10,100,100),
And I change it to (0,0,MAXScreenWidth,MAXScreenHeight)
The FPS or Text I am writting is just written in this block (10,10,100,100), I cannot write outside it (when I do it is not displayed).

I am using rasterPos2i() for positioning the text and glBitmap for writting the Bitmapped Text.

Share this post


Link to post
Share on other sites
If you want to display things outside the 3D window, your best bet is to use another separate form/widget/window. First it will be much faster, secondly it will be much easier, and third it will be more flexible. What else to say ?

Share this post


Link to post
Share on other sites
Quote:
Original post by vincoof
If you want to display things outside the 3D window, your best bet is to use another separate form/widget/window. First it will be much faster, secondly it will be much easier, and third it will be more flexible. What else to say ?


OOOOOOOOOOOOO
Cool buddy...

Now I think I know the Problem but I need a solution.

I said I can Change the ViewPort so no need of using another form/widget/window but I am not able to change the current allowed drawing area thats y my glBitmap is not working in my new Viewport (which I have set not the game).
I just need to enable drawing in my viewport

Currently I am using the below code... see if I am missing something here

/////////////////////////////////////////////////////////////////

//Saving Current Sceen

glGetIntegerv(GL_UNPACK_SWAP_BYTES, &swapbytes);
glGetIntegerv(GL_UNPACK_LSB_FIRST, &lsbfirst);
glGetIntegerv(GL_UNPACK_ROW_LENGTH, &rowlength);
glGetIntegerv(GL_UNPACK_SKIP_ROWS, &skiprows);
glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &skippixels);
glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment);
glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE);
glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE);
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

//then FPS drawing

glBitmap();

// Restoring saved sceen

glPixelStorei(GL_UNPACK_SWAP_BYTES, swapbytes);
glPixelStorei(GL_UNPACK_LSB_FIRST, lsbfirst);
glPixelStorei(GL_UNPACK_ROW_LENGTH, rowlength);
glPixelStorei(GL_UNPACK_SKIP_ROWS, skiprows);
glPixelStorei(GL_UNPACK_SKIP_PIXELS, skippixels);
glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);

/////////////////////////////////////////////////////////////////

Share this post


Link to post
Share on other sites
Seems that no one is willing to help me...

Common guys... Just tell me how to make a particular Region Draw able and then how to disable that area for drawing

Share this post


Link to post
Share on other sites
When you tell those games' viewport are limited, do you mean that the games runs in windowed mode ? Or do you mean that the game defines for instance a 800x600 buffer but only uses half of it at the time you render FPS ?

PS: please be patient. you seem to be hurried if no reply happens in 24 hours !

Share this post


Link to post
Share on other sites
sorry if i was hurried but my problem is solved

It was not that difficult but i dont know openGL thats y it took time


Now

MOHAA change its viewport to some small area of the screen which it wants to render at that moment and also calls this function

void glScissor(GLint x,GLint y,GLsizei width,GLsizei height);

after glViewPort, which makes a particular region drawable.
What i was doing was, changing the viewport back to full screen but not but not setting the drawable are with glScissor()

when I did things went perfect

Share this post


Link to post
Share on other sites
Ok. You can either reset scissor with glScissor() or with glDisable(GL_SCISSOR_TEST).

Glad you found your problem. Congrats !

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!