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

  • SEARCH
  • Home
  • 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 3981684
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:26:23+00:00 2026-05-20T05:26:23+00:00

I am trying to render an openGL es surface from the NDK, but got

  • 0

I am trying to render an openGL es surface from the NDK, but got halted early in my work. I have a setup similar to the 3d example in the NDK. I have a class inheriting from GLSurface view and one inheriting from GLSurfaceView.Renderer. In my .c file, I have a simple method that does NOTHING. It is just a void function with nothing in it. I can call this function in my class that inherit from activity onCreate method.
private static native void nativeSetup();

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    mGLView = new GraphGLSurfaceView(this);
    setContentView(mGLView);
    nativeSetup();
}

The program works fine. However, if i put the call (and declaration) in one of the GLSurfaceView classes, the program immediately fails (nativeSetup is the call in question). I have verified that everything is working fine without the native call (a colored surface is drawn). Does anyone have any ideas about why I cannot call native code from GLSurface classes?

My c file:

#include <string.h>
#include <jni.h>

void Java_com_test_intro_nativeSetup( JNIEnv*  env ){}

My java file in a non working manner:

package com.test;

import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;

import android.app.Activity;
import android.content.Context;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.util.Log;
import android.view.Window;

public class intro extends Activity {
    static{
        System.loadLibrary("graphrender");
    }
    private GLSurfaceView mGLView;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        mGLView = new GraphGLSurfaceView(this);
        setContentView(mGLView);

    }
}

class GraphGLSurfaceView extends GLSurfaceView {
    GraphRenderer mRenderer;    
    public GraphGLSurfaceView(Context context) {
        super(context);
        mRenderer = new GraphRenderer();
        setRenderer(mRenderer);

    }
}

class GraphRenderer implements GLSurfaceView.Renderer { 
    private static native void nativeSetup();
    private float _red = 0.9f;
    private float _green = 0.2f;
    private float _blue = 0.2f;

    public void onSurfaceCreated(GL10 gl, EGLConfig config) {

        Log.d("intro", "Got to intro 4" );
    }

    public void onSurfaceChanged(GL10 gl, int w, int h) {
        gl.glViewport(0, 0, w, h);
        nativeSetup();
        //Log.d("intro", "Got to intro 2" + debugStr);
    }

    public void onDrawFrame(GL10 gl) {
        Log.d("intro", "Got to intro 3");
        gl.glClearColor(_red, _green, _blue, 1.0f);
        // clear the color buffer to show the ClearColor we called above...
        gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
    }
}
  • 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-05-20T05:26:23+00:00Added an answer on May 20, 2026 at 5:26 am

    In your c file did you rename your native function?Maybe the problem is related to this issues, cause JNI uses a particular naming for the navtive functions.

    Have a look here and try to use javah -jni $CLASS-FILE-WITH-NATIVE-METHODS$ to obtain the c files.

    hope this helps.

    ciao

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a chart (in bitmap format) that I'm trying to render to a
I am trying to render to a texture using openGL ES (for iPhone) and
I am trying to render a user control into a string. The application is
I am trying to render a model in Direct3D using DrawIndexedPrimitives . However, I
I'm trying to render a bit of text using Core Graphics APIs and I'm
I am trying to get the DataGridView to render the insert new row row
I am trying to come up with the best way to render some hierarchical
I'm trying to write a C++ windows service that can render to a texture.
I'm trying to add support for stackoverflow feeds in my rss reader but SelectNodes
I have written some code to experiment with opengl programming on Ubuntu, its been

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.