1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef GRAPHICS_SPRITE_3DS_H
24 #define GRAPHICS_SPRITE_3DS_H
25 
26 #define FORBIDDEN_SYMBOL_EXCEPTION_time_h
27 
28 #include "graphics/surface.h"
29 #include <3ds.h>
30 #include <citro3d.h>
31 
32 namespace N3DS {
33 
34 typedef struct {
35 	float position[3];
36 	float texcoord[2];
37 } vertex;
38 
39 struct GfxMode3DS;
40 
41 class Sprite : public Graphics::Surface {
42 public:
43 	Sprite();
44 	~Sprite();
45 	void create(uint16 width, uint16 height, const GfxMode3DS *mode);
46 	void free();
47 	void convertToInPlace(const Graphics::PixelFormat &dstFormat, const byte *palette = 0);
48 	void transfer();
49 	void render();
50 	void clear(uint32 color = 0);
markDirty()51 	void markDirty(){ dirtyPixels = true; }
52 
53 	void setPosition(int x, int y);
54 	void setOffset(uint16 x, uint16 y);
55 	void setScale(float x, float y);
getScaleX()56 	float getScaleX() const { return scaleX; }
getScaleY()57 	float getScaleY() const { return scaleY; }
getPosX()58 	int getPosX() const { return posX; }
getPosY()59 	int getPosY() const { return posY; }
60 	C3D_Mtx* getMatrix();
61 
62 	void setFilteringMode(bool enableLinearFiltering);
63 
64 	uint16 actualWidth;
65 	uint16 actualHeight;
66 
67 private:
68 	uint32 textureTransferFlags;
69 	bool dirtyPixels;
70 	bool dirtyMatrix;
71 	C3D_Mtx modelview;
72 	C3D_Tex texture;
73 	vertex* vertices;
74 	int posX;
75 	int posY;
76 	uint16 offsetX;
77 	uint16 offsetY;
78 	float scaleX;
79 	float scaleY;
80 };
81 
82 } // namespace N3DS
83 
84 #endif
85