Любая помощь с этим я использую OpenGL с C #.Я не могу использовать другие библиотеки, кроме:
using System;
using OpenGL;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Drawing;
Я не могу повернуть свое изображение так, чтобы оно было направлено на его перемещение.
Это называется в моем методе рисования мира:
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();
}
и мой метод рисования вызывается в главном потоке здесь:
form.RegisterDraw(myWorld.Draw);
мой bug.draw отлично работает, он отображает и прекрасно смешивает текстуры.
кодв цикле foreach в моем методе world.draw возвращает скорость (getVel) и позицию (getPos) в виде двухмерных векторов.
Любая помощь приветствуется, ура.
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();
}