Difference between revisions of "GSDP:GAM100/CProcessing/worldToScreen()"
From Inside
< GSDP:GAM100 | CProcessing
>Zachary.logsdon |
>Zachary.logsdon |
||
Line 6: | Line 6: | ||
===Parameters=== | ===Parameters=== | ||
− | worldToScreen(float* | + | worldToScreen(float xIn, float yIn, float* xOut, float* yOut) |
− | * | + | * xIn - (float) The x coordinate to convert. |
− | * y - (float*) The | + | * 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 == | == Example == | ||
Line 15: | Line 17: | ||
void init() | void init() | ||
{ | { | ||
− | |||
− | |||
− | |||
− | |||
− | |||
// Variables to pass into the conversion functions | // Variables to pass into the conversion functions | ||
float x = PI; | float x = PI; | ||
Line 27: | Line 24: | ||
for (int i = 0; i < 100; ++i) | for (int i = 0; i < 100; ++i) | ||
{ | { | ||
− | screenToWorld(&x, &y); | + | screenToWorld(x, y, &x, &y); |
− | worldToScreen(&x, &y); | + | worldToScreen(x, y, &x, &y); |
} | } | ||
Latest revision as of 11:17, 3 June 2019
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);
}