Sign in to follow this  

Simple Draw Function, not working!

This topic is 4378 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

Okay, so we have our draw function, it calls getrenderdata from everything in a vector, then draws it according to that data... Not working... First, I'll give you an example of something the vector would hold
#ifndef OBJECT_H
#define OBJECT_H
#include "MS3D.h"
#include "ObjectFactory.h"
#include "ResourceManager.h"


enum OBJECTS
{
   SHIP_OBJECT
};

class Object
{
public:
	virtual ~Object() {}
	float locx, locy, locz;
	bool MarkedForDeletion;

	virtual MS3DModel *GetRenderInformation() = 0;
	virtual void GetPhysicsInformation() = 0;
	virtual void GetSoundInformation() = 0;
	virtual void Update() = 0;


};

class Ship : public Object
{
public:
	
	Ship(float x, float y, float z)
	{
		x = locx;
		y = locy;
		z = locz;
	}

	virtual MS3DModel *GetRenderInformation()
	{
		MS3DModel * Obj;
		Obj = Models.Model1;
		return Obj;
	}

	virtual void GetPhysicsInformation()
	{
	
	}

	virtual void GetSoundInformation()
	{
	
	}

	virtual void Update()
	{
	
	}

protected:

	// Cross specific functions go here

};

#endif
Okay, notice how we have a GetRenderInformation() function, that houses a pointer to an MS3D model, and sets it Equal to Obj before returning it.... (this way we can do Obj->DrawMS3DModels() in our render loop) Here is an example of the Draw Function
void GLRenderer::DrawSceneObjects()
{
	for (int i = 0; i<Scene_Objects.size(); i++)
	{
		Scene_Objects[i]->GetRenderInformation();
		Obj->DrawMS3DModels();
	}
}
Simple as that, unfortunately, I get these errors...
c:\documents and settings\jonathan\desktop\renderengine\renderer.cpp(53) : error C2065: 'Obj' : undeclared identifier
c:\documents and settings\jonathan\desktop\renderengine\renderer.cpp(53) : error C2227: left of '->DrawMS3DModels' must point to class/struct/union
Now I know its something silly, any info?

Share this post


Link to post
Share on other sites
c:\documents and settings\jonathan\desktop\renderengine\renderer.cpp(54) : warning C4700: local variable 'Obj' used without having been initialized


It doesn't understand that I'm setting returning a filled Obj with my GetRenderInformation function.... why?

Share this post


Link to post
Share on other sites
Now I got this

virtual MS3DModel *GetRenderInformation()
{
return Models.Model1; // returns a pointer to a model
}



void GLRenderer::DrawSceneObjects()
{
MS3DModel * Obj;
for (int i = 0; i<Scene_Objects.size(); i++)
{
Scene_Objects[i]->GetRenderInformation();
Obj = Scene_Objects[i]->GetRenderInformation();
Obj->DrawMS3DModels();
}
}

Share this post


Link to post
Share on other sites
it depends on your structure.

if you want to delete then delteit with

delete Obj;

but i don't know how your code manage the objects
I use atm linked lists so i have the objectss dinamically

Share this post


Link to post
Share on other sites

This topic is 4378 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this