Question

Toute aide à ce sujet, j'utilise OpenGL avec C #. Je ne peux pas utiliser d'autres bibliothèques autres que:

using System;
using OpenGL;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Drawing;

Je n'arrive pas à faire pivoter mon image pour qu'il soit confronté à la façon dont il se déplace.

C'est ce qu'on appelle dans ma méthode de dessin du monde:

foreach (Bug bug in m_Bugs) 
            {
                double radians = Math.Atan2(bug.getPos().X + bug.getVel().X, bug.getPos().Y + bug.getVel().Y);
                double angle = radians * (180 / Math.PI);

                GL.glRotated(angle, 0, 0, 1);
                bug.Draw(); 
            }

Et ma méthode de dessin est appelée dans le fil principal ici:

form.RegisterDraw(myWorld.Draw);

mon bug.Draw fonctionne pérefectely qu'il affiche et mélange bien les textures.

Le code dans la boucle foreach de ma méthode World.

Toute aide serait appréciée, applaudie.

private void Load(uint[] array, int index, string filepath)
    {
        Bitmap image = new Bitmap(filepath);
        image.RotateFlip(RotateFlipType.RotateNoneFlipY);
        System.Drawing.Imaging.BitmapData bitmapdata;
        Rectangle rect = new Rectangle(0, 0, image.Width, image.Height);
        bitmapdata = image.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb);

        /* Set the correct ID, then load the texture for that ID * from RAM onto the Graphics card */
        GL.glBindTexture(GL.GL_TEXTURE_2D, array[index]);
        GL.glTexImage2D(GL.GL_TEXTURE_2D, 0, (int)GL.GL_RGB8, image.Width, image.Height, 0, GL.GL_BGR_EXT, GL.GL_UNSIGNED_byte, bitmapdata.Scan0);
        GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, (int)GL.GL_LINEAR);
        GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, (int)GL.GL_LINEAR);

        /* This code releases the data that we loaded to RAM * but the texture is still on the Graphics Card */
        image.UnlockBits(bitmapdata);
        image.Dispose();
    }

Pas de solution correcte

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top