Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by BenT39 · Jul 12, 2016 at 11:49 AM · androidtexture2dopenglc++

Android: Alter texture from c++

Hi, I would like to alter a Texture2D from C++ on Android. How do I pass the texture to C++ side? Can I just alter it with OpenGL afterwards and my changes will be displayed or will I have to call some Unity function after my work is done to apply the changes?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by liortal · Jul 16, 2016 at 10:50 AM

You should check out this method: https://docs.unity3d.com/ScriptReference/Texture.GetNativeTexturePtr.html

This gives you a pointer to the native texture (e.g: OpenGL) so you can work with this pointer in your native C++ code.

*Note that on other platforms this may be a different API (Metal on iOS and OSX).

Comment
Add comment · Show 6 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image BenT39 · Jul 16, 2016 at 11:51 AM 0
Share

Thank you, this seems like the thing I need. One more thing though: Do I have to somehow synchronise my edits with unity or can I draw whatever I want whenever I want and next time the scene is rendered my changes appear on the surface? I am completely new to Unity and do not really know how the ti$$anonymous$$gs are (If you can point me to any reference on this it would help me a lot as well!).

avatar image liortal BenT39 · Jul 16, 2016 at 04:27 PM 0
Share

I have no idea as i've never used this approach. I guess the circumstances where one should need something like this are pretty rare (what is your scenario?)

avatar image BenT39 liortal · Jul 16, 2016 at 04:39 PM 0
Share

I guess I will have to see if it refreshes automatically. I need this to display the preview from an external USB camera. I have written a library to access V4L2 cameras in C++, and I want the preview to display on a Unity surface. I guess the best way to do this is to store the raw images from the camera on C++ side and then load them onto the surface when Update() is called on my surface. The other idea would have been to load the images onto the surface each time an image is sent by the camera, gaining a few microseconds of delay, but I assume the safer way is to use Surface2D's LoadImage on Update().

Show more comments
Show more comments

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

low-level OpenGL code running on iOS and Android ? 0 Answers

Render Android device camera from native pointer 0 Answers

Rendering Android native view with OpenGL 0 Answers

Deployed Android Texture2d image scrambled 0 Answers

[Android+Eclipse]Get album image from mp3 file 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges