WinGL: Added gui locks, fixed blur shader conformance

git-svn-id: svn://ultimatepp.org/upp/trunk@6184 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
unodgs 2013-07-11 14:26:44 +00:00
parent 364b2c88df
commit 1851fe470e
11 changed files with 67 additions and 20 deletions

View file

@ -1,5 +1,7 @@
#include "Console.h"
#ifdef GUI_WINGL
NAMESPACE_UPP
void Console::Paint(Draw& w)
@ -176,4 +178,6 @@ Console::Console() : init(true), resize(false)
scrollLine = 0;
}
END_UPP_NAMESPACE
END_UPP_NAMESPACE
#endif

View file

@ -1,5 +1,7 @@
#include "ControlPanel.h"
#ifdef GUI_WINGL
NAMESPACE_UPP
ValueSlider::ValueSlider()
@ -204,4 +206,6 @@ float InfoPanel::GetScale()
return scaleSlider.GetPos();
}
END_UPP_NAMESPACE
END_UPP_NAMESPACE
#endif

View file

@ -65,6 +65,10 @@ void GuiPlatformAfterMenuPopUp()
{
}
void Ctrl::InstallPanicBox()
{
}
void Ctrl::ApplyLayout()
{
GuiLock __;

View file

@ -42,6 +42,7 @@ int SystemDraw::GetCloffLevel() const
void SystemDraw::InitClip(const Rect& clip)
{
GuiLock __;
drawing_clip = clip;
}
@ -63,10 +64,12 @@ void SystemDraw::Reset() {
}
SystemDraw::SystemDraw() {
GuiLock __;
Reset();
}
SystemDraw::SystemDraw(Size sz) {
GuiLock __;
Reset();
drawing_clip = sz;
drawing_size = sz;
@ -107,6 +110,7 @@ void SystemDraw::Init()
void SystemDraw::Clear(bool ontransforms)
{
GuiLock __;
if(ontransforms && (angle == 0 && scale == 1))
return;
#if CLIP_MODE == 0
@ -120,11 +124,13 @@ void SystemDraw::Clear(bool ontransforms)
void SystemDraw::ViewPort(int width, int height)
{
GuiLock __;
glViewport(0, 0, (GLsizei) width < 0 ? drawing_size.cx : width, (GLsizei) height < 0 ? drawing_size.cy : height);
}
void SystemDraw::OrthogonalView(bool clear_modelview)
{
GuiLock __;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, drawing_size.cx, drawing_size.cy, 0, -100, 100);
@ -135,6 +141,7 @@ void SystemDraw::OrthogonalView(bool clear_modelview)
void SystemDraw::PerspectiveView(bool clear_modelview)
{
GuiLock __;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f, GetAspect(), 1.f, 100.0f);
@ -145,6 +152,7 @@ void SystemDraw::PerspectiveView(bool clear_modelview)
void SystemDraw::ApplyTransforms()
{
GuiLock __;
float dx = (float) drawing_size.cx / 2;
float dy = (float) drawing_size.cy / 2;
glTranslatef(dx, dy, 0.f);
@ -155,6 +163,7 @@ void SystemDraw::ApplyTransforms()
void SystemDraw::PushContext()
{
GuiLock __;
MatrixStack& m = mstack[mi++];
glGetDoublev(GL_PROJECTION_MATRIX, m.projection_matrix);
glGetDoublev(GL_MODELVIEW_MATRIX, m.modelview_matrix);
@ -163,6 +172,7 @@ void SystemDraw::PushContext()
void SystemDraw::PopContext()
{
GuiLock __;
MatrixStack& m = mstack[--mi];
glMatrixMode(GL_PROJECTION);
glLoadMatrixd(m.projection_matrix);

View file

@ -279,6 +279,7 @@ void SystemDraw::Text(int x, int y, int angle, const wchar *text, Font font, Col
void SystemDraw::DrawTextOp(int x, int y, int angle, const wchar *text, Font font, Color ink, int n, const int *dx)
{
GuiLock __;
Text(x, y, angle, text, font, ink, 0, White, 0, White, n, dx);
}

View file

@ -12,6 +12,14 @@ Point GetMousePos() {
return glmousepos;
}
void Ctrl::SysEndLoop()
{
}
void WakeUpGuiThread()
{
}
void Ctrl::MouseEventGl(Ptr<Ctrl> t, int event, Point p, int zdelta)
{
if(!t->IsEnabled() && (t != (Ctrl*) &infoPanel && t != (Ctrl*) &console))

View file

@ -1,5 +1,7 @@
#include "Scrollbar.h"
#ifdef GUI_WINGL
NAMESPACE_UPP
void AlignedFrame::FrameLayout(Rect &r)
@ -321,4 +323,6 @@ bool SlimScrollBar::IsScrollable() const
return t > sz.cx && sz.cx > 0;
}
END_UPP_NAMESPACE
END_UPP_NAMESPACE
#endif

View file

@ -1,4 +1,7 @@
#include <CtrlLib/CtrlLib.h>
#ifdef GUI_WINGL
#include "Shaders.h"
NAMESPACE_UPP
@ -237,4 +240,6 @@ void Shader::Stop()
Shader::Shader() : program(-1)
{}
END_UPP_NAMESPACE
END_UPP_NAMESPACE
#endif

View file

@ -4,11 +4,6 @@
NAMESPACE_UPP
Size GetScreenSize()
{
return Ctrl::screenRect.GetSize();
}
void DDRect(RGBA *t, int dir, const byte *pattern, int pos, int count)
{
while(count-- > 0) {
@ -44,7 +39,7 @@ void DrawLine(const Vector<Rect>& clip, int x, int y, int cx, int cy, bool horz,
//glVertex2i(10, 10);
//glVertex2i(100, 100);
glEnd();
glDisable(GL_LINE_STIPPLE);
//glDisable(GL_LINE_STIPPLE);
}
void DragRectDraw0(const Vector<Rect>& clip, const Rect& rect, int n, const byte *pattern, int animation)
@ -83,6 +78,10 @@ void DrawDragRect(Ctrl& q, const Rect& rect1, const Rect& rect2, const Rect& cli
{
}
void FinishDragRect(Ctrl& q)
{
}
END_UPP_NAMESPACE
#endif

View file

@ -259,6 +259,8 @@ int AppMain(HINSTANCE hInstance, LPSTR lpCmdLine)
{
GuiMainFn_();
UPP::Ctrl::ExitGl();
USRLOG("---------- About to delete this log of WinGL...");
UPP::AppExit__();
return UPP::GetExitCode();
}
else

View file

@ -28,11 +28,13 @@ int Ctrl::PaintLock;
void GlLog(int line, const char* text, Color ink)
{
GuiLock __;
Ctrl::console.Log(line, text, ink);
}
void GlLog(const char* text, Color ink)
{
GuiLock __;
Ctrl::console.Log(text, ink);
}
@ -205,9 +207,13 @@ bool Ctrl::ProcessEvent(bool *quit)
}
else if(glDrawMode == DRAW_ON_IDLE)
{
TimerProc(GetTickCount());
SweepMkImageCache();
DrawScreen();
if(!painting)
{
GuiSleep(0);
TimerProc(GetTickCount());
SweepMkImageCache();
DrawScreen();
}
}
return false;
@ -216,10 +222,10 @@ bool Ctrl::ProcessEvent(bool *quit)
void Ctrl::DrawScreen()
{
if(hRC && desktop && !painting) {
painting = true;
resources.BindStatic();
int64 t0 = GetHighTickCount();
frameInfo.curr_tick_count = t0;
painting = true;
desktop->ApplyLayout();
desktop->ApplyTransform(TS_BEFORE_SCREEN);
for(int i = 0; i < topctrl.GetCount(); i++) {
@ -295,8 +301,9 @@ void Ctrl::DrawScreen()
}
CursorSync(draw);
desktop->ApplyTransform(TS_AFTER_PAINT);
desktop->PostPaint(draw);
desktop->ApplyTransform(TS_AFTER_PAINT);
glLoadIdentity();
#if CLIP_MODE == 2
@ -320,14 +327,13 @@ void Ctrl::DrawScreen()
//glEnable(GL_STENCIL_TEST);
#endif
MouseSync(draw);
SwapBuffers(hDC);
painting = false;
int64 t1 = GetHighTickCount();
frameInfo.frame_time = t1 - t0;
frameInfo.frame_factor = frameInfo.frame_time * frameInfo.frame_skip / 1000.f;
frameInfo.fps = frameInfo.frame_time > 0.f ? 1000.f / (float)frameInfo.frame_time : 0.f;
//LOGF("ft: %d, t0: %d, t1: %d\n", frameInfo.frame_time, t0, t1);
painting = false;
}
}
@ -369,8 +375,8 @@ void Ctrl::EventLoop0(Ctrl *ctrl)
while(loopno > EndSessionLoopNo && !quit && (ctrl ? ctrl->IsOpen() && ctrl->InLoop() : GetTopCtrls().GetCount()))
{
SyncCaret();
if(glDrawMode == DRAW_ON_TIMER)
GuiSleep(20);
//if(glDrawMode == DRAW_ON_TIMER)
// GuiSleep(20);
ProcessEvents(&quit);
}