3 #if SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGL
9 #if SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
10 using OpenTK.Graphics.ES30;
13 using OpenTK.Graphics.OpenGL;
17 namespace SiliconStudio.
Paradox.Graphics
24 #if SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
25 private const TextureTarget TextureTarget1D = TextureTarget.Texture2D;
27 private const TextureTarget TextureTarget1D = TextureTarget.Texture1D;
30 protected internal Texture1D(GraphicsDevice device, TextureDescription description1D, DataBox[] dataBox = null)
36 protected internal Texture1D(GraphicsDevice device, Texture1D texture) : base(device, texture,
ViewType.
Full, 0, 0)
41 public override Texture ToTexture(
ViewType viewType,
int arraySlice,
int mipMapSlice)
44 if (viewType !=
ViewType.Full || arraySlice != 0 || mipMapSlice != 0)
45 throw new NotImplementedException();
47 return new Texture1D(GraphicsDevice,
this);
54 protected virtual void Init(DataRectangle[] textureDatas)
56 using (var creationContext = GraphicsDevice.UseOpenGLCreationContext())
58 PixelInternalFormat internalFormat;
63 ConvertPixelFormat(GraphicsDevice, Description.Format, out internalFormat, out format, out type, out pixelSize, out compressed);
65 InternalFormat = internalFormat;
72 if (!creationContext.UseDeviceCreationContext)
73 GraphicsDevice.UseTemporaryFirstTexture();
75 GL.GenTextures(1, out textureId);
76 GL.BindTexture(TextureTarget1D, textureId);
79 if (format == PixelFormatGl.DepthComponent)
81 GL.TexParameter(TextureTarget1D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Nearest);
82 GL.TexParameter(TextureTarget1D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Nearest);
83 GL.TexParameter(TextureTarget1D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.ClampToEdge);
84 GL.TexParameter(TextureTarget1D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.ClampToEdge);
87 for (
int i = 0; i < Description.MipLevels; ++i)
89 IntPtr data = IntPtr.Zero;
90 var width = CalculateMipSize(Description.Width, i);
91 if (textureDatas != null && i < textureDatas.Length)
93 if (textureDatas[i].Pitch != width *
pixelSize)
94 throw new NotSupportedException(
"Can't upload texture with pitch in glTexImage1D.");
95 data = textureDatas[i].DataPointer;
97 #if SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
98 GL.TexImage2D(TextureTarget1D, i, internalFormat, width, 1, 0,
format, type, data);
100 GL.TexImage1D(TextureTarget1D, i, internalFormat, width, 0,
format, type, data);
103 GL.BindTexture(TextureTarget1D, 0);
105 resourceId = textureId;
114 protected int ComputeLevelCount(
int mipLevels)
118 return (
int)Math.Ceiling(Math.Log(Description.Width) / Math.Log(2.0));
The type of the serialized type will be passed as a generic arguments of the serializer. Example: serializer of A becomes instantiated as Serializer{A}.
ViewType
Defines how a view is selected from a resource.
Same as Deferred mode, except sprites are sorted by texture prior to drawing. This can improve perfor...
Gets a texture view for the whole texture for all mips/arrays dimensions.
_In_ size_t _In_ size_t _In_ DXGI_FORMAT format
The texture dimension is 1D.
PixelFormat
Defines various types of pixel formats.