Panda3D WebGL Port!

#61

Thanks @rdb That was the problem.

How do I generate the .bc files like those used in the --preload-file argument in freezify.py?

I’m trying to get a project with multiple files running. I assume generating .bc files would be the best way to do this, but I don’t know if it would be the most easy to use for others once I have it setup.

Now, I have the editor working in an Angular JS project. Hopefully, it’s a short ride to Android using Cordova after that. If anyone’s interested, I plan to post a seed project to Github. (I tried Angular 6 & 7, but I couldn’t get it to play nice after ~10 days. Angular JS took 2.)

#62

It seems I’m close to getting a project up using freezer.addModule. Now I’m getting errors about missing Python modules. This one and another from collections saying no operator module exists. I see an “operator.bc” and an “itertools.bc” in the python-modules folder. So, I’m not sure why the error?

File "heapq", line 132, in 
ImportError: No module named itertools

When I add these to the bottom of your main.py I get the following error.

import itertools
import operator
import collections
import heapq

" Loading…
Downloading data…
Running…
Invalid function pointer called with signature ‘vii’. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)
Build with ASSERTIONS=2 for more info.
48"

#63

The .bc files are emscripten-generated bytecode files produced as result of building Python and Panda3D.

This is not the same as the files that are passed to --preload-file, which become part of emscripten’s virtual file system. You can just pass any files you like using as many of these options as it takes. It is also possible to package all your assets as a .mf and then mount that in your Panda game using the virtual file system, though.

Make sure that the itertools.bc is actually being added by freezify as part of the command-line.

As for the error message, this indicates an issue with CPython which violates the C standard on casting incompatible function pointers in a lot of different places. I’ve fixed many cases where it does this, but there may be missing cases. If you add -s ASSERTIONS=2 it will add more debugging information which will help track down which specific function call needs to be fixed in CPython.

#64

I posted an angular project with some instructions on how to git it running. With the instructions and those I gave above, you should be able to compile your own and switch it out for the /app/panda-engine/panda-engine27.js file.

It’s just a starting point. I believe you can use Cordova to get on Android or IPhone, but I haven’t gotten that far.

#65

Does anyone know how to get past this? I suspect it started when I added render to texture to my project.

:display:gsg:gles2gsg(warning): Immutable texture storage advertised as supported by OpenGL runtime, but could not get pointers to extension functions.

:display:gsg:gles2gsg(warning): Indirect draw advertised as supported by OpenGL runtime, but could not get pointers to extension functions.

WebGL: INVALID_ENUM: getParameter: invalid parameter name, WEBGL_draw_buffers not enabled

WebGL: INVALID_ENUM: getParameter: invalid parameter name

WebGL: INVALID_ENUM: getParameter: invalid parameter name

:display:gsg:gles2gsg(warning): GL_ARB_sampler_objects advertised as supported by OpenGL runtime, but could not get pointers to extension function.
#66

In case anyone else runs into this.
Adding “#version 300 es, got rid of” to my shaders got rid of “WEBGL_draw_buffers not enabled”

EDIT (I can’t add what I’ve done without editing this post)

To get rid of the WEBGL_draw_buffers error without adding the 3.0 version to the shader I added the first #ifdef __EMSCRIPTEN__ calling for drawBuffers to panda/src/glstuff/glGraphicsStateGuardian_src.cxx. I bet this can be coded better. I tested #version 100 es

#if defined(OPENGLES_1)
  _glDrawBuffers = NULL;
  _max_color_targets = 1;

#elif defined(OPENGLES_2)
  if (is_at_least_gles_version(3, 0)) {
  #ifdef __EMSCRIPTEN__
    _glDrawBuffers = (PFNGLDRAWBUFFERSPROC)
      get_extension_func("drawBuffers");
  #else
    _glDrawBuffers = (PFNGLDRAWBUFFERSPROC)
      get_extension_func("glDrawBuffers");
  #endif
#ifdef __EMSCRIPTEN__
  } else if (has_extension("WEBGL_draw_buffers")) {
    _glDrawBuffers = (PFNGLDRAWBUFFERSPROC)
      get_extension_func("glDrawBuffers");
#endif  // EMSCRIPTEN

There’s no glTexStorage1D in WebGL, best I can tell.
https://www.khronos.org/registry/OpenGL-Refpages/es3.0/html/glTexStorage2D.xhtml

This does not account for any down stream calls to _glTexStorage1D. I replaced this first block with that below:

  if (_supports_tex_storage) {
    if (_glTexStorage1D == NULL || _glTexStorage2D == NULL || _glTexStorage3D == NULL) {
      GLCAT.warning()
        << "Immutable texture storage advertised as supported by OpenGL runtime, but could not get pointers to extension functions.\n";
      _supports_tex_storage = false;
    }
  }



  if (_supports_tex_storage) {
#ifdef OPENGLES
    if (_glTexStorage2D == NULL || _glTexStorage3D == NULL) {
#else
    if (_glTexStorage1D == NULL || _glTexStorage2D == NULL || _glTexStorage3D == NULL) {
#endif
      GLCAT.warning()
        << "Immutable texture storage advertised as supported by OpenGL runtime, but could not get pointers to extension functions.\n";
      _supports_tex_storage = false;
    }
  }