Quantcast
Channel: Questions in topic: "ios"
Viewing all articles
Browse latest Browse all 4709

iOS, Replacing texture at opengl level

$
0
0
Hi, i'm quite stuck at this because i had it working months ago with Unity 3.5 and now i can't reproduce it (someone forgot to save) on Unity 4.1 (stuck with that version). I'm trying to replace a PVRTC (4bpp, RGBA) texture with another one loaded from a downloaded file (actually for testing purposes i'm loading it from a textasset shouldn't matter anyway). So basically @ C# level. Texture2D placeholder; [DllImport ("__Internal")] private static extern int UpdateTexture(int textureID, System.IntPtr newImage, int byteLength, int imageSize, int level ); [...] void LoadPVRTC(GameObject target) { Texture2D tex = (Texture2D) GameObject.Instantiate(placeholder); TextAsset az = Resources.Load("amso4") as TextAsset; GCHandle handle = GCHandle.Alloc(az.bytes, GCHandleType.Pinned); UpdateTexture(tex.GetNativeTextureID(), handle.AddrOfPinnedObject(), az.bytes.Length,128,0); handle.Free(); target.renderer.material.mainTexture = tex; } Now at plugin level im doing this. int UpdateTexture(int textureID, Byte* texPtr, int length, int imageSize, int level ) { glBindTexture(GL_TEXTURE_2D, textureID); glCompressedTexImage2D(GL_TEXTURE_2D, level, GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, imageSize, imageSize, 0, length, texPtr); return 1; } I'm getting a Opengl 0x0501 error. I've revised everything, both images are the same format. Read/Write is enabled on the texture i'm replacing in Unity, ImageSize is correct, The pointer points to the pvr texture and size is set to 128. so i can't figure what i'm missing. Any ideas? **Update**: I Forgot to remove the header. Thanks to rlabrecque to pointing it to me on the irc. **Edit** I'm feeling stupid/blind today, how i can mark it as answered if it's not reviewed by a mod yet (is it even possible?)

Viewing all articles
Browse latest Browse all 4709

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>