migueltk's picture

Glu is really obsolete, Glu.Build2DMipmap is an exception?

Hello, ...

As implemented "Glu.Build2DMipmap" without using Glu, I know how to do it. Does anyone know how to do it? ...

Programming using "OpenTK.dll is very easy but using both" OpenTK.Compatibility.dll "is a real problem, there are constantly name collisions.

OpenTK should be limited to the creation and support of the windows, mouse, keyboard, sound, and exclude the mathematical library. When you have your own mathematical library with the most common names "Vector3", "Matrix", there are constantly name collisions.

It is my opinion.

Regards, ...


Comments

the Fiddler's picture

Glu.Build2DMipmap is obsolete and has been obsolete for close to a decade:

GL.GenerateMipmap(); // for OpenGL 3.x
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.GenerateMipmap, 1); // for OpenGL 1.4-2.1

Barring (bad, obsolete) tutorials, noone should be using Glu.Build2DMipmap nowadays.

You can avoid name collisions by being more frugal with namespace imports:

// Pick one, not both, when using OpenTK.Compatibility.dll
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;
 
// Avoid "using OpenTK" in code that uses a different math library
using OpenTK;
using MyOwnMathLibrary;

In retrospect, it was probably a mistake to move math structures to the OpenTK namespace. Oh well, live and learn, maybe this can be reevaluated for some future 2.0 release.

migueltk's picture

True "Glu.Build2DMipmap" is outdated and I had the solution in the book "OpenGL Superbible 2" Chapter 8, I've only had to replace the line

Glu.Build2DMipmap(TextureTarget.Texture2D, (int)PixelInternalFormat.Rgba, data.Width, data.Height, PixelFormat.Bgra, PixelType.UnsignedByte, data.Scan0);

by the following code

// Requieres OpenGL >= 1.4
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.GenerateMipmap, 1); // 1 = True
GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, data.Width, data.Height, 0, PixelFormat.Bgra, PixelType.UnsignedByte, data.Scan0);

thanks for your answer, every day you learn something new ...