Jump to content
  • Advertisement
Sign in to follow this  
Meowmix

OpenGL OpenGL-ES can't get cube to dynamically render

This topic is 3050 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey guys,

I've got a float array `camObjCoord` declared as..

`public static float camObjCoord[] = new float[8000];`

I'm then filling its indexes in a class that does something like the following..

Quote:
public void addcube(float highx, float lowx, float highz, float lowz){
//Constructing new cube...
System.out.println("f = " + f);
Global.cubes++;
float y = 1.5f;
System.out.println("highx = " + highx + "lowx = " + lowx + "highz = " + highz + "lowz = " + lowz);
//FRONT
camObjCoord = lowx;
i++;
camObjCoord = -y;
i++;
camObjCoord = highz;
i++;
camObjCoord = highx;
i++;
camObjCoord = -y;
i++;
camObjCoord = highz;
i++;
camObjCoord = lowx;
i++;
camObjCoord = y;
i++;
camObjCoord = highz;
i++;
camObjCoord = highx;
i++;
camObjCoord = y;
i++;
camObjCoord = highz;
//BACK
i++;
camObjCoord = lowx;
i++;
camObjCoord = -y;
i++;
camObjCoord = lowz;
i++;
camObjCoord = lowx;
i++;
camObjCoord = y;
i++;
camObjCoord = lowz;
i++;
camObjCoord = highx;
i++;
camObjCoord = -y;
i++;
camObjCoord = lowz;
i++;
camObjCoord = highx;
i++;
camObjCoord = y;
i++;
camObjCoord = lowz;
i++;
//LEFT
camObjCoord = lowx;
i++;
camObjCoord = -y;
i++;
camObjCoord = highz;
i++;
camObjCoord = lowx;
i++;
camObjCoord = y;
i++;
camObjCoord = highz;
i++;
camObjCoord = lowx;
i++;
camObjCoord = -y;
i++;
camObjCoord = lowz;
i++;
camObjCoord = lowx;
i++;
camObjCoord = y;
i++;
camObjCoord = lowz;
i++;
//RIGHT
camObjCoord = highx;
i++;
camObjCoord = -y;
i++;
camObjCoord = lowz;
i++;
camObjCoord = highx;
i++;
camObjCoord = y;
i++;
camObjCoord = lowz;
i++;
camObjCoord = highx;
i++;
camObjCoord = -y;
i++;
camObjCoord = highz;
i++;
camObjCoord = highx;
i++;
camObjCoord = y;
i++;
camObjCoord = highz;
i++;
//TOP
camObjCoord = lowx;
i++;
camObjCoord = y;
i++;
camObjCoord = highz;
i++;
camObjCoord = highx;
i++;
camObjCoord = y;
i++;
camObjCoord = highz;
i++;
camObjCoord = lowx;
i++;
camObjCoord = y;
i++;
camObjCoord = highz;
i++;
camObjCoord = highx;
i++;
camObjCoord = y;
i++;
camObjCoord = lowz;
i++;
//BOTTOM
camObjCoord = lowx;
i++;
camObjCoord = -y;
i++;
camObjCoord = highz;
i++;
camObjCoord = lowx;
i++;
camObjCoord = -y;
i++;
camObjCoord = lowz;
i++;
camObjCoord = highx;
i++;
camObjCoord = -y;
i++;
camObjCoord = highz;
i++;
camObjCoord = highx;
i++;
camObjCoord = -y;
i++;
camObjCoord = lowz;

i++;
int p = 0;
System.out.println("FULL ARRAY");
while(p < 72){
System.out.println(camObjCoord

);
p++;
}
}



I'm then calling `makeview()`

Quote:

public void makeview() {
Intent myIntent = new Intent(this, GLCamTest.class);

Bundle b = new Bundle();
b.putFloatArray("tweets", camObjCoord);
myIntent.putExtras(b);
this.startActivity(myIntent);
}


and then in the new class it's doing...

Quote:

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle b = this.getIntent().getExtras();
float original[] = b.getFloatArray("tweets");
camObjCoord = original;
counter++;
}


I then have another class `class GLLayer` and it looks like the following.. http://pastebin.org/394884 inside this class I'm drawing the cube(s) from the float array, I've check and the values for the cube are indeed there and when I'm coding the array in it works but when I'm dynamically building the array then passing it the cube doesn't draw. I'm calling the class like so..

Quote:

glView=new GLLayer(this);

mPreview = new CamLayer(this, glView);

Anyone have any idea why? How would I fix my problem? Just to add, I am giving the exact same values to the exact same indexes when drawing dynamically

Quote:

final static float camObjCoord[] = new float[] {
// FRONT
-2.0f, -1.5f, 2.0f,
2.0f, -1.5f, 2.0f,
-2.0f, 1.5f, 2.0f,
2.0f, 1.5f, 2.0f,
// BACK
-2.0f, -1.5f, -2.0f,
-2.0f, 1.5f, -2.0f,
2.0f, -1.5f, -2.0f,
2.0f, 1.5f, -2.0f,
// LEFT
-2.0f, -1.5f, 2.0f,
-2.0f, 1.5f, 2.0f,
-2.0f, -1.5f, -2.0f,
-2.0f, 1.5f, -2.0f,
// RIGHT
2.0f, -1.5f, -2.0f,
2.0f, 1.5f, -2.0f,
2.0f, -1.5f, 2.0f,
2.0f, 1.5f, 2.0f,
// TOP
-2.0f, 1.5f, 2.0f,
2.0f, 1.5f, 2.0f,
-2.0f, 1.5f, -2.0f,
2.0f, 1.5f, -2.0f,
// BOTTOM
-2.0f, -1.5f, 2.0f,
-2.0f, -1.5f, -2.0f,
2.0f, -1.5f, 2.0f,
2.0f, -1.5f, -2.0f,
};


Then it will render this cube. It appears to not like that I'm making the array and then dynamically adding indexes. Why? how do I fix this? For the bounty I would also accept an appropriate workaround which will work in Android.

Thanks.

edit1: I've tried various things it's not the passing of the array causing the problems if I was to declare the array like so...

edit2: I've also tried printing the array as it goes into GLLayer (class which renders cubes) and everything is as you would expect. I've no idea why these cubes wouldn't be appearing :(

edit3: I've added how I'm constructing the float arrays.

[Edited by - Meowmix on July 16, 2010 11:11:16 AM]

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!