/* * Draw a line from a quad */ void S2D_DrawLine(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2, GLfloat width, GLfloat r1, GLfloat g1, GLfloat b1, GLfloat a1, GLfloat r2, GLfloat g2, GLfloat b2, GLfloat a2, GLfloat r3, GLfloat g3, GLfloat b3, GLfloat a3, GLfloat r4, GLfloat g4, GLfloat b4, GLfloat a4) { double length = sqrt(powf(x1 - x2, 2) + powf(y1 - y2, 2)); double x = ((x2 - x1) / length) * width / 2; double y = ((y2 - y1) / length) * width / 2; S2D_DrawQuad( x1 - y, y1 + x, r1, g1, b1, a1, x1 + y, y1 - x, r2, g2, b2, a2, x2 + y, y2 - x, r3, g3, b3, a3, x2 - y, y2 + x, r4, g4, b4, a4 ); };
void update() { S2D_DrawTriangle(10, 10, 1.0, 0, 0, 1.0, 100, 100, 0, 1.0, 0, 1.0, window->cursor_x, window->cursor_y, 0, 0, 1.0, 1.0); S2D_DrawQuad(window->cursor_x, window->cursor_y, 1.0, 0, 0, 0.5, 370, 70, 1.0, 0, 0, 0.5, 350, 250, 1.0, 0, 0, 0.5, 70, 270, 1.0, 0, 0, 0.5); S2D_DrawImage(img_jpg, window->cursor_x, window->cursor_y); S2D_DrawImage(img_png, 300, 300); puts("--------------------"); printf("cursor: %i, %i\n", window->cursor_x, window->cursor_y); printf("frames: %i\n", window->frames); printf("total_ms: %i\n", window->total_ms); printf("loop_ms: %i\n", window->loop_ms); printf("delay_ms: %i\n", window->delay_ms); printf("fps: %f\n", window->fps); }
void render() { S2D_DrawImage(controller); // Axes S2D_DrawQuad( 156, 130, 0, 1, 0, 1, 156 + axis_LEFTX, 130, 0, 1, 0, 1, 156 + axis_LEFTX, 159, 0, 1, 0, 1, 156, 159, 0, 1, 0, 1 ); S2D_DrawQuad( 142, 145 + axis_LEFTY, 0, 1, 0, 1, 171, 145 + axis_LEFTY, 0, 1, 0, 1, 171, 145, 0, 1, 0, 1, 142, 145, 0, 1, 0, 1 ); S2D_DrawQuad( 374, 215, 0, 1, 0, 1, 374 + axis_RIGHTX, 215, 0, 1, 0, 1, 374 + axis_RIGHTX, 244, 0, 1, 0, 1, 374, 244, 0, 1, 0, 1 ); S2D_DrawQuad( 359, 229 + axis_RIGHTY, 0, 1, 0, 1, 388, 229 + axis_RIGHTY, 0, 1, 0, 1, 388, 229, 0, 1, 0, 1, 359, 229, 0, 1, 0, 1 ); S2D_DrawQuad( 8, 71 - axis_TRIGGERLEFT * .84, 0, 1, 0, 1, 42, 71 - axis_TRIGGERLEFT * .84, 0, 1, 0, 1, 42, 71, 0, 1, 0, 1, 8, 71, 0, 1, 0, 1 ); S2D_DrawQuad( 8 + 550, 71 - axis_TRIGGERRIGHT * .84, 0, 1, 0, 1, 42 + 550, 71 - axis_TRIGGERRIGHT * .84, 0, 1, 0, 1, 42 + 550, 71, 0, 1, 0, 1, 8 + 550, 71, 0, 1, 0, 1 ); // Buttons if (btn_A) // green S2D_DrawQuad( 426, 167, 0, 1, 0, 1, 426 + 33, 167, 0, 1, 0, 1, 426 + 33, 167 + 33, 0, 1, 0, 1, 426, 167 + 33, 0, 1, 0, 1 ); if (btn_B) // red S2D_DrawQuad( 464, 129, 1, 0, 0, 1, 464 + 33, 129, 1, 0, 0, 1, 464 + 33, 129 + 33, 1, 0, 0, 1, 464, 129 + 33, 1, 0, 0, 1 ); if (btn_X) // blue S2D_DrawQuad( 388, 128, 0, .7, 1, 1, 388 + 33, 128, 0, .7, 1, 1, 388 + 33, 128 + 33, 0, .7, 1, 1, 388, 128 + 33, 0, .7, 1, 1 ); if (btn_Y) // yellow S2D_DrawQuad( 426, 91, 1, 1, 0, 1, 426 + 33, 91, 1, 1, 0, 1, 426 + 33, 91 + 33, 1, 1, 0, 1, 426, 91 + 33, 1, 1, 0, 1 ); if (btn_BACK) S2D_DrawQuad( 248, 133, 1, .5, 0, 1, 248 + 23, 133, 1, .5, 0, 1, 248 + 23, 133 + 23, 1, .5, 0, 1, 248, 133 + 23, 1, .5, 0, 1 ); if (btn_GUIDE) S2D_DrawQuad( 281, 69, .5, 1, .5, 1, 281 + 38, 69, .5, 1, .5, 1, 281 + 38, 69 + 38, .5, 1, .5, 1, 281, 69 + 38, .5, 1, .5, 1 ); if (btn_START) S2D_DrawQuad( 331, 133, 1, .5, 0, 1, 331 + 23, 133, 1, .5, 0, 1, 331 + 23, 133 + 23, 1, .5, 0, 1, 331, 133 + 23, 1, .5, 0, 1 ); if (btn_LEFTSTICK) S2D_DrawQuad( 134, 122, 1, 0, 0, 1, 134 + 45, 122, 1, 0, 0, 1, 134 + 45, 122 + 45, 1, 0, 0, 1, 134, 122 + 45, 1, 0, 0, 1 ); if (btn_RIGHTSTICK) S2D_DrawQuad( 351, 207, 1, 0, 0, 1, 351 + 45, 207, 1, 0, 0, 1, 351 + 45, 207 + 45, 1, 0, 0, 1, 351, 207 + 45, 1, 0, 0, 1 ); if (btn_LEFTSHOULDER) S2D_DrawQuad( 111, 84, .5, 0, 1, 1, 117, 64, .5, 0, 1, 1, 198, 39, .5, 0, 1, 1, 225, 52, .5, 0, 1, 1 ); if (btn_RIGHTSHOULDER) S2D_DrawQuad( 494, 85, .5, 0, 1, 1, 484, 64, .5, 0, 1, 1, 401, 39, .5, 0, 1, 1, 378, 51, .5, 0, 1, 1 ); if (btn_DPAD_UP) S2D_DrawQuad( 216, 194, 1, 0, .5, 1, 216 + 23, 194, 1, 0, .5, 1, 216 + 23, 194 + 28, 1, 0, .5, 1, 216, 194 + 28, 1, 0, .5, 1 ); if (btn_DPAD_DOWN) S2D_DrawQuad( 216, 243, 1, 0, .5, 1, 216 + 23, 243, 1, 0, .5, 1, 216 + 23, 243 + 27, 1, 0, .5, 1, 216, 243 + 27, 1, 0, .5, 1 ); if (btn_DPAD_LEFT) S2D_DrawQuad( 189, 221, 1, 0, .5, 1, 189 + 28, 221, 1, 0, .5, 1, 189 + 28, 221 + 22, 1, 0, .5, 1, 189, 221 + 22, 1, 0, .5, 1 ); if (btn_DPAD_RIGHT) S2D_DrawQuad( 238, 221, 1, 0, .5, 1, 238 + 28, 221, 1, 0, .5, 1, 238 + 28, 221 + 22, 1, 0, .5, 1, 238, 221 + 22, 1, 0, .5, 1 ); }