小编Lor*_*rin的帖子

SDL_Texture - 不完整类型

一天前我安装了一个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中包含路径.

哪里应该是问题?有必要使用任何标志配置文件?谢谢你的帮助.

c++ linux debian sdl-2

9
推荐指数
1
解决办法
4828
查看次数

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方法,它只是调用窗口的绘制方法。我想实施类似的系统。 …

c++ oop draw sdl-2

1
推荐指数
1
解决办法
2405
查看次数

Flex:使用 yymore()

这是 .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)

c++ g++ flex-lexer

1
推荐指数
1
解决办法
6390
查看次数

标签 统计

c++ ×3

sdl-2 ×2

debian ×1

draw ×1

flex-lexer ×1

g++ ×1

linux ×1

oop ×1