please help

Here is some code for displaying a polygon :

Code:
#include "sgl.h"

POINT point_poly1[] = {

POStoFIXED(-50.0000,-50.0000,-50.0000),

POStoFIXED( 50.0000,-50.0000,-50.0000),

POStoFIXED( 50.0000, 50.0000,-50.0000),

POStoFIXED(-50.0000, 50.0000,-50.0000),

POStoFIXED(-50.0000,-50.0000, 50.0000),

POStoFIXED( 50.0000,-50.0000, 50.0000),

POStoFIXED( 50.0000, 50.0000, 50.0000),

POStoFIXED(-50.0000, 50.0000, 50.0000),

};

POLYGON polygon_poly1[] = {

NORMAL( 0.0000, 0.0000, -1.0000), VERTICES( 0, 1, 2, 3),

NORMAL( 1.0000, 0.0000, 0.0000), VERTICES( 1, 5, 6, 2),

NORMAL( 0.0000, 0.0000, 1.0000), VERTICES( 5, 4, 7, 6),

NORMAL( -1.0000, 0.0000, 0.0000), VERTICES( 4, 0, 3, 7),

NORMAL( 0.0000, -1.0000, 0.0000), VERTICES( 0, 4, 5, 1),

NORMAL( 0.0000, 1.0000, 0.0000), VERTICES( 2, 6, 7, 3),

};

ATTR attribute_poly1[] = {

ATTRIBUTE(Single_Plane, SORT_CEN, No_Texture, C_RGB( 0,31, 0), No_Gouraud, CL32KRGB|MESHoff, sprPolygon, UseLight),

ATTRIBUTE(Single_Plane, SORT_CEN, No_Texture, C_RGB( 0,31, 0), No_Gouraud, CL32KRGB|MESHoff, sprPolygon, UseLight),

ATTRIBUTE(Single_Plane, SORT_CEN, No_Texture, C_RGB( 0,31, 0), No_Gouraud, CL32KRGB|MESHoff, sprPolygon, UseLight),

ATTRIBUTE(Single_Plane, SORT_CEN, No_Texture, C_RGB( 0,31, 0), No_Gouraud, CL32KRGB|MESHoff, sprPolygon, UseLight),

ATTRIBUTE(Single_Plane, SORT_CEN, No_Texture, C_RGB( 0,31, 0), No_Gouraud, CL32KRGB|MESHoff, sprPolygon, UseLight),

ATTRIBUTE(Single_Plane, SORT_CEN, No_Texture, C_RGB( 0,31, 0), No_Gouraud, CL32KRGB|MESHoff, sprPolygon, UseLight),

};

XPDATA xpdata_poly1[] = {

point_Model00, sizeof(point_Model00)/sizeof(POINT),

polygon_Model00, sizeof(polygon_Model00)/sizeof(POLYGON),

attribute_Model00,

NULL,

};

OBJECT object_Model00[] = {

(PDATA*)xpdata_Model00,

TRANSLATION( 0.0000, 0.0000, 0.0000),

ROTATION( 0.0000, 0.0000, 0.0000),

SCALING( 1.0000, 1.0000, 1.0000),

NULL,

NULL,

};

void ss_main(void)

{

static ANGLE ang[XYZ];

static FIXED pos[XYZ];

static FIXED light[XYZ];

slInitSystem(TV_320x224, NULL, 1);

ang[X]=toFIXED(120.50);

ang[Z]=toFIXED(0.0);

pos[X]=toFIXED(0.0);

pos[Y]=toFIXED(40.170);

pos[Z]=toFIXED(220.0);

light[X]=toFIXED(0.0);

light[Y]=light[Z]=toFIXED(-60.0);

slPutPolygon(&poly1);

slPrint("Saturn Demo Coding Contest June 2003", slLocate(1,1));

while(1){

 slSynch()

}

}

void sleepuntilbutton (Uint32 frames)

{

while (frames > 0)

  {

  SlSynch();

  if (Smpc_Peripheral[0].data && PER_DGT_TX) return;

  frames--

  }

}

Why won´t it work? Could someone help me woth fixing this code so it displays the polygon ive created?
 
1. You should put your "slPutPolygon" in the while(1){} loop, for your cube to be displayed at each synch/refresh, not only at the first time. The slprint is not concerned: its plane is not blanked by a slsynch.

2. I think your "sleepuntilbutton" function is never called.

3. if you want your

Code:
  if (Smpc_Peripheral[0].data && PER_DGT_TX) return;

to test if X button of the first pad is pressed, you should try :

Code:
  if (!(Smpc_Peripheral[0].data && PER_DGT_TX)) return;

Does it work, then ?
 
Code:
#include "sgl.h"

POINT point_poly1[] = {

POStoFIXED(-50.0000,-50.0000,-50.0000),

POStoFIXED( 50.0000,-50.0000,-50.0000),

POStoFIXED( 50.0000, 50.0000,-50.0000),

POStoFIXED(-50.0000, 50.0000,-50.0000),

POStoFIXED(-50.0000,-50.0000, 50.0000),

POStoFIXED( 50.0000,-50.0000, 50.0000),

POStoFIXED( 50.0000, 50.0000, 50.0000),

POStoFIXED(-50.0000, 50.0000, 50.0000),

};

POLYGON polygon_poly1[] = {

NORMAL( 0.0000, 0.0000, -1.0000), VERTICES( 0, 1, 2, 3),

NORMAL( 1.0000, 0.0000, 0.0000), VERTICES( 1, 5, 6, 2),

NORMAL( 0.0000, 0.0000, 1.0000), VERTICES( 5, 4, 7, 6),

NORMAL( -1.0000, 0.0000, 0.0000), VERTICES( 4, 0, 3, 7),

NORMAL( 0.0000, -1.0000, 0.0000), VERTICES( 0, 4, 5, 1),

NORMAL( 0.0000, 1.0000, 0.0000), VERTICES( 2, 6, 7, 3),

};

ATTR attribute_poly1[] = {

ATTRIBUTE(Single_Plane, SORT_CEN, No_Texture, C_RGB( 0,31, 0), No_Gouraud, CL32KRGB|MESHoff, sprPolygon, UseLight),

ATTRIBUTE(Single_Plane, SORT_CEN, No_Texture, C_RGB( 0,31, 0), No_Gouraud, CL32KRGB|MESHoff, sprPolygon, UseLight),

ATTRIBUTE(Single_Plane, SORT_CEN, No_Texture, C_RGB( 0,31, 0), No_Gouraud, CL32KRGB|MESHoff, sprPolygon, UseLight),

ATTRIBUTE(Single_Plane, SORT_CEN, No_Texture, C_RGB( 0,31, 0), No_Gouraud, CL32KRGB|MESHoff, sprPolygon, UseLight),

ATTRIBUTE(Single_Plane, SORT_CEN, No_Texture, C_RGB( 0,31, 0), No_Gouraud, CL32KRGB|MESHoff, sprPolygon, UseLight),

ATTRIBUTE(Single_Plane, SORT_CEN, No_Texture, C_RGB( 0,31, 0), No_Gouraud, CL32KRGB|MESHoff, sprPolygon, UseLight),

};

XPDATA xpdata_poly1[] = {

point_Model00, sizeof(point_Model00)/sizeof(POINT),

polygon_Model00, sizeof(polygon_Model00)/sizeof(POLYGON),

attribute_Model00,

NULL,

};

OBJECT object_Model00[] = {

(PDATA*)xpdata_Model00,

TRANSLATION( 0.0000, 0.0000, 0.0000),

ROTATION( 0.0000, 0.0000, 0.0000),

SCALING( 1.0000, 1.0000, 1.0000),

NULL,

NULL,

};

void ss_main(void)

{

static ANGLE ang[XYZ];

static FIXED pos[XYZ];

static FIXED light[XYZ];

slInitSystem(TV_320x224, NULL, 1);

ang[X]=toFIXED(120.50);

ang[Z]=toFIXED(0.0);

pos[X]=toFIXED(0.0);

pos[Y]=toFIXED(40.170);

pos[Z]=toFIXED(220.0);

light[X]=toFIXED(0.0);

light[Y]=light[Z]=toFIXED(-60.0);

}

slPrint("Saturn Demo Coding Contest June 2003", slLocate(1,1));

while(1){

slPutPolygon(&poly1);

 slSynch()

}

void sleepuntilbutton (Uint32 frames)

{

while (frames > 0)

  {

  SlSynch();

  if (!(Smpc_Peripheral[0].data && PER_DGT_TX)) return;

  frames--

  }

}

This is how the code looks right now. When i try to compile it i get these errors :

main.c:33: `point_model00´ undeclared here (not in function)

main.c:33: initializer element for `xpdata_poly1[0]´is not a constant

And the same goes for some other lines in the program.
 
1. In the XPDATA (or PDATA) structure, you have to put references to *your* POINTS, POLYGONS and ATTRIBUTES, like that :

Code:
XPDATA xpdata_poly1[] = {

point_point_poly1, sizeof(point_point_poly1)/sizeof(POINT),

polygon_point_poly1, sizeof(polygon_point_poly1)/sizeof(POLYGON),

attribute_point_poly1,

NULL,

};

2. The poly1 you use in

Code:
while(1){

 slPutPolygon(&poly1);

 slSynch()

}

is never defined. You named what you want to display xpdata_poly1. You have to use it.

3. Be sure to understand the differencies between the XPDATA and PDATA structure types. If you want to use XPDATA, you should use slPutPolygonX; PDATA is to be used with slPutPolygon. I believe slPutPolygonX is only provided with the most recent versions of the SGL, in order to make realtime gouraud shading easier. Try one of the TORUS example (can't remeber which one).
 
Pardon me, I made a mistake : polygons are great, *I* suck. I apologize, I crawl and kiss the feets of the great vreuzon, I owe him everything.
 
Back
Top