Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Now it works</p> <pre><code>glewExperimental=true; GLenum err=glewInit(); if(err!=GLEW_OK) { //Problem: glewInit failed, something is seriously wrong. fprintf(stderr, "glewInit failed, aborting.\n"); } #include "GL/glew.h" #include "GL/glext.h" #include "GL/glu.h" #include "GL/freeglut.h" #include &lt;cstdio&gt; uint16_t tex_width = 75; uint16_t tex_height = 24; GLuint texture; 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_TRIANGLE_STRIP); 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(); } void render_texture() { GLuint framebuffer = 0; glGenFramebuffers(1, &amp;framebuffer); glBindFramebuffer(GL_FRAMEBUFFER, framebuffer); glGenTextures(1, &amp;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(1.0f, 0.0f, 1.0f, 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(); } int main(int argc, char **argv) { glutInit(&amp;argc, argv); glutInitContextVersion(3, 1); glutInitContextProfile(GLUT_CORE_PROFILE); glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE/* | GLUT_DEPTH*/); glutInitWindowSize(1024, 1024); glutCreateWindow("texture test"); glutDisplayFunc(display); glewExperimental=true; GLenum err=glewInit(); if(err!=GLEW_OK) { //Problem: glewInit failed, something is seriously wrong. fprintf(stderr, "glewInit failed, aborting.\n"); } render_texture(); glutMainLoop(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload