I’m not able to find anthing usefull, but I’m searching further
I Post the whole code, maybe someone has an idea.
//using CsGL.OpenGL;
using CsGL.Basecode;
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Imaging;
using System.Reflection;
using System.Windows.Forms;
namespace Holomachine
{
class my_openGL : Model
{
// TODO
// Variabeln vom Programm bestimmen lassen
Boolean UVMapping = true;
float breite_bild = 400;
//Breite einer Einzelgrafik
float anzahl_bild = 50;
// Anzahl der Bilder
float zaehler_bild = 0;
// Zähler für den Counter
float position_bild = 0;
// Position des Einzelbildes in der Gesamtgrafik
private static uint[] texture = new uint[1]; // Our Texture
private static float xrot = 0; // X Rotation
private static float yrot = 0; // Y Rotation
private static float zrot = 0; // Z Rotation
public static void Main_2()
{ // Eingangspunkt
App.Run(new my_openGL()); // Starte das Programm als Windows Forms Application
}
public override void Initialize()
{
base.Initialize(); // Run The Base Initialization
glEnable(GL_TEXTURE_2D); // Enable Texture Mapping
LoadTextures(); // Jump To Our Texture Loading Routine
}
private void LoadTextures()
{
// TODO vom Programm steuern lassen
string filename = @"uvtestbild00003.png";
// The File To Load
Bitmap bitmap = null;
// The Bitmap Image For Our Texture
Rectangle rectangle;
// The Rectangle For Locking The Bitmap In Memory
BitmapData bitmapData = null;
// The Bitmap's Pixel Data
bitmap = new Bitmap(filename);
// Load The File As A Bitmap
rectangle = new Rectangle(0, 0, bitmap.Width, bitmap.Height);
// Select The Whole Bitmap
bitmapData = bitmap.LockBits(rectangle, ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
glGenTextures(1, texture);
// Create One Texture
glBindTexture(GL_TEXTURE_2D, texture[0]);
// Zuweisung: die Textur ist 2D
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
// tpnTextureMinFilter besagt, mit welchem Filter die Grafik zusammengedrückt werden soll.
// tpnTextureMagFilter besagt, mit welchem Filter die Grafik auseinandergezogen wird.
// Der Parameter GL_LINEAR erzeugt das beste Ergebnis, belastet aber den Prozessor.
// Möglich wäre auch GL_NEAREST. Das entlastet zwar die Hardware, sieht aber schnell recht pixelig aus.
glTexImage2D(GL_TEXTURE_2D, 0, (int)GL_RGB8, bitmap.Width, bitmap.Height, 0, GL_BGR_EXT, GL_UNSIGNED_BYTE, bitmapData.Scan0);
// Der 1. Parameter besagt wieder 2D Textur
// Der 2. Parameter gibt den Grad der Details an
// Der 3. Parameter gibt die Art der Farbkanäle an, 3 = RGB.
// Parameter 4 und 5 sind Breite und Höhe der Textur
// Der 6. Parameter gibt die Rahmenbreite an, vorerst aber mal 0.
// Parameter 7 und 8 geben Farbformat (RGB) und Art der Daten (Unsigned Byte = 0 - 255) an.
// Der letzte Parameter übergibt schlußendlich die eigentliche Textur.
}
public override void Draw()
{
bool debug = false;
if (UVMapping == true)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Clear Screen And Depth Buffer
glLoadIdentity();
// setzt die aktuelle Modell-Matrix zurück
glTranslatef(0.0f, 0.0f, -5.0f);
//Zeichenpunkt setzen
breite_bild = 1 / anzahl_bild;
position_bild = breite_bild * Convert.ToInt64( Math.Round(zaehler_bild));
//ohne Round haben wir einen Verlauf und keine GanzBilderSprünge
glBindTexture(GL_TEXTURE_2D, texture[0]);
//Dim PicPos () As GLfloat 'Position des Einzelbildes in der Gesamtgrafik
// position_bild
//Dim Piclength As GLfloat 'Breite einer Einzelgrafik
// breite_bild
//Dim Pic As GLfloat 'Zähler für den Counter
// zaehler_bild
//glLoadIdentity 'setzt die aktuelle Modell-Matrix zurück
//glTranslatef 2#, 0#, -8# 'Zeichenpunkt setzen
//Piclength = 1 / 8 'das Bild besteht aus 8 Einzelbildern
//PicPos = Round(Pic) * Piclength 'errechnen, an welcher Position das Einzelbild steht
glBegin(GL_QUADS);
glTexCoord2f(position_bild + breite_bild, 1f);
glVertex3f(0.5f, 0.5f, 1.0f);
// Oben Rechts
glTexCoord2f(position_bild, 1f);
glVertex3f(-0.5f, 0.5f, 1.0f);
// Oben Links
glTexCoord2f(position_bild, 0f);
glVertex3f(-0.5f, -0.5f, 1.0f);
// Unten Links
glTexCoord2f(position_bild + breite_bild, 0f);
glVertex3f(0.5f, -0.5f, 1.0f);
// Unten Rechts
glEnd();
zaehler_bild += 0.2F;
//Pic = Pic + 0.001
//Auch hier wäre die bessere Lösung eine Erhöhung anhand der verstrichenen Zeit,
// damit die Geschwindigkeit nicht hardwareabhängig ist.
}
// #############
if (UVMapping == false)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Clear Screen And Depth Buffer
glLoadIdentity();
// Reset The Current Modelview Matrix
glTranslatef(0.0f, 0.0f, -5.0f);
// Zeichenpunkt zurücksetzen
// glTranslate - Multipliziert die aktuelle Matrix mit einer Verschiebungsmatrix. x, y, z
// Move Into The Screen 5.0 Units, 1.0 for fullscreen (-5.0 or -1.0)
// glBindTexture - Bindet eine benannte Textur an ein Texturenziel.
glBindTexture(GL_TEXTURE_2D, texture[0]); // Select Our Texture
// Quadrat (Würfel) zeichnen
glBegin(GL_QUADS);
// Front Face
// glColor - Setzt die aktuelle Farbe. RGB
// glTexCoord2f - setzen die aktuellen Texturkoordinaten
// glVertex3f - - Bestimmt die Koordinaten eines Vertex. Ein Vertex (Mehrzahl: Vertice(s)) ist ein Punkt im Raum.
// --- unten links ---
glTexCoord2f(0.0f, 0.0f);
glVertex3f(-1.5f, -1.0f, 1.0f);
// --- unten rechts ---
glTexCoord2f(1.0f, 0.0f);
glVertex3f(1.0f, -1.0f, 1.0f);
// --- oben rechts ---
glTexCoord2f(1.0f, 1.0f);
glVertex3f(1.0f, 1.0f, 1.0f);
// --- oben links ---
glTexCoord2f(0.0f, 1.0f);
glVertex3f(-1.5f, 1.0f, 1.0f);
glEnd();
}
// #############
}
}
}