GSDP:GAM100/CProcessing/worldToScreen()

From Inside
< GSDP:GAM100‎ | CProcessing
Revision as of 11:06, 3 June 2019 by >Zachary.logsdon
Jump to: navigation, search

worldToScreen()

Description

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

Parameters

worldToScreen(float* x, float* y)

  • x - (float*) The x coordinate to convert, x result will be stored here as well.
  • y - (float*) The y coordinate to convert, y result will be stored here as well.

Example

void init()
{
    // transform a random amount
    translate((float)randomRangeFloat(-100.0f, 100.0f), (float)randomRangeFloat(-100.0f, 100.0f));
    scale((float)randomRangeFloat(0.1f, 10.0f));
    rotate((float)randomRangeFloat(0.0f, 360.0f));

    // 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);
        worldToScreen(&x, &y);
    }

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

Related

Personal tools
Namespaces

Variants
Actions
Navigation
NameSpaces:>
Tools
Dynamic:>