www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/11/13/09:31:02

Date: Sat, 13 Nov 1999 15:01:29 +0200
From: Marius Myburg <iti06469 AT mweb DOT co DOT za>
Subject: Dynamic pointer creation
To: djgpp AT delorie DOT com
Message-id: <0FL50055B01WP9@cpt-proxy1.mweb.co.za>
MIME-version: 1.0
X-Mailer: Microsoft Internet Mail 4.70.1154
X-MSMail-Priority: Normal
X-Priority: 3
Reply-To: djgpp AT delorie DOT com

Hi all,

I am working on a 3D engine, and I am having a little trouble.  Here are
the relevant source

//==============
// structures

typedef struct // a point
{
   float x, y, z;
   int scrx, scry;
   int distance;
   int color;
}point_s;

typedef struct // a face (trigon)
{
   point_s p1;
   point_s p2;
   point_s p3;
}face_s;

typedef struct // an object
{
   face_s *faces;
   int numfaces;
}object_s;


I want the object_s structure to be able to have any number of faces, hence
face_s *faces.  But, if I want to add a face (or a pointer to a face), how
do I do it?  Also, how do I access any given face, if I have say 20
pointers
to 20 faces in a given object?

Thank you,
Marius Myburg



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019