mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
GLCtrl: Implemented for GTK
git-svn-id: svn://ultimatepp.org/upp/trunk@5928 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
41c6bb5faf
commit
9e38cd6758
6 changed files with 99 additions and 1 deletions
|
|
@ -85,7 +85,7 @@ Image RichTextView::CursorImage(Point p, dword keyflags)
|
|||
{
|
||||
int pos = GetPointPos(p);
|
||||
if(WhenLink && pos >= 0 && !IsNull(GetLink(pos, p)))
|
||||
return CtrlImg::HandCursor();
|
||||
return Image::Hand();
|
||||
if(HasCapture())
|
||||
return Image::IBeam();
|
||||
return Image::Arrow();
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ void GLCtrl::StdView()
|
|||
glLoadIdentity();
|
||||
}
|
||||
|
||||
#ifndef GUI_GTK
|
||||
|
||||
Image GLCtrl::GLPane::MouseEvent(int event, Point p, int zdelta, dword keyflags)
|
||||
{
|
||||
p = p - GetScreenView().TopLeft() + ctrl->GetScreenView().TopLeft();
|
||||
|
|
@ -32,4 +34,6 @@ Vector<int> GLCtrl::Pick(int x, int y)
|
|||
return picking.Pick(x, y, THISBACK2(GLResize, GetSize().cx, GetSize().cy), THISBACK(GLPickingPaint));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -27,6 +27,22 @@
|
|||
|
||||
NAMESPACE_UPP
|
||||
|
||||
#ifdef GUI_GTK
|
||||
|
||||
class GLCtrl : public Ctrl {
|
||||
public:
|
||||
virtual void Paint(Draw& w);
|
||||
|
||||
public:
|
||||
Callback WhenGLPaint;
|
||||
|
||||
virtual void GLPaint();
|
||||
|
||||
void StdView();
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
class GLCtrl : public Ctrl {
|
||||
typedef GLCtrl CLASSNAME;
|
||||
|
||||
|
|
@ -155,6 +171,8 @@ public:
|
|||
Vector<int> Pick(int x, int y);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -7,10 +7,13 @@ library(LINUX) "GL GLU";
|
|||
|
||||
library(FREEBSD) "GL GLU";
|
||||
|
||||
library(GTK) "gdkglext-x11-1.0 gtkglext-x11-1.0";
|
||||
|
||||
file
|
||||
GLCtrl.h,
|
||||
GLPicking.cpp,
|
||||
Win32GLCtrl.cpp,
|
||||
X11GLCtrl.cpp,
|
||||
GtkGLCtrl.cpp,
|
||||
GLCtrl.cpp;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
NAMESPACE_UPP
|
||||
|
||||
#if defined(GUI_X11) || defined(GUI_WIN32)
|
||||
|
||||
void GLCtrl::GLPicking::InitPickMatrix()
|
||||
{
|
||||
if (_isPicking)
|
||||
|
|
@ -58,4 +60,6 @@ Vector<int> GLCtrl::GLPicking::ParseHits(GLuint *buffer, int hits)
|
|||
return result;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
|
|
|||
69
uppsrc/GLCtrl/GtkGLCtrl.cpp
Normal file
69
uppsrc/GLCtrl/GtkGLCtrl.cpp
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
#include "GLCtrl.h"
|
||||
|
||||
#ifdef GUI_GTK
|
||||
|
||||
#include <gtk/gtkgl.h>
|
||||
#include <gdk/gdkgl.h>
|
||||
#include <gdk/gdkglconfig.h>
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
GdkGLConfig *sGlconfig;
|
||||
|
||||
EXITBLOCK {
|
||||
if(sGlconfig)
|
||||
g_object_unref(G_OBJECT(sGlconfig));
|
||||
}
|
||||
|
||||
void GLCtrl::GLPaint()
|
||||
{
|
||||
WhenGLPaint();
|
||||
}
|
||||
|
||||
void GLCtrl::Paint(Draw& w)
|
||||
{
|
||||
Size sz = GetSize();
|
||||
|
||||
Ctrl *top = GetTopCtrl();
|
||||
if(!top)
|
||||
return;
|
||||
|
||||
GtkWindow *gtk = top->gtk();
|
||||
GdkWindow *win = top->gdk();
|
||||
|
||||
if(sz.cx <= 0 || sz.cy <= 0 || !win || !gtk)
|
||||
return;
|
||||
|
||||
ONCELOCK {
|
||||
sGlconfig = gdk_gl_config_new_by_mode ((GdkGLConfigMode)(GDK_GL_MODE_RGB|GDK_GL_MODE_DEPTH|GDK_GL_MODE_SINGLE));
|
||||
}
|
||||
|
||||
GdkPixmap *pixmap = gdk_pixmap_new(win, sz.cx, sz.cy, -1);
|
||||
if(pixmap) {
|
||||
GdkGLDrawable *gldrawable = GDK_GL_DRAWABLE(gdk_pixmap_set_gl_capability(pixmap, sGlconfig, NULL));
|
||||
if(gldrawable) {
|
||||
GdkGLContext *glcontext = gdk_gl_context_new(gldrawable, NULL, FALSE, GDK_GL_RGBA_TYPE);
|
||||
if(glcontext) {
|
||||
if(gdk_gl_drawable_gl_begin(gldrawable, glcontext)) {
|
||||
glViewport(0, 0, sz.cx, sz.cy);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
GLPaint();
|
||||
glFlush ();
|
||||
gdk_gl_drawable_gl_end(gldrawable);
|
||||
|
||||
Rect r = GetScreenView() - GetTopCtrl()->GetScreenView().TopLeft();
|
||||
GtkWidget *widget = GTK_WIDGET(gtk);
|
||||
gdk_draw_drawable(win, widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
|
||||
pixmap, 0, 0, r.left, r.top, r.GetWidth(), r.GetHeight());
|
||||
}
|
||||
g_object_unref(G_OBJECT(glcontext));
|
||||
}
|
||||
g_object_unref(G_OBJECT(gldrawable));
|
||||
}
|
||||
g_object_unref(G_OBJECT(pixmap));
|
||||
}
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue