ObjectivelyGPU
Object oriented graphics framework for SDL3 and C
Loading...
Searching...
No Matches
Texture.h
Go to the documentation of this file.
1/*
2 * ObjectivelyGPU: Object oriented graphics framework for SDL3 and C.
3 * Copyright (C) 2026 Jay Dolan <jay@jaydolan.com>
4 *
5 * This software is provided 'as-is', without any express or implied
6 * warranty. In no event will the authors be held liable for any damages
7 * arising from the use of this software.
8 *
9 * Permission is granted to anyone to use this software for any purpose,
10 * including commercial applications, and to alter it and redistribute it
11 * freely, subject to the following restrictions:
12 *
13 * 1. The origin of this software must not be misrepresented; you must not
14 * claim that you wrote the original software. If you use this software
15 * in a product, an acknowledgment in the product documentation would be
16 * appreciated but is not required.
17 *
18 * 2. Altered source versions must be plainly marked as such, and must not be
19 * misrepresented as being the original software.
20 *
21 * 3. This notice may not be removed or altered from any source distribution.
22 */
23
24#pragma once
25
26#include <SDL3/SDL_gpu.h>
27#include <SDL3/SDL_surface.h>
28
29#include <Objectively/Object.h>
30
32
39typedef struct Texture Texture;
40typedef struct TextureInterface TextureInterface;
41
60struct Texture {
61
65 Object object;
66
71 TextureInterface *interface;
72
76 SDL_GPUTexture *texture;
77
81 SDL_GPUTextureFormat format;
82
87
91 SDL_GPUTextureType type;
92
96 SDL_GPUTextureUsageFlags usage;
97
102
106 Uint32 numLevels;
107
111 SDL_GPUSampleCount sampleCount;
112
117 RenderDevice *device;
118
122 ident data;
123};
124
128struct TextureInterface {
129
133 ObjectInterface objectInterface;
134
151 Texture *(*initWithDevice)(Texture *self, RenderDevice *device, const SDL_GPUTextureCreateInfo *info, const void *pixels);
152
171 Texture *(*initWithSurface)(Texture *self, RenderDevice *device, SDL_Surface *surface, SDL_GPUTextureUsageFlags usage, bool generateMipmaps);
172
180 void (*setName)(Texture *self, const char *name);
181
194 void *(*downloadPixels)(const Texture *self);
195};
196
static void generateMipmaps(const CommandBuffer *self, SDL_GPUTexture *texture)
Definition CommandBuffer.c:157
OBJECTIVELYGPU_EXPORT Class * _Texture(void)
Definition Texture.c:307
#define OBJECTIVELYGPU_EXPORT
Definition Types.h:35
The RenderDevice encapsulates an SDL_GPUDevice and provides methods for allocating GPU resources,...
Definition RenderDevice.h:63
The SDL_Size type.
Definition Types.h:47
An SDL_GPUTexture and the metadata describing it.
Definition Texture.h:60
SDL_GPUSampleCount sampleCount
The MSAA sample count.
Definition Texture.h:111
SDL_GPUTextureUsageFlags usage
The usage flags the texture was created with.
Definition Texture.h:96
TextureInterface * interface
The interface.
Definition Texture.h:71
SDL_GPUTextureFormat format
The pixel format.
Definition Texture.h:81
SDL_GPUTexture * texture
The underlying SDL texture.
Definition Texture.h:76
Uint32 layerCountOrDepth
The depth (3D) or layer count (array/cube), or 1.
Definition Texture.h:101
Object object
The superclass.
Definition Texture.h:65
SDL_GPUTextureType type
The texture type (2D, cube, 3D, array).
Definition Texture.h:91
SDL_Size size
The texture dimensions in pixels.
Definition Texture.h:86
ident data
User data.
Definition Texture.h:122
Uint32 numLevels
The number of mip levels.
Definition Texture.h:106