SDL_Texture结构体

本文详细介绍了SDL_Texture结构的各个成员变量及其作用,包括纹理的像素格式、访问方式、尺寸等基本信息,以及与渲染器的关系、纹理调制模式、混合模式等高级特性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

struct SDL_Texture
{
    const void *magic;
    Uint32 format;              /**< The pixel format of the texture */
    int access;                 /**< SDL_TextureAccess */
    int w;                      /**< The width of the texture */
    int h;                      /**< The height of the texture */
    int modMode;                /**< The texture modulation mode */
    SDL_BlendMode blendMode;    /**< The texture blend mode */
    Uint8 r, g, b, a;           /**< Texture modulation values */


    SDL_Renderer *renderer;


    /* Support for formats not supported directly by the renderer */
    SDL_Texture *native;
    SDL_SW_YUVTexture *yuv;
    void *pixels;
    int pitch;
    SDL_Rect locked_rect;


    void *driverdata;           /**< Driver specific texture representation */


    SDL_Texture *prev;
    SDL_Texture *next;
};
#include <SDL2/SDL.h> #include <SDL_ttf.h> #include <iostream> #include <string> #include <cstdlib> #include <cstdio> #include "cpphead/init_sdl.h" using namespace std; int main() { // 初始化数据 int cols, rows; bool isquit = false; // 初始化 isquit = !(init_sdl()); // 初始化全部模块 SDL_Window *window = SDL_CreateWindow("小鸡快打", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 720, SDL_WINDOW_SHOWN); // 窗体 SDL_Renderer *render = SDL_CreateRenderer(window, -1, 0); // 渲染器 isquit = !(sdl_get_current_display_mode(&cols, &rows)); TTF_Font* font=TTF_OpenFont("cpphead/TT9.ttf",100); // 事件变量 SDL_Event event; // 事件循环 while (!isquit) { // 主循环 while (SDL_PollEvent(&event)) { // 退出和转入后台保存暂停 switch (event.type) { case SDL_KEYDOWN: if (event.key.keysym.sym == SDLK_AC_BACK) { SDL_PollEvent(&event); if (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_AC_BACK) { isquit = true; // 保存数据 break; } } break; case SDL_APP_WILLENTERBACKGROUND: isquit = true; // 保存游戏进度的方法 break; case SDL_APP_DIDENTERBACKGROUND: isquit = true; // 可能想要停止音乐播放等耗电活动 break; case SDLK_MENU: isquit = true; // 可能想要停止音乐播放等耗电活动 break; } //打字 SDL_SetRenderDrawColor(render, 150, 30, 0, 255); // 画笔 SDL_RenderClear(render);//清屏 SDL_Surface* solidsurface=TTF_RenderUTF8_Solid(font,"hello",{0,0,0,255}); SDL_Texture* solidtexture=SDL_CreateTextureFromSurface(render,solidsurface); SDL_FreeSurface(solidsurface); SDL_Rect srect={ 0, 0, 100, 100 }; // 绘画 /* SDL_SetRenderDrawColor(render, 150, 30, 0, 255); // 画笔 SDL_RenderClear(render);//清屏 SDL_Rect rect = { cols - 100, rows - 100, 100, 100 }; SDL_SetRenderDrawColor(render, 255, 255, 0, 255); // 画笔 SDL_RenderDrawRect(render, &rect); */ // 显示 SDL_RenderPresent(render); SDL_RenderCopy(render,solidtexture,nullptr,&srect); SDL_Delay(30); } // 主循环尾 } // 释放内存 TTF_CloseFont(font); TTF_Quit(); SDL_DestroyRenderer(render); SDL_DestroyWindow(window); SDL_Quit(); return 0; }怎么打字无效
最新发布
05-27
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值