So i want an OpenTK implementation, which does only draw a few images on a 2D window. I tried to go with what this answer provided, but it only drew a blue screen. I want to add that my understanding of OpenTK is basically not existant, I am just pissed by windows forms because it brings even simple graphical application to the brink of crashing. So far i got a GameWindow extension overriding OnLoad, OnResize, OnRenderFrame and OnUpdateFrame aswell as a perfectly sized NativeWindowSetting and GameWindowSetting.
Can someone please provide commented code (preferribly using OpenTK.Graphics.OpenGL4;
)using or replacing the function:
public int LoadTexture(string file)
{
Bitmap bitmap = new Bitmap(file);
int image;
GL.Hint(HintTarget.PerspectiveCorrectionHint, HintMode.Nicest);
GL.GenTextures(1, out image);
GL.BindTexture(TextureTarget.Texture2D, image);
BitmapData data = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, data.Width, data.Height, 0, OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, data.Scan0);
bitmap.UnlockBits(data);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.Repeat);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.Repeat);
return image;
}
and code on how to put the resulting texture in the window?
I know usually SOF is used for asking question while providing code but i don't know where to start because all tutorials i found require triangles etc before doing the graphics but i do not need any geometry for my application.