在这个简单的程序中,我们使用SDL库创建了一个窗口,并在窗口中显示了一个标题为“SDL Tutorial”的窗口。然后程序会延迟3秒后关闭窗口并退出。 编译这个程序可以使用以下命令: ```bash gcc sdl_tutorial.c -o sdl_tutorial -lSDL2 ``` 执行编译后生成的可执行文件,我们就可以看到一个简单的SDL窗口弹出并显示“...
AI代码解释 boolinit(){//初始化标志bool success=true;//初始化SDLif(SDL_Init(SDL_INIT_VIDEO)<0){printf("SDL could not initialize! SDL_Error: %s\n",SDL_GetError());success=false;}else{//创建窗口gWindow=SDL_CreateWindow("SDL Tutorial",SDL_WINDOWPOS_UNDEFINED,SDL_WINDOWPOS_UNDEFINED,SCREEN...
选择File->New,新建一个工程,选择Win32 Application,将工程gp保存为tutorial目录下,如图3所示。 图3 在图4中,保持默认设置,点击Finish。 图4 为了使用SDL,我们需要进行相关的设置,选择Project->Settings...,选择C/C++属性页,在Category中选择Code Generation,在Use run-time library中选择Debug Multithreaded DLL,如...
#include <SDL.h> #include <stdio.h> int main(int argc, char* argv[]) { if (SDL_Init(SDL_INIT_VIDEO) < 0) { printf("SDL could not initialize! SDL Error: %s\n", SDL_GetError()); return 1; } SDL_Window *window = SDL_CreateWindow("SDL Tutorial", SDL_WINDOWPOS_UNDEF...
Cancel Submit feedback Saved searches Use saved searches to filter your results more quickly Cancel Create saved search Sign in Sign up Reseting focus {{ message }} adolfans / sdltutorialcn Public Notifications You must be signed in to change notification settings Fork 1 Star ...
}else{//Create windowwindow = SDL_CreateWindow("SDL Tutorial",0,0, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN);if(window ==NULL) { printf("Window could not be created! SDL_Error: %s\n", SDL_GetError()); }else{//Get window surfacescreenSurface =SDL_GetWindowSurface(window); ...
https://fedoraproject.org/wiki/MinGW/Tutorial 前面文章中介绍的命令行录音机程序(在 LINUX 下用 MSVC CL.EXE 编译): https://1eq.ca/wp-content/uploads/2021/03/WXrecx64_48K_32bit_MSVC19_TimeStamped_OK_LINUX-BUILT.zip 步骤: 有效:
class CApp : public CEvent {private:bool Running;SDL_Surface* Surf_Display;private:SDL_Surface* Surf_Grid;SDL_Surface* Surf_X;SDL_Surface* Surf_O;public:CApp();int OnExecute();public:bool OnInit();void OnEvent(SDL_Event* Event);void OnExit();void OnLoop();void OnRender();void On...
SDL_Error: "<<SDL_GetError()<<std::endl;return1;}SDL_Window*window=SDL_CreateWindow("SDL Tutorial",SDL_WINDOWPOS_UNDEFINED,SDL_WINDOWPOS_UNDEFINED,SCREEN_WIDTH,SCREEN_HEIGHT,SDL_WINDOW_SHOWN);if(window==NULL){std::cerr<<"Window could not be created! SDL_Error: "<<SDL_GetError()<<std...
下面我们正式开始编程,将E:"tutorial"SDL-1.2.8"lib"SDL.dll拷贝到gp文件夹下,然后给gp工程增加一个C++文件main.cpp。如图9所示。 图9 将以下代码拷贝到main.cpp并保存。 #include <stdlib.h> #if defined(_MSC_VER) #include "SDL.h" #else