Question

Any help with this I'm using OpenGL with C#. I cant use any other libraries other than:

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

I cant seem to rotate my image so it faces the way its moving.

This is called in my world draw method:

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(); 
            }

and my draw method is called in the main thread here:

form.RegisterDraw(myWorld.Draw);

my bug.draw works perefectly it displays and blends the textures fine.

the code in the foreach loop in my world.draw method returns the velociity (getVel) and the position (getPos) as 2d vectors.

Any help would be appreciated, cheers.

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();
    }

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top