I have been stuck on a very simple issue for multiple days and need someone 
who knows what they are doing. I'm trying to use SDL2 and WebGL2 (OpenGL ES 
3) and sometimes it works, but sometimes it doesn't, depending on seemingly 
arbitrary code. Please help. See here for the full details and source code:

https://gist.github.com/AntonStrickland/433c911151ca73826ee679b120fe8d9e

Basically, I have a simple program (just over 100 lines of code) that 
changes the background color of the screen by calling glClear(). Probably 
the most basic OpenGL program one can write. When the color is pink, that 
means it's working, and when it's black, it's not working. In the above 
link there is main.cpp which works correctly. I have been doing trial and 
error for this past week commenting out random lines of code to isolate the 
problem, but it seems like changing arbitrary lines of code stops it from 
working. I've noticed that it happens when calling some SDL functions, but 
even just commenting out printing to the console is enough to break it. See 
main.cpp for details.

I don't know if this is just an issue with me not understanding how this 
works or if this is an actual bug in emscripten or the SDL port. it's 
frustrating because when it works, it works all the way (I can use shaders 
and textures to have a working app), but if I change just a tiny little 
thing (even just commenting out an unrelated line of code), suddenly 
nothing works at all. I have no idea where to even start debugging this.

I would imagine that there has to be a way to do this since people are 
obviously making WebGL games in C++, but since there are no tutorials 
online for how to do that it becomes impossible to even set up a simple 
"hello world" script. I purchased a book on how to make games in web 
assembly but they use the SDL renderer and not OpenGL rendering. Other 
OpenGL web assembly tutorials just use OpenGL without SDL. Surely there 
must be a way to use them together as I have done for my desktop app?

I have already reached out on the discord but to no avail so far. Someone 
suggested adding -fsanitize=address when compiling but that actually causes 
the above working code to stop working. I don't really have the time to 
just wait for an answer so I'm hoping this post will get the attention of 
more people.

So I know this is getting long, but I'm very confused. Since technically by 
code works, but it's one step away from breaking, and I have no idea what 
that step is or why. My ultimate goal is to copy and paste this code into a 
larger project, but every time I do so, it results in a black screen with 
no indication of what I did wrong.

I would like to understand a few things: 

   - Is this a problem with my code, my makefile, SDL, or emscripten?
   - If this is not a problem with my code, is someone going to fix the 
   issue?
   - If my desktop code is Open GL 3.3, should I be using OpenGL ES 3 or is 
   that part of the problem? And what files do I need to include and where do 
   I get them (if what I have isn't correct?)
   - What is the proper way to set up an emscripten webgl context? My 
   source code includes two different ways of setting it up and I am not sure 
   which is correct, even after trial and error.
   - Can I get someone who is willing to at least compile the code 
   themselves and try out different solutions until they find something that 
   can provide an explanation? I don't want someone to suggest adding a single 
   argument to my makefile, and then hours later I get home to try it out and 
   realize that it actually causes the program to fail. My program is small 
   enough that someone can copy and paste it together, compile it, and run it 
   in less than 2 minutes. There is no reason to not do that yourself to check 
   that it works before suggesting a solution to me. I am just a little 
   frustrated at this point so please don't take it the wrong way, I just want 
   someone to take me seriously so I can move on to the next step of my 
   project.
   - If this mailing list is not the best place to quickly get help like 
   that, who do I need to contact? I am willing to pay for work if that needs 
   to be done, but I don't think that should be necessary to get a "hello 
   world" program up and running, especially when I've already come this far 
   on my own.



-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/emscripten-discuss/1b15e019-08ff-4850-b522-fd2db0c12c9cn%40googlegroups.com.

Reply via email to