Compare commits
No commits in common. "dev" and "master" have entirely different histories.
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -1,3 +0,0 @@
|
|||||||
[submodule "shimatta-opengl"]
|
|
||||||
path = shimatta-opengl
|
|
||||||
url = ssh://git@git.shimatta.de/mhu/shimatta-opengl.git
|
|
@ -3,4 +3,3 @@ project(gtk-graph-view-dev)
|
|||||||
|
|
||||||
add_subdirectory(lib)
|
add_subdirectory(lib)
|
||||||
add_subdirectory(app)
|
add_subdirectory(app)
|
||||||
add_subdirectory(shimatta-opengl)
|
|
||||||
|
@ -5,5 +5,5 @@ aux_source_directory("src" SRC_DIR)
|
|||||||
|
|
||||||
add_executable(${PROJECT_NAME} ${SRC_DIR})
|
add_executable(${PROJECT_NAME} ${SRC_DIR})
|
||||||
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||||
target_link_libraries(${PROJECT_NAME} gtkgraphview shimatta-opengl)
|
target_link_libraries(${PROJECT_NAME} gtkgraphview)
|
||||||
add_dependencies(${PROJECT_NAME} gtkgraphview)
|
add_dependencies(${PROJECT_NAME} gtkgraphview)
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <gtk-graph-view.h>
|
#include <gtk-graph-view.h>
|
||||||
#include <shimatta-opengl-program.h>
|
|
||||||
|
|
||||||
static gboolean main_window_delete_event(GtkWidget *window, gpointer user)
|
static gboolean main_window_delete_event(GtkWidget *window, gpointer user)
|
||||||
{
|
{
|
||||||
|
@ -9,26 +9,9 @@ pkg_check_modules(EPOXY REQUIRED epoxy)
|
|||||||
add_compile_options(-Wall -Wextra -Wold-style-declaration -Wuninitialized -Wmaybe-uninitialized -Wunused-parameter)
|
add_compile_options(-Wall -Wextra -Wold-style-declaration -Wuninitialized -Wmaybe-uninitialized -Wunused-parameter)
|
||||||
aux_source_directory("src" SRC_DIR)
|
aux_source_directory("src" SRC_DIR)
|
||||||
|
|
||||||
IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
||||||
message("${Yellow}Debug mode for shader locations used!${ColorReset}")
|
|
||||||
add_definitions(-DSHADER_DIRECTORY=\"${CMAKE_CURRENT_BINARY_DIR}/shaders\")
|
|
||||||
message("${BoldMagenta}${CMAKE_CURRENT_BINARY_DIR}/shaders used as shader directory${ColorReset}")
|
|
||||||
else(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
||||||
message("Global shader directory used. Make sure files in /usr/share/gtk-graph-view/shaders are available")
|
|
||||||
add_definitions(-DSHADER_DIRECTORY=\"/usr/share/gtk-graph-view/shaders\")
|
|
||||||
ENDIF(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
||||||
|
|
||||||
|
|
||||||
add_library(${PROJECT_NAME} SHARED ${SRC_DIR})
|
add_library(${PROJECT_NAME} SHARED ${SRC_DIR})
|
||||||
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||||
target_include_directories(${PROJECT_NAME} PRIVATE ${EPOXY_INCLUDE_DIRS})
|
target_include_directories(${PROJECT_NAME} PRIVATE ${EPOXY_INCLUDE_DIRS})
|
||||||
target_link_libraries(${PROJECT_NAME} PUBLIC ${GLIB_LDFLAGS} ${GTK3_LDFLAGS} ${EPOXY_LDFLAGS} shimatta-opengl)
|
target_link_libraries(${PROJECT_NAME} PUBLIC ${GLIB_LDFLAGS} ${GTK3_LDFLAGS} ${EPOXY_LDFLAGS})
|
||||||
target_link_directories(${PROJECT_NAME} PUBLIC ${GLIB_LINK_DIRS} ${GTK3_LINK_DIRS} ${EPOXY_LINK_DIRS})
|
target_link_directories(${PROJECT_NAME} PUBLIC ${GLIB_LINK_DIRS} ${GTK3_LINK_DIRS} ${EPOXY_LINK_DIRS})
|
||||||
target_include_directories(${PROJECT_NAME} PUBLIC ${GLIB_INCLUDE_DIRS} ${GTK3_INCLUDE_DIRS})
|
target_include_directories(${PROJECT_NAME} PUBLIC ${GLIB_INCLUDE_DIRS} ${GTK3_INCLUDE_DIRS})
|
||||||
|
|
||||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/shaders/passthrough3d.vertex.glsl"
|
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/shaders/passthrough3d.vertex.glsl" COPYONLY)
|
|
||||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/shaders/monochrome.fragment.glsl"
|
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/shaders/monochrome.fragment.glsl" COPYONLY)
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of GtkGraphView.
|
* This file is part of GtkGraphView.
|
||||||
*
|
*
|
||||||
* GtkGraphView is free software: you can redistribute it and/or modify
|
* Foobar is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License version 2 as
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
* published by the Free Software Foundation.
|
* published by the Free Software Foundation.
|
||||||
*
|
*
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
#version 330 core
|
|
||||||
|
|
||||||
out vec4 fragmentColor;
|
|
||||||
|
|
||||||
uniform vec3 color;
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
fragmentColor = vec4(color.r, color.g, color.b, 1.0);
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
#version 330 core
|
|
||||||
|
|
||||||
layout (location = 0) in vec2 inputVertex;
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
gl_Position = vec4(inputVertex.x, inputVertex.y, 0.0, 1.0);
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
#version 330 core
|
|
||||||
|
|
||||||
layout (location = 0) in vec3 inputVertex;
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
gl_Position = vec4(inputVertex.x, inputVertex.y, inputVertex.z, 1.0);
|
|
||||||
}
|
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of GtkGraphView.
|
* This file is part of GtkGraphView.
|
||||||
*
|
*
|
||||||
* GtkGraphView is free software: you can redistribute it and/or modify
|
* Foobar is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License version 2 as
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
* published by the Free Software Foundation.
|
* published by the Free Software Foundation.
|
||||||
*
|
*
|
||||||
@ -16,12 +16,6 @@
|
|||||||
|
|
||||||
#include <gtk-graph-view.h>
|
#include <gtk-graph-view.h>
|
||||||
#include <epoxy/gl.h>
|
#include <epoxy/gl.h>
|
||||||
#include <shimatta-opengl-program.h>
|
|
||||||
#include <shimatta-opengl-colored-triangle.h>
|
|
||||||
|
|
||||||
#ifndef SHADER_DIRECTORY
|
|
||||||
#define SHADER_DIRECTORY "/usr/share/gtk-graph-view/shaders"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct _GtkGraphView {
|
struct _GtkGraphView {
|
||||||
GtkBox super;
|
GtkBox super;
|
||||||
@ -30,13 +24,10 @@ struct _GtkGraphView {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
/**
|
/**
|
||||||
* @brief The gl area displaying the graph view.
|
* @brief The gl area displaying the graph view.
|
||||||
* @note This variable is not referenced, because the gl_area is tightly bound to the GraphView widget itself.
|
* @note This variable is not referenced, because the gl_area is tightly bound to the GrapgView widget itself.
|
||||||
*/
|
*/
|
||||||
GtkWidget *gl_area;
|
GtkWidget *gl_area;
|
||||||
GdkRGBA background_color;
|
GdkRGBA background_color;
|
||||||
ShimattaOpenglProgram *passthrough_prog;
|
|
||||||
ShimattaOpenglGraphics *test;
|
|
||||||
|
|
||||||
} GtkGraphViewPrivate;
|
} GtkGraphViewPrivate;
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_PRIVATE(GtkGraphView, gtk_graph_view, GTK_TYPE_BOX)
|
G_DEFINE_TYPE_WITH_PRIVATE(GtkGraphView, gtk_graph_view, GTK_TYPE_BOX)
|
||||||
@ -67,9 +58,6 @@ static gboolean gl_render(GtkGLArea *gl_area, GdkGLContext *context, GtkGraphVie
|
|||||||
|
|
||||||
gl_area_set_clear_color(gl_area, &priv->background_color);
|
gl_area_set_clear_color(gl_area, &priv->background_color);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
shimatta_opengl_graphics_draw(priv->test);
|
|
||||||
|
|
||||||
glFlush();
|
glFlush();
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -102,14 +90,6 @@ static void gtk_graph_view_set_property(GObject *obj, guint property_id, const G
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gtk_graph_view_dispose(GObject *obj)
|
|
||||||
{
|
|
||||||
GtkGraphView *graph_view = GTK_GRAPH_VIEW(obj);
|
|
||||||
GtkGraphViewPrivate *priv = gtk_graph_view_get_instance_private(graph_view);
|
|
||||||
|
|
||||||
G_OBJECT_CLASS(gtk_graph_view_parent_class)->dispose(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
static GParamSpec *gtk_graph_view_properties[N_PROPERTIES] = {NULL};
|
static GParamSpec *gtk_graph_view_properties[N_PROPERTIES] = {NULL};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -123,7 +103,6 @@ static void gtk_graph_view_class_init(GtkGraphViewClass *klass)
|
|||||||
oclass = G_OBJECT_CLASS(klass);
|
oclass = G_OBJECT_CLASS(klass);
|
||||||
oclass->set_property = gtk_graph_view_set_property;
|
oclass->set_property = gtk_graph_view_set_property;
|
||||||
oclass->get_property = gtk_graph_view_get_property;
|
oclass->get_property = gtk_graph_view_get_property;
|
||||||
oclass->dispose = gtk_graph_view_dispose;
|
|
||||||
|
|
||||||
gtk_graph_view_properties[PROP_BG_COLOR] =
|
gtk_graph_view_properties[PROP_BG_COLOR] =
|
||||||
g_param_spec_boxed("background-color", "background color", "Background color of Graph View",
|
g_param_spec_boxed("background-color", "background color", "Background color of Graph View",
|
||||||
@ -132,50 +111,6 @@ static void gtk_graph_view_class_init(GtkGraphViewClass *klass)
|
|||||||
g_object_class_install_properties(oclass, N_PROPERTIES, gtk_graph_view_properties);
|
g_object_class_install_properties(oclass, N_PROPERTIES, gtk_graph_view_properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gl_area_realize(GtkGLArea *area, GtkGraphView *graph_view)
|
|
||||||
{
|
|
||||||
GtkGraphViewPrivate *priv;
|
|
||||||
char error_text[512];
|
|
||||||
int status;
|
|
||||||
const vec3 color = {1.0f, 0.0f, 0.0f};
|
|
||||||
const vec3 vertecies[3] = {
|
|
||||||
{-0.5f, 0.0f, 0.0f},
|
|
||||||
{0.5f, 0.0f, 0.0f},
|
|
||||||
{0.0, 0.5f, 0.0f},
|
|
||||||
};
|
|
||||||
|
|
||||||
gtk_gl_area_make_current(area);
|
|
||||||
priv = gtk_graph_view_get_instance_private(graph_view);
|
|
||||||
|
|
||||||
priv->passthrough_prog = shimatta_opengl_program_new_from_file(SHADER_DIRECTORY"/passthrough3d.vertex.glsl",
|
|
||||||
NULL,
|
|
||||||
SHADER_DIRECTORY"/monochrome.fragment.glsl");
|
|
||||||
status = shimatta_opengl_program_compile(priv->passthrough_prog, error_text, sizeof(error_text));
|
|
||||||
if (status) {
|
|
||||||
g_warning("Error compiling shader: %s", error_text);
|
|
||||||
}
|
|
||||||
|
|
||||||
priv->test = shimatta_opengl_colored_triangle_new(priv->passthrough_prog, color, vertecies);
|
|
||||||
shimatta_opengl_graphics_realize(priv->test);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void gl_area_unrealize(GtkGLArea *area, GtkGraphView *graph_view)
|
|
||||||
{
|
|
||||||
GtkGraphViewPrivate *priv;
|
|
||||||
|
|
||||||
gtk_gl_area_make_current(area);
|
|
||||||
priv = gtk_graph_view_get_instance_private(graph_view);
|
|
||||||
|
|
||||||
g_clear_object(&priv->passthrough_prog);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void gl_area_resize(GtkGLArea *area, GtkGraphView *graph_view)
|
|
||||||
{
|
|
||||||
(void)graph_view;
|
|
||||||
|
|
||||||
gtk_gl_area_queue_render(area);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Init a new GtkGraphView GObject
|
* @brief Init a new GtkGraphView GObject
|
||||||
* @param obj Object to initialize
|
* @param obj Object to initialize
|
||||||
@ -189,9 +124,6 @@ static void gtk_graph_view_init(GtkGraphView *obj)
|
|||||||
/* Create new GTK GL_Area as only child of the box */
|
/* Create new GTK GL_Area as only child of the box */
|
||||||
priv->gl_area = gtk_gl_area_new();
|
priv->gl_area = gtk_gl_area_new();
|
||||||
g_signal_connect(priv->gl_area, "render", G_CALLBACK(gl_render), obj);
|
g_signal_connect(priv->gl_area, "render", G_CALLBACK(gl_render), obj);
|
||||||
g_signal_connect(priv->gl_area, "realize", G_CALLBACK(gl_area_realize), obj);
|
|
||||||
g_signal_connect(priv->gl_area, "unrealize", G_CALLBACK(gl_area_unrealize), obj);
|
|
||||||
g_signal_connect(priv->gl_area, "resize", G_CALLBACK(gl_area_resize), obj);
|
|
||||||
gtk_container_add(GTK_CONTAINER(obj), priv->gl_area);
|
gtk_container_add(GTK_CONTAINER(obj), priv->gl_area);
|
||||||
gtk_box_set_child_packing(GTK_BOX(obj), priv->gl_area, TRUE, TRUE, 0, GTK_PACK_START);
|
gtk_box_set_child_packing(GTK_BOX(obj), priv->gl_area, TRUE, TRUE, 0, GTK_PACK_START);
|
||||||
gtk_widget_show(priv->gl_area);
|
gtk_widget_show(priv->gl_area);
|
||||||
|
@ -1 +0,0 @@
|
|||||||
Subproject commit 97ac18d3d2c8c072cd51237cf5348e21c396da99
|
|
Loading…
Reference in New Issue
Block a user