나는 C#으로 OpenGL을 사용하고 있습니다. 다음과 같은 다른 라이브러리를 사용할 수 없습니다.이미지 회전?
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이 perefectly 작동이 표시하고 혼합 텍스처 괜찮아.
내 world.draw 메서드의 foreach 루프에있는 코드는 벨로 시티 (getVel)와 위치 (getPos)를 2 차원 벡터로 반환합니다.
도움이 되시면 감사하겠습니다.
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();
}
답장을 보내 주셔서 감사합니다. 코드에서 좌표계와 속도 사이의 각도로 어떻게 버그를 회전시킬 수 있습니까? – rx432