#emscripten stuck at download

27 messages · Page 1 of 1 (latest)

tame pilot
#

Hi I have a problem I made a program printing a fractal but it gets stuck when opening the html file and it does nothing i can't even use inspect on it I'm using the latest version of emscripten and SDL3

hoary pantherBOT
#

When your question is answered use !solved or the button below to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

tame pilot
#

#include <SDL3/SDL.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#include <iostream>
#define M_PI 3.14159265358979323846 // pi
#define WINDOW_W 800
#define WINDOW_H 600

void draw_fractal(SDL_Renderer* r,
float x, float y,
float length,
float angle,
int depth,
int maxDepth,
float angleLeft,
float angleRight)
{
if (depth >= maxDepth || length < 1.0f)
return;

float x2 = x + cosf(angle) * length;
float y2 = y - sinf(angle) * length;

SDL_RenderLine(r, (int)x, (int)y, (int)x2, (int)y2);


draw_fractal(r, x2, y2, length * 0.75f, angle + angleLeft,
    depth + 1, maxDepth, angleLeft, angleRight);

draw_fractal(r, x2, y2, length * 0.75f, angle - angleRight,
    depth + 1, maxDepth, angleLeft, angleRight);

}

int main(int argc, char** argv)
{
Uint64 itteracje,multi = 5;
Uint16 key = 1;

SDL_Init(SDL_INIT_VIDEO);

SDL_Window* win = SDL_CreateWindow("Fraktal", WINDOW_W, WINDOW_H, 0);
SDL_Renderer* ren = SDL_CreateRenderer(win, NULL);

srand((unsigned)time(NULL));

switch (key) 
{
case 1:
    key = 90;
    break;
case 2:
    key = 35;
    break;
case 3:
    key = 360;
    break;
}


float angleLeft = (rand() % key
    + 10) * M_PI / 180.0f; 
float angleRight = (rand() % key
    + 10) * M_PI / 180.0f;

int run = 1;
SDL_Event evt;

while (run) {
    while (SDL_PollEvent(&evt)) {
        if (evt.type == SDL_EVENT_QUIT)
            run = 0;
    }
   
    SDL_SetRenderDrawColor(ren, 0, 0, 0, 255);
    SDL_RenderClear(ren);

    SDL_SetRenderDrawColor(ren, 255, 255, 255,
#

255);

    draw_fractal(ren,
        WINDOW_W / 2, WINDOW_H - 20,  
        120,                          
        M_PI / 2,                      
        0,
        (itteracje * multi),                           
        angleLeft, angleRight);


    SDL_RenderPresent(ren);

}

SDL_DestroyRenderer(ren);
SDL_DestroyWindow(win);
SDL_Quit();
return 0;

}

#

255);

    draw_fractal(ren,
        WINDOW_W / 2, WINDOW_H - 20,  
        120,                          
        M_PI / 2,                      
        0,
        (itteracje * multi),                           
        angleLeft, angleRight);


    SDL_RenderPresent(ren);

}

SDL_DestroyRenderer(ren);
SDL_DestroyWindow(win);
SDL_Quit();
return 0;

}

#

and here is the http

#

expected return is a fractal drawn using line primitives

torn cradle
#

Where do you click inspect?

#

Try right-clicking an empty space instead of the black rect

tame pilot
tame pilot
#

alr i so i think i get it

#

it must be my code

#

bc the site decided to load in

#

so that's not html

#

welp

#

OOOH

#

I think i know

torn cradle
#

Ah I should've looked at the code before saying anything. Emscripten has special requirements regarding the main loop

tame pilot
#

I'll use callback

torn cradle
#

Yep 🙂