zoomedit: Added RenderArea with OpenGL support.
This commit is contained in:
parent
cbc867ee44
commit
761c681764
13 changed files with 877 additions and 322 deletions
|
@ -1,4 +1,4 @@
|
|||
noinst_LTLIBRARIES = libgui.la
|
||||
|
||||
libgui_la_SOURCES = Window.cpp
|
||||
libgui_la_SOURCES = Window.cpp RenderArea.cpp
|
||||
libgui_la_CPPFLAGS = $(glademm_CFLAGS) $(GTKGLEXT_CFLAGS)
|
|
@ -1,8 +1,8 @@
|
|||
# Makefile.in generated by automake 1.10 from Makefile.am.
|
||||
# Makefile.in generated by automake 1.10.1 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||
# 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
@ -43,9 +43,9 @@ CONFIG_HEADER = $(top_builddir)/src/config.h
|
|||
CONFIG_CLEAN_FILES =
|
||||
LTLIBRARIES = $(noinst_LTLIBRARIES)
|
||||
libgui_la_LIBADD =
|
||||
am_libgui_la_OBJECTS = libgui_la-Window.lo
|
||||
am_libgui_la_OBJECTS = libgui_la-Window.lo libgui_la-RenderArea.lo
|
||||
libgui_la_OBJECTS = $(am_libgui_la_OBJECTS)
|
||||
DEFAULT_INCLUDES = -I. -I$(top_builddir)/src@am__isrc@
|
||||
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
|
||||
depcomp = $(SHELL) $(top_srcdir)/depcomp
|
||||
am__depfiles_maybe = depfiles
|
||||
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
|
||||
|
@ -81,6 +81,7 @@ CXXFLAGS = @CXXFLAGS@
|
|||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DSYMUTIL = @DSYMUTIL@
|
||||
ECHO = @ECHO@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
|
@ -106,6 +107,7 @@ LTLIBOBJS = @LTLIBOBJS@
|
|||
MAINT = @MAINT@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MKDIR_P = @MKDIR_P@
|
||||
NMEDIT = @NMEDIT@
|
||||
OBJEXT = @OBJEXT@
|
||||
PACKAGE = @PACKAGE@
|
||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||
|
@ -175,7 +177,7 @@ target_alias = @target_alias@
|
|||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
noinst_LTLIBRARIES = libgui.la
|
||||
libgui_la_SOURCES = Window.cpp
|
||||
libgui_la_SOURCES = Window.cpp RenderArea.cpp
|
||||
libgui_la_CPPFLAGS = $(glademm_CFLAGS) $(GTKGLEXT_CFLAGS)
|
||||
all: all-am
|
||||
|
||||
|
@ -228,6 +230,7 @@ mostlyclean-compile:
|
|||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgui_la-RenderArea.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgui_la-Window.Plo@am__quote@
|
||||
|
||||
.cpp.o:
|
||||
|
@ -258,6 +261,13 @@ libgui_la-Window.lo: Window.cpp
|
|||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgui_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libgui_la-Window.lo `test -f 'Window.cpp' || echo '$(srcdir)/'`Window.cpp
|
||||
|
||||
libgui_la-RenderArea.lo: RenderArea.cpp
|
||||
@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgui_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libgui_la-RenderArea.lo -MD -MP -MF $(DEPDIR)/libgui_la-RenderArea.Tpo -c -o libgui_la-RenderArea.lo `test -f 'RenderArea.cpp' || echo '$(srcdir)/'`RenderArea.cpp
|
||||
@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/libgui_la-RenderArea.Tpo $(DEPDIR)/libgui_la-RenderArea.Plo
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='RenderArea.cpp' object='libgui_la-RenderArea.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgui_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libgui_la-RenderArea.lo `test -f 'RenderArea.cpp' || echo '$(srcdir)/'`RenderArea.cpp
|
||||
|
||||
mostlyclean-libtool:
|
||||
-rm -f *.lo
|
||||
|
||||
|
@ -269,8 +279,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
|
|||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
$(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
mkid -fID $$unique
|
||||
tags: TAGS
|
||||
|
||||
|
@ -282,8 +292,8 @@ TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
|||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
|
||||
test -n "$$unique" || unique=$$empty_fix; \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
|
@ -293,13 +303,12 @@ ctags: CTAGS
|
|||
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
tags=; \
|
||||
here=`pwd`; \
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|
||||
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
|
||||
$$tags $$unique
|
||||
|
|
53
src/Gui/RenderArea.cpp
Normal file
53
src/Gui/RenderArea.cpp
Normal file
|
@ -0,0 +1,53 @@
|
|||
#include "RenderArea.h"
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include <GL/gl.h>
|
||||
|
||||
namespace ZoomEdit {
|
||||
namespace Gui {
|
||||
|
||||
GdkGLConfig *RenderArea::glconfig = NULL;
|
||||
|
||||
RenderArea::RenderArea(BaseObjectType *cobject, const Glib::RefPtr<Gnome::Glade::Xml> &xml)
|
||||
: Gtk::DrawingArea(cobject) {
|
||||
if(!glconfig) {
|
||||
glconfig = gdk_gl_config_new_by_mode((GdkGLConfigMode)(GDK_GL_MODE_RGB | GDK_GL_MODE_DOUBLE));
|
||||
if(!glconfig) glconfig = gdk_gl_config_new_by_mode(GDK_GL_MODE_RGB); // Hmm, can't find double buffered config
|
||||
if(!glconfig) {
|
||||
std::cerr << "*** No appropriate OpenGL-capable visual found." << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
signal_realize().connect(sigc::mem_fun(this, &RenderArea::onRealize));
|
||||
|
||||
gtk_widget_set_gl_capability(GTK_WIDGET(cobject), glconfig, NULL, TRUE, GDK_GL_RGBA_TYPE);
|
||||
}
|
||||
|
||||
RenderArea::~RenderArea() {
|
||||
}
|
||||
|
||||
void RenderArea::onRealize() {
|
||||
GtkWidget *widget = GTK_WIDGET(gobj());
|
||||
GdkGLContext *context = gtk_widget_get_gl_context(widget);
|
||||
GdkGLDrawable *drawable = gtk_widget_get_gl_drawable(widget);
|
||||
|
||||
if(!gdk_gl_drawable_gl_begin(drawable, context))
|
||||
return;
|
||||
|
||||
glClearColor(0, 0, 0, 0);
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
glEnable(GL_POINT_SMOOTH);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
|
||||
gdk_gl_drawable_gl_end(drawable);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
25
src/Gui/RenderArea.h
Normal file
25
src/Gui/RenderArea.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
#ifndef ZOOMEDIT_GUI_RENDERAREA_H_
|
||||
#define ZOOMEDIT_GUI_RENDERAREA_H_
|
||||
|
||||
#include <gtkmm/drawingarea.h>
|
||||
#include <libglademm/xml.h>
|
||||
#include <gtk/gtkgl.h>
|
||||
|
||||
namespace ZoomEdit {
|
||||
namespace Gui {
|
||||
|
||||
class RenderArea : public Gtk::DrawingArea {
|
||||
public:
|
||||
RenderArea(BaseObjectType *cobject, const Glib::RefPtr<Gnome::Glade::Xml> &xml);
|
||||
virtual ~RenderArea();
|
||||
|
||||
private:
|
||||
static GdkGLConfig *glconfig;
|
||||
|
||||
void onRealize();
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif /*ZOOMEDIT_GUI_RENDERAREA_H_*/
|
|
@ -6,9 +6,13 @@ namespace Gui {
|
|||
Window::Window(BaseObjectType *cobject, const Glib::RefPtr<Gnome::Glade::Xml> &xml)
|
||||
: Gtk::Window(cobject) {
|
||||
xml->connect_clicked("MenuItemQuit", sigc::mem_fun(this, &Window::hide));
|
||||
|
||||
xml->get_widget_derived("RenderArea", renderArea);
|
||||
}
|
||||
|
||||
Window::~Window() {
|
||||
if(renderArea)
|
||||
delete renderArea;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,11 +3,15 @@
|
|||
|
||||
#include <gtkmm/window.h>
|
||||
#include <libglademm/xml.h>
|
||||
#include "RenderArea.h"
|
||||
|
||||
namespace ZoomEdit {
|
||||
namespace Gui {
|
||||
|
||||
class Window : public Gtk::Window {
|
||||
private:
|
||||
RenderArea *renderArea;
|
||||
|
||||
public:
|
||||
Window(BaseObjectType *cobject, const Glib::RefPtr<Gnome::Glade::Xml> &xml);
|
||||
virtual ~Window();
|
||||
|
|
|
@ -25,7 +25,7 @@ class Instance {
|
|||
|
||||
// Prevent shallow copy
|
||||
Instance(const Instance &o);
|
||||
Instance& operator=(const Instance &o);
|
||||
const Instance& operator=(const Instance &o);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
# Makefile.in generated by automake 1.10 from Makefile.am.
|
||||
# Makefile.in generated by automake 1.10.1 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||
# 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
@ -98,6 +98,7 @@ CXXFLAGS = @CXXFLAGS@
|
|||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DSYMUTIL = @DSYMUTIL@
|
||||
ECHO = @ECHO@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
|
@ -123,6 +124,7 @@ LTLIBOBJS = @LTLIBOBJS@
|
|||
MAINT = @MAINT@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MKDIR_P = @MKDIR_P@
|
||||
NMEDIT = @NMEDIT@
|
||||
OBJEXT = @OBJEXT@
|
||||
PACKAGE = @PACKAGE@
|
||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||
|
@ -255,8 +257,8 @@ install-binPROGRAMS: $(bin_PROGRAMS)
|
|||
|| test -f $$p1 \
|
||||
; then \
|
||||
f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
|
||||
echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
|
||||
$(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
|
||||
echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
|
||||
$(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
|
||||
else :; fi; \
|
||||
done
|
||||
|
||||
|
@ -417,8 +419,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
|
|||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
$(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
mkid -fID $$unique
|
||||
tags: TAGS
|
||||
|
||||
|
@ -443,8 +445,8 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
|
|||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
|
||||
test -n "$$unique" || unique=$$empty_fix; \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
|
@ -454,13 +456,12 @@ ctags: CTAGS
|
|||
CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
tags=; \
|
||||
here=`pwd`; \
|
||||
list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|
||||
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
|
||||
$$tags $$unique
|
||||
|
|
|
@ -1,18 +1,11 @@
|
|||
#include <gtkmm/main.h>
|
||||
//#include <gtk/gtkgl.h>
|
||||
#include <gtk/gtkgl.h>
|
||||
#include "Instance.h"
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
Gtk::Main gtk(&argc, &argv);
|
||||
//gtk_gl_init(&argc, &argv);
|
||||
|
||||
/*GdkGLConfig *glconfig = gdk_gl_config_new_by_mode((GdkGLConfigMode)(GDK_GL_MODE_RGB | GDK_GL_MODE_DOUBLE));
|
||||
if(!glconfig) glconfig = gdk_gl_config_new_by_mode(GDK_GL_MODE_RGB);
|
||||
if(!glconfig) {
|
||||
g_print("*** No appropriate OpenGL-capable visual found.\n");
|
||||
return 1;
|
||||
}*/
|
||||
gtk_gl_init(&argc, &argv);
|
||||
|
||||
if(!ZoomEdit::Instance::create())
|
||||
return 1;
|
||||
|
|
Reference in a new issue