summaryrefslogtreecommitdiff
path: root/Runtime/Graphics/GfxDevice.cpp
blob: e4747d86699e52e3067f87474e957db68cea9c94 (plain)
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#include "GfxDevice.h"

static bool deviceInited = false;

GfxDevice g_GfxDevice;

GfxDevice::GfxDevice()
{
	Assert(!deviceInited);
	deviceInited = true;
}

GfxDevice::~GfxDevice()
{

}

void GfxDevice::Initialize(GfxDeviceSetting setting)
{
}

void GfxDevice::Enable(EDeviceEnable enabled)
{

}

void GfxDevice::Disable(EDeviceEnable enabled)
{

}

void GfxDevice::IsEnable(uint flag)
{

}

void GfxDevice::SetDepthTest(EDepthTest testing)
{

}

void GfxDevice::SetCullFace(ECullFace face)
{

}

void GfxDevice::SetStencilMask(byte stencilMask)
{

}

void GfxDevice::SetStencilOp(EStencilOp op)
{

}

void GfxDevice::SetAntiAliasing(int level /*= 0*/)
{

}

void GfxDevice::Clear(int clearFlag)
{

}

void GfxDevice::UseShader(LuaBind::State& state, Shader* shader, int idx)
{
    if (shader == NULL)
        return;

    GLuint id = shader->GetID();
    if (id == 0)
        return;

    glUseProgram(id);

    m_Shader.shader = shader;
    m_Shader.ref.SetRef(state, idx);
}

void GfxDevice::UnuseShader()
{
    if (m_Shader)
    {
        m_Shader.shader = NULL;
        m_Shader.ref.UnRef();
    }
    glUseProgram(0);
}

void GfxDevice::SetUniformVec2(const char* name, Internal::Vector2 vec2)
{
    if (!m_Shader)
        return;
    GLint loc = glGetUniformLocation(m_Shader.GetID(), name);
    glUniform2f(loc, vec2.x, vec2.y);
}

void GfxDevice::SetUniformVec3(const char* name, Internal::Vector3 vec3)
{
    if (!m_Shader)
        return;
    GLint loc = glGetUniformLocation(m_Shader.GetID(), name);
    glUniform3f(loc, vec3.x, vec3.y, vec3.z);
}

void GfxDevice::SetUniformVec4(const char* name, Internal::Vector4 vec4)
{
    if (!m_Shader)
        return;
    GLint loc = glGetUniformLocation(m_Shader.GetID(), name);
    glUniform4f(loc, vec4.x, vec4.y, vec4.z, vec4.w);
}

void GfxDevice::SetUniformMat4(const char* name, Internal::Matrix44 mat4)
{
    if (!m_Shader)
        return;
    GLint loc = glGetUniformLocation(m_Shader.GetID(), name);
    glUniformMatrix4fv(loc, 1, GL_TRUE, &mat4.m[0][0]);
}

void GfxDevice::BeginFrame()
{
	m_IsInsideFrame = true;
	
}

void GfxDevice::EndFrame()
{	
	//GPU::BufferPool::Instance()->OnEndFrame();

	m_IsInsideFrame = false;
}

void GfxDevice::PresentFrame()
{
// swap buffers
}

bool GfxDevice::IsInsideFrame()
{
	return m_IsInsideFrame;
}