They are the same type but it still doesn't work. I could post my program in it's entirety so far, but tis rather long in several files.
Oh what the hell, this is bugging me like mad:
tile.h:
Code:
#pragma once
typedef struct _coord {
int x;
int y;
} coord;
class tile
{
union _coords {
coord* topRight;
coord* bottomRight;
coord* bottomLeft;
coord* topLeft;
} coords;
public:
tile (void);
~tile (void);
void draw ();
void setCoords (coord* tr, coord* br, coord* bl, coord* tl);
void dumpCoords ();
};
tile.cpp
Code:
#include "StdAfx.h"
#include ".\tile.h"
tile::tile (void)
{
coords.bottomLeft = new coord;
coords.bottomRight = new coord;
coords.topLeft = new coord;
coords.topRight = new coord;
}
tile::~tile (void)
{
delete coords.bottomLeft;
delete coords.bottomRight;
delete coords.topLeft;
delete coords.topRight;
}
// draw
// Draws tile @ coords
void tile::draw ()
{
glBegin (GL_QUADS);
glVertex2i (coords.topRight->x, coords.topRight->y);
glVertex2i (coords.bottomRight->x, coords.bottomRight->y);
glVertex2i (coords.bottomLeft->x, coords.bottomLeft->y);
glVertex2i (coords.topLeft->x, coords.topLeft->y);
glEnd ();
}
// setCoords
//
void tile::setCoords (coord* tr, coord* br, coord* bl, coord* tl)
{
std::cout << "assigning [" << tr->x << ", " << tr->y << "]\n";
std::cout << "assigning [" << br->x << ", " << br->y << "]\n";
std::cout << "assigning [" << bl->x << ", " << bl->y << "]\n";
std::cout << "assigning [" << tl->x << ", " << tl->y << "]\n";
*coords.topRight = *tr;
*coords.bottomRight = *br;
*coords.bottomLeft = *bl;
*coords.topLeft = *tl;
std::cout << "assigned [" << coords.topRight->x << ", " << coords.topRight->y << "]\n";
std::cout << "assigned [" << coords.bottomRight->x << ", " << coords.bottomRight->y << "]\n";
std::cout << "assigned [" << coords.bottomLeft->x << ", " << coords.bottomLeft->y << "]\n";
std::cout << "assigned [" << coords.topLeft->x << ", " << coords.topLeft->y << "]\n";
}
// dumpCoords
// Output coords to stdout for debugging
void tile::dumpCoords ()
{
std::cout << "tr: [" << coords.topRight->x << ", " << coords.topRight->y << "]\n";
std::cout << "br: [" << coords.bottomRight->x << ", " << coords.bottomRight->y << "]\n";
std::cout << "bl: [" << coords.bottomLeft->x << ", " << coords.bottomLeft->y << "]\n";
std::cout << "tl: [" << coords.topLeft->x << ", " << coords.topLeft->y << "]\n";
}
EDIT: I take back what I said at the top because half of it isn't here - I don't think it's relevant but if you need it, just shout.