It is currently Sun Sep 24, 2017 12:09 am

All times are UTC - 5 hours




 Page 1 of 4 [ 92 posts ]  Go to page 1, 2, 3, 4  Next
Author Message
 Post subject: Return to frontpage (of the forum)
PostPosted: Fri Sep 01, 2006 7:01 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1105
Location: Ontario Canada
This class is used to handle all OpenGL code in the game engine. VMK 3 is broken up into three parts (A,B,C).


Offline
 Profile  
 
 Post subject: Re: GameDev VMK 3 - GameOGL class
PostPosted: Sat Sep 02, 2006 7:38 am 

Joined: Sun Feb 11, 2007 10:04 am
Posts: 16
THIS IS CRITICAL.

I am ment to write every single code down that I see in the video. Clip nr. 13 in this VMK, have a static function that I am unable of seeing. It is listed...

File: GameOGl.h
Class: GameOGL
Place in class: Private.

What I can see: "static LRESULT CALLBACK WindowProc(HWND hWindow, UNIT iMessage, WPARAM, wParam, LPARAM lPara" The rest is not viewed in the entire set of video.

I think I should also mention that this is VMK 3a, not the B nor C, but the A one, the first one. Track number 13.

Please could you remake that track and remember to show the entire function? That will be great.

Your student, Mossa Da'Great...


Offline
 Profile  
 
 Post subject: Re: GameDev VMK 3 - GameOGL class
PostPosted: Sat Sep 02, 2006 7:39 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1105
Location: Ontario Canada
Thank you for pointing that out to me. I'll go an make the correction.

The entire function is:

static LRESULT CALLBACK WindowProc(HWND hWindow, UINT iMessage, WPARAM wParam, LPARAM lParam);


This function is also explained here
 


Last edited by Marek on Fri Aug 22, 2008 3:30 pm, edited 1 time in total.

Offline
 Profile  
 
 Post subject: Re: GameDev VMK 3 - GameOGL class
PostPosted: Fri Sep 22, 2006 7:41 am 

Joined: Sun Feb 11, 2007 10:04 am
Posts: 16
There is some more missing stuff in the 3b Video. At the Create section of the video.

Please I decided to do these videos on my weekends - school is taking time - and I still need to get you the source code from the videos. Could you please re watch the videos and look at the code that you haven't showed us? I can remember two ErrorHandler code that is missing, the string and some other things that I can't see...

How is everyone else following along without addressing these issues? You download and wait or what?!

Anyways, I hope you post these things soon sir, 'cuz I want to do these tutorials this weekend.


Offline
 Profile  
 
 Post subject: Re: GameDev VMK 3 - GameOGL class
PostPosted: Sat Sep 23, 2006 7:41 am 

Joined: Sun Feb 11, 2007 10:04 am
Posts: 16
Mossa: I havent had a single problem setting up the code. If you feel like something is missing, then it shouldnt be that much of a problem, since you can look up the function in MSDN.


Offline
 Profile  
 
 Post subject: Re: GameDev VMK 3 - GameOGL class
PostPosted: Sat Sep 23, 2006 7:41 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1105
Location: Ontario Canada
The only thing that I see that may cause a problem in the create function is:

m_pErrorHandler->SetError(EC_Windows,"Failed to switch to %dx%d fullscreen mode.", m_iWidth, m_iHeight);

The ending of this was cut off in the video. All the other error messages just have text. You can put in what ever error message you like in there.


Last edited by Marek on Fri Jan 04, 2008 2:26 pm, edited 1 time in total.

Offline
 Profile  
 
 Post subject: Re: GameDev VMK 3 - GameOGL class
PostPosted: Wed Jun 27, 2007 8:04 am 

Joined: Sat Jun 23, 2007 7:56 pm
Posts: 145
Hello Everyone,I've just joined the community and am enjoying myself, these videos are great.Am having a problem with the openGl game class. Am at the end of video 3 and have written the code up to the end.

Now when I compile, it compiles fine. And when i runit it also runs fine.

However, when I minimize the window and try to maximize it from the windows taskbar, the program ends.I've detected the problem to a failure in the RenderPost() call to SwapBuffer. It fails when you try to maximize a window.

Please help.(am going over the videos again incase I missed something but would appreciate your help.)

My pc specs are
AMD Athlon 64 3700+ 2.20GHz,
1.0 GB RAM
NVidia GeForce Fx5500 (latest Drivers)
WinXp 32bit SP 2


Offline
 Profile  
 
 Post subject: Re: GameDev VMK 3 - GameOGL class
PostPosted: Fri Jun 29, 2007 2:27 am 

Joined: Thu Jun 28, 2007 2:20 pm
Posts: 7
Hello,

As many other people, I recently got hold of this site, and havent regret it. Impressive guide, great learning method and such.
---
Now, for this short questions. First of all, when I started out, I realized some errors with the compiler in Visual Studio 2005. Since Microsoft have changed some settings regarding the use of character set, this can easily be changed back from the "Unicode" to "Multi-Byte character set, as used in 2003 .NET. This helps a bit getting rid of some error messages while compiling. While it is recommmended to keep it at default, and learnto use the unicode set, it helps while learning through the videos that the code doesnt need aditional changes to function proper.

I now stand with a question regarding the FPS counter. In the video where the program is finally compiled, I noticed that it ends up counting around 140fps, while mine stops at 30fps and go down when it is being moved around with great speed across the monitor. I am not quite sure if I have made some mistakes while setting up the FPS counter, or if it is in the DisplayFPSinTitle. As I understand, shouldnt it set it partly from the selected refresh rate (60) in the main.cpp file?

I currently run the application on a AMD64 3000+, 2gb ram, nVidia 7900GTX, so I reckon the program should run higher in fps. Since I am new to OpenGL programming, I was wondering if it could be something speciel that the graphics card needs active to run, saying that it might not run at 100% capacity?

Best regards, Gavin.


Offline
 Profile  
 
 Post subject: Re: GameDev VMK 3 - GameOGL class
PostPosted: Fri Jun 29, 2007 7:36 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1105
Location: Ontario Canada
The selected refresh rate of your program should be set inside the WindowParameters struct. When you call GameOGL.Create you pass this struct into the function to save the refresh rate as a member variable of GameOGL. Now you will notice that I don't actually use this value anywhere in the code (yet). When using DirectX as a renderer, you need to specify the refresh rate when creating your window. However with OpenGL you don't need to do this.

Eventually you will make your game run at two different rates. One rate will be used to render things to the screen, the other rate will be used to calculate physics. Initially the scenes are very simple so I do not make the destinction between the two rates and I let everything run as fast as possible. In a few VMK's you'll see my FPS counter shoot up to 500. Later on when you will need to split up your code to run at two different paths, the refresh rate variable will be used.

Email me your code and I will take a look at your functions to see if I can find out why you are getting a slow refresh rate. Have you tried your program in full screen yet? Is the performance still sluggish?


Last edited by Marek on Fri Jan 04, 2008 2:28 pm, edited 1 time in total.

Offline
 Profile  
 
 Post subject: Re: GameDev VMK 3 - GameOGL class
PostPosted: Fri Jun 29, 2007 9:12 pm 

Joined: Sat Jun 23, 2007 7:56 pm
Posts: 145
Am having a similar problem. Am getting 60 FPS with the basic setup up to VMK6. It also goes down when I move the window then back to 60. It never goes above that.

p.s. my delta time in the update function is always 0.250. Could this be the cause?


Offline
 Profile  
 
 Post subject: Re: GameDev VMK 3 - GameOGL class
PostPosted: Sat Jun 30, 2007 7:38 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1105
Location: Ontario Canada
I think by default OpenGL will use your monitor refresh rate set within Windows to dictate the number of FPS your program runs at.

You should see a drop in FPS when you move your camera/player causing more or less items to be rendered on the screen.

How are you viewing your delta time value? If you have setup a break point and are monitoring it in the debugger then of course you will see 0.25 always because you have slowed down your program. To get a more accurate reading for this variable, you need to output this variable's value to the screen during run time, or to save the value to a file while your program is running.


Last edited by Marek on Thu Apr 22, 2010 5:13 am, edited 2 times in total.

Offline
 Profile  
 
 Post subject: Re: GameDev VMK 3 - GameOGL class
PostPosted: Sun Jul 01, 2007 1:53 am 

Joined: Thu Jun 28, 2007 2:20 pm
Posts: 7
Thanks for your response - In return I have tried to run with different screenmodes, e.g. 640 x 480 and up to 1280 x 1024, the screen resolution doesnt change, it is static locked at 30-32, and goes down when stressing the window by moving it fast around on the desktop. The FPS it unchanged wheter I run in windowed or in fullscreen mode.


Offline
 Profile  
 
 Post subject: Re: GameDev VMK 3 - GameOGL class
PostPosted: Sun Jul 01, 2007 7:54 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1105
Location: Ontario Canada
Hold on. What do you mean by "when stressing the window by moving it fast around on the desktop"? Do you mean, grabbing the window's titlebar and draging it around on the screen? If so then the drop of FPS makes perfect sense. When you click and hold your mouse over top of the title bar to move the window, the program actually stops executing the Frame() function code. When you release the mouse button, your program continues to run. Because of the pause in the game, the FPS counter will get confused because a lot of time has passed, but only a few frames were drawn and that is why the FPS value is low. As the program continues to run normally, the FPS value will return back up to its regular value once the counter value averages everything out again.


Offline
 Profile  
 
 Post subject: Re: GameDev VMK 3 - GameOGL class
PostPosted: Sun Jul 01, 2007 11:14 am 

Joined: Thu Jun 28, 2007 2:20 pm
Posts: 7
You are fully correct! :) Although, what I ment to say was, it goes down when moving the window (as it should), but maximum reaches 30-32FPS when the counter evens out to normal. It is static locked at 30FPS when running fullscreen at various screen resolutions.


Offline
 Profile  
 
 Post subject: Re: GameDev VMK 3 - GameOGL class
PostPosted: Tue Jul 03, 2007 8:14 am 

Joined: Thu Jun 28, 2007 2:20 pm
Posts: 7
Update:

Alrigh, I finally found out where my error was. In the Frame() function, I had by mistake set my total game time to

m_dTimeDelta += m_dTimeDelta;

instead of

m_dTimeGame += m_dTimeDelta;

which caused the problems with a fixed FPS rate. Now I am running at maximum 60FPS as set to be the base of the iRefreshRate. Anything else I could have missed? Please note, that setting the iRefreshRate at 75 in the main.cpp, doesnt allow it to jump up further in the FPS. It starts off at 75FPS counter for 0.2seconds, whereas it goes directly back to 60FPS.


Offline
 Profile  
 
 Post subject: Re: GameDev VMK 3 - GameOGL class
PostPosted: Tue Jul 03, 2007 9:59 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1105
Location: Ontario Canada
Good work in finding the typo. If you look closely at the code, you will find that iRefreshRate is not used anywhere in the OpenGL creation of the window. Right now if you set the refresh rate to 1000, your code will still run at the same speed. The current limit is decided by your monitor's refresh rate. See what happens when you change your monitor refresh rate up to 70 or 75Hz (assuming your monitor can handle this refresh rate).

Later on, when we start working with the physics engine, I'll come back to the refresh rate issue. Right now it is not important. Anything larger than 30FPS and you are in business :)


Last edited by Marek on Fri Jan 04, 2008 2:30 pm, edited 1 time in total.

Offline
 Profile  
 
 Post subject: Re: GameDev VMK 3 - GameOGL class
PostPosted: Tue Jul 03, 2007 8:21 pm 

Joined: Sat Jun 23, 2007 7:56 pm
Posts: 145
Nope, Gavin. I still get 60FPS

Note: When I increase my monitor refresh rate to 70/75, my FPS goes up to 64 FPS

I think this is tied to our monitor refresh rate as Marek has said and our video card type.


Offline
 Profile  
 
 Post subject: Re: GameDev VMK 3 - GameOGL class
PostPosted: Wed Jul 04, 2007 6:23 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1105
Location: Ontario Canada
If you really want to disable the linkage between your monitor refresh rate and your FPS, you can do so with the code shown
in the Physics VMK1

 


Last edited by Marek on Fri Aug 22, 2008 3:38 pm, edited 2 times in total.

Offline
 Profile  
 
 Post subject: Re: GameDev VMK 3 - GameOGL class
PostPosted: Tue Sep 18, 2007 5:45 am 

Joined: Tue May 01, 2007 2:55 pm
Posts: 96
Location: Behind you
Just a little question: What are the advantages of using the TimePerformanceHigh function over the TimePerformanceRegular?


Offline
 Profile  
 
 Post subject: Re: GameDev VMK 3 - GameOGL class
PostPosted: Tue Sep 18, 2007 6:25 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1105
Location: Ontario Canada
The TimePerformanceHigh function will give you a more accurate time reading. This will be very important when we start using the Physics engine to do calculations.


Offline
 Profile  
 
 Post subject: Re: GameDev VMK 3 - GameOGL class
PostPosted: Tue Sep 25, 2007 5:15 am 

Joined: Tue May 01, 2007 2:55 pm
Posts: 96
Location: Behind you
I have a question about a statement I have seen you use at least three times, namely "? true : false".

Now I may be doing something wrong, but if I would have to put that statement into plain English, I would say "If true,tru. If false, false" (okey it's not 100% plain, but at least it no longer involves a programming language). But that would mean it does... nothing

Am I wrong here, is this intentional or did it slip in accidentally?


Offline
 Profile  
 
 Post subject: Re: GameDev VMK 3 - GameOGL class
PostPosted: Wed Sep 26, 2007 11:33 pm 

Joined: Wed Sep 12, 2007 10:56 pm
Posts: 7
Jasper,

That is called the terniary operator, and it is more less a short hand version for a simple if/else statement.
(expression) if(?) {true} else(:) {false}


That may not have been the best way to show it, but that is basically how it works. Well here is another way to read it as well.

if (5 > 3) then (?) true else(:) it is false.


Hope that helps, if not I am sure Marek can give you a better explanation.


Offline
 Profile  
 
 Post subject: Re: GameDev VMK 3 - GameOGL class
PostPosted: Thu Sep 27, 2007 6:31 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1105
Location: Ontario Canada
You are correct Jasper, there are a number of places that I do things like:

bool booleanVariable = ((floatValue>5.0f)?true:false);

I wrote it out this way so that it is more obvious to the people watching the video's what it is that I am comparing, and what is the value that gets returned. Normally I would just do this:

bool booleanVariable = (floatValue > 5.0f);

But as you can see, this may confuse people because it looks like I am setting a boolean value equal to a floating point number.


Last edited by Marek on Fri Jan 04, 2008 2:31 pm, edited 1 time in total.

Offline
 Profile  
 
 Post subject: Re: GameDev VMK 3 - GameOGL class
PostPosted: Thu Oct 04, 2007 1:41 am 

Joined: Tue May 01, 2007 2:55 pm
Posts: 96
Location: Behind you
@jmenzer: yes I am aware of how the statement works, but as Marek also confirmed, in this situation it did do nothing, and that's what boggled me. Thanks for explaining anyway.

@Marek: Okey, that's what I thought. If it's intentional it's okey of course

So now I will add my own story of framerate's to this one, as I do think something is wrong with the code. In all the following cases were I use the GameEngine, I have it render nothing, just an empty screen.

At first I ran the program and got a pretty stable 60 fps, which went down to about 30 when dragging the screen. Anyway, that's low for my computer and it was way to stable, it didn't fluctuate at all. As a test I commented out the sleep line and the frame rate went up to 64 fps.

Then I removed the need for half a second to have passed before updating, and this did have an effect, now the framerate was finally fluctuating (from about 61 to 66) but really quickly and probably the half-a-second avarages were still stable. Now I was at my school computer some time, with a different compiler (Dev c++ which uses MinGW) and I got an even more stable result of 60 fps, which appeared to change to what I initialized the frame rate.

Now I found out through debugging that in that case the deltaTime was negative... i was not able to find out though, how this came to be, as the debugger started to do strange things and crashed a number of times. So I wrote of that debuuger and the compiler. But now comes the most important thing of my story. A few days later I was looking for a library that could handle opening a window for me, as I preferred that over what you did. When I found a library that did just what I wanted it to do (glfw) I started having a look at the examples it was delivered with. And I started compiling them with Dev c++. The results were astonishing, this scene that did some animation (opposed to none by GameEngine) ran over 500 fps at school and at home I reached a frame rate in thousands (varying from 2700~4000) with a simple scene.

Personally I am going to implement glfw in my version of the GameEngine, so I don't think there is going to be a problem for me, but I thought I would share my story with you anyway, because I think there is something wrong.

As a last note: glfw both provides functions to open a window and a openGL context, but also has a time function. So which of the two the problem lies with is still unknown to me


Offline
 Profile  
 
 Post subject: Re: GameDev VMK 3 - GameOGL class
PostPosted: Thu Oct 04, 2007 5:27 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1105
Location: Ontario Canada
Thanks Jasper for sharing your findings. I just wanted to add here, if you want my game engine code to run at higher than 60FPS, you will need to disable the vertical synch using wglSwapInterval. See this Physics VMK


Last edited by Marek on Fri Aug 22, 2008 3:40 pm, edited 2 times in total.

Offline
 Profile  
 
Display posts from previous:  Sort by  
 Page 1 of 4 [ 92 posts ]  Go to page 1, 2, 3, 4  Next

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


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

Jump to:  

cron