Hi Brandon
Looking good mate!
Just though I'd share my hook for getting compass angle. It's messy but very simple.
I stripped silentwolf's version as a base for mine as I had trouble compiling yours. Anyway it should be easy enough to implement in your code.
Code:
// globals
bool GettingCompassAngle;
int CompassVertexCount;
int CompassDeltaX;
int CompassDeltaY;
float CompassAngle = 0.;
void sys_glBindTexture (GLenum target, GLuint texture)
{
// 0x84F5 = GL_TEXTURE_RECTANGLE
if(target == 0x84F5) {
GLint textureWidth, textureHeight;
glGetTexLevelParameteriv(GL_TEXTURE_RECTANGLE_ARB, 0, GL_TEXTURE_WIDTH, &textureWidth);
glGetTexLevelParameteriv(GL_TEXTURE_RECTANGLE_ARB, 0, GL_TEXTURE_HEIGHT, &textureHeight);
if (textureWidth == 51) {
if (textureHeight == 51) {
//add_log("Found the compass %d", currentPossibleItem->texture_id);
GettingCompassAngle = true;
CompassVertexCount = 0;
}
}
....
void sys_glVertex2f (GLfloat x, GLfloat y)
{
if(GettingCompassAngle) {
if (CompassVertexCount == 0) {
CompassDeltaX = x;
CompassDeltaY = y;
}
if (CompassVertexCount == 3) {
CompassDeltaX = x - CompassDeltaX;
CompassDeltaY = y - CompassDeltaY;
}
CompassVertexCount++;
}
....
void sys_glEnd (void)
{
if(GettingCompassAngle) {
GettingCompassAngle = false;
CompassAngle = atan2f(CompassDeltaY, CompassDeltaX) * 180 / M_PI;
if (CompassAngle < 0)
CompassAngle = 360 + CompassAngle;
add_log("COMPASS ANGLE = %f", CompassAngle);
}
....
EDIT: Sorry I didn't realize you'd already done this