Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update usage of 'sinf()' and 'cosf()' to be correct #3181

Merged
merged 2 commits into from
Jul 19, 2023

Conversation

RokasPuzonas
Copy link
Contributor

Changes for fixing #3180

Besides swapping sinf() and cosf(), the vertex order for quads and triangles was updated, so they would be visible.

Here is an example that I used to test if my changes were good, this includes all functions that were updated:

// example.cpp
// Compiling:  g++ example.cpp -lraylib
#include <raylib.h>
#include <raymath.h>

int main() {
	InitWindow(800, 800, "Reproduction");
	SetTargetFPS(60);

	while (!WindowShouldClose())
	{
		BeginDrawing();
		ClearBackground(RAYWHITE);

		float angle = (int)(GetTime()*100) % 360;

		DrawCircleSector({ 150, 100 }, 50, 0, angle, 5, BLACK);
		DrawCircleLines(150, 100, 50, BLACK);

		DrawCircleSectorLines({ 300, 100 }, 50, 0, angle, 5, BLACK);
		DrawCircleLines(300, 100, 50, BLACK);

		DrawRing({ 450, 100 }, 25, 50, 0, angle, 5, BLACK);
		DrawCircleLines(450, 100, 50, BLACK);

		DrawCircleGradient(600, 100, 50, BLUE, RED);

		DrawCircleLines(150, 250, 50, BLACK);
		Vector2 line_dir = { 50, 0 };
		DrawLine(150, 250, 150 + line_dir.x, 250 + line_dir.y, BLACK);
		line_dir = Vector2Rotate(line_dir, DEG2RAD*angle);
		DrawLine(150, 250, 150 + line_dir.x, 250 + line_dir.y, BLACK);

		DrawEllipse(300, 250, 25, 50, BLACK);

		DrawEllipseLines(450, 250, 50, 25, BLACK);

		DrawRingLines({ 600, 250 }, 25, 50, 0, angle, 5, BLACK);
		DrawCircleLines(600, 250, 50, BLACK);

		DrawRectangleRounded({ 100, 350, 100, 100 }, 0.4, 5, BLACK);

		DrawRectangleRoundedLines({ 250, 350, 100, 100 }, 0.4, 5, 1, BLACK);

		DrawRectangleRoundedLines({ 400, 350, 100, 100 }, 0.4, 5, 3, BLACK);

		DrawPoly({ 600, 400 }, 5, 50, 0, BLACK);

		DrawPolyLines({ 150, 550 }, 5, 50, 0, BLACK);

		DrawPolyLinesEx({ 300, 550 }, 5, 50, 0, 10, BLACK);

		EndDrawing();
	}

	CloseWindow();

	return 0;
}

Screenshot of program used to test changes:

image

@raysan5 raysan5 merged commit d6f16b7 into raysan5:master Jul 19, 2023
@raysan5
Copy link
Owner

raysan5 commented Jul 19, 2023

@RokasPuzonas Thank you very much again for this great improvement!

ashn-dot-dev added a commit to ashn-dot-dev/scratch that referenced this pull request Aug 12, 2023
I think raysan5/raylib#3181 might be responsible
for the altered behavior of DrawPoly and DrawPolyLines.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants