Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
José Pardo Madera
/
ProjectoMultimeda2025
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
0166aee8
authored
Apr 06, 2025
by
José Pardo Madera
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Texto carga lazy.
parent
4a1a360f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
5 deletions
Executable
Texto.cpp
Texto.h
makefile
Executable
View file @
0166aee8
No preview for this file type
Texto.cpp
View file @
0166aee8
#include "Texto.h"
#include <SDL2/SDL_ttf.h>
#include <stdexcept>
SDL_Texture
*
Texto
::
get_textura
(
SDL_Renderer
*
renderer
)
{
if
(
texture
==
nullptr
)
{
...
...
@@ -7,6 +9,16 @@ SDL_Texture *Texto::get_textura(SDL_Renderer *renderer) {
return
texture
;
}
SDL_Surface
*
Texto
::
get_surface
()
{
if
(
surface
==
nullptr
)
{
surface
=
TTF_RenderUTF8_Solid
(
*
fuente
,
text
,
fg
);
if
(
surface
==
nullptr
)
{
throw
std
::
runtime_error
(
SDL_GetError
());
}
}
return
surface
;
}
void
Texto
::
renderizar
(
SDL_Renderer
*
renderer
,
int
x
,
int
y
,
int
tamx
,
int
tamy
)
{
texture
=
get_textura
(
renderer
);
...
...
Texto.h
View file @
0166aee8
...
...
@@ -7,15 +7,20 @@
#include <SDL2/SDL_ttf.h>
class
Texto
{
SDL_Surface
*
surface
;
Fuente
fuente
;
const
char
*
text
;
SDL_Color
fg
;
SDL_Surface
*
surface
=
nullptr
;
SDL_Texture
*
texture
=
nullptr
;
SDL_Texture
*
get_textura
(
SDL_Renderer
*
renderer
);
SDL_Surface
*
get_surface
();
public
:
Texto
(
Fuente
&
fuente
,
const
char
*
texto
,
SDL_Color
fg
)
{
surface
=
TTF_RenderUTF8_Solid
(
*
fuente
,
texto
,
fg
);
};
Texto
(
Fuente
&
fuente
,
const
char
*
texto
,
SDL_Color
fg
)
:
fuente
(
fuente
),
text
(
texto
),
fg
(
fg
)
{};
void
renderizar
(
SDL_Renderer
*
Renderer
,
int
x
,
int
y
,
int
tamx
,
int
tamy
);
...
...
makefile
View file @
0166aee8
...
...
@@ -10,7 +10,7 @@ objs = $(code_files_in_obj:.cpp=.o)
deps
=
$
(
code_files_in_obj:.cpp
=
.d
)
link_flags
=
-lSDL2
-lSDL2_image
-lSDL2_ttf
-lSDL2_mixer
compile_flags
=
-w
$(link_flags)
compile_flags
=
-w
$(link_flags)
-g
$(bin)
:
$(objs)
$(CC)
$(objs)
$(compile_flags)
-o
$@
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment