使用OpenGL的GTK 汇编
Compilation for GTK+ using OpenGL
上下文:我正在学习使用GTK 学习GUI的开发。我还想在GUI上画线条和圆圈。因此,我从教程开始,然后被GTKGLAREA的一部分所困。我正在遵循GTK 文档中给出的代码
错误:
glTrial.cpp:32:13: error: variable or field ‘on_realize’ declared void
on_realize (GtkGLarea *area)
^
glTrial.cpp:32:13: error: ‘GtkGLarea’ was not declared in this scope
glTrial.cpp:32:24: error: ‘area’ was not declared in this scope
on_realize (GtkGLarea *area)
我相信我无法正确编译,并且编译器无法找到正确的标题。
汇编:
g++ -std=c++14 `pkg-config --cflags gtk+-3.0` -o glTrial glTrial.cpp `pkg-config --libs gtk+-3.0`
代码:
#include <gtk/gtk.h>
#include <gtkgl-2.0/gtkgl/gdkgl.h>
#include <gtkgl-2.0/gtkgl/gtkglarea.h>
static void
print_hello (GtkWidget *widget,
gpointer user_data)
{
g_print ("Hello Worldn");
}
static gboolean
render (GtkGLArea *area, GdkGLContext *context)
{
// inside this function it's safe to use GL; the given
// #GdkGLContext has been made current to the drawable
// surface used by the #GtkGLArea and the viewport has
// already been set to be the size of the allocation
// we can start by clearing the buffer
//glClearColor (0, 0, 0, 0);
// glClear (GL_COLOR_BUFFER_BIT);
// draw your object
// draw_an_object ();
// we completed our drawing; the draw commands will be
// flushed at the end of the signal emission chain, and
// the buffers will be drawn on the window
return TRUE;
}
static void
on_realize (GtkGLarea *area)
{
// We need to make the context current if we want to
// call GL API
gtk_gl_area_make_current (area);
// If there were errors during the initialization or
// when trying to make the context current, this
// function will return a #GError for you to catch
if (gtk_gl_area_get_error (area) != NULL)
return;
// You can also use gtk_gl_area_set_error() in order
// to show eventual initialization errors on the
// GtkGLArea widget itself
GError *internal_error = NULL;
init_buffer_objects (&error);
if (error != NULL)
{
gtk_gl_area_set_error (area, error);
g_error_free (error);
return;
}
init_shaders (&error);
if (error != NULL)
{
gtk_gl_area_set_error (area, error);
g_error_free (error);
return;
}
}
static void
activate (GtkApplication* app,
gpointer user_data)
{
GtkWidget *window;
GtkWidget *grid;
GtkWidget *button;
GtkWidget *gl_area =gtk_gl_area_new();
/* Create a new window, and set its title */
window = gtk_application_window_new(app);
gtk_window_set_title(GTK_WINDOW(window), "Window");
gtk_container_set_border_width(GTK_CONTAINER(window), 10);
// gtk_window_set_default_size(GTK_WINDOW(window), 200, 200);
/* Here we construct the container that is going to pack the buttons*/
grid = gtk_grid_new();
/* Pack the container in the window */
gtk_container_add (GTK_CONTAINER (window), grid);
button = gtk_button_new_with_label ("Quit");
g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_widget_destroy), window);
gtk_grid_attach (GTK_GRID (grid), button, 0, 0, 2, 1);
button = gtk_button_new_with_label ("Hello");
g_signal_connect_swapped (button, "clicked", G_CALLBACK (print_hello), NULL);
gtk_grid_attach (GTK_GRID (grid), button, 0, 1, 2, 1);
/* Trial for GL area*/
g_signal_connect (gl_area, "render", G_CALLBACK(render), NULL);
gtk_grid_attach (GTK_GRID (grid), gl_area, 0, 2, 10, 10);
gtk_widget_show_all (window);
}
int
main (int argc,
char **argv)
{
GtkApplication *app;
int status;
g_application_run (G_APPLICATION (app), argc, argv);
// app = gtk_application_new("org.gtk.example", G_APPLICATION_FLAGS_NONE);
g_signal_connect(app, "activate", G_CALLBACK (activate), NULL);
status = g_application_run (G_APPLICATION (app), argc, argv);
g_object_unref (app);
return status;
}
根据快速的Google,您正在寻找GtkGLArea
,请注意 uppercase a 。 &ndash;&nbsp; derhass
您需要:
sudo apt install *epoxy*
和
c++ t.c --target=arm-linux-gnu `pkg-config --libs --cflags gtk+-3.0 epoxy ` -o op
相关文章:
- 如何在运行中期切换GTK CSS style_context
- 如何在GTK程序运行时禁用屏幕保护程序/电源管理/屏幕消隐
- 如何使用 GTK 3 正确设置默认文本
- 为什么我的C++程序的程序集输出充满了 .ascii,没有汇编代码?
- Gtkmm 会不断检查 Gtk::日历上的所选日期是否发生变化
- 使用 Gtkmm 以编程方式选择 Gtk::TextView 中的文本
- 在 emscripten 网页汇编正在运行期间更新进度条?
- 为什么我们不编写可以处理C++标识符的汇编器和链接器?
- 在什么情况下,我想在 C/C++ 代码中使用内联汇编代码
- 是否可以编译 Gtk+ 应用程序以同时在 Gtk 2 和 3 上运行
- GTK 最大化表单 C++
- GTK:完全摆脱系统主题/CSS
- 为什么 memcpy() 和其他类似的函数使用汇编?
- GTK C++:找不到信号处理程序 您是否使用 -rdynamic 进行了编译?
- [[可能]]和[[不太可能]]影响程序汇编的简单示例?
- 如何从 Gtk::窗口调用派生对象的析构函数
- 为什么 MSVC C++编译器将一个简单的 Hello World 扩展为 4000 行汇编?
- Gtk::带有set_icon_name的窗口图标集在 wayland 上不起作用
- GTK 3 C++按钮中带有标签的图标
- 使用OpenGL的GTK 汇编