huffman数据压缩算法验证成功
This commit is contained in:
23
sdl/.vscode/c_cpp_properties.json
vendored
Normal file
23
sdl/.vscode/c_cpp_properties.json
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Win32",
|
||||
"includePath": [
|
||||
"${workspaceFolder}/**",
|
||||
"C:/MinGW/include/"
|
||||
],
|
||||
"defines": [
|
||||
"_DEBUG",
|
||||
"UNICODE",
|
||||
"_UNICODE",
|
||||
"__WIN32__",
|
||||
"DLL_EXPORT"
|
||||
],
|
||||
"cStandard": "c17",
|
||||
"cppStandard": "gnu++17",
|
||||
"intelliSenseMode": "windows-gcc-x64",
|
||||
"compilerPath": "C:/MinGW/bin/gcc.exe"
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
}
|
5
sdl/.vscode/settings.json
vendored
Normal file
5
sdl/.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"sdl.h": "c"
|
||||
}
|
||||
}
|
62
sdl/hello_sdl.c
Normal file
62
sdl/hello_sdl.c
Normal file
@@ -0,0 +1,62 @@
|
||||
|
||||
|
||||
|
||||
//使用 SDL 和 标准 IO
|
||||
#include <C:\MinGW\include\sdl2\SDL.h>
|
||||
#include <stdio.h>
|
||||
|
||||
//定义屏幕尺寸常量
|
||||
const int SCREEN_WIDTH = 640;
|
||||
const int SCREEN_HEIGHT = 480;
|
||||
|
||||
|
||||
int main( int argc, char* args[] )
|
||||
{
|
||||
//将要渲染的窗口
|
||||
SDL_Window* window = NULL;
|
||||
|
||||
//窗口含有的surface
|
||||
SDL_Surface* screenSurface = NULL;
|
||||
|
||||
//初始化SDL
|
||||
if( SDL_Init( SDL_INIT_VIDEO ) < 0 )
|
||||
{
|
||||
printf( "SDL could not initialize! SDL_Error: %s\n", SDL_GetError() );
|
||||
}
|
||||
else
|
||||
{
|
||||
//创建 window
|
||||
window = SDL_CreateWindow( "SDL Tutorial", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN );
|
||||
if( window == NULL )
|
||||
{
|
||||
printf( "Window could not be created! SDL_Error: %s\n", SDL_GetError() );
|
||||
}
|
||||
else
|
||||
{
|
||||
//获取 window surface
|
||||
screenSurface = SDL_GetWindowSurface( window );
|
||||
|
||||
//用白色填充surface
|
||||
SDL_FillRect( screenSurface, NULL, SDL_MapRGB( screenSurface->format, 0xFF, 0xFF, 0xFF ) );
|
||||
|
||||
//更新surface
|
||||
SDL_UpdateWindowSurface( window );
|
||||
|
||||
//延迟两秒
|
||||
SDL_Delay( 2000 );
|
||||
}
|
||||
}
|
||||
//销毁 window
|
||||
SDL_DestroyWindow( window );
|
||||
|
||||
//退出 SDL subsystems
|
||||
SDL_Quit();
|
||||
|
||||
return 0;}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user