GSDP:GAM100/CProcessing/worldToScreen()

worldToScreen()

Description

Takes an input coordinate in world space and transforms it to screen coordinates.

Parameters

worldToScreen(float xIn, float yIn, float* xOut, float* yOut)

  • xIn - (float) The x coordinate to convert.
  • yIn - (float) The y coordinate to convert.
  • xOut - (float*) The place to store the converted x coordinate.
  • yOut - (float*) The place to store the converted y coordinate.

Example

void init()
{
    // Variables to pass into the conversion functions
    float x = PI;
    float y = PI;

    // Run back and forth 100 times
    for (int i = 0; i < 100; ++i)
    {
        screenToWorld(x, y, &x, &y);
        worldToScreen(x, y, &x, &y);
    }

    // Should still be PI
    printf(" %9f\n(%9f,%9f)\n", PI, x, y);
}

Related