आप texImage2D
फ़ंक्शन का उपयोग करते हैं। आप इसे इस तरह आह्वान चाहते हैं:
import Data.Vector.Storable (unsafeWith)
import Graphics.Rendering.OpenGL.GL.Texturing.Specification (texImage2D, Level, Border, TextureSize2D(..))
import Graphics.Rendering.OpenGL.GL.PixelRectangles.ColorTable (Proxy(..), PixelInternalFormat(..))
import Graphics.Rendering.OpenGL.GL.PixelRectangles.Rasterization (PixelData(..))
-- ...
(ImageRGBA8 (Image width height dat)) ->
-- Access the data vector pointer
unsafeWith dat $ \ptr ->
-- Generate the texture
texImage2D
-- No cube map
Nothing
-- No proxy
NoProxy
-- No mipmaps
0
-- Internal storage format: use R8G8B8A8 as internal storage
RGBA8
-- Size of the image
(TextureSize2D width height)
-- No borders
0
-- The pixel data: the vector contains Bytes, in RGBA order
(PixelData RGBA UnsignedByte ptr)
ध्यान दें कि रसदार हमेशा एक RGBA छवि वापस नहीं देता है। इस आदेश से पहले, आप में बनावट डाटा स्टोर करने के लिए एक बनावट वस्तु बाध्य है करने के लिए Btw,
ImageY8, ImageYA8, ImageRGB8, ImageRGBA8, ImageYCrCb8
इसके अलावा,
import Data.ObjectName (genObjectNames)
import Graphics.Rendering.OpenGL.GL.Texturing.Objects (textureBinding)
import Graphics.Rendering.OpenGL.GL.Texturing.Specification (TextureTarget(..))
-- ...
-- Generate 1 texture object
[texObject] <- genObjectNames 1
-- Make it the "currently bound 2D texture"
textureBinding Texture2D $= Just texObject
के कई: आप अलग छवि प्रत्येक विविधता का हैंडल करने के लिए किया है। जब आप Graphics.Rendering.OpenGL
आयात करते हैं तो उन आयात स्वचालित रूप से जोड़े जाते हैं; यदि आप नहीं चाहते हैं तो आपको व्यक्तिगत रूप से प्रत्येक चीज़ को आयात करने की आवश्यकता नहीं है।
ध्यान दें कि यह आंशिक रूप से JuicyPixels-Repa के लिए सहायक था, लेकिन इसे रेपा 3.0 (जीएचसी 7.4 या ऊपर) के लिए अद्यतन करने की आवश्यकता है। –
ओह। मैं भूल गया कि मैंने नए प्रतिनिधि के लिए जेपी-रेपा अपडेट करने के लिए पहले से ही कुछ काम किया है। वाह। –