一天前我安装了一个SDL2库.它还没有在Debian Wheezy中,所以我使用了configure, make, make install
命令.
毕竟,当我尝试使用SDL_Texture时,我收到此错误:
error: forward declaration of ‘SDL_Texture {aka struct SDL_Texture}’
invalid use of incomplete type ‘SDL_Texture {aka struct SDL_Texture}’
Run Code Online (Sandbox Code Playgroud)
在寻找声明后,我发现的所有内容都是SDL_render.h中的这两行:
struct SDL_Texture;
typedef struct SDL_Texture SDL_Texture;
Run Code Online (Sandbox Code Playgroud)
根本没有定义.我认为我的安装缺少文件SDL_sysrender.h.它是在我下载的源代码中,但不是在SDL2中包含路径.
哪里应该是问题?有必要使用任何标志配置文件?谢谢你的帮助.
我正在创建基于 SDL2 库的简单游戏渲染引擎。我的设计看起来类似于这个 ASCII 图形。
DrawTarget RenderTarget
| |
| |
+---> Window <---+
Run Code Online (Sandbox Code Playgroud)
DrawTarget
是适用于 SDL_Surface 块传输的绘制目标的抽象类。
RenderTarget
是适用于 SDL_Texture 的渲染目标的抽象类。
Window
是管理 SDL_Window、SDL_Renderer 和所有绘制和渲染功能的派生类。
Renderable
| | |
| | |
| | +-> Player
| | ^
| | |
| +----> Animation
| ^
| |
+-------> Texture
Run Code Online (Sandbox Code Playgroud)
Renderable
是一切,可以渲染到屏幕或另一个 RenderTarget。
Texture
是 SDL_Texture 实现。纹理不应该知道自己的位置。
Animation
有一个私有的 Texture 成员,允许设置动画帧。动画本身不应该知道渲染位置。
Player
有一个私人动画成员。玩家应该知道当前位置。
这一次,我SDL_Renderer
每个窗口都有一个并将它传递给纹理、动画等。纹理具有SDL_Renderer
将自身渲染到屏幕的知识。但我不认为一直调用 Texture->draw( x, y ) 是高效且缓存友好的。
我喜欢 SFML 呈现的方式。所有可渲染对象都有draw
方法,它只是调用窗口的绘制方法。我想实施类似的系统。 …
这是 .lex 文件的片段:
/* Empty line just with the newline character signs end of
the title block
*/
<title>^[\n]{1} {
yymore(); ECHO;
// std::cout << "Text: " << yytext << std::endl;
// ... do something with yytext
BEGIN(INITIAL);
}
/* Reads everything up to the end of line. */
<title>.+ {
ECHO; yymore();
//std::cout << "yymore: " << yytext << std::endl;
}
/* Every title starts with # and text follows. */
#[\t\ ] {
// ... prepare for html …
Run Code Online (Sandbox Code Playgroud)