Skip to main content
gamedev.net
🔒 Locked

Pointer to Hell

Started by lopatsch 5 replies 700+ views
Original Post
lopatsch
lopatsch
Hi out there. well as you imagine, i have some problems with pointers. i uploaded my whole code (MVC6) at: http://www33.brinkster.com/warsim/warsim.ace well its not quite well structured, because its experemental. the important parts are the Object.h & cpp with all derivates and world.h & cpp. here is my problem: i am trying to build an engine where any dynamic part is treated the same way. so it doesnt really matter if you have a texture or a mesh or a ki-unit. everything is stored in a linked list, that starts at world.Base. every class has an own Object-Type, which is returned by the Type() funcion. and every object is referneced with a GUID (global unique id). at the current state there are the following object types: cBaseObject (Object.h) ---cVisObject (VisObject.h) ------cMeshObject (VisObject.h) ---cBaseTexture (Texture.h) ---cBaseMaterial (Material.h) the critical part is in VisObject.cpp -void cMeshObject::Render3D() void cMeshObject::Render3D() { if (MeshID==0) return; glPushMatrix(); glTranslatef(m_vPos.x,m_vPos.y,m_vPos.z); glScalef(0.1f,0.1f,0.1f); cBaseMesh *mesh = (cBaseMesh*) world.Get(MeshID); mesh->Render3D(); glPopMatrix(); } all what this function is meant to do, is to render a mesh, BUT if i debug the mesh->Render3D function (hit f11), the program jumps into Material.h - void cBaseMaterial::Activate() what''s wrong??? (sorry for my poor english, hope it doesn''t offend anyone )
lopatsch
lopatsch
hmm that''s what i do. its starts alright.

mymeshid = world.Attach(OT_MESH,"sniper.3ds");

seems to be alright, but when it tries to refer on mymeshid, it doesn''t find a mesh, it finds a material and if i step debug into mesh->render3d i land in cbasematerial::activate()

lopatsch
lopatsch
hmmm, seems that no one has ideas...

could you just download the code and try to debug, and post what you find out...
T2k
T2k
hmm ok i will tell u what NET told me, 1st ur jpg lib not needed but u try to include it (removed to compile), after this the 1st error i get is how u try to copy a filename into an pointer poin ting to nowhere... fixed in hope i can reach ur error, after this it crashes on another memleak, ok dont tried further (i was a bit pissed off :D)... but all ive seen is that u will have to check out the calling-stack to get an idea why ur activate is called thats the funny list by default at the bottom right...


T2k
superpig
superpig
I think you need to look at the world.Get() function.

It''s obviously returning the wrong object.

Superpig
- saving pigs from untimely fates, and when he''s not doing that, runs The Binary Refinery.
Enginuity1 | Enginuity2 | Enginuity3
Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse
shurcool
shurcool
superpig, when will the next Enginuity article be ready? just wondering. :D

---
shurcool
wwdev

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.