sdl笔记
程序员文章站
2022-07-10 22:27:33
...
sdl教程教程
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
加载一张图片
在mac下的例子参考
https://github.com/killinux/ffmpeg-leaning/tree/master/sdl/sdl_practic_1
或者我的mtcode
emscripten 加载文件
https://github.com/3dgen/cppwasm-book/blob/master/zh/ch3-runtime/ch3-03-fs.md
############################
emcc使用sdl2
emcc main.c -s USE_SDL=2 -o main.html
[url]https://www.jamesfmackenzie.com/2019/12/01/webassembly-graphics-with-sdl/
[/url]
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
########
问题:
1.浏览器最基本的sdl
2.加载图片?
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; }
加载一张图片
在mac下的例子参考
https://github.com/killinux/ffmpeg-leaning/tree/master/sdl/sdl_practic_1
或者我的mtcode
#include <iostream> extern "C" { #include <SDL2/SDL.h> #include <SDL2/SDL_test_images.h> } using namespace std; const int WIDTH = 960, HEIGHT = 540; int main() { SDL_Surface *imageSurface = NULL; SDL_Surface *windowSurface = NULL; if (SDL_Init(SDL_INIT_EVERYTHING) < 0) { cout << "SDL could not initialized with error: " << SDL_GetError() << endl; } SDL_Window *window = SDL_CreateWindow("Hello SDL world!", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, WIDTH, HEIGHT, SDL_WINDOW_ALLOW_HIGHDPI); if (NULL == window) { cout << "SDL could not create window with error: " << SDL_GetError() << endl; } windowSurface = SDL_GetWindowSurface(window); imageSurface = SDL_LoadBMP("little_prince.bmp"); if (NULL == imageSurface) { cout << "SDL could not load image with error: " << SDL_GetError() << endl; } SDL_Event windowEvent; while(true) { if (SDL_PollEvent(&windowEvent)) { if (SDL_QUIT == windowEvent.type) { cout << "SDL quit!!" << endl; break; } } SDL_BlitSurface(imageSurface, NULL, windowSurface, NULL); SDL_UpdateWindowSurface(window); } imageSurface = NULL; windowSurface = NULL; SDL_DestroyWindow(window); SDL_Quit(); return 0; }
emscripten 加载文件
https://github.com/3dgen/cppwasm-book/blob/master/zh/ch3-runtime/ch3-03-fs.md
############################
emcc使用sdl2
emcc main.c -s USE_SDL=2 -o main.html
[url]https://www.jamesfmackenzie.com/2019/12/01/webassembly-graphics-with-sdl/
[/url]
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 <stdio.h> #include <SDL/SDL.h> #ifdef __EMSCRIPTEN__ #include <emscripten.h> #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: |<cheez></cheez>|\nanother line.\n"); SDL_Quit(); return 0; }
########
问题:
1.浏览器最基本的sdl
2.加载图片?
上一篇: mxgraph之保存图片
推荐阅读
-
canvas学习笔记之绘制简单路径
-
华硕飞行堡垒FX 4200笔记本性能如何? 华硕fx4200详细评测
-
PHP 面向对象程序设计(oop)学习笔记(一) - 抽象类、对象接口、instanceof 和契约式编程
-
PHP 面向对象程序设计(oop)学习笔记 (二) - 静态变量的属性和方法及延迟绑定
-
惠普omen15笔记本怎么样? 惠普omen15详细测评
-
戴尔vostro15 5568笔记本怎么样? 戴尔笔记本vostro15详细测评
-
笔记本ABCD壳怎么区分 笔记本abcd面图解介绍
-
戴尔Dell N4110笔记本怎么拆机清灰?
-
联想拯救者笔记本开机蓝屏代码0xc000000d怎么办?
-
宏碁4745g笔记本键盘出问题该办?