Change fro, RL_QUADS to RL_TRIANGLES

for web support
This commit is contained in:
Nikola Petrov 2024-03-31 00:35:33 +01:00
parent 09d1b0f5b0
commit e62b0eb6bf
3 changed files with 20 additions and 13 deletions

View File

@ -78,6 +78,10 @@
"__config": "cpp",
"__split_buffer": "cpp",
"__verbose_abort": "cpp",
"locale": "cpp"
"locale": "cpp",
"coroutine": "cpp",
"forward_list": "cpp",
"span": "cpp",
"variant": "cpp"
}
}

View File

@ -10,6 +10,7 @@ std::filesystem::path BUILD_FILE = "main";
bool web_build = false;
bool build = false;
bool clear = false;
bool run = false;
std::string cpp_compiler = "g++";
std::string c_compiler = "gcc";
@ -171,6 +172,9 @@ int main(int argc, char const *argv[])
if (!std::strcmp(argv[i], "build"))
build = true;
if (!std::strcmp(argv[i], "run"))
run = true;
if (!std::strcmp(argv[i], "cla"))
{
clear_build_dir(true, true);
@ -215,7 +219,6 @@ int main(int argc, char const *argv[])
if (web_build)
{
clear_build_dir(true, true);
cpp_compiler = "em++";
c_compiler = "emcc";
opt_flags = "-Os";
@ -233,7 +236,7 @@ int main(int argc, char const *argv[])
if (!std::filesystem::exists(BUILD_FILE))
compile_obj_dir();
if (!web_build && !build)
if (!web_build && run)
{
command = {"./" + BUILD_FILE.string()};
nob_cmd_run_sync(command);

View File

@ -25,7 +25,7 @@ void BackGround::newGen()
void BackGround::starts()
{
rlSetTexture(texShapes.id);
rlBegin(RL_QUADS);
rlBegin(RL_TRIANGLES);
rlNormal3f(0.0f, 0.0f, 1.0f);
for (size_t i = 1; i <= numOfStarts; i++)
@ -40,18 +40,18 @@ void BackGround::starts()
rlColor4ub(color.r, color.g, color.b, color.a);
// topLeft
rlTexCoord2f(0, 0);
rlVertex2f(x, y);
// bottomLeft
rlTexCoord2f(0, 1);
rlVertex2f(x, y + weight);
// topRight
rlVertex2f(x + weight, y);
// bottomRight
rlTexCoord2f(1, 1);
rlVertex2f(x + weight, y + weight);
// topRight
rlTexCoord2f(1, 0);
rlVertex2f(x + weight, y);
// bottomLeft
rlVertex2f(x, y + weight);
}
rlEnd();
rlSetTexture(0);
@ -83,17 +83,15 @@ void BackGround::mounten(size_t mountenSegments, float scale, int min, int max,
int y = Lerp(min, max, p);
rlSetTexture(texShapes.id);
rlBegin(RL_QUADS);
rlBegin(RL_TRIANGLES);
rlNormal3f(0.0f, 0.0f, 1.0f);
rlColor4ub(color.r, color.g, color.b, color.a);
for (size_t i = 1; i <= mountenSegments; i++)
{
// topLeft
rlTexCoord2f(0, 0);
rlVertex2f(x, y);
// bottomLeft
rlTexCoord2f(0, 1);
rlVertex2f(x, size);
nx = (float)(i + offsetX) * scale;
@ -101,13 +99,15 @@ void BackGround::mounten(size_t mountenSegments, float scale, int min, int max,
p = (p + 1.0f) / 2.0f;
y = Lerp(min, max, p);
x += diff;
// topRight
rlVertex2f(x, y);
// bottomRight
rlTexCoord2f(1, 1);
rlVertex2f(x, size);
// topRight
rlTexCoord2f(1, 0);
rlVertex2f(x, y);
rlVertex2f(x - diff, size);
}
rlEnd();
rlSetTexture(0);