It is currently Tue Dec 12, 2017 6:44 pm

All times are UTC - 5 hours




 Page 1 of 1 [ 24 posts ] 
Author Message
 Post subject: Dependency tree
PostPosted: Wed Sep 20, 2006 7:01 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1105
Location: Ontario Canada
The scene class is used to lay the foundation down for the scene graph that we will be making. The scene class is used to store all the objects in the game world.


Offline
 Profile  
 
 Post subject: Re: GameDev VMK 5 - Scene class
PostPosted: Sun Aug 05, 2007 8:39 am 

Joined: Sat Aug 04, 2007 6:15 am
Posts: 5
hello , i have these errors :

1>GameOGL.cpp
1>c:waxpgameenginegameenginegameoglgameogl.cpp(95) : error C2065: 'p' : undeclared identifier
1>c:waxpgameenginegameenginegameoglgameogl.cpp(95) : error C2143: syntax error : missing ';' before '{'
1>c:waxpgameenginegameenginegameoglgameogl.cpp(95) : error C2541: 'delete' : cannot delete objects that are not pointers
1>Scene.cpp
1>c:waxpgameenginegameenginescenescene.cpp(43) : error C2065: 'p' : undeclared identifier
1>c:waxpgameenginegameenginescenescene.cpp(43) : error C2143: syntax error : missing ';' before '{'
1>c:waxpgameenginegameenginescenescene.cpp(43) : error C2541: 'delete' : cannot delete objects that are not pointers

i think it related to the SAFE_DELETE macro , it works only in the main file but in scene and gameogl it doesnt work

if i replace SAFE_DELETE in scene.cpp or gameogl.cpp with
delete (m_pTriangle) ;
m_pTriangle = NULL ;

it works !!

my compiler is VS 2005


Offline
 Profile  
 
 Post subject: Re: GameDev VMK 5 - Scene class
PostPosted: Mon Aug 06, 2007 12:06 pm 

Joined: Sat Aug 04, 2007 6:15 am
Posts: 5
i found the problem

SAFE_DELETE (p)

must be

SAFE_DELETE(p)

without the space between DELETE and (p)


Offline
 Profile  
 
 Post subject: Let me Father confess my sins.
PostPosted: Sun Aug 31, 2008 3:11 pm 

Joined: Wed Aug 06, 2008 7:53 pm
Posts: 182
Location: Russia
Let me share some thoughts about what I have found interesting |&| curious in VMK005-Scene.

On SAFE_DELETE macro. First, for the sake of completeness I would add similar macro to delete an array of objects allocated with new []:
#ifndef SAFE_DELETE
#define SAFE_DELETE(p)   { if (p) { delete (p); (p) = NULL; } }
#endif // SAFE_DELETE

#ifndef SAFE_DELETE_ARRAY
#define SAFE_DELETE_ARRAY(p)   { if (p) { delete [] (p); (p) = NULL; } }
#endif // SAFE_DELETE_ARRAY

So far so good. Second, unfortunately SAFE_DELETE is not so safe as suggests its name. For instance, if one pass an integer instead of pointer a compiler doesn’t even squeak:
int i = 0x1234;
…
SAFE_DELETE( i ); // oops, compiler is happy, we are not :(

To counter disaster above I have forged more advanced version of safe-delete with the same functionality, but more robust against invalid arguments. To a delight of founding fathers of C++, my code is not a macro at all, but global inline function.
// delete one object
template <typename T> inline void safe_delete(T & ptr)
{
    delete ptr;
    ptr = NULL;
}

// delete an array
template <typename T> inline void safe_delete_array(T & ptr)
{
    delete [] ptr;
    ptr = NULL;
}
...
// usage
void foo() {
    int * ptr = new int;
    int fake_ptr = 0x666;
    ...
    safe_delete( ptr ); // ok
    safe_delete( fake_ptr ); // error C2541: cannot delete objects that are not pointers
}

I have exploited an ability of compiler to deduce template argument from the using code.
There is no need to check that the pointer is not null, because C++ standard demands operator-delete to deal correctly with null pointers. So, { int * p = 0; delete p; } is correct and safe code. You cannot even say that you optimize out extra calls of function (meaning that internally a compiler generates a call of special delete-function), because statistically you invoke operator delete almost always passing nonzero pointer.
To be continued…


Offline
 Profile  
 
 Post subject: Who wants to be shocked?
PostPosted: Sun Aug 31, 2008 5:04 pm 

Joined: Wed Aug 06, 2008 7:53 pm
Posts: 182
Location: Russia
This is rather important topic. And pretty unexpected for old-school boys and girls. This about operator-new in VC and beyond.

In fact, since VC6, Microsoft C++ compiler became more standard compliant. In particular in MSDN you can read:
[quote]
In Visual C++ .NET 2002, the “newâ€


Offline
 Profile  
 
 Post subject:
PostPosted: Thu Jan 01, 2009 4:30 pm 
Please help, i can not compile this vmk tutorial
The Compiler says that ClearAll' : cannot access private member declared in class 'Scene'
if i try to declare it as public it dont compile too.

You can download my code here
deleted

I use Visual Studio 2008.
I hope you can help me :)

1>------ Build started: Project: GameEngine, Configuration: Debug Win32 ------
1>Compiling...
1>GameOGL.cpp
1>c:\gameengine2\checkout\gameengine\gameogl\gameogl.cpp(66) : error C2248: 'Scene::ClearAll' : cannot access private member declared in class 'Scene'
1>        c:\gameengine2\checkout\gameengine\scene\scene.h(14) : see declaration of 'Scene::ClearAll'
1>        c:\gameengine2\checkout\gameengine\scene\scene.h(6) : see declaration of 'Scene'
1>c:\gameengine2\checkout\gameengine\gameogl\gameogl.cpp(67) : error C2248: 'Scene::~Scene' : cannot access private member declared in class 'Scene'
1>        c:\gameengine2\checkout\gameengine\scene\scene.h(31) : compiler has generated 'Scene::~Scene' here
1>        c:\gameengine2\checkout\gameengine\scene\scene.h(6) : see declaration of 'Scene'
1>c:\gameengine2\checkout\gameengine\gameogl\gameogl.cpp(380) : error C2248: 'Scene::Scene' : cannot access private member declared in class 'Scene'
1>        c:\gameengine2\checkout\gameengine\scene\scene.h(7) : see declaration of 'Scene::Scene'
1>        c:\gameengine2\checkout\gameengine\scene\scene.h(6) : see declaration of 'Scene'
1>c:\gameengine2\checkout\gameengine\gameogl\gameogl.cpp(387) : error C2248: 'Scene::Initialize' : cannot access private member declared in class 'Scene'
1>        c:\gameengine2\checkout\gameengine\scene\scene.h(10) : see declaration of 'Scene::Initialize'
1>        c:\gameengine2\checkout\gameengine\scene\scene.h(6) : see declaration of 'Scene'
1>c:\gameengine2\checkout\gameengine\gameogl\gameogl.cpp(446) : error C2248: 'Scene::Update' : cannot access private member declared in class 'Scene'
1>        c:\gameengine2\checkout\gameengine\scene\scene.h(12) : see declaration of 'Scene::Update'
1>        c:\gameengine2\checkout\gameengine\scene\scene.h(6) : see declaration of 'Scene'
1>Build log was saved at "file://c:\gameengine2\checkout\GameEngine\Debug\BuildLog.htm"
1>GameEngine - 5 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========



Last edited by Vivian on Thu Jan 01, 2009 5:48 pm, edited 1 time in total.

  
 
 Post subject:
PostPosted: Thu Jan 01, 2009 5:33 pm 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1105
Location: Ontario Canada
Your code
class Scene{
   Scene(ErrorHandler *pErrorHandler, GameOGL* pGameOGL);
   virtual ~Scene();

   bool Initialize();

   bool Update(float fDeltaTime);

   bool ClearAll();

public:

protected:
private:
   GraphicsRenderer m_Renderer;

   ErrorHandler* m_pErrorHandler;
   GameOGL*     m_pGameOGL;
   Triangle* m_pTriangle;

};


By not placing a public/protected/private tag at the very top of your class, the compiler defaults your functions to be private. This means that all of these functions:

Scene(ErrorHandler *pErrorHandler, GameOGL* pGameOGL);
~Scene();
Initialize();
Update(float fDeltaTime);
ClearAll();

are private and the GameOGL class will not be able to call them.

If you make these all public, you will be able to compile your code.

NOTE, when sending your code, DO NOT include the GameEngine.ncb file in the RAR. This is a temp file created by the compiler. It is not needed for someone else to compile your code.


Offline
 Profile  
 
 Post subject:
PostPosted: Thu Jan 01, 2009 5:48 pm 
Thank you Marek, its work ;)


  
 
 Post subject: Not Renderering after VMK 5
PostPosted: Sun Mar 27, 2011 1:57 pm 

Joined: Sun Mar 27, 2011 1:46 pm
Posts: 1
Hello all,

Thank you Marek for the great tutoriels!!

I have just finished VMK 5. WHen I run in debug mode I have no errors, the window is created, the FPS are displyed in the title, and i have steped though the engine an is steps though correctly but I do not see a triangle rendered in the window. I have changed the background colors to see if I was just not seeing it and nothing.

ANy ideas??

Windows 7 32bit
VS2008


Offline
 Profile  
 
 Post subject: Re: Not Renderering after VMK 5
PostPosted: Mon Mar 28, 2011 5:04 pm 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1105
Location: Ontario Canada
A very common mistake to make is to mix up the coordinates for each of the corners of the triangle. If the coordinates are wrong you could end up drawing a triangle what has two vertices at exactly the space spot in space thus shrinking the triangle into a line which you might not see.

Also make sure you are not rendering your triangle "backwards" in reverse order or else it would be culled out of view. Another thing to check is to make sure that the triangle vertices are between your clipping planes as defined by the projection matrix.


Offline
 Profile  
 
 Post subject: Re: GameDev VMK 5 - Scene class
PostPosted: Mon Apr 02, 2012 3:06 am 

Joined: Mon Oct 24, 2011 5:16 am
Posts: 2
I have just finished VMK 05 but when i run the code instead of the triangle rotating the game just flashes and nothing rotates, can you suggest anywhere to start debugging this?


Offline
 Profile  
 
 Post subject: Re: GameDev VMK 5 - Scene class
PostPosted: Mon Apr 02, 2012 4:34 pm 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1105
Location: Ontario Canada
Do you see a triangle at all? Can you describe the flashing, maybe upload a video or capture some screenshots.


Offline
 Profile  
 
 Post subject: Re: GameDev VMK 5 - Scene class
PostPosted: Tue Jan 01, 2013 12:54 am 

Joined: Thu Sep 13, 2007 10:38 pm
Posts: 19
I have followed the code in your VMK 5 Scene Class video and my code compiles and runs without error but I don't see the triangle at all. I have checked to make sure that the coordinates for each of the corners of the triangle are not mixed up, and that it is not rendering backwards. Still no Triangle!


Offline
 Profile  
 
 Post subject: Re: GameDev VMK 5 - Scene class
PostPosted: Tue Jan 01, 2013 6:52 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1105
Location: Ontario Canada
StaticHash wrote:
I have followed the code in your VMK 5 Scene Class video and my code compiles and runs without error but I don't see the triangle at all. I have checked to make sure that the coordinates for each of the corners of the triangle are not mixed up, and that it is not rendering backwards. Still no Triangle!


Did you check all of the things that I mentioned in my post above: viewtopic.php?p=2017#p2017


Offline
 Profile  
 
 Post subject: Re: GameDev VMK 5 - Scene class
PostPosted: Tue Jan 01, 2013 8:56 am 

Joined: Thu Sep 13, 2007 10:38 pm
Posts: 19
Yes, I did.
I even went back and listened to the vmk twice. I did not miss anything.
I am using VC++ 2010 Express, if that matters?


Offline
 Profile  
 
 Post subject: Re: GameDev VMK 5 - Scene class
PostPosted: Tue Jan 01, 2013 11:57 am 

Joined: Thu Sep 13, 2007 10:38 pm
Posts: 19
Well, I have a working one in VC++ 2008 Express all the way through VMK 16b. It runs and I can move around and see the houses and the slightly transparent triangle that is culled on one side. So, I guess I will just continue with this one.

I tried to upgrade this one in VC++ 2010 Express, but I never could get the MSB8012 warning about the "TargetPath does not match the Library's OutputFile property value" resolved. Even all of the solutions on the internet did not work. If anyone has a solution for that warning for the OpenGL engine, I sure would like to have that one!

Update! Finally got my VC++ 2010 version to compile and run after reading this post!
Marek wrote:
I compile and build all my files into one directory called _build. The difference between the debug and the release versions is defined by the output file name. All my debug builds have "_debug" appended to the end of the library or exe name.

My VS 2010 setup looks like this:
Properties for each library:
Configuration Prop. > General > Output Directory = ..\_build\
Configuration Prop. > General > Intermediate Directory = _temp\$(Configuration)\
Configuration Prop. > Debugging > Working Directory = $(ProjectDir)
Configuration Prop. > Librarian > Output File = ../_build/$(ProjectName).lib for the debug version this is set to ../_build/$(ProjectName)_Debug.lib

Properties for the GameEngine EXE:
Configuration Prop. > General > Output Directory = _build\
Configuration Prop. > General > Intermediate Directory = _temp\$(Configuration)\
Configuration Prop. > Debugging > Working Directory = $(ProjectDir)
Configuration Prop. > Linker > Output File = ./_build/$(ProjectName).exe (add _debug for the debug version of the build)


Awesome stuff Marek!


Offline
 Profile  
 
 Post subject: Re: Not Renderering after VMK 5
PostPosted: Wed May 22, 2013 4:57 pm 

Joined: Tue May 21, 2013 11:23 am
Posts: 5
Marek wrote:
A very common mistake to make is to mix up the coordinates for each of the corners of the triangle. If the coordinates are wrong you could end up drawing a triangle what has two vertices at exactly the space spot in space thus shrinking the triangle into a line which you might not see.

Also make sure you are not rendering your triangle "backwards" in reverse order or else it would be culled out of view. Another thing to check is to make sure that the triangle vertices are between your clipping planes as defined by the projection matrix.


My triangle is not being drawn, I am not sure where I messed up at. I've watched the video a few times, and even went back to make sure I didn't mess up on any previous steps.
My vertex's are
Vertex v1( 0.866f, -0.5f, 0.0f);
   Vertex v2( 0.0f,   1.0f,  0.0f);
   Vertex v3(-0.866f, -0.5f, 0.0f);


I would be very thankful if you could tell me what I did wrong.
I am completely oblivious when it comes to OpenGL.


Offline
 Profile  
 
 Post subject: Re: GameDev VMK 5 - Scene class
PostPosted: Wed May 22, 2013 6:02 pm 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1105
Location: Ontario Canada
laso49, you have a bunch of warnings that show up in the compiler when you build your code. Don't ignore warnings, they may seem harmless but in your case they are not. When you fix the warnings, then the triangle will draw on the screen correctly.

Please post the solution to your problem in the forum here once you find it so that others that may experience the same problem will know how to fix it too. Thanks!


Offline
 Profile  
 
 Post subject: Re: GameDev VMK 5 - Scene class
PostPosted: Wed May 22, 2013 7:12 pm 

Joined: Tue May 21, 2013 11:23 am
Posts: 5
Marek wrote:
laso49, you have a bunch of warnings that show up in the compiler when you build your code. Don't ignore warnings, they may seem harmless but in your case they are not. When you fix the warnings, then the triangle will draw on the screen correctly.

Please post the solution to your problem in the forum here once you find it so that others that may experience the same problem will know how to fix it too. Thanks!

Man I feel like an idiot. Lol.
I had functions for getting the m_x, m_y. and m_z in the Vertex class. I made the mistake of having the return type int instead of float, which screwed it up.
Example of my mistake:
 
int Vertex::GetX() {
return m_x; //m_x is a float not an int!
}


Thank you Marek. Sorry for bothering you, I cannot believe I missed that
*facepalm*


Offline
 Profile  
 
Display posts from previous:  Sort by  
 Page 1 of 1 [ 24 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 0 guests


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