当前位置: 首页>>代码示例>>C++>>正文


C++ SDL_Renderer类代码示例

本文整理汇总了C++中SDL_Renderer的典型用法代码示例。如果您正苦于以下问题:C++ SDL_Renderer类的具体用法?C++ SDL_Renderer怎么用?C++ SDL_Renderer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SDL_Renderer类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SDL_UpdateTexture

int
SDL_UpdateTexture(SDL_Texture * texture, const SDL_Rect * rect,
                  const void *pixels, int pitch)
{
    SDL_Renderer *renderer;
    SDL_Rect full_rect;

    CHECK_TEXTURE_MAGIC(texture, -1);

    if (!rect) {
        full_rect.x = 0;
        full_rect.y = 0;
        full_rect.w = texture->w;
        full_rect.h = texture->h;
        rect = &full_rect;
    }

    if (texture->yuv) {
        return SDL_UpdateTextureYUV(texture, rect, pixels, pitch);
    } else if (texture->native) {
        return SDL_UpdateTextureNative(texture, rect, pixels, pitch);
    } else {
        renderer = texture->renderer;
        return renderer->UpdateTexture(renderer, texture, rect, pixels, pitch);
    }
}
开发者ID:ryanzhao006,项目名称:IOSAVDecode,代码行数:26,代码来源:SDL_render.c

示例2: SDL_RendererEventWatch

static int
SDL_RendererEventWatch(void *userdata, SDL_Event *event)
{
    SDL_Renderer *renderer = (SDL_Renderer *)userdata;

    if (event->type == SDL_WINDOWEVENT) {
        SDL_Window *window = SDL_GetWindowFromID(event->window.windowID);
        if (window == renderer->window) {
            if (renderer->WindowEvent) {
                renderer->WindowEvent(renderer, &event->window);
            }

            if (event->window.event == SDL_WINDOWEVENT_SIZE_CHANGED) {
                /* Try to keep the previous viewport centered */
                int w, h;
                SDL_Rect viewport;

                SDL_GetWindowSize(window, &w, &h);
                viewport.x = (w - renderer->viewport.w) / 2;
                viewport.y = (h - renderer->viewport.h) / 2;
                viewport.w = renderer->viewport.w;
                viewport.h = renderer->viewport.h;
                SDL_RenderSetViewport(renderer, &viewport);
            } else if (event->window.event == SDL_WINDOWEVENT_MINIMIZED) {
                renderer->minimized = SDL_TRUE;
            } else if (event->window.event == SDL_WINDOWEVENT_RESTORED) {
                renderer->minimized = SDL_FALSE;
            }
        }
    }
    return 0;
}
开发者ID:ryanzhao006,项目名称:IOSAVDecode,代码行数:32,代码来源:SDL_render.c

示例3: SDL_LockTexture

int
SDL_LockTexture(SDL_Texture * texture, const SDL_Rect * rect,
                void **pixels, int *pitch)
{
    SDL_Renderer *renderer;
    SDL_Rect full_rect;

    CHECK_TEXTURE_MAGIC(texture, -1);

    if (texture->access != SDL_TEXTUREACCESS_STREAMING) {
        SDL_SetError("SDL_LockTexture(): texture must be streaming");
        return -1;
    }

    if (!rect) {
        full_rect.x = 0;
        full_rect.y = 0;
        full_rect.w = texture->w;
        full_rect.h = texture->h;
        rect = &full_rect;
    }

    if (texture->yuv) {
        return SDL_LockTextureYUV(texture, rect, pixels, pitch);
    } else if (texture->native) {
        return SDL_LockTextureNative(texture, rect, pixels, pitch);
    } else {
        renderer = texture->renderer;
        return renderer->LockTexture(renderer, texture, rect, pixels, pitch);
    }
}
开发者ID:ryanzhao006,项目名称:IOSAVDecode,代码行数:31,代码来源:SDL_render.c

示例4: SDL_SetTextureBlendMode

int
SDL_SetTextureBlendMode(SDL_Texture * texture, SDL_BlendMode blendMode)
{
    SDL_Renderer *renderer;

    CHECK_TEXTURE_MAGIC(texture, -1);

    renderer = texture->renderer;
    texture->blendMode = blendMode;
    if (texture->native) {
        return SDL_SetTextureBlendMode(texture->native, blendMode);
    } else if (renderer->SetTextureBlendMode) {
        return renderer->SetTextureBlendMode(renderer, texture);
    } else {
        return 0;
    }
}
开发者ID:ryanzhao006,项目名称:IOSAVDecode,代码行数:17,代码来源:SDL_render.c

示例5: SDL_UnlockTexture

void
SDL_UnlockTexture(SDL_Texture * texture)
{
    SDL_Renderer *renderer;

    CHECK_TEXTURE_MAGIC(texture, );

    if (texture->access != SDL_TEXTUREACCESS_STREAMING) {
        return;
    }
    if (texture->yuv) {
        SDL_UnlockTextureYUV(texture);
    } else if (texture->native) {
        SDL_UnlockTextureNative(texture);
    } else {
        renderer = texture->renderer;
        renderer->UnlockTexture(renderer, texture);
    }
}
开发者ID:ryanzhao006,项目名称:IOSAVDecode,代码行数:19,代码来源:SDL_render.c

示例6: SDL_SetTextureAlphaMod

int
SDL_SetTextureAlphaMod(SDL_Texture * texture, Uint8 alpha)
{
    SDL_Renderer *renderer;

    CHECK_TEXTURE_MAGIC(texture, -1);

    renderer = texture->renderer;
    if (alpha < 255) {
        texture->modMode |= SDL_TEXTUREMODULATE_ALPHA;
    } else {
        texture->modMode &= ~SDL_TEXTUREMODULATE_ALPHA;
    }
    texture->a = alpha;
    if (texture->native) {
        return SDL_SetTextureAlphaMod(texture->native, alpha);
    } else if (renderer->SetTextureAlphaMod) {
        return renderer->SetTextureAlphaMod(renderer, texture);
    } else {
        return 0;
    }
}
开发者ID:ryanzhao006,项目名称:IOSAVDecode,代码行数:22,代码来源:SDL_render.c

示例7: SDL_SetTextureColorMod

int
SDL_SetTextureColorMod(SDL_Texture * texture, Uint8 r, Uint8 g, Uint8 b)
{
    SDL_Renderer *renderer;

    CHECK_TEXTURE_MAGIC(texture, -1);

    renderer = texture->renderer;
    if (r < 255 || g < 255 || b < 255) {
        texture->modMode |= SDL_TEXTUREMODULATE_COLOR;
    } else {
        texture->modMode &= ~SDL_TEXTUREMODULATE_COLOR;
    }
    texture->r = r;
    texture->g = g;
    texture->b = b;
    if (texture->native) {
        return SDL_SetTextureColorMod(texture->native, r, g, b);
    } else if (renderer->SetTextureColorMod) {
        return renderer->SetTextureColorMod(renderer, texture);
    } else {
        return 0;
    }
}
开发者ID:ryanzhao006,项目名称:IOSAVDecode,代码行数:24,代码来源:SDL_render.c

示例8: SDL_RendererEventWatch

static int
SDL_RendererEventWatch(void *userdata, SDL_Event *event)
{
    SDL_Renderer *renderer = (SDL_Renderer *)userdata;

    if (event->type == SDL_WINDOWEVENT) {
        SDL_Window *window = SDL_GetWindowFromID(event->window.windowID);
        if (window == renderer->window) {
            if (renderer->WindowEvent) {
                renderer->WindowEvent(renderer, &event->window);
            }

            if (event->window.event == SDL_WINDOWEVENT_RESIZED) {
                /* Try to keep the previous viewport centered */
                int w, h;
                SDL_Rect viewport;

                SDL_GetWindowSize(window, &w, &h);
                if (renderer->target) {
                    renderer->viewport_backup.x = (w - renderer->viewport_backup.w) / 2;
                    renderer->viewport_backup.y = (h - renderer->viewport_backup.h) / 2;
                } else {
                    viewport.x = (w - renderer->viewport.w) / 2;
                    viewport.y = (h - renderer->viewport.h) / 2;
                    viewport.w = renderer->viewport.w;
                    viewport.h = renderer->viewport.h;
                    SDL_RenderSetViewport(renderer, &viewport);
                }
                renderer->resized = SDL_TRUE;
            } else if (event->window.event == SDL_WINDOWEVENT_SIZE_CHANGED) {
                int w, h;
                SDL_Rect viewport;

                if (!renderer->resized) {
                    /* Window was programmatically resized, reset viewport */
                    SDL_GetWindowSize(window, &w, &h);
                    if (renderer->target) {
                        renderer->viewport_backup.x = 0;
                        renderer->viewport_backup.y = 0;
                        renderer->viewport_backup.w = w;
                        renderer->viewport_backup.h = h;
                    } else {
                        viewport.x = 0;
                        viewport.y = 0;
                        viewport.w = w;
                        viewport.h = h;
                        SDL_RenderSetViewport(renderer, &viewport);
                    }
                    renderer->resized = SDL_FALSE;
                }
            } else if (event->window.event == SDL_WINDOWEVENT_HIDDEN) {
                renderer->hidden = SDL_TRUE;
            } else if (event->window.event == SDL_WINDOWEVENT_SHOWN) {
                if (!(SDL_GetWindowFlags(window) & SDL_WINDOW_MINIMIZED)) {
                    renderer->hidden = SDL_FALSE;
                }
            } else if (event->window.event == SDL_WINDOWEVENT_MINIMIZED) {
                renderer->hidden = SDL_TRUE;
            } else if (event->window.event == SDL_WINDOWEVENT_RESTORED) {
                if (!(SDL_GetWindowFlags(window) & SDL_WINDOW_HIDDEN)) {
                    renderer->hidden = SDL_FALSE;
                }
            }
        }
    }
    return 0;
}
开发者ID:DarkWolk,项目名称:libsdl,代码行数:67,代码来源:SDL_render.c

示例9: SDL_RendererEventWatch

static int
SDL_RendererEventWatch(void *userdata, SDL_Event *event)
{
    SDL_Renderer *renderer = (SDL_Renderer *)userdata;

    if (event->type == SDL_WINDOWEVENT) {
        SDL_Window *window = SDL_GetWindowFromID(event->window.windowID);
        if (window == renderer->window) {
            if (renderer->WindowEvent) {
                renderer->WindowEvent(renderer, &event->window);
            }

            if (event->window.event == SDL_WINDOWEVENT_SIZE_CHANGED) {
                if (renderer->logical_w) {
                    UpdateLogicalSize(renderer);
                } else {
                    /* Window was resized, reset viewport */
                    int w, h;

                    SDL_GetWindowSize(window, &w, &h);
                    if (renderer->target) {
                        renderer->viewport_backup.x = 0;
                        renderer->viewport_backup.y = 0;
                        renderer->viewport_backup.w = w;
                        renderer->viewport_backup.h = h;
                    } else {
                        renderer->viewport.x = 0;
                        renderer->viewport.y = 0;
                        renderer->viewport.w = w;
                        renderer->viewport.h = h;
                        renderer->UpdateViewport(renderer);
                    }
                }
            } else if (event->window.event == SDL_WINDOWEVENT_HIDDEN) {
                renderer->hidden = SDL_TRUE;
            } else if (event->window.event == SDL_WINDOWEVENT_SHOWN) {
                if (!(SDL_GetWindowFlags(window) & SDL_WINDOW_MINIMIZED)) {
                    renderer->hidden = SDL_FALSE;
                }
            } else if (event->window.event == SDL_WINDOWEVENT_MINIMIZED) {
                renderer->hidden = SDL_TRUE;
            } else if (event->window.event == SDL_WINDOWEVENT_RESTORED) {
                if (!(SDL_GetWindowFlags(window) & SDL_WINDOW_HIDDEN)) {
                    renderer->hidden = SDL_FALSE;
                }
            }
        }
    } else if (event->type == SDL_MOUSEMOTION) {
        if (renderer->logical_w) {
            event->motion.x -= renderer->viewport.x;
            event->motion.y -= renderer->viewport.y;
            event->motion.x = (int)(event->motion.x / renderer->scale.x);
            event->motion.y = (int)(event->motion.y / renderer->scale.y);
        }
    } else if (event->type == SDL_MOUSEBUTTONDOWN ||
               event->type == SDL_MOUSEBUTTONUP) {
        if (renderer->logical_w) {
            event->button.x -= renderer->viewport.x;
            event->button.y -= renderer->viewport.y;
            event->button.x = (int)(event->button.x / renderer->scale.x);
            event->button.y = (int)(event->button.y / renderer->scale.y);
        }
    }
    return 0;
}
开发者ID:phossy,项目名称:bloq,代码行数:65,代码来源:SDL_render.c


注:本文中的SDL_Renderer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。