-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVirtualDevice.h
74 lines (53 loc) · 1.62 KB
/
VirtualDevice.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//
// Created by jeff2310 on 4/18/18.
//
#ifndef VKSOFTWARERENDER_VIRTUALDEVICE_H
#define VKSOFTWARERENDER_VIRTUALDEVICE_H
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <string>
#include "MathUtility.h"
#include "Camera.h"
#include "TextureLoader/Texture.h"
using namespace std;
namespace VkRenderer {
#define DRAW_FACES 1
#define DRAW_BORDERS 2
#define DRAW_TEXTURE 4
#define FACE_CULLING 1
typedef float VkFloat;
typedef uint VkUint;
typedef unsigned char VkModeCode;
class VirtualDevice {
private:
string name;
//pixels中行从y较大的方向开始存
// unsigned char *framebuffer;
VkFloat *depthBuffer;
VkFloat *stencilBuffer;
VkUint width, height;
GLFWwindow *window;
Color backgroundColor;
public:
unsigned char *framebuffer;
Camera *camera;
VkModeCode drawMode;
VkModeCode optimizationMode;
Image::Texture *currentTexture;
explicit VirtualDevice(const string &name, VkUint width = 1, VkUint height = 1);
// todo deep-copy
~VirtualDevice();
int getWidth() const;
int getHeight() const;
VkFloat *getDepth(int x, int y);
bool shouldShutdown();
void setBackgroundColor(float r, float g, float b);
void refreshBuffer();
void setDrawMode(VkModeCode modeCode, bool enabled);
void setOptimization(VkModeCode modeCode, bool enabled);
void bindTexture(Image::Texture *texture);
void drawPixel(int x, int y, Color color);
void mainLoop();
};
}
#endif //VKSOFTWARERENDER_VIRTUALDEVICE_H