From: reinert <reinkor@gmail.com>
Subject: Re: Best way to put an array-based pixmap on a screen?
Date: Sun, 26 Mar 2017 06:27:58 -0700 (PDT)
Date: 2017-03-26T06:27:58-07:00 [thread overview]
Message-ID: <7830a5ce-52a3-46b8-8a73-3738005cd206@googlegroups.com> (raw)
In-Reply-To: <lyr31kcqfz.fsf@pushface.org>
In case it could be useful, here is a simple test program using GLOBE_3D (texture). I just started to use GLOBE_3D for fast (interactive) video-like rendering (programming in Ada).
reinert
https://korsnesbiocomputing.no/
with Text_IO; use Text_IO;
with GL, GLUT.Devices;
use GL, GLUT.Devices;
procedure a1 is
package Flt_Io is new Text_IO.Float_Io (Float);
package Int_Io is new Text_IO.Integer_Io (Integer);
use Flt_Io,Int_Io;
GLUT_Problem: exception;
use GLUT;
texDat : array (1..64) of aliased gl.ushort;
texDat_Ptr : constant pointer := to_Pointer(texDat(texDat'First)'unchecked_access);
tex : aliased GL.uint;
tex_Ptr : constant GL.uintPtr := tex'unchecked_access;
n,k : Integer := 1;
begin
glut.Init;
glut.SetOption(GLUT.ACTION_ON_WINDOW_CLOSE, GLUT.ACTION_GLUTMAINLOOP_RETURNS);
glut.InitDisplayMode( GLUT.DOUBLE or GLUT.RGB or GLUT.DEPTH );
glut.InitWindowSize(800,600);
glut.InitWindowPosition(1, 1);
if glut.CreateWindow( "Tittel A" ) = 0 then
raise GLUT_Problem;
end if;
glut.Devices.Initialize;
n := texDat'First;
for i in 1..8 loop
for j in 1..8 loop
k := (if i = j then 1 else 0);
k := (if (i + j) mod 2 = 0 then 1 else 0);
texDat(n) := gl.ushort(k*100 + 100);
n := n + 1;
end loop;
end loop;
gl.GenTextures(1, tex_Ptr);
gl.BindTexture(GL.TEXTURE_2D, tex);
gl.TexParameter(GL.TEXTURE_2D, GL.TEXTURE_MIN_FILTER, GL.NEAREST);
gl.TexParameter(GL.TEXTURE_2D, GL.TEXTURE_MAG_FILTER, GL.NEAREST);
gl.TexImage2D(GL.TEXTURE_2D, 0, GL.LUMINANCE, 8, 8, 0, GL.LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, texDat_Ptr);
gl.BindTexture(GL.TEXTURE_2D, 0);
gl.MatrixMode(GL.PROJECTION);
gl.Ortho(0.0, 800.0, 0.0, 600.0, -1.0, 1.0);
gl.MatrixMode(GL.MODELVIEW);
gl.ClearColor(1.0, 1.0, 1.0, 0.0);
gl.Clear(GL.COLOR_BUFFER_BIT);
gl.BindTexture(GL.TEXTURE_2D, tex);
gl.Enable(GL.TEXTURE_2D);
gl.Color(1.0, 1.0, 1.0, 1.0);
gl_Begin(QUADS);
gl.TexCoord(0.0, 0.0); gl.Vertex(100, 100);
gl.TexCoord(0.0, 1.0); gl.Vertex(100, 500);
gl.TexCoord(1.0, 1.0); gl.Vertex(500, 500);
gl.TexCoord(1.0, 0.0); gl.Vertex(500, 100);
gl_End;
gl.Disable(GL.TEXTURE_2D);
gl.BindTexture(GL.TEXTURE_2D, 0);
gl.Flush;
glut.SwapBuffers;
Delay 10.0;
end a1;
next prev parent reply other threads:[~2017-03-26 13:27 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-26 1:01 Best way to put an array-based pixmap on a screen? LaeMing Ai
2017-03-26 8:25 ` Dmitry A. Kazakov
2017-03-26 9:55 ` Simon Wright
2017-03-26 13:27 ` reinert [this message]
2017-03-26 16:48 ` gautier_niouzes
2017-03-26 19:10 ` Lucretia
2017-03-26 19:13 ` Lucretia
2017-03-26 21:00 ` BartC
2017-03-26 21:48 ` Dmitry A. Kazakov
2017-03-26 9:35 ` Dirk Craeynest
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox