我有这个程序你可以看到下面。程序应该将一些东西渲染成一个纹理,渲染的纹理应该被绘制出来显示。但是当调用glBegin(GL_QUADS)时,程序在display()函数处失败。程序结束打印
ElectricFence Aborting: free(96f110): address not from malloc().
Ungültiger Maschinenbefehl (Speicherabzug geschrieben)
invalid machine command (dump written)
#include "GL/glew.h"
#include "GL/glext.h"
#include "GL/glu.h"
#include "GL/glut.h"
#include <cstdio>
uint16_t tex_width = 75;
uint16_t tex_height = 24;
GLuint texture;
void render_texture()
{
GLuint framebuffer = 0;
glGenFramebuffers(1, &framebuffer);
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex_width, tex_height, 0, GL_RGBA,
GL_UNSIGNED_BYTE, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
GLenum draw_buffers[1] = {GL_COLOR_ATTACHMENT0};
glDrawBuffers(1, draw_buffers);
if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
{
fprintf(stderr, "[render_texture] Fehler im Framebuffer\n");
exit(1);
}
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
glViewport(0, 0, tex_width, tex_height);
glColor4f(0.8f, 0.0f, 0.8f, 0.5f);
glBegin(GL_POLYGON);
glVertex2f(0.f,0.f);
glVertex2f(tex_width, 0.0f);
glVertex2f(tex_width, (GLfloat)tex_height/2.f);
glVertex2f(tex_width-(GLfloat)tex_height/2.f, tex_height);
glVertex2f(0, tex_height);
glEnd();
}
void display(void)
{
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glViewport(0, 0, glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT));
glClearColor(0.0, 0.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT/* | GL_DEPTH_BUFFER_BIT*/);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0.0, glutGet(GLUT_WINDOW_WIDTH), 0.0, glutGet(GLUT_WINDOW_HEIGHT), -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glEnable(GL_TEXTURE_2D);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture);
// Draw a textured quad
glBegin(GL_QUADS);
glTexCoord2f(0, 0); glVertex3f(0, 0, 0);
glTexCoord2f(0, 1); glVertex3f(0, tex_width, 0);
glTexCoord2f(1, 1); glVertex3f(tex_height, tex_width, 0);
glTexCoord2f(1, 0); glVertex3f(tex_height, 0, 0);
glEnd();
glDisable(GL_TEXTURE_2D);
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glutSwapBuffers();
}
int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE/* | GLUT_DEPTH*/);
glutInitWindowSize(1024, 1024);
glutCreateWindow("texture copy test");
glutDisplayFunc(display);
glewInit();
render_texture();
glutMainLoop();
}
g++ -o test test.cpp -std=c++11 -lpng -lGL -lglut -lGLEW -lGLU -lefence -g
ElectricFence Aborting: free(769110): address not from malloc().
Program received signal SIGILL, Illegal instruction.
0x00007ffff645c6c7 in kill () from /usr/lib/libc.so.6
(gdb) q
A debugging session is active.
Inferior 1 [process 1350] will be killed.
Quit anyway? (y or n) y
[rejak@localhost src]$ gdb ./test
GNU gdb (GDB) 7.6.1
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/rejak/projects/glwidgets/src/test...done.
(gdb) run
Starting program: /home/rejak/projects/glwidgets/src/./test
warning: no loadable sections found in added symbol-file system-supplied DSO at 0x7ffff7ffa000
warning: Could not load shared library symbols for linux-vdso.so.1.
Do you need "set solib-search-path" or "set sysroot"?
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
ElectricFence Aborting: free(769110): address not from malloc().
Program received signal SIGILL, Illegal instruction.
0x00007ffff645c6c7 in kill () from /usr/lib/libc.so.6
(gdb) bt full
#0 0x00007ffff645c6c7 in kill () from /usr/lib/libc.so.6
No symbol table info available.
#1 0x00007ffff6ff14ad in ?? () from /usr/lib/libefence.so.0
No symbol table info available.
#2 0x00007ffff6ff18c7 in EF_Abortv () from /usr/lib/libefence.so.0
No symbol table info available.
#3 0x00007ffff6ff1968 in EF_Abort () from /usr/lib/libefence.so.0
No symbol table info available.
#4 0x00007ffff6ff0eda in free () from /usr/lib/libefence.so.0
No symbol table info available.
#5 0x00007ffff2a53e68 in _mesa_align_realloc () from /usr/lib/libdricore9.2.0.so.1
No symbol table info available.
#6 0x00007ffff2bced4c in _mesa_add_parameter () from /usr/lib/libdricore9.2.0.so.1
No symbol table info available.
#7 0x00007ffff2bceefa in _mesa_add_state_reference () from /usr/lib/libdricore9.2.0.so.1
No symbol table info available.
#8 0x00007ffff2fedb29 in ?? () from /usr/lib/xorg/modules/dri/i965_dri.so
No symbol table info available.
#9 0x00007ffff2bc4882 in _mesa_glsl_link_shader () from /usr/lib/libdricore9.2.0.so.1
No symbol table info available.
#10 0x00007ffff2a38c33 in _mesa_get_fixed_func_fragment_program () from /usr/lib/libdricore9.2.0.so.1
No symbol table info available.
#11 0x00007ffff2a86f68 in _mesa_update_state_locked () from /usr/lib/libdricore9.2.0.so.1
No symbol table info available.
#12 0x00007ffff2a87041 in _mesa_update_state () from /usr/lib/libdricore9.2.0.so.1
No symbol table info available.
#13 0x00007ffff2ac5a08 in ?? () from /usr/lib/libdricore9.2.0.so.1
No symbol table info available.
#14 0x0000000000401675 in display () at test.cpp:75
No locals.
#15 0x00007ffff7720ac4 in ?? () from /usr/lib/libglut.so.3
No symbol table info available.
#16 0x00007ffff7724329 in fgEnumWindows () from /usr/lib/libglut.so.3
No symbol table info available.
#17 0x00007ffff772107d in glutMainLoopEvent () from /usr/lib/libglut.so.3
No symbol table info available.
#18 0x00007ffff772187d in glutMainLoop () from /usr/lib/libglut.so.3
No symbol table info available.
#19 0x00000000004017b3 in main (argc=1, argv=0x7fffffffe6e8) at test.cpp:110
No locals.
(gdb) list 75
70 glEnable(GL_TEXTURE_2D);
71 glActiveTexture(GL_TEXTURE0);
72 glBindTexture(GL_TEXTURE_2D, texture);
73
74 // Draw a textured quad
75 glBegin(GL_QUADS);
76 glTexCoord2f(0, 0); glVertex3f(0, 0, 0);
77 glTexCoord2f(0, 1); glVertex3f(0, tex_width, 0);
78 glTexCoord2f(1, 1); glVertex3f(tex_height, tex_width, 0);
79 glTexCoord2f(1, 0); glVertex3f(tex_height, 0, 0);
(gdb)
使用gl_quads
时要小心,它的支持现在取决于您的OpenGL版本。首先尝试修复您使用的OpenGL版本,然后看看接下来会发生什么。
glutInitContextVersion(3, 3);
glutInitContextProfile(GLUT_CORE_PROFILE);
3.3是一个例子。实际上,我不确定该实现版本是否存在gl_quads
。
我制作了一个OpenGL应用程序,用于测试Framebuffer Objects,该应用程序适用于我制作的笔记本电脑,我拥有的另一台笔记本电脑和我的台式PC。但是,对于我要求为我测试该应用程序的其他人来说,它似乎崩溃了。 到目前为止,我已经将它缩小到在我调用的第一个扩展(在本例中为glGenBuffers)上崩溃,我100%确定在调用该函数(见下文)之前不会调用该扩展。在浏览了许多答案后,我确定了
我创建了一个应用程序,在Android marshmallow中崩溃,而在under版本中我的应用程序正常工作。 这怎么可能?这是我的清单代码: 这是分级代码: 我读到你必须在代码中修改一些东西,使其与AndroidMarshmallow兼容。 我该如何解决问题呢?
golang window程序崩溃 最近遇到一个问题,程序在window上运行,运行一段时间后就会崩溃,以下是崩溃时捕捉到的日志 使用pprof分析过,还是没有找到哪里异常,问问大佬们
我的整个节点应用程序崩溃,“未处理的承诺拒绝”SequelizeConnectionRefusedError时,由于某种原因(例如数据库负载过大)数据库拒绝连接。 我想找到一个解决方案,使应用程序不崩溃,如果可能的话,尝试重新连接。 这就是我连接数据库的方式
以下相同的代码在除android 11以外的所有android版本中完美运行。在Android11或API 30中,我们的应用程序崩溃了,甚至根本打不开。我们正在使用请求网络API在我们的应用程序中执行GET、POST操作。 这是一份日志: 主要活动。爪哇: 请求网络。爪哇: 请求网络控制器。爪哇: 请帮助我们解决这个错误。提前感谢:)
我正在使用内置于Web View的Android开发浏览器。其中我面临的一个问题是,当我访问http://crashmybrowser.com测试浏览器上的选项卡崩溃时,我的整个浏览器应用程序都会崩溃。但是,当在chrome或Opera上进行相同的测试时,这些浏览器会在崩溃中幸存下来,并且只有特定的选项卡崩溃是由于访问上述网站而预期的结果。有人能帮助理解我如何在使用Webview的浏览器上处理此崩