https://github.com/Twinklebear/TwinklebearDev-Lessons
asm.js的教程
https://github.com/3dgen/cppwasm-book
入门
http://www.ruanyifeng.com/blog/2017/09/asmjs_emscripten.html
#######
vim格式化:
1,gg 跳转到第一行
2,shift+v 转到可视模式
3,shift+g 全选
4,按下神奇的 =
centos7安装
yum install SDL SDL-devel SDL-static -y
helloworld
https://www.linuxidc.com/Linux/2012-12/75255.htm
main.c
#include "SDL/SDL.h" int main( int argc, char* args[] ) { //Start SDL SDL_Init( SDL_INIT_EVERYTHING ); //Quit SDL SDL_Quit(); return 0; }
emscripten 加载文件
https://github.com/3dgen/cppwasm-book/blob/master/zh/ch3-runtime/ch3-03-fs.md
加载一张图片
#include#include int main() { //The images SDL_Surface* hello = NULL; SDL_Surface* screen = NULL; SDL_Init( SDL_INIT_EVERYTHING ); //Set up screen screen = SDL_SetVideoMode( 640, 480, 32, SDL_SWSURFACE ); //Load image //hello = SDL_LoadBMP( "1.bmp" ); hello = SDL_LoadBMP( "1.bmp" ); //Apply image to screen SDL_BlitSurface( hello, NULL, screen, NULL ); //Update Screen SDL_Flip( screen ); //Pause SDL_Delay( 5000 ); //Quit SDL SDL_Quit(); //Free memory SDL_FreeSurface( hello ); //Quit SDL SDL_Quit(); return 0; }
############################
emcc使用sdl2
emcc main.c -s USE_SDL=2 -o main.html
https://blog.csdn.net/pkx1993/article/details/82015659?utm_source=blogxgwz4
Emscripten Ports
有用库的收集,并移植到Emscripten。Github地址:https://github.com/emscripten-ports
他们已经被整合到了emcc中。当你请求一个ports被使用时,emcc会从远程服务器获取,设置并在本地构建它,然后将其链接到您的项目,向您的构建命令添加必需的包含。
例如:SDL2是一个ports,可以请求并并使用命令-s USE_SDL=2链接他。
emcc tests/sdl2glshader.c -s USE_SDL=2 -s LEGACY_GL_EMULATION=1 -o sdl2.html
###############
SDL入门教程:
https://segmentfault.com/a/1190000011328496
emscripten 加载sdl的helloworld
hello_world_cube.cpp
#include#include #ifdef __EMSCRIPTEN__ #include #endif extern "C" int main(int argc, char** argv) { printf("hello, world!\n"); SDL_Init(SDL_INIT_VIDEO); SDL_Surface *screen = SDL_SetVideoMode(256, 256, 32, SDL_SWSURFACE); #ifdef TEST_SDL_LOCK_OPTS EM_ASM("SDL.defaults.copyOnLock = false; SDL.defaults.discardOnLock = true; SDL.defaults.opaqueFrontBuffer = false;"); #endif if (SDL_MUSTLOCK(screen)) SDL_LockSurface(screen); for (int i = 0; i < 256; i++) { for (int j = 0; j < 256; j++) { #ifdef TEST_SDL_LOCK_OPTS // Alpha behaves like in the browser, so write proper opaque pixels. int alpha = 255; #else // To emulate native behavior with blitting to screen, alpha component is ignored. Test that it is so by outputting // data (and testing that it does get discarded) int alpha = (i+j) % 255; #endif *((Uint32*)screen->pixels + i * 256 + j) = SDL_MapRGBA(screen->format, i, j, 255-i, alpha); } } if (SDL_MUSTLOCK(screen)) SDL_UnlockSurface(screen); SDL_Flip(screen); printf("you should see a smoothly-colored square - no sharp lines but the square borders!\n"); printf("and here is some text that should be HTML-friendly: amp: |&| double-quote: |\"| quote: |'| less-than, greater-than, html-like tags: | |\nanother line.\n"); SDL_Quit(); return 0; }
########
问题:
1.浏览器最基本的sdl
2.加载图片?