From 7bef996a8ed2e2e347e487fcc36a21bbe91b3574 Mon Sep 17 00:00:00 2001 From: polos Date: Tue, 29 Nov 2016 13:54:09 +0100 Subject: [PATCH] some revisions --- examples/8-OpenGL/main-window.lisp | 36 ++---------------------------- examples/M-modules/sql/sqlite.lisp | 1 + helper/generate.lisp | 5 ++++- src/ecl_fun.cpp | 5 ++++- src/gen/_main_q_methods.h | 4 ++-- 5 files changed, 13 insertions(+), 38 deletions(-) diff --git a/examples/8-OpenGL/main-window.lisp b/examples/8-OpenGL/main-window.lisp index 5352318..d1f8e5e 100644 --- a/examples/8-OpenGL/main-window.lisp +++ b/examples/8-OpenGL/main-window.lisp @@ -51,17 +51,9 @@ (|setWindowTitle| (tr "Grabber")) (|resize| (list 400 300))))) -(defun render-into-pixmap () - (let ((size (get-size))) - (when (every 'plusp size) - (set-pixmap (|grab| *gl-widget* (append '(0 0) size)))))) - (defun grab-frame-buffer () (set-pixmap (|fromImage.QPixmap| (|grabFramebuffer| *gl-widget*)))) -(defun clear-pixmap () - (set-pixmap (qnew "QPixmap"))) - (defun about () (|about.QMessageBox| *me* @@ -79,11 +71,9 @@ (file-menu (|addMenu| menu-bar (tr "&File"))) (help-menu (|addMenu| menu-bar (tr "&Help")))) ;; file menu - (add-action file-menu (tr "&Render into Pixmap...") "Ctrl+R" 'render-into-pixmap) - (add-action file-menu (tr "&Grab Frame Buffer") "Ctrl+G" 'grab-frame-buffer) - (add-action file-menu (tr "&Clear Pixmap") "Ctrl+L" 'clear-pixmap) + (add-action file-menu (tr "&Grab Frame Buffer") "Ctrl+G" 'grab-frame-buffer) (|addSeparator| file-menu) - (add-action file-menu (tr "E&xit") "Ctrl+Q" (lambda () (|close| *me*))) + (add-action file-menu (tr "E&xit") "Ctrl+Q" (lambda () (|close| *me*))) ;; help menu (add-action help-menu (tr "&About") nil 'about) (add-action help-menu (tr "About &Qt") nil (lambda () (|aboutQt| (qapp)))))) @@ -109,28 +99,6 @@ (setf (first size) (1- width))) (|resize| *pixmap-label* size))) -(defun get-size () - (let ((text (|getText.QInputDialog| - *me* - (tr "Grabber") - (tr "Enter pixmap size:") - |QLineEdit.Normal| - (format nil "~{~D~^ x ~}" (|size| *gl-widget*)) - nil))) ; ok - (if (qok) - (progn - (qlet ((reg-exp "QRegExp(QString)" "([0-9]+) *x *([0-9]+)")) - (flet ((cap (n) - (parse-integer (|cap| reg-exp n)))) - (when (|exactMatch| reg-exp text) - (let ((width (cap 1)) - (height (cap 2))) - (when (and (< 0 width 2048) - (< 0 height 2048)) - (return-from get-size (list width height))))))) - (|size| *gl-widget*)) - '(0 0)))) - (defun start () (ini) (x:do-with *me* |show| |raise|)) diff --git a/examples/M-modules/sql/sqlite.lisp b/examples/M-modules/sql/sqlite.lisp index ec76f3c..89501bb 100644 --- a/examples/M-modules/sql/sqlite.lisp +++ b/examples/M-modules/sql/sqlite.lisp @@ -12,6 +12,7 @@ "windowTitle" "sqlite")) (defun populate-db () + ;; dumb, just for this example; you normally want QSqlQuery (x:do-with (|exec| *database*) "CREATE TABLE friends ( id INT PRIMARY KEY, name VARCHAR(50), country INT )" "CREATE TABLE countries ( id INT PRIMARY KEY, country VARCHAR(50) )") diff --git a/helper/generate.lisp b/helper/generate.lisp index abb2c68..f38037e 100644 --- a/helper/generate.lisp +++ b/helper/generate.lisp @@ -110,6 +110,7 @@ (let ((enum (find #\: type))) (when (or (and (qt-class-p type) (not enum)) + (starts-with "GL" type) (not (or (string= "void" type) enum (upper-case-p (char type 0)) @@ -309,7 +310,8 @@ (defun add-namespace (name class) (unless (empty-string name) (if (and class - (string/= "Handle" name)) + (string/= "Handle" name) + (not (starts-with "GL" name))) (let ((1st (char name 0)) (templ (position #\< name))) (when templ @@ -1106,6 +1108,7 @@ "uchar" "uint" "ulong" + "GLuint" "QByteArray" "QChar" "QFileInfoList" diff --git a/src/ecl_fun.cpp b/src/ecl_fun.cpp index 28c6d91..a0be8b8 100644 --- a/src/ecl_fun.cpp +++ b/src/ecl_fun.cpp @@ -21,6 +21,7 @@ static StrList _cstring_buffer_; static const QMetaObject* staticQtMetaObject = QtMetaObject::get(); META_TYPE (T_bool_ok_pointer, bool*) +META_TYPE (T_GLuint, GLuint) META_TYPE (T_QFileInfo, QFileInfo) META_TYPE (T_QFileInfoList, QFileInfoList) META_TYPE (T_QGradient, QGradient) @@ -344,7 +345,7 @@ static T toUInt(cl_object l_num) { i = fixnnint(l_num); } return i; } -static int toUInt(cl_object l_num) { +static uint toUInt(cl_object l_num) { return toUInt(l_num); } template @@ -1198,6 +1199,7 @@ static MetaArg toMetaArg(const QByteArray& sType, cl_object l_arg) { else if(T_QVector_QTextLength == n) p = new QVector(toQTextLengthVector(l_arg)); else if(T_QVector_qreal == n) p = new QVector(toqrealVector(l_arg)); else if(T_WId == n) p = new ulong(toUInt(l_arg)); + else if(T_GLuint == n) p = new GLuint(toUInt(l_arg)); // module types else if((n >= LObjects::T_QHostAddress) && (n <= LObjects::T_QSslKey)) { @@ -1345,6 +1347,7 @@ cl_object to_lisp_arg(const MetaArg& arg) { else if(T_QVector_QTextLength == n) l_ret = from_qtextlengthvector(*(QVector*)p); else if(T_QVector_qreal == n) l_ret = from_qrealvector(*(QVector*)p); else if(T_WId == n) l_ret = ecl_make_unsigned_integer(*(ulong*)p); + else if(T_GLuint == n) l_ret = ecl_make_unsigned_integer(*(GLuint*)p); // module types else if((n >= LObjects::T_QHostAddress) && (n <= LObjects::T_QSslKey)) { diff --git a/src/gen/_main_q_methods.h b/src/gen/_main_q_methods.h index 0a261a0..4238790 100644 --- a/src/gen/_main_q_methods.h +++ b/src/gen/_main_q_methods.h @@ -3528,7 +3528,7 @@ class EQL_EXPORT Q122 : public Q216 { // QOpenGLWidget public: Q_INVOKABLE void* C(uint u, QWidget* x1 = 0, Qt::WindowFlags x2 = 0) { return new LOpenGLWidget(u, x1, x2); } Q_INVOKABLE QOpenGLContext* Mcontext(QOpenGLWidget* o) const { return o->context(); } - Q_INVOKABLE int MdefaultFramebufferObject(QOpenGLWidget* o) const { return o->defaultFramebufferObject(); } + Q_INVOKABLE GLuint MdefaultFramebufferObject(QOpenGLWidget* o) const { return o->defaultFramebufferObject(); } Q_INVOKABLE void MdoneCurrent(QOpenGLWidget* o) { o->doneCurrent(); } Q_INVOKABLE QSurfaceFormat Mformat(QOpenGLWidget* o) const { return o->format(); } Q_INVOKABLE QImage MgrabFramebuffer(QOpenGLWidget* o) { return o->grabFramebuffer(); } @@ -4375,7 +4375,7 @@ public: Q_INVOKABLE void* C(uint u, QOpenGLWindow::UpdateBehavior x1 = QOpenGLWindow::NoPartialUpdate, QWindow* x2 = 0) { return new LOpenGLWindow(u, x1, x2); } Q_INVOKABLE void* C(uint u, QOpenGLContext* x1, QOpenGLWindow::UpdateBehavior x2 = QOpenGLWindow::NoPartialUpdate, QWindow* x3 = 0) { return new LOpenGLWindow(u, x1, x2, x3); } Q_INVOKABLE QOpenGLContext* Mcontext(QOpenGLWindow* o) const { return o->context(); } - Q_INVOKABLE int MdefaultFramebufferObject(QOpenGLWindow* o) const { return o->defaultFramebufferObject(); } + Q_INVOKABLE GLuint MdefaultFramebufferObject(QOpenGLWindow* o) const { return o->defaultFramebufferObject(); } Q_INVOKABLE void MdoneCurrent(QOpenGLWindow* o) { o->doneCurrent(); } Q_INVOKABLE QImage MgrabFramebuffer(QOpenGLWindow* o) { return o->grabFramebuffer(); } Q_INVOKABLE bool MisValid(QOpenGLWindow* o) const { return o->isValid(); }