title: How to load textures using SDL to a WebAssembly project using emscripten?
body: <p>I'm trying to load a texture to my application using SDL. When building as a native application, it works as it should. But when I'm building it with Emscripten, the texture cannot be loaded.</p>
  
  <p>The width of the texture image is <strong>64</strong> pixels, which I can verify by printing out the <code>w</code> member of the SDL_Surface instance. But when I try to print out the same member in the WebAssembly application, it yields <strong>5076</strong>...</p>
  
  <p><strong>Does the image become "broken" somehow when packed with emscripten?</strong></p>
  
  <p>Here's the code to load the texture:</p>
  
  <pre><code>SDL_Surface *image = IMG_Load("resources/binaries/crate.jpg");
  GLuint textureID;
  glGenTextures(1, &amp;textureID);
  glBindTexture(GL_TEXTURE_2D, textureID);
  std::cout &lt;&lt; image-&gt;w &lt;&lt; std::endl;
  glTexImage2D(GL_TEXTURE_2D, 0, 3, 64, 64, 0, GL_RGB, GL_UNSIGNED_BYTE, image-&gt;pixels);
  </code></pre>
  
  <p>Here's the command to build the web app with Emscripten</p>
  
  <pre><code>emcc --bind -s USE_SDL=2 -s USE_SDL_IMAGE=2 -o webapp.js src/webapp.cpp --preload-file resources
  </code></pre>
  
  <p>The error message I'm getting the browser when launching the web app is</p>
  
  <blockquote>
    <p>webapp.js:9533 WebGL: INVALID_VALUE: texImage2D: width or height out of range</p>
  </blockquote>
  
  <p>Which makes sense, since the resolution of the image is so crazy...</p>