From: slack Date: Sun, 10 Jan 2010 17:29:40 +0000 (+0100) Subject: Initial commit. Qt + OGL init X-Git-Url: http://slack.codemaniacs.com/git/?a=commitdiff_plain;h=f77466a754e682ca354104ee87a31ac5c42f598f;p=md5view.git Initial commit. Qt + OGL init --- f77466a754e682ca354104ee87a31ac5c42f598f diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4aaff0a --- /dev/null +++ b/Makefile @@ -0,0 +1,224 @@ +############################################################################# +# Makefile for building: md5view +# Generated by qmake (2.01a) (Qt 4.5.2) on: Sun Jan 10 04:17:42 2010 +# Project: md5view.pro +# Template: app +# Command: /usr/bin/qmake-qt4 -spec /usr/share/qt4/mkspecs/linux-g++ -unix CONFIG+=debug -o Makefile md5view.pro +############################################################################# + +####### Compiler, tools and options + +CC = gcc +CXX = g++ +DEFINES = -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED +CFLAGS = -pipe -g -Wall -W -D_REENTRANT $(DEFINES) +CXXFLAGS = -pipe -g -Wall -W -D_REENTRANT $(DEFINES) +INCPATH = -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtOpenGL -I/usr/include/qt4 -I/usr/X11R6/include -I. -I. +LINK = g++ +LFLAGS = +LIBS = $(SUBLIBS) -L/usr/lib -L/usr/X11R6/lib -lQtOpenGL -lQtGui -lQtCore -lGLU -lGL -lpthread +AR = ar cqs +RANLIB = +QMAKE = /usr/bin/qmake-qt4 +TAR = tar -cf +COMPRESS = gzip -9f +COPY = cp -f +SED = sed +COPY_FILE = $(COPY) +COPY_DIR = $(COPY) -r +INSTALL_FILE = install -m 644 -p +INSTALL_DIR = $(COPY_DIR) +INSTALL_PROGRAM = install -m 755 -p +DEL_FILE = rm -f +SYMLINK = ln -sf +DEL_DIR = rmdir +MOVE = mv -f +CHK_DIR_EXISTS= test -d +MKDIR = mkdir -p + +####### Output directory + +OBJECTS_DIR = ./ + +####### Files + +SOURCES = main.cpp \ + mainwindow.cpp \ + viewerwidget.cpp moc_mainwindow.cpp +OBJECTS = main.o \ + mainwindow.o \ + viewerwidget.o \ + moc_mainwindow.o +DIST = /usr/share/qt4/mkspecs/common/g++.conf \ + /usr/share/qt4/mkspecs/common/unix.conf \ + /usr/share/qt4/mkspecs/common/linux.conf \ + /usr/share/qt4/mkspecs/qconfig.pri \ + /usr/share/qt4/mkspecs/features/qt_functions.prf \ + /usr/share/qt4/mkspecs/features/qt_config.prf \ + /usr/share/qt4/mkspecs/features/exclusive_builds.prf \ + /usr/share/qt4/mkspecs/features/default_pre.prf \ + /usr/share/qt4/mkspecs/features/debug.prf \ + /usr/share/qt4/mkspecs/features/default_post.prf \ + /usr/share/qt4/mkspecs/features/warn_on.prf \ + /usr/share/qt4/mkspecs/features/qt.prf \ + /usr/share/qt4/mkspecs/features/unix/opengl.prf \ + /usr/share/qt4/mkspecs/features/unix/thread.prf \ + /usr/share/qt4/mkspecs/features/moc.prf \ + /usr/share/qt4/mkspecs/features/resources.prf \ + /usr/share/qt4/mkspecs/features/uic.prf \ + /usr/share/qt4/mkspecs/features/yacc.prf \ + /usr/share/qt4/mkspecs/features/lex.prf \ + /usr/share/qt4/mkspecs/features/include_source_dir.prf \ + md5view.pro +QMAKE_TARGET = md5view +DESTDIR = +TARGET = md5view + +first: all +####### Implicit rules + +.SUFFIXES: .o .c .cpp .cc .cxx .C + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cc.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cxx.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.C.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.c.o: + $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" + +####### Build rules + +all: Makefile $(TARGET) + +$(TARGET): ui_mainwindow.h $(OBJECTS) + $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS) + +Makefile: md5view.pro /usr/share/qt4/mkspecs/linux-g++/qmake.conf /usr/share/qt4/mkspecs/common/g++.conf \ + /usr/share/qt4/mkspecs/common/unix.conf \ + /usr/share/qt4/mkspecs/common/linux.conf \ + /usr/share/qt4/mkspecs/qconfig.pri \ + /usr/share/qt4/mkspecs/features/qt_functions.prf \ + /usr/share/qt4/mkspecs/features/qt_config.prf \ + /usr/share/qt4/mkspecs/features/exclusive_builds.prf \ + /usr/share/qt4/mkspecs/features/default_pre.prf \ + /usr/share/qt4/mkspecs/features/debug.prf \ + /usr/share/qt4/mkspecs/features/default_post.prf \ + /usr/share/qt4/mkspecs/features/warn_on.prf \ + /usr/share/qt4/mkspecs/features/qt.prf \ + /usr/share/qt4/mkspecs/features/unix/opengl.prf \ + /usr/share/qt4/mkspecs/features/unix/thread.prf \ + /usr/share/qt4/mkspecs/features/moc.prf \ + /usr/share/qt4/mkspecs/features/resources.prf \ + /usr/share/qt4/mkspecs/features/uic.prf \ + /usr/share/qt4/mkspecs/features/yacc.prf \ + /usr/share/qt4/mkspecs/features/lex.prf \ + /usr/share/qt4/mkspecs/features/include_source_dir.prf \ + /usr/lib/libQtOpenGL.prl \ + /usr/lib/libQtGui.prl \ + /usr/lib/libQtCore.prl + $(QMAKE) -spec /usr/share/qt4/mkspecs/linux-g++ -unix CONFIG+=debug -o Makefile md5view.pro +/usr/share/qt4/mkspecs/common/g++.conf: +/usr/share/qt4/mkspecs/common/unix.conf: +/usr/share/qt4/mkspecs/common/linux.conf: +/usr/share/qt4/mkspecs/qconfig.pri: +/usr/share/qt4/mkspecs/features/qt_functions.prf: +/usr/share/qt4/mkspecs/features/qt_config.prf: +/usr/share/qt4/mkspecs/features/exclusive_builds.prf: +/usr/share/qt4/mkspecs/features/default_pre.prf: +/usr/share/qt4/mkspecs/features/debug.prf: +/usr/share/qt4/mkspecs/features/default_post.prf: +/usr/share/qt4/mkspecs/features/warn_on.prf: +/usr/share/qt4/mkspecs/features/qt.prf: +/usr/share/qt4/mkspecs/features/unix/opengl.prf: +/usr/share/qt4/mkspecs/features/unix/thread.prf: +/usr/share/qt4/mkspecs/features/moc.prf: +/usr/share/qt4/mkspecs/features/resources.prf: +/usr/share/qt4/mkspecs/features/uic.prf: +/usr/share/qt4/mkspecs/features/yacc.prf: +/usr/share/qt4/mkspecs/features/lex.prf: +/usr/share/qt4/mkspecs/features/include_source_dir.prf: +/usr/lib/libQtOpenGL.prl: +/usr/lib/libQtGui.prl: +/usr/lib/libQtCore.prl: +qmake: FORCE + @$(QMAKE) -spec /usr/share/qt4/mkspecs/linux-g++ -unix CONFIG+=debug -o Makefile md5view.pro + +dist: + @$(CHK_DIR_EXISTS) .tmp/md5view1.0.0 || $(MKDIR) .tmp/md5view1.0.0 + $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/md5view1.0.0/ && $(COPY_FILE) --parents mainwindow.h viewerwidget.h .tmp/md5view1.0.0/ && $(COPY_FILE) --parents main.cpp mainwindow.cpp viewerwidget.cpp .tmp/md5view1.0.0/ && $(COPY_FILE) --parents mainwindow.ui .tmp/md5view1.0.0/ && (cd `dirname .tmp/md5view1.0.0` && $(TAR) md5view1.0.0.tar md5view1.0.0 && $(COMPRESS) md5view1.0.0.tar) && $(MOVE) `dirname .tmp/md5view1.0.0`/md5view1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/md5view1.0.0 + + +clean:compiler_clean + -$(DEL_FILE) $(OBJECTS) + -$(DEL_FILE) *~ core *.core + + +####### Sub-libraries + +distclean: clean + -$(DEL_FILE) $(TARGET) + -$(DEL_FILE) Makefile + + +mocclean: compiler_moc_header_clean compiler_moc_source_clean + +mocables: compiler_moc_header_make_all compiler_moc_source_make_all + +compiler_moc_header_make_all: moc_mainwindow.cpp +compiler_moc_header_clean: + -$(DEL_FILE) moc_mainwindow.cpp +moc_mainwindow.cpp: mainwindow.h + /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) mainwindow.h -o moc_mainwindow.cpp + +compiler_rcc_make_all: +compiler_rcc_clean: +compiler_image_collection_make_all: qmake_image_collection.cpp +compiler_image_collection_clean: + -$(DEL_FILE) qmake_image_collection.cpp +compiler_moc_source_make_all: +compiler_moc_source_clean: +compiler_uic_make_all: ui_mainwindow.h +compiler_uic_clean: + -$(DEL_FILE) ui_mainwindow.h +ui_mainwindow.h: mainwindow.ui + /usr/bin/uic-qt4 mainwindow.ui -o ui_mainwindow.h + +compiler_yacc_decl_make_all: +compiler_yacc_decl_clean: +compiler_yacc_impl_make_all: +compiler_yacc_impl_clean: +compiler_lex_make_all: +compiler_lex_clean: +compiler_clean: compiler_moc_header_clean compiler_uic_clean + +####### Compile + +main.o: main.cpp mainwindow.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o main.cpp + +mainwindow.o: mainwindow.cpp mainwindow.h \ + ui_mainwindow.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o mainwindow.o mainwindow.cpp + +viewerwidget.o: viewerwidget.cpp viewerwidget.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o viewerwidget.o viewerwidget.cpp + +moc_mainwindow.o: moc_mainwindow.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_mainwindow.o moc_mainwindow.cpp + +####### Install + +install: FORCE + +uninstall: FORCE + +FORCE: + diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..6e7efd9 --- /dev/null +++ b/main.cpp @@ -0,0 +1,10 @@ +#include +#include "mainwindow.h" + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.show(); + return a.exec(); +} diff --git a/mainwindow.cpp b/mainwindow.cpp new file mode 100644 index 0000000..ea37e3f --- /dev/null +++ b/mainwindow.cpp @@ -0,0 +1,36 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); + viewer = new ViewerWidget(this); + viewer->setMinimumSize(800,600); + ui->horizontalLayout->addWidget(viewer); +} + +MainWindow::~MainWindow() +{ + delete ui; +} + +void MainWindow::writeLog(QString s) +{ + logString += s; + ui->textBrowser->setText(logString); +} + + +void MainWindow::changeEvent(QEvent *e) +{ + QMainWindow::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; + } +} diff --git a/mainwindow.h b/mainwindow.h new file mode 100644 index 0000000..a42a5ed --- /dev/null +++ b/mainwindow.h @@ -0,0 +1,28 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include +#include +#include "viewerwidget.h" + +namespace Ui { + class MainWindow; +} + +class MainWindow : public QMainWindow { + Q_OBJECT +public: + MainWindow(QWidget *parent = 0); + ~MainWindow(); + void writeLog(QString s); + +protected: + void changeEvent(QEvent *e); + +private: + QString logString; + Ui::MainWindow *ui; + ViewerWidget *viewer; +}; + +#endif // MAINWINDOW_H diff --git a/mainwindow.ui b/mainwindow.ui new file mode 100644 index 0000000..e0acbec --- /dev/null +++ b/mainwindow.ui @@ -0,0 +1,84 @@ + + + MainWindow + + + + 0 + 0 + 1000 + 600 + + + + + 1000 + 600 + + + + MainWindow + + + + + + + 0 + + + + + + 200 + 0 + + + + + + + + + + + + 0 + 0 + 1000 + 24 + + + + + File + + + + + + + + + TopToolBarArea + + + false + + + + + + Open + + + + + Quit + + + + + + + diff --git a/md5view.pro b/md5view.pro new file mode 100644 index 0000000..99d63ef --- /dev/null +++ b/md5view.pro @@ -0,0 +1,12 @@ +# ------------------------------------------------- +# Project created by QtCreator 2010-01-10T03:28:19 +# ------------------------------------------------- +QT += opengl +TARGET = md5view +TEMPLATE = app +SOURCES += main.cpp \ + mainwindow.cpp \ + viewerwidget.cpp +HEADERS += mainwindow.h \ + viewerwidget.h +FORMS += mainwindow.ui diff --git a/md5view.pro.user b/md5view.pro.user new file mode 100644 index 0000000..91dadb7 --- /dev/null +++ b/md5view.pro.user @@ -0,0 +1,243 @@ + + + + RunConfiguration0-BaseEnvironmentBase + 2 + + + RunConfiguration0-CommandLineArguments + + + + RunConfiguration0-ProFile + md5view.pro + + + RunConfiguration0-RunConfiguration.name + md5view + + + RunConfiguration0-UseDyldImageSuffix + false + + + RunConfiguration0-UseTerminal + false + + + RunConfiguration0-UserEnvironmentChanges + + + + RunConfiguration0-UserSetName + false + + + RunConfiguration0-UserSetWorkingDirectory + false + + + RunConfiguration0-UserWorkingDirectory + + + + RunConfiguration0-type + Qt4ProjectManager.Qt4RunConfiguration + + + activeRunConfiguration + 0 + + + activebuildconfiguration + Debug + + + buildConfiguration-Debug + + Debug + 0 + 0 + + 2 + + + + buildConfiguration-Release + + Release + 0 + + 0 + + + + buildconfiguration-Debug-buildstep0 + + Debug + + DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-Dj3Bbe55NG,guid=c59e58cab9ff6389416a749d4b491a91 + DESKTOP_SESSION=gnome + DISPLAY=:0.0 + GDMSESSION=gnome + GDM_KEYBOARD_LAYOUT=es + GDM_LANG=es_ES.UTF-8 + GNOME_DESKTOP_SESSION_ID=this-is-deprecated + GNOME_KEYRING_PID=2234 + GNOME_KEYRING_SOCKET=/tmp/keyring-iuKvkY/socket + GTK_MODULES=canberra-gtk-module + GTK_RC_FILES=/etc/gtk/gtkrc:/home/slack/.gtkrc-1.2-gnome2 + HOME=/home/slack + LANG=es_ES.UTF-8 + LANGUAGE=es_ES.UTF-8 + LD_LIBRARY_PATH=/home/slack/qtcreator-1.3.0/lib/qtcreator: + LOGNAME=slack + ORBIT_SOCKETDIR=/tmp/orbit-slack + PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/usr/games + PWD=/home/slack + QTDIR=/usr/share/qt4 + SESSION_MANAGER=local/ommadawn:@/tmp/.ICE-unix/2249,unix/ommadawn:/tmp/.ICE-unix/2249 + SHELL=/bin/bash + SPEECHD_PORT=7560 + SSH_AGENT_PID=2300 + SSH_AUTH_SOCK=/tmp/keyring-iuKvkY/socket.ssh + USER=slack + USERNAME=slack + XAUTHORITY=/var/run/gdm/auth-for-slack-dbUjQ9/database + XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/ + XDG_SESSION_COOKIE=b95e9de5c0255c87d4458400462bf263-1263082128.724084-492310790 + + + /home/slack/md5view/md5view.pro + -spec + linux-g++ + -r + CONFIG+=debug + + /usr/bin/qmake-qt4 + false + /home/slack/md5view + + + + buildconfiguration-Debug-buildstep1 + + Debug + + DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-Dj3Bbe55NG,guid=c59e58cab9ff6389416a749d4b491a91 + DESKTOP_SESSION=gnome + DISPLAY=:0.0 + GDMSESSION=gnome + GDM_KEYBOARD_LAYOUT=es + GDM_LANG=es_ES.UTF-8 + GNOME_DESKTOP_SESSION_ID=this-is-deprecated + GNOME_KEYRING_PID=2234 + GNOME_KEYRING_SOCKET=/tmp/keyring-iuKvkY/socket + GTK_MODULES=canberra-gtk-module + GTK_RC_FILES=/etc/gtk/gtkrc:/home/slack/.gtkrc-1.2-gnome2 + HOME=/home/slack + LANG=es_ES.UTF-8 + LANGUAGE=es_ES.UTF-8 + LD_LIBRARY_PATH=/home/slack/qtcreator-1.3.0/lib/qtcreator: + LOGNAME=slack + ORBIT_SOCKETDIR=/tmp/orbit-slack + PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/usr/games + PWD=/home/slack + QTDIR=/usr/share/qt4 + SESSION_MANAGER=local/ommadawn:@/tmp/.ICE-unix/2249,unix/ommadawn:/tmp/.ICE-unix/2249 + SHELL=/bin/bash + SPEECHD_PORT=7560 + SSH_AGENT_PID=2300 + SSH_AUTH_SOCK=/tmp/keyring-iuKvkY/socket.ssh + USER=slack + USERNAME=slack + XAUTHORITY=/var/run/gdm/auth-for-slack-dbUjQ9/database + XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/ + XDG_SESSION_COOKIE=b95e9de5c0255c87d4458400462bf263-1263082128.724084-492310790 + + false + + -w + + /usr/bin/make + true + /home/slack/md5view + + + + buildconfiguration-Debug-cleanstep0 + + Debug + true + + clean + + + + + buildconfiguration-Release-buildstep0 + + Release + + + + buildconfiguration-Release-buildstep1 + + Release + + + + buildconfiguration-Release-cleanstep0 + + Release + + + + buildconfigurations + + Debug + Release + + + + buildstep0 + + + + + + + buildstep1 + + + + + + buildsteps + + trolltech.qt4projectmanager.qmake + trolltech.qt4projectmanager.make + + + + cleanstep0 + + + true + + + + cleansteps + + trolltech.qt4projectmanager.make + + + + defaultFileEncoding + System + + + project + + + diff --git a/viewerwidget.cpp b/viewerwidget.cpp new file mode 100644 index 0000000..7856195 --- /dev/null +++ b/viewerwidget.cpp @@ -0,0 +1,30 @@ +#include "viewerwidget.h" +#include "mainwindow.h" + +ViewerWidget::ViewerWidget(MainWindow *parent): + QGLWidget(parent) +{ + mainWindow = parent; +} + +void ViewerWidget::initializeGL() +{ + mainWindow->writeLog("Initializing...\n"); + if (context()->format().openGLVersionFlags() & QGLFormat::OpenGL_Version_2_1) + mainWindow->writeLog("OpenGL 2.1 is available :)\n"); + // Set up the rendering context, define display lists etc.: + glClearColor(0.0, 0.0, 0.0, 0.0); + glEnable(GL_DEPTH_TEST); +} + +void ViewerWidget::resizeGL(int w, int h) +{ + // setup viewport, projection etc.: + glViewport(0, 0, (GLint)w, (GLint)h); +} + +void ViewerWidget::paintGL() +{ + // draw the scene: + glClear(GL_COLOR_BUFFER_BIT); +} diff --git a/viewerwidget.h b/viewerwidget.h new file mode 100644 index 0000000..916809f --- /dev/null +++ b/viewerwidget.h @@ -0,0 +1,23 @@ +#ifndef VIEWERWIDGET_H +#define VIEWERWIDGET_H + +#include + +class MainWindow; + +class ViewerWidget : public QGLWidget +{ +public: + ViewerWidget(MainWindow *parent); + +protected: + void initializeGL(); + void resizeGL(int w, int h); + void paintGL(); + +private: + MainWindow *mainWindow; + +}; + +#endif // VIEWERWIDGET_H