Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  glarea-gl-only.c

  Sprache: C
 

#include <gtk/gtk.h>
#include <epoxy/gl.h>

/* A png for a red/yellow checkerboard */
static const char image_data[] = {
  0211012001160107001500120032001200000000000000150111011001040122,
  0000000000000040000000000000004000010003000000000000011102640350,
  0267000000000000000601200114012401050377000000000377034000000241,
  0105032500020000000000000025011101040101012400100327014302300011,
  0004001401510100000000410300033401010044000600000355027500770301,
  0347017301530007000000000000000001110105011601040256010201400202
};

G_MODULE_EXPORT gboolean
render_orange_glonly (GtkWidget    *glarea,
                      GdkGLContext *context)
{
  GdkTexture *texture;
  GdkTextureDownloader *downloader;
  GBytes *bytes; 
  gsize stride, width, height;
  GLuint tex_id, fb_id;

  gdk_gl_context_make_current (context);

  /* Clear to green, so that errors in the following code cause a problem */
  glClearColor (0.01.00.01.0);
  glClear (GL_COLOR_BUFFER_BIT);

  /* load the checkerboard image */
  bytes = g_bytes_new_static (image_data, G_N_ELEMENTS (image_data));
  texture = gdk_texture_new_from_bytes (bytes, NULL);
  g_bytes_unref (bytes);
  width = gdk_texture_get_width (texture);
  height = gdk_texture_get_height (texture);
  downloader = gdk_texture_downloader_new (texture);
  /* Make sure we use a format that GLES does *NOT* support.
   * And that must include extensions.
   * But GL_EXT_texture_norm16 does support RGB16 as a source, which
   * is why we also use mipmaps below. */

  gdk_texture_downloader_set_format (downloader, GDK_MEMORY_R16G16B16);
  bytes = gdk_texture_downloader_download_bytes (downloader, &stride);
  g_object_unref (texture);
  gdk_texture_downloader_free (downloader);

  glGenTextures (1, &tex_id);
  glActiveTexture (GL_TEXTURE0);
  glBindTexture (GL_TEXTURE_2D, tex_id);
  /* Now load the image in this ideally unsupported format. Maybe
   * things fail already here. Usually they don't. */

  glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB16,
                width, height,
                0, GL_RGB, GL_UNSIGNED_SHORT, g_bytes_get_data (bytes, NULL));
  g_bytes_unref (bytes);
  /* Generate mipmaps. GLES should give up now.
   * GL should turn the checkerboard into orange mipmap levels though.
   */

  glGenerateMipmap (GL_TEXTURE_2D);

  glGenFramebuffers (1, &fb_id);
  glBindFramebuffer (GL_READ_FRAMEBUFFER, fb_id);
  /* Bind mipmap level 2 for reading, so we rely on properly converted
   * mipmaps. */

  glFramebufferTexture2D (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex_id, 2);

  /* On GLES, this should now fail due to incomplete framebuffer and
   * leave us with the green contents we've drawn above.
   * Or we are on GL, everything works perfectly, and we now get orange. */

  glBlitFramebuffer (00,
                     width / 4, height / 4,
                     00,
                     gtk_widget_get_width (glarea) * gtk_widget_get_scale_factor (glarea),
                     gtk_widget_get_height (glarea) * gtk_widget_get_scale_factor (glarea),
                     GL_COLOR_BUFFER_BIT,
                     GL_LINEAR);

  glDeleteFramebuffers (1, &fb_id);
  glDeleteTextures (1, &tex_id);

  return TRUE;
}


Messung V0.5 in Prozent
C=99 H=93 G=95

¤ Dauer der Verarbeitung: 0.11 Sekunden  (vorverarbeitet am  2026-07-02) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik