private bool IsStaticImageProducer(IOpenTKImageRenderable imageProducer) { //HelloKitty: This is kind of hacky, I know. BUT because of the way that the static frames //around the in-game UI work they don't recreate after login and logout. Unlike almost all other frames. //So we must handle them specially. /*Created ImageProducer: backLeftIP1 * Created ImageProducer: backLeftIP2 * Created ImageProducer: backRightIP1 * Created ImageProducer: backRightIP2 * Created ImageProducer: backTopIP1 * Created ImageProducer: backVmidIP1 * Created ImageProducer: backVmidIP2 * Created ImageProducer: backVmidIP3 * Created ImageProducer: backVmidIP2_2*/ switch (imageProducer.Name) { case "backLeftIP1": case "backLeftIP2": case "backRightIP1": case "backRightIP2": case "backTopIP1": case "backVmidIP1": case "backVmidIP2": case "backVmidIP3": case "backVmidIP2_2": return(true); } return(false); }
public OpenGlRegisteredOpenTKImageRenderable(IOpenTKImageRenderable renderable, int textureId) { if (textureId <= 0) { throw new ArgumentOutOfRangeException(nameof(textureId)); } Renderable = renderable ?? throw new ArgumentNullException(nameof(renderable)); TextureId = textureId; }
private void AddToRenderCollection(IOpenTKImageRenderable imageProducer) { int textureId = CreateTexture(imageProducer); if (IsStaticImageProducer(imageProducer)) { InGameStaticRenderables.Add(new OpenGlRegisteredOpenTKImageRenderable(imageProducer, textureId)); } else { Renderables.Add(new OpenGlRegisteredOpenTKImageRenderable(imageProducer, textureId)); } }
/// <summary> /// Creates the texture in OpenGL. /// Returns the associated texture id. /// </summary> /// <param name="drawRequest"></param> /// <returns></returns> private int CreateTexture(IOpenTKImageRenderable drawRequest) { GL.Hint(HintTarget.PerspectiveCorrectionHint, HintMode.Nicest); int texture; GL.GenTextures(1, out texture); GL.BindTexture(TextureTarget.Texture2D, texture); 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.ClampToEdge); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.ClampToEdge); GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, drawRequest.ImageLocation.Width, drawRequest.ImageLocation.Height, 0, OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, drawRequest.ImageDataPointer); return(texture); }
private void DrawTexture(IOpenTKImageRenderable renderable) { float xOffset = (float)renderable.ImageLocation.X; float yOffset = (float)renderable.ImageLocation.Y; //Scaling code for resizable //765, 503 default size. //Get current size modifier float widthModifier = (float)this.Width / 765.0f; float heightModifier = (float)this.Height / 503.0f; GL.Begin(PrimitiveType.Quads); GL.TexCoord2(0, 0); GL.Vertex2(xOffset * widthModifier, yOffset * heightModifier); GL.TexCoord2(1, 0); GL.Vertex2((renderable.ImageLocation.Width + xOffset) * widthModifier, yOffset * heightModifier); GL.TexCoord2(1, 1); GL.Vertex2((renderable.ImageLocation.Width + xOffset) * widthModifier, (renderable.ImageLocation.Height + yOffset) * heightModifier); GL.TexCoord2(0, 1); GL.Vertex2(xOffset * widthModifier, (renderable.ImageLocation.Height + yOffset) * heightModifier); GL.End(); }
public void OnImageProducerCreated(object sender, IOpenTKImageRenderable imageProducer) { ImageProducerCreationQueue.Enqueue(imageProducer); }