My favorites | Sign in
Project Home Downloads Source
Checkout   Browse   Changes    
 
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#include <CtrlCore/CtrlCore.h>

#ifdef GUI_WINGL

NAMESPACE_UPP

#define LLOG(x) // LOG(x)
#define LTIMING(x) // RTIMING(x)

FrameInfo frameInfo;
SystemDraw* SystemDraw::systemDraw = NULL;
float SystemDraw::blurStrength = 0;
float SystemDraw::grayStrength = 0;

dword SystemDraw::GetInfo() const
{
return 0;
}

Size SystemDraw::GetPageSize() const
{
return Size(0, 0);
}

Size SystemDraw::GetNativeDpi() const
{
return Size(96, 96);
}

void SystemDraw::BeginNative()
{
}

void SystemDraw::EndNative()
{
}

int SystemDraw::GetCloffLevel() const
{
return ci;
}

void SystemDraw::InitClip(const Rect& clip)
{
drawing_clip = clip;
}

void SystemDraw::Reset() {
systemDraw = this;
cloff.SetCount(32);
mstack.SetCount(32);
ci = 0;
cn = 0;
cd = 0;
mi = 0;
drawing_offset = Point(0, 0);
alpha = 255;
r = g = b = a = 255;
angle = 0;
scale = 1;
image_coloring = true;
projection_mode = 0;
}

SystemDraw::SystemDraw() {
Reset();
}

SystemDraw::SystemDraw(Size sz) {
Reset();
drawing_clip = sz;
drawing_size = sz;
clip = sz;
Init();
}

void SystemDraw::Init()
{
//glVertexPointer(2, GL_FLOAT, 0, vtx);
//glTexCoordPointer(2, GL_FLOAT, 0, crd);
glEnable(GL_BLEND);
glDisable(GL_DEPTH_TEST);
glShadeModel(GL_SMOOTH);
glDisable(GL_ALPHA_TEST);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
#if CLIP_MODE == 0
glEnable(GL_SCISSOR_TEST);
#elif CLIP_MODE == 1
glEnable(GL_CLIP_PLANE0);
glEnable(GL_CLIP_PLANE1);
glEnable(GL_CLIP_PLANE2);
glEnable(GL_CLIP_PLANE3);
#elif CLIP_MODE == 2
glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_ALWAYS, 0, ~0);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
glClearStencil(0);
#endif
glEnable(GL_LINE_SMOOTH);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glClearColor(0.f, 0.f, 0.f, 1.f);
glClearDepth(1.0f);
glEnableClientState(GL_VERTEX_ARRAY);
//glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glColor4f(1.f, 1.f, 1.f, 1.f);
}

void SystemDraw::Clear(bool ontransforms)
{
if(ontransforms && (angle == 0 && scale == 1))
return;
#if CLIP_MODE == 0
glDisable(GL_SCISSOR_TEST);
#endif
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
#if CLIP_MODE == 0
glEnable(GL_SCISSOR_TEST);
#endif
}

void SystemDraw::ViewPort(int width, int height)
{
glViewport(0, 0, (GLsizei) width < 0 ? drawing_size.cx : width, (GLsizei) height < 0 ? drawing_size.cy : height);
}

void SystemDraw::OrthogonalView(bool clear_modelview)
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, drawing_size.cx, drawing_size.cy, 0, -100, 100);
glMatrixMode(GL_MODELVIEW);
if(clear_modelview)
glLoadIdentity();
}

void SystemDraw::PerspectiveView(bool clear_modelview)
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f, GetAspect(), 1.f, 100.0f);
glMatrixMode(GL_MODELVIEW);
if(clear_modelview)
glLoadIdentity();
}

void SystemDraw::ApplyTransforms()
{
float dx = (float) drawing_size.cx / 2;
float dy = (float) drawing_size.cy / 2;
glTranslatef(dx, dy, 0.f);
glRotatef(angle, 0, 0, 1);
glScalef(scale, scale, 1);
glTranslatef(-dx, -dy, 0.f);
}

void SystemDraw::PushContext()
{
MatrixStack& m = mstack[mi++];
glGetDoublev(GL_PROJECTION_MATRIX, m.projection_matrix);
glGetDoublev(GL_MODELVIEW_MATRIX, m.modelview_matrix);
m.projection_mode = projection_mode;
}

void SystemDraw::PopContext()
{
MatrixStack& m = mstack[--mi];
glMatrixMode(GL_PROJECTION);
glLoadMatrixd(m.projection_matrix);
glMatrixMode(GL_MODELVIEW);
glLoadMatrixd(m.modelview_matrix);
projection_mode = m.projection_mode;
}

SystemDraw::~SystemDraw() {
}

END_UPP_NAMESPACE

#endif

Change log

r4853 by unodgs on Apr 24, 2012   Diff
WinGL: Fixed timers, added support for
perspective view
Go to: 
Project members, sign in to write a code review

Older revisions

r4385 by unodgs on Jan 9, 2012   Diff
WinGL: Texture alignment fixes, added
grayscale to blur shader
r4365 by unodgs on Jan 6, 2012   Diff
WinGL: Added painting through fbo,
added blur shader, fixed children
clipping, optimized painting a bit
r4189 by unodgs on Nov 22, 2011   Diff
WinGL: Added missing WakeUpGuiThread
function, increased cloff stack to 30
All revisions of this file

File info

Size: 3578 bytes, 179 lines

File properties

svn:eol-style
native
Powered by Google Project Hosting