Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8258489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:33:15+00:00 2026-06-08T02:33:15+00:00

I’m currently playing around with the native activity stuff and GLES 2.0 and I’m

  • 0

I’m currently playing around with the native activity stuff and GLES 2.0 and I’m loading the shaders for GLES from the assets using the ndk.

This is the source of the simple shaders:

Vertex shader: simple.vsh

attribute vec4 vPosition;
void main()
{
    gl_Position = vPosition;
}

Fragment shader: simple.fsh

precision mediump float;
void main()
{
    gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}

This is the code that I’m using to load the shader files

AAsset *shaderAsset= AAssetManager_open(app->activity->assetManager, path, AASSET_MODE_BUFFER);
size_t length = AAsset_getLength(shaderAsset);

LOGI("Shader source size: %d\n", length);


char* buffer = (char*) malloc(length);

AAsset_read(shaderAsset, buffer, length);   

LOGI("Shader source : %s\n", buffer);

AAsset_close(shaderAsset);
free(buffer);

When I run the application I see this in android logcat:

 Shader source size: 71
 07-22 13:23:52.683 11135 11146 I native-activity: Shader source : attribute vec4 vPosition;
 07-22 13:23:52.683 11135 11146 I native-activity: void main()
 07-22 13:23:52.683 11135 11146 I native-activity: {
 07-22 13:23:52.683 11135 11146 I native-activity:     gl_Position = vPosition;
 07-22 13:23:52.683 11135 11146 I native-activity: }
 07-22 13:23:52.683 11135 11146 I native-activity: sP
 07-22 13:23:52.683 11135 11146 I native-activity: Shader source size: 86
 07-22 13:23:52.683 11135 11146 I native-activity: Shader source : precision mediump float;
 07-22 13:23:52.683 11135 11146 I native-activity: void main()
 07-22 13:23:52.683 11135 11146 I native-activity: {
 07-22 13:23:52.683 11135 11146 I native-activity:     gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
 07-22 13:23:52.683 11135 11146 I native-activity: }
 07-22 13:23:52.683 11135 11146 I native-activity: fs`

Notice the “sP” and the “fs'” at the end of the files.

I’ve also added “nocompression” for the file extensions in my build xml file, just in case that is the problem, but hence the problem remains.

Does anyone have an idea what maybe causing this ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T02:33:17+00:00Added an answer on June 8, 2026 at 2:33 am

    Somehow the trailing zero does not get into the asset.

    Try using

    // one extra char for the trailing zero
    char* buffer = (char*) malloc(length + 1);
    
    AAsset_read(shaderAsset, buffer, length);   
    
    // fix the string to be zero-terminated
    buffer[length] = 0;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am currently running into a problem where an element is coming back from
Does anyone know how can I replace this 2 symbol below from the string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I used javascript for loading a picture on my website depending on which small
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.