ja,
ich hab mich nun endg�ltig mit c und c++ besch�ftigt, doch leider h�nge ich
immer an einem problem. dem speicher. mit dem memory management habe ich so
meine probleme. vieleicht kann mir wer weiter helfen. anbei f�ge ich die
class mit kommentaren, wo ich meine problemchen habe. der code an sich
funktioniert, allerdings ist durch die festen gr�ssen der arrays irgendwann
schluss mit speicherplatz f�r meine GLobjects.
den code f�r die proceduren packe ich nicht dazu, das w�re viel zu viel und
ich denke es ist auch nicht umbedingt notwendig, den code hier zu
ver�ffentlichen.
�henrik
#define MAX_POLYGON 500 //fixed array size, i was not in the
mood to makes the hole thing with maloc
#define MAX_VERTEX 10 //same like MAX_POLYGON. how the fuck
can i use pointers and such stuff for memmgt)
struct VERTEX //the vertext structur holds x,y,z
and the colors of one vertex
{
float vcolor_r; // Vertex Color Red
float vcolor_g; // Vertex Color Green
float vcolor_b; // Vertex Color Blue
// float valpha; // not in use atm
float vpos_x; // Vertex Position X
float vpos_y; // Vertex Position Y
float vpos_z; // Vertex Position Z
};
struct POLYGON // hold the vertexes per polygon
{
int NumOfVertex; // counter for the vertex struct
float ppos_x, ppos_y, ppos_z; // x,y,z of the polygon
VERTEX vertex[MAX_VERTEX]; // the array of VERTEX - at this
point i want unlimited vertexs (HOW?) but i dont want, that the whole memory
is reserved for the vertexe (i used for testing some utopic values
(max_vertex 1000 and max_polygon 1000. and i lost 600mb memory on my system
(o.O)
};
class globject // class globject
{
private:
int NumOfPolygons; // index of polygon
float rotatevalue; // for rotation
float posx; // Position X of the object
float posy; // Position Y of the object
float posz; // Position Z of the object
POLYGON AllPolygons[MAX_POLYGON]; // array of POLYGON - at this
point i want unlimited polygons(HOW?)
BOOL visible; // FALSE will not draw this
object
GLuint texture[1];
public:
int AddPolygon(); // Add a polygon to object
and +1 the NumOfPolygon
int AddVertex(int PolygonNum, // Add a vertex to a polygon
float vcolor_r, // red
float vcolor_g, // green
float vcolor_b, // blue
float vpos_x, // Position X of Vertex
float vpos_y, // Position Y of Vertex
float vpos_z); // Position Z of Vertex
void DrawObject(); // draw the object
void RotateObject(float speed); // add speed to the
rotatevalue on every call
void MoveObject(int direction); // move the object in
specified direction
void LoadObject(char* ObjectFileName); // Load the object from file
};
----------------------------------------------------------------------------
PUG - Penguin User Group Wiesbaden - http://www.pug.org