Compare commits

..

No commits in common. "4aa63db8dd1f2ac0c78aa9c542487550dbadb6f0" and "8b1f6678196010f889711ef60718e39bb5b90e33" have entirely different histories.

14 changed files with 5 additions and 316 deletions

View File

@ -1,7 +1,3 @@
if (POLICY CMP0048)
cmake_policy(SET CMP0048 NEW)
endif (POLICY CMP0048)
project(gds-render LANGUAGES C)
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
@ -28,7 +24,7 @@ if(NOT WIN32)
set(BoldWhite "${Esc}[1;37m")
endif()
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 2.8)
find_package(PkgConfig REQUIRED)
pkg_search_module(GLIB REQUIRED glib-2.0)
pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
@ -85,12 +81,6 @@ set(FORT_ENABLE_TESTING OFF CACHE INTERNAL "")
add_subdirectory(3rdparty/libfort)
if(OPENGL_PREVIEW)
message("${Green}OpenGL preview activated${ColorReset}")
add_definitions(-DGDS_RENDER_OPGENGL_PREVIEW)
add_subdirectory(preview-rendering)
endif(OPENGL_PREVIEW)
link_directories(${GLIB_LINK_DIRS} ${GTK3_LINK_DIRS} ${CAIRO_LINK_DIRS})
add_definitions(${GLIB2_CFLAGS_OTHER})
@ -98,10 +88,6 @@ add_executable(${PROJECT_NAME} ${SOURCE} ${SOURCE_GENERATED})
add_dependencies(${PROJECT_NAME} glib-resources)
add_dependencies(${PROJECT_NAME} version)
add_dependencies(${PROJECT_NAME} translations)
if(OPENGL_PREVIEW)
add_dependencies(${PROJECT_NAME} opengl-preview)
target_link_libraries(${PROJECT_NAME} opengl-preview)
endif(OPENGL_PREVIEW)
install (TARGETS ${PROJECT_NAME}
RUNTIME

View File

@ -44,10 +44,6 @@
#include <gds-render/geometric/cell-geometrics.h>
#include <gds-render/version.h>
#ifdef GDS_RENDER_OPGENGL_PREVIEW
#include <preview-rendering/preview-rendering-gui.h>
#endif
/** @brief Columns of selection tree view */
enum cell_store_columns {
CELL_SEL_LIBRARY = 0,
@ -72,9 +68,6 @@ struct _GdsRenderGui {
/* Custom fields */
GtkWindow *main_window;
#ifdef GDS_RENDER_OPGENGL_PREVIEW
OpenGlPreviewGui *preview_gui;
#endif
GtkWidget *convert_button;
GtkWidget *open_button;
GtkWidget *load_layer_button;
@ -672,9 +665,6 @@ static void gds_render_gui_dispose(GObject *gobject)
g_clear_object(&self->save_layer_button);
g_clear_object(&self->open_button);
g_clear_object(&self->select_all_button);
#ifdef GDS_RENDER_OPGENGL_PREVIEW
g_clear_object(&self->preview_gui);
#endif
if (self->main_window) {
g_signal_handlers_destroy(self->main_window);
@ -778,15 +768,7 @@ static void gds_render_gui_init(GdsRenderGui *self)
GtkWidget *activity_bar_box;
GtkWidget *auto_color_button;
GtkWidget *auto_naming_button;
#ifdef GDS_RENDER_OPGENGL_PREVIEW
OpenGlPreviewGui *preview_gui;
preview_gui = opengl_preview_gui_new();
/* No need to reference the preview gui. It is already referenced upon creation */
self->preview_gui = preview_gui;
opengl_preview_gui_show(preview_gui);
#endif
main_builder = gtk_builder_new_from_resource("/gui/main.glade");
self->cell_tree_view = GTK_TREE_VIEW(gtk_builder_get_object(main_builder, "cell-tree"));

5
main.c
View File

@ -96,11 +96,6 @@ static void app_about(GSimpleAction *action, GVariant *parameter, gpointer user_
comment_text = g_string_new(_("gds-render is a free tool for rendering GDS2 layout files into vector graphics."));
g_string_append_printf(comment_text, _("\n\nFull git commit: %s"), _app_git_commit);
#ifdef GDS_RENDER_OPGENGL_PREVIEW
g_string_append_printf(comment_text, _("\nOpenGL Previev: Availabe"));
#else
g_string_append_printf(comment_text, _("\nOpenGL Previev: Unavailabe"));
#endif
builder = gtk_builder_new_from_resource("/gui/about.glade");
dialog = GTK_DIALOG(gtk_builder_get_object(builder, "about-dialog"));
gtk_window_set_transient_for(GTK_WINDOW(dialog), NULL);

View File

@ -1,3 +1,2 @@
add_subdirectory(plugin-example)
add_custom_target(plugins DEPENDS pluginexample)
cmake_minimum_required(VERSION 3.0)

View File

@ -1,5 +1,5 @@
project(pluginexample)
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 2.8)
find_package(PkgConfig REQUIRED)
pkg_search_module(PYTHON REQUIRED python3)

View File

@ -1,15 +0,0 @@
project(opengl-preview)
cmake_minimum_required(VERSION 3.0)
find_package(PkgConfig REQUIRED)
pkg_check_modules(EPOXY REQUIRED epoxy)
pkg_search_module(GLIB REQUIRED glib-2.0)
pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
aux_source_directory("src" SRCS)
add_library(${PROJECT_NAME} STATIC ${SRCS})
target_include_directories(${PROJECT_NAME} PUBLIC "include")
target_include_directories(${PROJECT_NAME} PRIVATE ${EPOXY_INCLUDE_DIRS} ${GLIB_INCLUDE_DIRS} ${GTK3_INCLUDE_DIRS})
target_link_directories(${PROJECT_NAME} PUBLIC ${EPOXY_LINK_DIRS} ${GLIB_LINK_DIRS} ${GTK3_LINK_DIRS})
target_link_libraries(${PROJECT_NAME} ${GLIB_LDFLAGS} ${EPOXY_LDFLAGS} ${GTK3_LDFLAGS})

View File

@ -1,14 +0,0 @@
#ifndef _PREVIEW_RENDERING_GUI_H_
#define _PREVIEW_RENDERING_GUI_H_
#include <gtk/gtk.h>
G_DECLARE_FINAL_TYPE(OpenGlPreviewGui, opengl_preview_gui, GDS_RENDER, OPENGL_PREVIEW_GUI, GObject)
#define TYPE_GDS_RENDER_OPENGL_PREVIEW_GUI (opengl_preview_gui_get_type())
OpenGlPreviewGui *opengl_preview_gui_new(void);
void opengl_preview_gui_show(OpenGlPreviewGui *self);
#endif /* _PREVIEW_RENDERING_GUI_H_ */

View File

@ -1,167 +0,0 @@
#include <preview-rendering/preview-rendering-gui.h>
#include <epoxy/gl.h>
struct _OpenGlPreviewGui {
GObject super;
GtkWindow *main_window;
GtkGLArea *gl_area;
unsigned int polygon_shader_prog;
unsigned int vao;
unsigned int vbo;
float color[4];
};
G_DEFINE_TYPE(OpenGlPreviewGui, opengl_preview_gui, G_TYPE_OBJECT)
static void opengl_preview_gui_dispose(GObject *gobj)
{
OpenGlPreviewGui *self;
self = GDS_RENDER_OPENGL_PREVIEW_GUI(gobj);
g_clear_object(&self->gl_area);
if (self->main_window) {
gtk_widget_destroy(GTK_WIDGET(self->main_window));
self->main_window = NULL;
}
G_OBJECT_CLASS(opengl_preview_gui_parent_class)->dispose(gobj);
}
static void opengl_preview_gui_class_init(OpenGlPreviewGuiClass *klass)
{
GObjectClass *oclass = G_OBJECT_CLASS(klass);
oclass->dispose = opengl_preview_gui_dispose;
}
static gboolean gl_area_render(GtkGLArea *area, GdkGLContext *context, gpointer user)
{
OpenGlPreviewGui *gui;
int loc;
gui = GDS_RENDER_OPENGL_PREVIEW_GUI(user);
gtk_gl_area_make_current(area);
glClearColor (0, 0, 0, 1.0);
glClear (GL_COLOR_BUFFER_BIT);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glUseProgram(gui->polygon_shader_prog);
glBindVertexArray(gui->vao);
loc = glGetUniformLocation(gui->polygon_shader_prog, "const_color");
glUniform4fv(loc, 1, gui->color);
glDrawArrays(GL_TRIANGLES, 0, 3);
glFlush();
return TRUE;
}
static int compile_shader_from_resource(GLenum shader_type, const char *res_name, unsigned int *shader)
{
int success;
GBytes *res_bytes;
const char *data;
gsize size;
int size_int;
int sh;
res_bytes = g_resources_lookup_data(res_name, G_RESOURCE_LOOKUP_FLAGS_NONE, NULL);
data = g_bytes_get_data(res_bytes, &size);
sh = glCreateShader(shader_type);
size_int = (int)size;
glShaderSource(sh, 1, &data, &size_int);
glCompileShader(sh);
glGetShaderiv(sh, GL_COMPILE_STATUS, &success);
g_bytes_unref(res_bytes);
if (shader)
*shader = sh;
return success;
}
static gboolean gl_area_realize(GtkGLArea *area, gpointer user)
{
unsigned int vbo;
unsigned int vs;
unsigned int fs;
unsigned int prog;
unsigned int vao;
OpenGlPreviewGui *gui;
int success;
gui = GDS_RENDER_OPENGL_PREVIEW_GUI(user);
gui->color[0] = 0.6f;
gui->color[1] = 0.5f;
gui->color[2] = 0.12f;
gui->color[3] = 1.0f;
gtk_gl_area_make_current(area);
if (!compile_shader_from_resource(GL_VERTEX_SHADER, "/shaders/polygon.vs", &vs)) {
g_warning("Error compiling vertex shader");
}
if (!compile_shader_from_resource(GL_FRAGMENT_SHADER, "/shaders/polygon.fs", &fs)) {
g_warning("Error compiling fragment shader");
}
prog = glCreateProgram();
glAttachShader(prog, vs);
glAttachShader(prog, fs);
glLinkProgram(prog);
glGetProgramiv(prog, GL_LINK_STATUS, &success);
if (!success) {
g_warning("Error linking shader");
}
glUseProgram(prog);
glDeleteShader(vs);
glDeleteShader(fs);
float vertices[] = {
-0.5f, -0.5f,
0.5f, -0.5f,
0.0f, 0.5f,
};
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
glGenBuffers(1, &vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2*sizeof(float), (void *)0);
glEnableVertexAttribArray(0);
gui->polygon_shader_prog = prog;
gui->vao = vao;
gui->vbo = vbo;
return TRUE;
}
static void opengl_preview_gui_init(OpenGlPreviewGui *self)
{
GtkBuilder *builder;
builder = gtk_builder_new_from_resource("/gui/preview-window.glade");
self->main_window = GTK_WINDOW(gtk_builder_get_object(builder, "main-window"));
self->gl_area = GTK_GL_AREA(gtk_builder_get_object(builder, "gl-area"));
g_signal_connect(self->gl_area, "render", G_CALLBACK(gl_area_render), self);
g_signal_connect(self->gl_area, "realize", G_CALLBACK(gl_area_realize), self);
g_object_ref(self->gl_area);
}
OpenGlPreviewGui *opengl_preview_gui_new(void)
{
return GDS_RENDER_OPENGL_PREVIEW_GUI(g_object_new(TYPE_GDS_RENDER_OPENGL_PREVIEW_GUI, NULL));
}
void opengl_preview_gui_show(OpenGlPreviewGui *self)
{
gtk_widget_show(GTK_WIDGET(self->main_window));
}

View File

@ -1,8 +0,0 @@
#include <epoxy/gl.h>
int foobar(void)
{
GLuint foo;
glGenBuffers(1, &foo);
return 42;
}

View File

@ -1,43 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2 -->
<interface>
<requires lib="gtk+" version="3.24"/>
<object class="GtkWindow" id="main-window">
<property name="can-focus">False</property>
<property name="default-width">1024</property>
<property name="default-height">500</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="baseline-position">bottom</property>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">button</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkGLArea" id="gl-area">
<property name="visible">True</property>
<property name="app-paintable">True</property>
<property name="can-focus">False</property>
<property name="has-alpha">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

View File

@ -5,7 +5,6 @@
<file compressed="true">about.glade</file>
<file>layer-widget.glade</file>
<file>dialog.glade</file>
<file compressed="true">preview-window.glade</file>
</gresource>
<gresource prefix="/data">
<file compressed="true">color-palette.txt</file>
@ -13,10 +12,6 @@
<gresource prefix="/images">
<file compressed="true" alias="logo.svg">../icon/gds-render.svg</file>
</gresource>
<gresource prefix="/shaders">
<file compressed="true" alias="polygon.fs">./shaders/polygon.fs.glsl</file>
<file compressed="true" alias="polygon.vs">./shaders/polygon.vs.glsl</file>
</gresource>
</gresources>

View File

@ -1,9 +0,0 @@
#version 330 core
out vec4 FragColor;
in vec4 vertex_color;
void main()
{
FragColor = vertex_color;
}

View File

@ -1,12 +0,0 @@
#version 330 core
//uniform mat4 mvp;
uniform vec4 const_color;
layout (location = 0) in vec2 input_vertex;
out vec4 vertex_color;
void main()
{
gl_Position = vec4(input_vertex.x, input_vertex.y, 0.0, 1.0);
vertex_color = const_color;
}

View File

@ -1,5 +1,4 @@
project(gds-render-test)
cmake_minimum_required(VERSION 3.0)
add_custom_target(test "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}" "-r compact" "-s" DEPENDS ${PROJECT_NAME})
@ -23,6 +22,7 @@ if(NOT WIN32)
set(BoldWhite "${Esc}[1;37m")
endif()
cmake_minimum_required(VERSION 2.8)
find_package(PkgConfig REQUIRED)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/catch-framework")