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 720091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:43:08+00:00 2026-05-14T05:43:08+00:00

For some reason my code here (this is the entire thing) doesnt actually render

  • 0

For some reason my code here (this is the entire thing) doesnt actually render anything besides a red screen.. can anyone tell me why?

package com.ntu.way2fungames.earth.testbed;

import java.nio.FloatBuffer;

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.opengl.GLSurfaceView.Renderer;
import android.os.Bundle;

public class projectiles extends Activity {
    GLSurfaceView lGLView;
    Renderer lGLRenderer;
    float projectilesX[]= new float[5001];
    float projectilesY[]= new float[5001];
    float projectilesXa[]= new float[5001];
    float projectilesYa[]= new float[5001];
    float projectilesTheta[]= new float[5001];
    float projectilesSpeed[]= new float[5001];
    private static FloatBuffer drawBuffer;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        SetupProjectiles();

        Context mContext = this.getWindow().getContext();
        lGLView= new MyView(mContext);
        lGLRenderer= new MyRenderer();
        lGLView.setRenderer(lGLRenderer);
        setContentView(lGLView);
    }

    private void SetupProjectiles() {
        int i=0;
        for (i=5000;i>0;i=i-1){
            projectilesX[i] = 240;
            projectilesY[i] = 427;

            float theta = (float) ((i/5000)*Math.PI*2);
            projectilesXa[i] = (float) Math.cos(theta);
            projectilesYa[i] = (float) Math.sin(theta);
            projectilesTheta[i]= theta;
            projectilesSpeed[i]= (float) (Math.random()+1);
        }

    }

    public class MyView extends GLSurfaceView{

        public MyView(Context context) {
            super(context);
            // TODO Auto-generated constructor stub
        }

    }

    public class MyRenderer implements Renderer{

        private float[] projectilecords = new float[] {
               .0f, .5f, 0,
              -.5f,  0f, 0,
               .5f,  0f, 0,
                 0, -5f, 0,

        };


        @Override
        public void onDrawFrame(GL10 gl) {

            gl.glClear(GL10.GL_COLOR_BUFFER_BIT);                
            gl.glMatrixMode(GL10.GL_MODELVIEW);
            //gl.glLoadIdentity();
            gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
            for (int i=5000;i>4500;i=i-1){

                //drawing section
                gl.glLoadIdentity();
                gl.glColor4f(.9f, .9f,.9f,.9f);
                gl.glTranslatef(projectilesY[i], projectilesX[i],1);    
                gl.glVertexPointer(3, GL10.GL_FLOAT, 0, drawBuffer); 
                gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, 12);


                //physics section
                projectilesX[i]=projectilesX[i]+projectilesXa[i];
                projectilesY[i]=projectilesY[i]+projectilesYa[i];


            }
            gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
        }

        @Override
        public void onSurfaceChanged(GL10 gl, int width, int height) {
             if (height == 0) height = 1;
             // draw on the entire screen
             gl.glViewport(0, 0, width, height);
             // setup projection matrix
             gl.glMatrixMode(GL10.GL_PROJECTION);
             gl.glLoadIdentity();
             gl.glOrthof(0,width,height,0, -100, 100);

        }

        @Override
        public void onSurfaceCreated(GL10 gl, EGLConfig arg1) {
            gl.glShadeModel(GL10.GL_SMOOTH);
            gl.glClearColor(1f, .01f, .01f, 1f);

            gl.glClearDepthf(1.0f);
            gl.glEnable(GL10.GL_DEPTH_TEST);
            gl.glDepthFunc(GL10.GL_LEQUAL);

            gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST);

            drawBuffer = FloatBuffer.wrap(projectilecords);         
        }


    }
}
  • 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-14T05:43:08+00:00Added an answer on May 14, 2026 at 5:43 am

    Turns out that the projectile initialization code was broken

     int i=0;
            for (i=5000;i>0;i=i-1){
                projectilesX[i] = 240;
                projectilesY[i] = 427;
    
                float theta = (float) ((i/5000)*Math.PI*2);
                projectilesXa[i] = (float) Math.cos(theta);
                projectilesYa[i] = (float) Math.sin(theta);
                projectilesTheta[i]= theta;
                projectilesSpeed[i]= (float) (Math.random()+1);
            }
    

    not sure exactly why but when i replaced it with

    int i=0;
            float pi2=(float)(Math.PI *2);
            for (i=5000;i>0;i=i-1){
                projectilesX[i] = 160;
                projectilesY[i] = 320;
    
                float theta = (float)(Math.random());
                projectilesSpeed[i]= (float) (Math.random()+1);
                projectilesXa[i] = (float) Math.cos(theta*pi2)*projectilesSpeed[i];
                projectilesYa[i] = (float) Math.sin(theta*pi2)*projectilesSpeed[i];
                projectilesTheta[i]= (float) (theta*360);
    
            }
    

    things started working…

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

Sidebar

Ask A Question

Stats

  • Questions 512k
  • Answers 512k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer HBitmap is a handle, it has no sense to serialize… May 16, 2026 at 5:34 pm
  • Editorial Team
    Editorial Team added an answer Here is some code that will take a screen shoot… May 16, 2026 at 5:34 pm
  • Editorial Team
    Editorial Team added an answer You're probably better off using an Object, and storing it… May 16, 2026 at 5:34 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

For some reason this jQuery function is not working properly. Here's my code... the
With help from the community last week, I successfully implemented this code here Now
For some reason, I'm getting this error message: Uncaught TypeError: Object #<an Object> has
everyone, i have no idea why this doesn't work hopefully someone here can help
Update: After some experimentation, it appears that the thing that is slow is when
I'm trying to edit this JQuery code to work with a PHP, but for
For some reason, putting @Override on methods overriding interface methods causes JSP compilation to
Why does this code not work? echo explode(?, $_SERVER[REQUEST_URI])[0]; It says syntax error, unexpected
Here's the background info first. ASP.NET 2.0 Web Site with AJAX Extensions 1.0. I
I know this is normally rather stupid, but don't shoot me before reading 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.