mirror of
https://github.com/Relintai/programming_tutorials.git
synced 2025-05-11 22:52:11 +02:00
Cleaned up the remaining 3 txts.
This commit is contained in:
parent
4d1e74b62c
commit
22d5415c86
@ -3,204 +3,232 @@
|
||||
|---------------------------------------------------------------------------------------|
|
||||
| class Texture |
|
||||
|---------------------------------------------------------------------------------------|
|
||||
| + Color get_color_mod() const; |
|
||||
| + void set_color_mod(const Color &color); |
|
||||
| + Color get_color_mod() const |
|
||||
| + void set_color_mod(const Color &color) |
|
||||
| |
|
||||
| + SDL_BlendMode get_blend_mode() const; |
|
||||
| + void set_blend_mode(const SDL_BlendMode blend_mode); |
|
||||
| + SDL_BlendMode get_blend_mode() const |
|
||||
| + void set_blend_mode(const SDL_BlendMode blend_mode) |
|
||||
| |
|
||||
| + SDL_ScaleMode get_texture_scale_mode() const; |
|
||||
| + void set_texture_scale_mode(const SDL_ScaleMode scale_mode); |
|
||||
| + SDL_ScaleMode get_texture_scale_mode() const |
|
||||
| + void set_texture_scale_mode(const SDL_ScaleMode scale_mode) |
|
||||
| |
|
||||
| + Image *get_image(); |
|
||||
| + void set_image(Image *image); |
|
||||
| + Image *get_image() |
|
||||
| + void set_image(Image *image) |
|
||||
| |
|
||||
| + int get_width() const; |
|
||||
| + int get_height() const; |
|
||||
| + Uint32 get_format() const; |
|
||||
| + int get_access() const; |
|
||||
| + int get_width() const |
|
||||
| + int get_height() const |
|
||||
| + Uint32 get_format() const |
|
||||
| + int get_access() const |
|
||||
| |
|
||||
| + void create(const int access, const int w, const int h); |
|
||||
| + void refresh(); |
|
||||
| + void free(); |
|
||||
| + void create(const int access, const int w, const int h) |
|
||||
| + void refresh() |
|
||||
| + void free() |
|
||||
| |
|
||||
| + SDL_Texture *get_texture(); |
|
||||
| + SDL_Texture *get_texture() const; |
|
||||
| + SDL_Texture *get_texture() |
|
||||
| + SDL_Texture *get_texture() const |
|
||||
| |
|
||||
| + bool is_render_target(); |
|
||||
| + bool is_render_target() |
|
||||
| |
|
||||
| + Texture(); |
|
||||
| + Texture(Image *image); |
|
||||
| + virtual ~Texture(); |
|
||||
| + Texture() |
|
||||
| + Texture(Image *image) |
|
||||
| + virtual ~Texture() |
|
||||
| |
|
||||
| - Image *_image; |
|
||||
| - SDL_Texture *_texture; |
|
||||
| - Image *_image |
|
||||
| - SDL_Texture *_texture |
|
||||
|---------------------------------------------------------------------------------------|
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
#include "texture.h"
|
||||
get_color_mod:
|
||||
Uint8 r
|
||||
Uint8 g
|
||||
Uint8 b
|
||||
Uint8 a
|
||||
|
||||
#include "renderer.h"
|
||||
SDL_GetTextureColorMod(_texture, &r, &g, &b)
|
||||
SDL_GetTextureAlphaMod(_texture, &a)
|
||||
|
||||
Color Texture::get_color_mod() const {
|
||||
Uint8 r;
|
||||
Uint8 g;
|
||||
Uint8 b;
|
||||
Uint8 a;
|
||||
return Color(r, g, b, a)
|
||||
|
||||
SDL_GetTextureColorMod(_texture, &r, &g, &b);
|
||||
SDL_GetTextureAlphaMod(_texture, &a);
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
return Color(r, g, b, a);
|
||||
}
|
||||
void Texture::set_color_mod(const Color &color) {
|
||||
SDL_SetTextureColorMod(_texture, color.r, color.g, color.b);
|
||||
SDL_SetTextureAlphaMod(_texture, color.a);
|
||||
}
|
||||
set_color_mod:
|
||||
SDL_SetTextureColorMod(_texture, color.r, color.g, color.b)
|
||||
SDL_SetTextureAlphaMod(_texture, color.a)
|
||||
|
||||
SDL_BlendMode Texture::get_blend_mode() const {
|
||||
SDL_BlendMode blendMode;
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
SDL_GetTextureBlendMode(_texture, &blendMode);
|
||||
get_blend_mode:
|
||||
SDL_BlendMode blendMode
|
||||
|
||||
return blendMode;
|
||||
}
|
||||
void Texture::set_blend_mode(const SDL_BlendMode blend_mode) {
|
||||
SDL_SetTextureBlendMode(_texture, blend_mode);
|
||||
}
|
||||
SDL_GetTextureBlendMode(_texture, &blendMode)
|
||||
|
||||
SDL_ScaleMode Texture::get_texture_scale_mode() const {
|
||||
SDL_ScaleMode scale_mode;
|
||||
return blendMode
|
||||
|
||||
SDL_GetTextureScaleMode(_texture, &scale_mode);
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
return scale_mode;
|
||||
}
|
||||
void Texture::set_texture_scale_mode(const SDL_ScaleMode scale_mode) {
|
||||
SDL_SetTextureScaleMode(_texture, scale_mode);
|
||||
}
|
||||
set_blend_mode:
|
||||
SDL_SetTextureBlendMode(_texture, blend_mode)
|
||||
|
||||
Image *Texture::get_image() {
|
||||
return _image;
|
||||
}
|
||||
void Texture::set_image(Image *image) {
|
||||
if (_texture) {
|
||||
free();
|
||||
}
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
_image = image;
|
||||
get_texture_scale_mode:
|
||||
SDL_ScaleMode scale_mode
|
||||
|
||||
refresh();
|
||||
}
|
||||
SDL_GetTextureScaleMode(_texture, &scale_mode)
|
||||
|
||||
int Texture::get_width() const {
|
||||
Uint32 format;
|
||||
int access;
|
||||
int w;
|
||||
int h;
|
||||
return scale_mode
|
||||
|
||||
if (SDL_QueryTexture(_texture, &format, &access, &w, &h)) {
|
||||
return 0;
|
||||
}
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
return w;
|
||||
}
|
||||
int Texture::get_height() const {
|
||||
Uint32 format;
|
||||
int access;
|
||||
int w;
|
||||
int h;
|
||||
set_texture_scale_mode:
|
||||
SDL_SetTextureScaleMode(_texture, scale_mode)
|
||||
|
||||
if (SDL_QueryTexture(_texture, &format, &access, &w, &h)) {
|
||||
return 0;
|
||||
}
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
return h;
|
||||
}
|
||||
Uint32 Texture::get_format() const {
|
||||
Uint32 format;
|
||||
int access;
|
||||
int w;
|
||||
int h;
|
||||
get_image:
|
||||
return _image
|
||||
|
||||
if (SDL_QueryTexture(_texture, &format, &access, &w, &h)) {
|
||||
return 0;
|
||||
}
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
return format;
|
||||
}
|
||||
int Texture::get_access() const {
|
||||
Uint32 format;
|
||||
int access;
|
||||
int w;
|
||||
int h;
|
||||
set_image:
|
||||
if (_texture)
|
||||
free()
|
||||
|
||||
|
||||
if (SDL_QueryTexture(_texture, &format, &access, &w, &h)) {
|
||||
return 0;
|
||||
}
|
||||
_image = image
|
||||
|
||||
return access;
|
||||
}
|
||||
refresh()
|
||||
|
||||
void Texture::create(int access, int w, int h) {
|
||||
if (_texture) {
|
||||
free();
|
||||
}
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
_image = nullptr;
|
||||
get_width:
|
||||
Uint32 format
|
||||
int access
|
||||
int w
|
||||
int h
|
||||
|
||||
_texture = SDL_CreateTexture(Renderer::get_singleton()->get_renderer(), SDL_PIXELFORMAT_RGBA8888, access, w, h);
|
||||
}
|
||||
void Texture::refresh() {
|
||||
if (_image == nullptr) {
|
||||
return;
|
||||
}
|
||||
if (SDL_QueryTexture(_texture, &format, &access, &w, &h))
|
||||
return 0
|
||||
|
||||
|
||||
if (_image->get_surface() == nullptr) {
|
||||
return;
|
||||
}
|
||||
return w
|
||||
|
||||
if (_texture) {
|
||||
free();
|
||||
}
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
_texture = SDL_CreateTextureFromSurface(Renderer::get_singleton()->get_renderer(), _image->get_surface());
|
||||
}
|
||||
void Texture::free() {
|
||||
if (_texture) {
|
||||
SDL_DestroyTexture(_texture);
|
||||
get_height:
|
||||
Uint32 format
|
||||
int access
|
||||
int w
|
||||
int h
|
||||
|
||||
_texture = nullptr;
|
||||
}
|
||||
}
|
||||
if (SDL_QueryTexture(_texture, &format, &access, &w, &h))
|
||||
return 0
|
||||
|
||||
|
||||
SDL_Texture *Texture::get_texture() {
|
||||
return _texture;
|
||||
}
|
||||
SDL_Texture *Texture::get_texture() const {
|
||||
return _texture;
|
||||
}
|
||||
return h
|
||||
|
||||
bool Texture::is_render_target() {
|
||||
if (_texture == Renderer::get_singleton()->get_render_target()) {
|
||||
return true;
|
||||
}
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
return false;
|
||||
}
|
||||
get_format:
|
||||
Uint32 format
|
||||
int access
|
||||
int w
|
||||
int h
|
||||
|
||||
Texture::Texture() {
|
||||
_image = nullptr;
|
||||
_texture = nullptr;
|
||||
}
|
||||
Texture::Texture(Image *image) {
|
||||
_image = nullptr;
|
||||
_texture = nullptr;
|
||||
if (SDL_QueryTexture(_texture, &format, &access, &w, &h))
|
||||
return 0
|
||||
|
||||
|
||||
set_image(image);
|
||||
}
|
||||
Texture::~Texture() {
|
||||
if (_texture) {
|
||||
free();
|
||||
}
|
||||
}
|
||||
return format
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
get_access:
|
||||
Uint32 format
|
||||
int access
|
||||
int w
|
||||
int h
|
||||
|
||||
if (SDL_QueryTexture(_texture, &format, &access, &w, &h))
|
||||
return 0
|
||||
|
||||
|
||||
return access
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
create:
|
||||
if (_texture)
|
||||
free()
|
||||
|
||||
|
||||
_image = nullptr
|
||||
|
||||
_texture = SDL_CreateTexture(Renderer::get_singleton()->get_renderer(), SDL_PIXELFORMAT_RGBA8888, access, w, h)
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
refresh:
|
||||
if (_image == nullptr)
|
||||
return
|
||||
|
||||
|
||||
if (_image->get_surface() == nullptr)
|
||||
return
|
||||
|
||||
|
||||
if (_texture)
|
||||
free()
|
||||
|
||||
|
||||
_texture = SDL_CreateTextureFromSurface(Renderer::get_singleton()->get_renderer(), _image->get_surface())
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
free:
|
||||
if (_texture)
|
||||
SDL_DestroyTexture(_texture)
|
||||
|
||||
_texture = nullptr
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
get_texture():
|
||||
return _texture
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
get_texture() const:
|
||||
return _texture
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
is_render_target:
|
||||
if (_texture == Renderer::get_singleton()->get_render_target())
|
||||
return true
|
||||
|
||||
|
||||
return false
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
Texture():
|
||||
_image = nullptr
|
||||
_texture = nullptr
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
Texture(Image *image):
|
||||
_image = nullptr
|
||||
_texture = nullptr
|
||||
|
||||
set_image(image)
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
~Texture:
|
||||
if (_texture)
|
||||
free()
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
@ -56,7 +56,7 @@
|
||||
| |
|
||||
| + Sprite(Texture *texture, const float x, const float y, |
|
||||
| const float w, const float h, const double angle = 0) |
|
||||
| + virtual ~Sprite() |
|
||||
| + virtual ~Sprite() | -> Üres
|
||||
| |
|
||||
| - Rect2 _texture_clip_rect |
|
||||
| - Rect2 _transform |
|
||||
@ -72,107 +72,172 @@
|
||||
| - Texture *_texture |
|
||||
|---------------------------------------------------------------------------------------|
|
||||
|
||||
#include "sprite.h"
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
#include "renderer.h"
|
||||
|
||||
Rect2 Sprite::get_texture_clip_rect() const {
|
||||
get_texture_clip_rect:
|
||||
return _texture_clip_rect
|
||||
}
|
||||
void Sprite::set_texture_clip_rect(const Rect2 &rect) {
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
set_texture_clip_rect:
|
||||
_texture_clip_rect = rect
|
||||
}
|
||||
|
||||
Rect2 Sprite::get_transform() const {
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
get_transform:
|
||||
return _transform
|
||||
}
|
||||
void Sprite::set_transform(const Rect2 &rect) {
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
set_transform:
|
||||
_transform = rect
|
||||
}
|
||||
|
||||
float Sprite::get_x() const {
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
get_x:
|
||||
return _transform.x
|
||||
}
|
||||
void Sprite::set_x(const float val) {
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
set_x:
|
||||
_transform.x = val
|
||||
}
|
||||
|
||||
float Sprite::get_y() const {
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
get_y:
|
||||
return _transform.y
|
||||
}
|
||||
void Sprite::set_y(const float val) {
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
set_y:
|
||||
_transform.y = val
|
||||
}
|
||||
|
||||
float Sprite::get_w() const {
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
get_w:
|
||||
return _transform.w
|
||||
}
|
||||
void Sprite::set_w(const float val) {
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
set_w:
|
||||
_transform.w = val
|
||||
}
|
||||
|
||||
float Sprite::get_h() const {
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
get_h:
|
||||
return _transform.h
|
||||
}
|
||||
void Sprite::set_h(const float val) {
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
set_h:
|
||||
_transform.h = val
|
||||
}
|
||||
|
||||
double Sprite::get_angle() const {
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
get_angle:
|
||||
return _angle
|
||||
}
|
||||
void Sprite::set_angle(const double val) {
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
set_angle:
|
||||
_angle = val
|
||||
}
|
||||
|
||||
float Sprite::get_anchor_x() const {
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
get_anchor_x:
|
||||
return _anchor_x
|
||||
}
|
||||
void Sprite::set_anchor_x(const float val) {
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
set_anchor_x:
|
||||
_anchor_x = val
|
||||
}
|
||||
|
||||
float Sprite::get_anchor_y() const {
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
get_anchor_y:
|
||||
return _anchor_y
|
||||
}
|
||||
void Sprite::set_anchor_y(const float val) {
|
||||
_anchor_y = val
|
||||
}
|
||||
|
||||
void Sprite::set_anchor(const float x, const float y) {
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
set_anchor_y:
|
||||
_anchor_y = val
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
set_anchor:
|
||||
_anchor_x = x
|
||||
_anchor_y = y
|
||||
}
|
||||
|
||||
SDL_RendererFlip Sprite::get_flip() const {
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
get_flip:
|
||||
return _flip
|
||||
}
|
||||
void Sprite::set_flip(const SDL_RendererFlip val) {
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
set_flip:
|
||||
_flip = val
|
||||
}
|
||||
|
||||
Color Sprite::get_color_mod() const {
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
get_color_mod:
|
||||
return _color_mod
|
||||
}
|
||||
void Sprite::set_color_mod(const Color &color) {
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
set_color_mod:
|
||||
_color_mod = color
|
||||
}
|
||||
|
||||
Texture *Sprite::get_texture() {
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
get_texture():
|
||||
return _texture
|
||||
}
|
||||
Texture *Sprite::get_texture() const {
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
get_texture() const:
|
||||
return _texture
|
||||
}
|
||||
void Sprite::set_texture(Texture *texture) {
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
set_texture:
|
||||
_texture = texture
|
||||
}
|
||||
|
||||
void Sprite::draw() {
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
draw:
|
||||
Renderer::get_singleton()->draw_sprite(this)
|
||||
}
|
||||
|
||||
Sprite::Sprite() {
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
Sprite():
|
||||
_angle = 0
|
||||
|
||||
_anchor_x = 0
|
||||
@ -183,8 +248,10 @@ Sprite::Sprite() {
|
||||
_texture = nullptr
|
||||
|
||||
_color_mod = Color(255, 255, 255, 255)
|
||||
}
|
||||
Sprite::Sprite(Texture *texture) {
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
Sprite(Texture *texture):
|
||||
_angle = 0
|
||||
|
||||
_anchor_x = 0
|
||||
@ -194,18 +261,19 @@ Sprite::Sprite(Texture *texture) {
|
||||
|
||||
_texture = texture
|
||||
|
||||
if (_texture != nullptr) {
|
||||
if (_texture != nullptr):
|
||||
_texture_clip_rect.w = texture->get_width()
|
||||
_texture_clip_rect.h = texture->get_height()
|
||||
|
||||
_transform.w = texture->get_width()
|
||||
_transform.h = texture->get_height()
|
||||
}
|
||||
|
||||
|
||||
_color_mod = Color(255, 255, 255, 255)
|
||||
}
|
||||
|
||||
Sprite::Sprite(Texture *texture, const Color &color_mod) {
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
Sprite(Texture *texture, const Color &color_mod):
|
||||
_angle = 0
|
||||
|
||||
_anchor_x = 0
|
||||
@ -215,18 +283,19 @@ Sprite::Sprite(Texture *texture, const Color &color_mod) {
|
||||
|
||||
_texture = texture
|
||||
|
||||
if (_texture != nullptr) {
|
||||
if (_texture != nullptr):
|
||||
_texture_clip_rect.w = texture->get_width()
|
||||
_texture_clip_rect.h = texture->get_height()
|
||||
|
||||
_transform.w = texture->get_width()
|
||||
_transform.h = texture->get_height()
|
||||
}
|
||||
|
||||
|
||||
_color_mod = color_mod
|
||||
}
|
||||
|
||||
Sprite::Sprite(Texture *texture, const float x, const float y, const double angle) {
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
Sprite(Texture *texture, const float x, const float y, const double angle):
|
||||
_angle = angle
|
||||
|
||||
_anchor_x = 0
|
||||
@ -239,17 +308,19 @@ Sprite::Sprite(Texture *texture, const float x, const float y, const double angl
|
||||
_transform.x = x
|
||||
_transform.y = y
|
||||
|
||||
if (_texture != nullptr) {
|
||||
if (_texture != nullptr):
|
||||
_texture_clip_rect.w = texture->get_width()
|
||||
_texture_clip_rect.h = texture->get_height()
|
||||
|
||||
_transform.w = texture->get_width()
|
||||
_transform.h = texture->get_height()
|
||||
}
|
||||
|
||||
|
||||
_color_mod = Color(255, 255, 255, 255)
|
||||
}
|
||||
Sprite::Sprite(Texture *texture, const float x, const float y, const Rect2 &texture_clip_rect, const double angle) {
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
Sprite(Texture *texture, const float x, const float y, const Rect2 &texture_clip_rect, const double angle):
|
||||
_angle = angle
|
||||
|
||||
_anchor_x = 0
|
||||
@ -262,16 +333,18 @@ Sprite::Sprite(Texture *texture, const float x, const float y, const Rect2 &text
|
||||
_transform.x = x
|
||||
_transform.y = y
|
||||
|
||||
if (_texture != nullptr) {
|
||||
if (_texture != nullptr):
|
||||
_transform.w = texture->get_width()
|
||||
_transform.h = texture->get_height()
|
||||
}
|
||||
|
||||
|
||||
_texture_clip_rect = texture_clip_rect
|
||||
|
||||
_color_mod = Color(255, 255, 255, 255)
|
||||
}
|
||||
Sprite::Sprite(Texture *texture, const Rect2 &transform, const Rect2 &texture_clip_rect, const double angle) {
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
Sprite(Texture *texture, const Rect2 &transform, const Rect2 &texture_clip_rect, const double angle):
|
||||
_angle = angle
|
||||
|
||||
_anchor_x = 0
|
||||
@ -285,8 +358,10 @@ Sprite::Sprite(Texture *texture, const Rect2 &transform, const Rect2 &texture_cl
|
||||
_texture_clip_rect = texture_clip_rect
|
||||
|
||||
_color_mod = Color(255, 255, 255, 255)
|
||||
}
|
||||
Sprite::Sprite(Texture *texture, const float x, const float y, const float w, const float h, const double angle) {
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
Sprite(Texture *texture, const float x, const float y, const float w, const float h, const double angle):
|
||||
_angle = angle
|
||||
|
||||
_anchor_x = 0
|
||||
@ -301,12 +376,11 @@ Sprite::Sprite(Texture *texture, const float x, const float y, const float w, co
|
||||
_transform.w = w
|
||||
_transform.h = h
|
||||
|
||||
if (_texture != nullptr) {
|
||||
if (_texture != nullptr):
|
||||
_texture_clip_rect.w = texture->get_width()
|
||||
_texture_clip_rect.h = texture->get_height()
|
||||
}
|
||||
|
||||
|
||||
_color_mod = Color(255, 255, 255, 255)
|
||||
}
|
||||
Sprite::~Sprite() {
|
||||
}
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
@ -2,41 +2,37 @@
|
||||
|---------------------------------------------------------------------------------------|
|
||||
| class Camera |
|
||||
|---------------------------------------------------------------------------------------|
|
||||
| + void bind(); |
|
||||
| + void bind() |
|
||||
| |
|
||||
| + Camera(); |
|
||||
| + virtual ~Camera(); |
|
||||
| + Camera() |
|
||||
| + virtual ~Camera() | -> Üres
|
||||
| |
|
||||
| + bool integer_scaling; |
|
||||
| + float scale_w; |
|
||||
| + float scale_h; |
|
||||
| + viewport; |
|
||||
| + Rect2 clip_rect; |
|
||||
| + bool integer_scaling |
|
||||
| + float scale_w |
|
||||
| + float scale_h |
|
||||
| + viewport |
|
||||
| + Rect2 clip_rect |
|
||||
|---------------------------------------------------------------------------------------|
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
#include "camera.h"
|
||||
bind:
|
||||
Renderer::get_singleton()->set_integer_scaling(integer_scaling)
|
||||
|
||||
#include "renderer.h"
|
||||
Renderer::get_singleton()->set_scale(scale_w, scale_h)
|
||||
|
||||
void Camera::bind() {
|
||||
Renderer::get_singleton()->set_integer_scaling(integer_scaling);
|
||||
Renderer::get_singleton()->set_viewport(viewport)
|
||||
Renderer::get_singleton()->set_clip_rect(&clip_rect)
|
||||
|
||||
Renderer::get_singleton()->set_scale(scale_w, scale_h);
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
Renderer::get_singleton()->set_viewport(viewport);
|
||||
Renderer::get_singleton()->set_clip_rect(&clip_rect);
|
||||
}
|
||||
Camera:
|
||||
integer_scaling = false
|
||||
|
||||
Camera::Camera() {
|
||||
integer_scaling = false;
|
||||
scale_w = 1
|
||||
scale_h = 1
|
||||
|
||||
scale_w = 1;
|
||||
scale_h = 1;
|
||||
|
||||
viewport = Renderer::get_singleton()->get_viewport();
|
||||
clip_rect = Renderer::get_singleton()->get_clip_rect();
|
||||
}
|
||||
Camera::~Camera() {
|
||||
}
|
||||
viewport = Renderer::get_singleton()->get_viewport()
|
||||
clip_rect = Renderer::get_singleton()->get_clip_rect()
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user