It is currently Fri Jun 23, 2017 5:21 pm

All times are UTC - 5 hours




 Page 3 of 4 [ 92 posts ]  Go to page Previous  1, 2, 3, 4  Next
Author Message
 Post subject:
PostPosted: Thu Mar 20, 2008 7:24 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1094
Location: Ontario Canada
that is correct, in VS2005 you will need to add the & sign to your code to fix the error you were seeing.

I took a look at your code and found your bug. I sent you and email with details about your code.


Offline
 Profile  
 
 Post subject: Something about GameDev-VMK003A-GameOGL_setup
PostPosted: Wed Aug 20, 2008 11:04 am 

Joined: Wed Aug 06, 2008 7:53 pm
Posts: 182
Location: Russia
Something about GameDev-VMK003A-GameOGL_setup.

- There is a confusing comment in the file "Core.h" (according to the swf-movie):
//default constructor
WindowParameter(char* _szTitle, HINSTANCE _hInst) {
...

The real signature of this ctor shows that it is not a default ctor, but so called initialization-ctor. The difference is that default ctor must have no parameters at all or all it's parameters must have default values so you can create an object of that class not passing any arguments to it, like this: W w;
Probably your initial intention was to make a genuine default ctor, but then you have added arguments to it and doing so you have "converted" default-ctor into initialization-ctor while old comment has been left intact.

- One more thought. Is it correct to put the struct ColorOGL in "Core.h" ? Isn't this structure is renderer-dependent? For my money the file "GameOGL.h" is more appropriate place. If you have a DirectX release of the engine and need another color-holder struct like ColorDX {} you would put it in "GameDX.h".

- Besides, I've enriched this ColorOGL structure with init-ctor. Naming rules and bracket style is of personal choice, don't grumble. Nowadays I rarely use Hungarian notation (all those u-, i-, f-, d-, w-, dw-, sz-, wsz-, etc name prefixes) because so many people believe modern IDEs made that notation obsolete.
struct ColorOGL
{
   float red, green, blue;
   
   ColorOGL()
   { }
   ColorOGL(float r, float g, float b) : red(r), green(g), blue(b)
   { }
   void operator() (float r, float g, float b) { red = r; green = g; blue = b; }
};

Yes, custom member-function Set() has been replaced with operator(), just for fun.
So you can use this object like this:
ColorOGL c0, c1(1.f, .6f, .7f), c_[3];
...
c0(1., 2., 3.);
...
for (size_t _ = 0; _<_countof(c_); ++_)
    c_[_](_/10., _/20., _/30.);
...


Apart from this stuff I find the tutorial crystal clear. Thanks a lot.


Offline
 Profile  
 
 Post subject: Something about GameDev-VMK003B-GameOGL_cpp1
PostPosted: Sat Aug 23, 2008 4:52 am 

Joined: Wed Aug 06, 2008 7:53 pm
Posts: 182
Location: Russia
Something about GameDev-VMK003B-GameOGL_cpp1

First of all it should be said that major portion of following suggestions mere speculative. I mean there is no need to change anything in the course. As most of us I find this tutorial an excellent starting point.

Passing remarks and suggestions.

- There was a discussion about that pesky excessive pointer WindowParameters *. A problem is: some of data members of GameOGL, like “widthâ€


Offline
 Profile  
 
 Post subject: Something about GameDev-VMK003C-GameOGL_cpp2
PostPosted: Sun Aug 24, 2008 4:54 am 

Joined: Wed Aug 06, 2008 7:53 pm
Posts: 182
Location: Russia
Something about GameDev-VMK003C-GameOGL_cpp2

on DisplayFPSinTitle()
One standard game dev advice. It is strongly not recommended to allocate/deallocate dynamic memory inside game loop. NO new/delete, malloc/free. If you need some memory then allocate it before starting game loop. However feel free to use local (stack) variables. An explanation is like this. Whenever dynamic memory is allocated/deallocated a memory manager is in charge. General purpose memory managers have to be multithreaded, be able to allocate arbitrary sized chunks of memory and oppose memory fragmentation. This is why they are have to be relatively slow.

It's important to understand that FPS is inverse proportional function but frame time one is linear (relative to the time spent on frame). More about that can be found here:
"FPS versus Frame Time": http://www.mvps.org/directx/articles/fp ... e_time.htm

Here is another version of DisplayFPSInTitle(). Note that the time of frame in milliseconds is shown as well.
void GameOGL::DisplayFPSinTitle() // later will be eliminated
{
    TCHAR buf[ 1<<8 ]; // I'm joking it's just 0x100
    _stprintf( buf, TEXT("%s - %2.0f FPS = %.3f ms"), m_wndParam.title, m_FPS, 1000./m_FPS );
    ::SetWindowText( m_WND, buf );
}


-------------------

on RenderPre()
We are not going to create/destroy Z-Buffer on the fly, right? If no then one minor improvement could be done. Note, that some rendering technique require on and off Z-Buffer check, but this does not destroy Z-Buffer. I would propose following refactoring:
1) let's replace a variable "bool m_bZBuffer" with a variable "GLenum m_clearMask".
2) in ctor GameOGL::GameOGL() initialize it: m_clearMask = GL_COLOR_BUFFER_BIT;
3) during initialization in GameOGL::Create() update that mask if necessary:
    if (pfd.cDepthBits > 0) // we have Z-Buffer
        m_clearMask |= GL_DEPTH_BUFFER_BIT;

3) As a result in game cycle we have a slightly better code
// in GameOGL::RenderPre()
glClear( m_clearMask );

instad of former one:
if (m_bZBuffer) {
    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
}
else {
    glClear( GL_COLOR_BUFFER_BIT );
}
...

Furthmore if we decide to use more OpenGL buffers, such as accumulator, stencil etc we can simply update the mask (via bitwise OR ):
m_clearMask |= GL_STENCIL_BUFFER_BIT. The code in RenderPre() will stay the same.

Additionally, I would consider the lack of Z-Buffer as critical error. Something must be deadly wrong in that case and you can't expect good game performance anyway.

-------------------

Let's insert in GameGL a function to control VSync. To turn VSync off pass 0. (Unfortunately not all video drivers support this.)
Link has been shown http://www.devmaster.net/forums/showthread.php?t=443
BOOL GameOGL::SetVSync( int interval )
{
    if( strstr( (const char *)glGetString( GL_EXTENSIONS ), "WGL_EXT_swap_control" ) )
    {
        typedef BOOL (APIENTRY *PFN)( int );
        if ( PFN wglSwapIntervalEXT = (PFN)wglGetProcAddress( "wglSwapIntervalEXT" ) )
            return wglSwapIntervalEXT( interval );
    }
    return FALSE; // (Error: WGL_EXT_swap_control extension is not available.\n");
}

By default VSync is ON and I have stable ~ 75 FPS = 13.333 ms (monitor’s refresh rate). When VSync is off it hits up to 500 FPS (or even 1111 FPS with some tricks).

-------------------

On libraries issue.
One way to add libraries in the project via project options dialog was shown. Here is the other way. Add a magic strings in any cpp file, say in "main.cpp":
#pragma comment (lib, "opengl32")
#pragme comment (lib, "glu32" )
#pragma comment (lib, "winmm" )
This has the same effect as adding libs via project settings dialog.


Steadely we will increase speed of slipper up to the speed of light! 8)

VMKs are wonderful!


Offline
 Profile  
 
 Post subject:
PostPosted: Sun Aug 24, 2008 7:31 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1094
Location: Ontario Canada
Great suggestions! Keep it coming!

Just wanted to add that I have a separate VMK that discusses VSynch in the Physics series here: http://www.marek-knows.com/downloadSect ... 1#Physics1


Offline
 Profile  
 
 Post subject:
PostPosted: Tue Aug 26, 2008 10:28 am 

Joined: Sat Jun 23, 2007 7:56 pm
Posts: 145
Problem with using the PRAGMA macro is that its not Standard C++.

So as soon as you change compilers or try to compile your code on say Linux or Mac, you'll have to remove them all again.


Offline
 Profile  
 
 Post subject: #pragma comment (lib, "libname")
PostPosted: Wed Aug 27, 2008 3:53 pm 

Joined: Wed Aug 06, 2008 7:53 pm
Posts: 182
Location: Russia
Quote:
Problem with using the PRAGMA

You are partly right. Pragmas are compiler specific. Here is a quote from C++ Standard ISO/IEC 14882:2003(E):
Quote:
16.6 Pragma directive [cpp.pragma]
A preprocessing directive of the form # pragma <token>
causes the implementation to behave in an implementation-defined manner. Any pragma that is not recognized by the implementation is ignored.

In other words if compiler does not recognize #pragma <token> it must ignore it. Therefore you do not need to delete, say, a line #pragma comment(), if some environment doesn't support it.
From the other side if somebody moves a project on other compiler/platform there is a necessity to reassemble the project anyway, I mean write make-file or tune project options. ;)

VMKs are MS Visual Studio centered, so I've decided not to mention that those pragmas mostly for VC (or Intel IC, or Borland BCC). For novices pragmas are OK.


Offline
 Profile  
 
 Post subject: compiler errors
PostPosted: Thu Oct 30, 2008 12:59 am 

Joined: Wed Oct 29, 2008 11:32 pm
Posts: 4
Hi i'm new here and have just started following the OpenGL Game Engine series...i'm done with vmk3c but i seem to get the following compiler errors :

error C3861: 'timeGetTime': identifier not found

and also opengl errors as shown in the video tutorial

I get these eventhough i have included mmsystem.h,gl.h,glu.h and linked to opengl32.lib,glu32.lib and winmm.lib

I am using Visual Studio 2008 Pro.

This is very confusing and im helpless.Can someone help me out?

Thanks in advance. :)


Offline
 Profile  
 
 Post subject:
PostPosted: Thu Oct 30, 2008 4:29 am 

Joined: Sat Apr 19, 2008 6:26 am
Posts: 62
Show the code where you use this feature (timeGetTime)


Offline
 Profile  
 
 Post subject: Re: compiler errors
PostPosted: Thu Oct 30, 2008 6:34 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1094
Location: Ontario Canada
scarecrow wrote:
error C3861: 'timeGetTime': identifier not found


Have you included windows.h in your project?


Offline
 Profile  
 
 Post subject:
PostPosted: Thu Oct 30, 2008 7:14 am 

Joined: Wed Oct 29, 2008 11:32 pm
Posts: 4
Quote:
Show the code where you use this feature (timeGetTime)


part of GameOGL constructor:
LONGLONG lPerformanceCounter;
   if(QueryPerformanceFrequency((LARGE_INTEGER *) &lPerformanceCounter))
   {
      QueryPerformanceCounter((LARGE_INTEGER *) &m_lPrevTime);

      m_dTimeScaleFactor = 1.0/lPerformanceCounter;

      GetDeltaTime = &GameOGL::GetTimePerformanceHigh;
   }
   else
   {
      m_lPrevTime = timeGetTime();

      m_dTimeScaleFactor = 0.001;

      GetDeltaTime = &GameOGL::GetTimePerformanceRegular;
   }


and also GetTimePerformanceRegular :
double GameOGL::GetTimePerformanceRegular(void)
{
   LONGLONG lCurrentTime;
   double dDeltaTime;

   lCurrentTime = timeGetTime();
   dDeltaTime = (lCurrentTime - m_lPrevTime)*m_dTimeScaleFactor;
   m_lPrevTime = lCurrentTime;

   return dDeltaTime;
}


and yes marek i have included windows.h...just to be sure here is stdafx.h code :
#ifndef STDAFX_H
#define STDAFX_H

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <objbase.h>
#include <winbase.h>

#include <stdio.h>
#include <time.h>
#include <Mmsystem.h>

#include <GL/gl.h>
#include <GL/glu.h>

#endif


In gamedev.net i read somewhere that the timeGetTime error is because of
#define WIN32_LEAN_AND_MEAN

so i tried removing it and compiling but it was still the same...it doesnt explain the opengl errors anyway...
:?:

BTW the video tutorials are really great Marek thanks a lot!


Offline
 Profile  
 
 Post subject:
PostPosted: Thu Oct 30, 2008 8:44 am 

Joined: Fri Oct 12, 2007 4:41 pm
Posts: 24
When i get errors like that i try to #include the needed include files directly in the files where they are used to get me closer to tracking down the error. Try that and see if they disapear and we go on from that.

You could also post your complete cpp and h file for the class that is using timeGetTime() to see if we can find anything else that could cause problem.


Offline
 Profile  
 
 Post subject:
PostPosted: Thu Oct 30, 2008 9:46 am 

Joined: Wed Oct 29, 2008 11:32 pm
Posts: 4
Quote:
When i get errors like that i try to #include the needed include files directly in the files where they are used to get me closer to tracking down the error. Try that and see if they disapear and we go on from that.

hey thanks i tried doing that by including the opengl headers and mmsystem.h in gameogl.cpp and it worked!...
so i went and checked out stdafx.cpp 's properties and i found that 'Use Precompiled Header' was chosen instead of 'Create Precompiled Header'...although i am pretty sure that i had chosen the latter...anyway my mistake, sorry for being such a noob ...and thanks for helping me out guys :)


Offline
 Profile  
 
 Post subject: remove the line #define WIN32_LEAN_AND_MEAN
PostPosted: Thu Oct 30, 2008 2:12 pm 

Joined: Wed Aug 06, 2008 7:53 pm
Posts: 182
Location: Russia
You should remove the line:
#define WIN32_LEAN_AND_MEAN
before
#include <windows.h>


There is an explanation:
To speed the build process, Visual C++ provides the WIN32_LEAN_AND_MEAN definition that reduce the size of the Win32 header files by excluding some of the less common APIs.

Unfortunately this macro disables multi-media API as well.

Oops, I'm late :)


Offline
 Profile  
 
 Post subject:
PostPosted: Thu Oct 30, 2008 4:36 pm 

Joined: Wed Oct 29, 2008 11:32 pm
Posts: 4
Bughunter, I read that somewhere...nice to see you know know about it... but it works for me though even when i dont remove the define...how come? could it be because of the compiler?


Offline
 Profile  
 
 Post subject:
PostPosted: Fri Oct 31, 2008 9:24 am 

Joined: Fri Oct 12, 2007 4:41 pm
Posts: 24
Your both right in that #define WIN32_LEAN_AND_MEAN removes some multimedia stuff from the windows.h file. But it does not do anything magical. It simply prevents these includes to be loaded automatically when you include windows.h

#include <cderr.h>
#include <dde.h>
#include <ddeml.h>
#include <dlgs.h>
#include <lzexpand.h>
#include <mmsystem.h>
#include <nb30.h>
#include <rpc.h>
#include <shellapi.h>
#include <winperf.h>
#include <winsock.h>

#include <wincrypt.h>
#include <winefs.h>
#include <winscard.h>

#include <commdlg.h>
#include <ole2.h>
#include <ole.h>
#include <winspool.h>

If you need any of these includes you can still include them manually
afterwards. We include the <mmsystem.h> in our stdafx file, and get
access to the function. That is why it works for you scarecrow.


Offline
 Profile  
 
 Post subject: Full screen games window with current RES, BPP, REFRESH RATE
PostPosted: Wed Dec 10, 2008 9:05 am 

Joined: Wed Aug 06, 2008 7:53 pm
Posts: 182
Location: Russia
To facilitate the creation of the full screen game window I would propose the extension to the structure WindowsParameters:
//------------------------------------------------------------------------------
// Read active monitor parameters:  refresh rate / BPP / width / height
// and store them as current values. Additionally "windowed" is set to false.
// After the call you can create full screen game window with resolution,
// refresh rate and BPP equal to the current monitor's settings.
//------------------------------------------------------------------------------
void WindowParameters::PrepareFullScreen()
{
    HDC hActiveMonitor = ::GetDC( NULL );

    this->width       = ::GetDeviceCaps( hActiveMonitor, HORZRES   );
    this->height      = ::GetDeviceCaps( hActiveMonitor, VERTRES   );
    this->refreshRate = ::GetDeviceCaps( hActiveMonitor, VREFRESH  );
    this->is32bpp     = ::GetDeviceCaps( hActiveMonitor, BITSPIXEL ) == 32;
    this->windowed    = false;
}


To create a full screen game with current monitor resolution, BPP and refresh rate you can call PrepareFullScreen() in the following way:
// deep inside WinMain(..)
:
WindowParameters wndParams( title, hInst, 800, 600, 60 );

if ( some condition i.e. game options )
    wndParams.PrepareFullScreen();

GameGL myGame( wndParams );
:


Last edited by BugHunter on Thu Dec 11, 2008 3:23 am, edited 1 time in total.

Offline
 Profile  
 
 Post subject: A small bug in window creation subsystem has detected
PostPosted: Wed Dec 10, 2008 9:18 am 

Joined: Wed Aug 06, 2008 7:53 pm
Posts: 182
Location: Russia
It seems a small bug in window creation subsystem has been detected - inside Game::Create().

SYMPTOMS
This bug is related to the windowed mode only. In Game::Create() we adjust window position by
::AdjustWindowRectEx( &rcWnd, dwStyle, FALSE, dwStyleEx );
adding the sizes of non-client area. Then we create the window CreateWindowEx( ... );
using extended size. But a little later the original code centers AND RESIZES the window, using old width/height values, instead of adjusted ones:
MoveWindow(m_WND, px, py, m_wndParam.width, m_wndParam.height, FALSE);
This call spoils the whole idea to have the client area of the engine's window to be, say 800x600. The whole window must then have the size (800+nonclient_width) x (600 + nonclient_height) etc.

Additionally, I've noticed that when the engine's window is created in windowed mode, it may leave some unpleasant traces on the windows of the background programs. Basically this looks like a frame of the former window, as if it was drawn in the position (0, 0). (This can be seen only in Windows XP, not in Vista. I'm also not sure whether this is the problem of the original code or not, because I have added to my code an add-on to make game window resizable http://www.marek-knows.com/phpBB3/viewt ... highlight= ).

WORKAROUND
Anyway, we should update the code in Game::Create(), for instance in the following way.

:
    RECT rcWnd;
    rcWnd.left = 0;
    rcWnd.top = 0;
    rcWnd.right = m_wndParam.width;
    rcWnd.bottom = m_wndParam.height;

    //
    // center the window on screen if it is windowed
    //
    int win_pos_x = 0; // <-- NEW!
    int win_pos_y = 0; // <-- NEW!

    if ( m_wndParam.windowed )
    {
        ::AdjustWindowRectEx( &rcWnd, dwStyle, FALSE, dwStyleEx );

        const int screen_width  = GetSystemMetrics( SM_CXSCREEN );
        const int screen_height = GetSystemMetrics( SM_CYSCREEN );

        const int wnd_width  = rcWnd.right - rcWnd.left;
        const int wnd_height = rcWnd.bottom - rcWnd.top;

        if ( screen_width > wnd_width )
            win_pos_x = ( screen_width - wnd_width ) / 2;
        if ( screen_height > wnd_height )
            win_pos_y = ( screen_height - wnd_height ) / 2;
    }

    m_WND = ::CreateWindowEx(
        dwStyleEx,
        m_wndParam.title, m_wndParam.title,
        dwStyle | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
        win_pos_x, win_pos_y, // <-- UPDATED!
        rcWnd.right - rcWnd.left,
        rcWnd.bottom - rcWnd.top,
        0, 0, m_wndParam.instance,
        PVOID(this)
        );
:


Don't forget please to remove an old code, which moves the window to the middle of the screen, I mean
MoveWindow(m_WND, px, py, m_wndParam.width, m_wndParam.height, FALSE); etc.

Take notice that instead of creating the window in position (0, 0) and then moving it to the middle of the screen, my code creates the window in the desirable position at once.


Offline
 Profile  
 
 Post subject: Can't create window
PostPosted: Wed Oct 14, 2009 12:26 am 

Joined: Thu Sep 13, 2007 10:38 pm
Posts: 18
I have followed the videos thru VMK3C and get a successful build but I am getting the Can't Create Window error message from the ErrorHandler!

Here is my code in GameOGL.cpp right before and after the CreateWindowEx call

   DWORD dwStyle, dwStyleEx;
   if (m_bIsFullScreen)
   {
      // full screen window
      dwStyle = WS_POPUP | WS_VISIBLE | WS_SYSMENU | WS_MINIMIZEBOX;
      dwStyleEx = WS_EX_APPWINDOW;
   }
   else
   {
      // windowed game
      dwStyle = WS_OVERLAPPEDWINDOW & ~WS_THICKFRAME & ~WS_MAXIMIZEBOX;
      dwStyleEx = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
   }

   RECT rcWnd;
   // correct window size so that active area = width x height
   rcWnd.left = 0;
   rcWnd.right = m_iWidth;
   rcWnd.top = 0;
   rcWnd.bottom = m_iHeight;
   AdjustWindowRectEx(&rcWnd, dwStyle, FALSE, dwStyleEx);

   m_hWnd = CreateWindowEx(dwStyle,
                          m_pszClassName,
                     m_pszClassName,
                     dwStyle | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
                     0,0,
                     rcWnd.right - rcWnd.left, // window width
                     rcWnd.bottom - rcWnd.top, // window height
                     NULL,
                     NULL,
                     m_hInst,
                     (void*)this);

   if (m_hWnd == NULL)
   {
      DestroyWnd();
      m_pErrorHandler->SetError(EC_Windows, "Cannot create window.");
      return false;
   }
   pWndParam->hWnd = m_hWnd;


Any suggestions?

:(


Offline
 Profile  
 
 Post subject:
PostPosted: Wed Oct 14, 2009 2:15 am 

Joined: Fri Sep 04, 2009 3:24 am
Posts: 30
@ StaticHash
m_hWnd = CreateWindowEx(dwStyle, <-- should be dwStyleEx


@ Marek

In WindowProc you have
if (NULL != pWnd)


It makes sense, I'm just curious about why it was setup this way. It's just odd.


Offline
 Profile  
 
 Post subject:
PostPosted: Sat Oct 17, 2009 12:27 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1094
Location: Ontario Canada
Groggy wrote:
In WindowProc you have
if (NULL != pWnd)


It makes sense, I'm just curious about why it was setup this way. It's just odd.


I will sometimes write my comparisons this way to avoid making typo's. For example if I forgot to include the not sign (!) here and the statement was reversed then the compiler will accept it and let me carry on. If you place the constant value on the left rather than the right of the comparison then any typo's that may pop up, will be caught by the compiler.

Same thing with comparing for equality

if (pValue = NULL) //no complaint from compiler even with typo

if (NULL = pValue) //compiler complains

//desired expression:
if (NULL == pValue)


Offline
 Profile  
 
 Post subject:
PostPosted: Wed Apr 21, 2010 7:26 pm 

Joined: Sun Apr 18, 2010 11:46 am
Posts: 8
Ach, I hate to be posting so many questions, I just keep having problems.

So I just finished 3C, and when I compiled it, I got a lot of errors (As I expected, I knew I couldn't have written 500 lines of code with 0 typos). I can figure out most of them, but one I just cannot figure out.

error C2143: syntax error : missing ';' before ':'

Now, I know what this means, but I can't figure out why its giving me this error. I'm not missing any semicolons. Its at the very beginning of the GameOGL constructor. Heres the code for the surrounding area:

GameOGL::GameOGL(ErrorHandler *pErrorHandler )
{
   m_pszTitle      = NULL;
   m_pszClassName   = NULL;

   m_bQuit      = false;
   m_bActive   = true;
   m_GameState   = GS_STOP;

   m_iWidth      = 0;
   m_iHeight      = 0;
   m_bIsFullScreen   = false;
   m_iRefreshRate   = 60;
   m_fps         = 60;
   m_b32Bit      = true;
   m_bZBuffer      = true;

   m_dTimeGame = 0.0;  //The line the error is on!

   m_hWnd      = NULL:
   m_hDC      = NULL;
   m_hGLRC      = NULL;



EDIT: I've been doing pretty good getting rid of more of the compile errors (still not the one above), but I have a few more I can't fix.

Here is one:

error C2440: '=' : cannot convert from 'double' to 'double (__thiscall GameOGL::* )(void)'

Which I get twice in the following code:

GameOGL::GameOGL(ErrorHandler *pErrorHandler )
{
   m_pszTitle      = NULL;
   m_pszClassName   = NULL;

   m_bQuit      = false;
   m_bActive   = true;
   m_GameState   = GS_STOP;

   m_iWidth      = 0;
   m_iHeight      = 0;
   m_bIsFullScreen   = false;
   m_iRefreshRate   = 60;
   m_fps         = 60;
   m_b32Bit      = true;
   m_bZBuffer      = true;

   m_dTimeGame = 0.0;

   m_hWnd      = NULL:
   m_hDC      = NULL;
   m_hGLRC      = NULL;

   m_pErrorHandler = pErrorHandler;

   //define function pointers to GetDeltaTime

   LONGLONG lPerformanceCounter;
   if (QueryPerformanceFrequency((LARGE_INTEGER *) &lPerformanceCounter)) {
      // read initial time
      QueryPerformanceCounter((LARGE_INTEGER *) &m_lPrevTime);
      // set scaling factor
      m_dTimeScaleFactor=1.0/lPerformanceCounter;
      //define function to be used
      GetDeltaTime = GameOGL::GetTimePerformanceHigh(); //And here
   }
   else {
      //no performance counter, read in using timeGetTime
      m_lPrevTime = timeGetTime();

      //set timer scaling factor
      m_dTimeScaleFactor=0.001;
      //define function
      GetDeltaTime = GameOGL::GetTimePerformanceRegular(); //Here!!
   }
}


So its a problem with GetDeltaTime. They are both doubles, so it seems like they should be able to convert.

--

I'm also getting this error:

error C2440: '=' : cannot convert from 'HCURSOR' to 'HBRUSH'

On this line of code:

m_WindowClassEx.hbrBackground   = LoadCursor(NULL, IDC_ARROW);


in the bool GameOGL::Create(WindowParameters* pWndParam) function.

Again, I apologize for so many questions, I'm doing my best :).

Check back here later, I may edit this post further with more questions on this particular build XD!


Offline
 Profile  
 
 Post subject:
PostPosted: Wed Apr 21, 2010 8:31 pm 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1094
Location: Ontario Canada
AdamD wrote:
error C2143: syntax error : missing ';' before ':'


Have a look at the following line for the typo in your code.

AdamD wrote:
error C2440: '=' : cannot convert from 'double' to 'double (__thiscall GameOGL::* )(void)'


The solution to this is explained in the forum and also in VMK45.

AdamD wrote:
error C2440: '=' : cannot convert from 'HCURSOR' to 'HBRUSH'

On this line of code:

m_WindowClassEx.hbrBackground   = LoadCursor(NULL, IDC_ARROW);



Watch the video again and take a look at what hbrBackground should be set to. The Background is not a Cursor object!


Offline
 Profile  
 
 Post subject:
PostPosted: Wed Apr 21, 2010 9:45 pm 

Joined: Sun Apr 18, 2010 11:46 am
Posts: 8
Thanks!

However...

When I run the program, it made a error noise, and quit. I checked the error log, and it had the error, "Could not find suitable OpenGL pixel format to use."

... Well, at least the error handler works :). But what is causing this to happen?


Offline
 Profile  
 
 Post subject:
PostPosted: Thu Apr 22, 2010 5:30 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1094
Location: Ontario Canada
Run your code in the debugger and watch all the variables that you use in the function that is giving your problems. By the sounds of it, you have an invalid value set somewhere so you are not able to set a pixel format.


Offline
 Profile  
 
Display posts from previous:  Sort by  
 Page 3 of 4 [ 92 posts ]  Go to page Previous  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