Jump to content

  • Log In with Google      Sign In   
  • Create Account


PaulCaben

Member Since 01 Jul 2012
Offline Last Active Jul 10 2012 05:22 AM

Posts I've Made

In Topic: Texture image replaced by a "number" ?

09 July 2012 - 11:20 PM

Thanks for the answer, Edit: so i am not sure why this did not work, but i found an example from the project "Explosions" made by 71squared, that has a file that deals with the texture import. It works fine, if anyone is looking for the same thing.

Thanks for the answer

In Topic: Why do i get stripes instead of a plain color? (in a defined area)

04 July 2012 - 08:34 PM

Okay thanks :)

In Topic: Why do i get stripes instead of a plain color? (in a defined area)

02 July 2012 - 04:44 PM

Thanks, ok so it works!

I changed a bit the vertices, and added some glDisable... in the draw method.

Could you explain me a little bit about these snapshots :

With :

//glDisable(GL_TEXTURE_2D);
//glDisableClientState(GL_COLOR_ARRAY);
//glDisableClientState(GL_TEXTURE_COORD_ARRAY);
  
	glBindTexture(GL_TEXTURE_2D, _textureImage.texture.name);
  
	glColor4f(1, 1, 1, 1);
	glVertexPointer(2, GL_FLOAT, 0, _polyVertices);
	glTexCoordPointer(2, GL_FLOAT, 0, _polyTexCoords);
	glDrawArrays(GL_TRIANGLE_STRIP, 0, (GLsizei)_nPolyVertices);

Attached File  Cnothing.png   9.92KB   23 downloads


Then with :

//glDisable(GL_TEXTURE_2D);
glDisableClientState(GL_COLOR_ARRAY);
//glDisableClientState(GL_TEXTURE_COORD_ARRAY);

Attached File  CdisableColor.png   7.41KB   45 downloads

And finally with :

//glDisable(GL_TEXTURE_2D);
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);

The final image :

Attached File  CdisableTexture.png   7.29KB   30 downloads

What are these COLOR_ARRAY and TEXTURE_COORD by default? And why the texture coord would create stripes on the image?

Thanks!

In Topic: Why do i get stripes instead of a plain color? (in a defined area)

02 July 2012 - 12:07 AM

Thanks,
I would like to create a special wall, with different points in the x-axis (the red points), all connected to the y-axis (the green points). Is that what you mean by triangulate the vertices?

Attached File  ques.png   5.74KB   45 downloads

I've tried to do this, but i have a problem (Edit)

I have a EXC_BAD_ACCESS in the draw method, next to "bind texture", i thought it might be because of the textCoord array, that may be looking for empty coordinates, but the texture is a 512pixels/or points (i'm not sure) square...

- (void)generatePath {
  
	int _nVertices = 0;
	_hillKeyPoints[_nVertices] = CGPointMake(44, 0); //_nVertices = 1
	_hillKeyPoints[++_nVertices] = CGPointMake(100, 75); //_nVertices = 2
	_hillKeyPoints[++_nVertices] = CGPointMake(50, 150); //_nVertices = 3
	_hillKeyPoints[++_nVertices] = CGPointMake(150, 225); //_nVertices = 4
}
-(void)generatePolygons{
  
	_nPolyVertices = 0;
	float x1 = 0;
	float y1 = 0;
	int keyPoints = 0;
  
	_fromKeyPointI = 0;
	_toKeyPointI = 4;
  
	for (int i=_fromKeyPointI; i<_toKeyPointI; i++){
	  
		//V0: at (0,0)
		_polyVertices[_nPolyVertices] = CGPointMake(x1, y1);
		_polyTexCoords[_nPolyVertices++] = CGPointMake(x1, y1);
	  
		//V1: to the first "point"
		_polyVertices[_nPolyVertices] = CGPointMake(_hillKeyPoints[keyPoints].x, _hillKeyPoints[keyPoints].y);
		_polyTexCoords[_nPolyVertices++] = CGPointMake(_hillKeyPoints[keyPoints].x, _hillKeyPoints[keyPoints].y);
	  
		//V2, same y as point n°2:
		_polyVertices[_nPolyVertices] = CGPointMake(0, _hillKeyPoints[keyPoints+1].y);
		_polyTexCoords[_nPolyVertices++] = CGPointMake(0, _hillKeyPoints[keyPoints+1].y);
	  
	  
	  
		//V3 = V1
		_polyVertices[_nPolyVertices] = _polyVertices[_nPolyVertices-2];
		_polyTexCoords[_nPolyVertices++] = _polyVertices[_nPolyVertices-2];
	  
		//V4 = V2
		_polyVertices[_nPolyVertices] = _polyVertices[_nPolyVertices-2];
		_polyTexCoords[_nPolyVertices++] = _polyVertices[_nPolyVertices-2];
	  
		//V5 = same x,y as point n°2
		keyPoints++;
		_polyVertices[_nPolyVertices] = CGPointMake(_hillKeyPoints[keyPoints].x, _hillKeyPoints[keyPoints].y);
		_polyTexCoords[_nPolyVertices++] = CGPointMake(_hillKeyPoints[keyPoints].x, _hillKeyPoints[keyPoints].y);
	  
		y1 = _polyVertices[_nPolyVertices].y;
		//CCLOG(@"y1 : %f", y1);
	}
  
	for(int i = 1; i < kMaxPolyVertices; ++i) {  
		//ccDrawLine(_polyVertices[i-1], _polyVertices[i]);
		CCLOG(@"_polyVertices[i-1].y : %f, _polyVertices[i].y : %f", _polyVertices[i-1].y, _polyVertices[i].y);
	}
}

- (id)init {
	if ((self = [super init])) {
		[self generatePath];
		[self generatePolygons];
	}
	return self;
}
- (void) draw {
  
	glBindTexture(GL_TEXTURE_2D, _textureImage.texture.name);//EXC_BAD_ACCESS
	glDisableClientState(GL_COLOR_ARRAY);
  
	glColor4f(1, 1, 1, 1);
	glVertexPointer(2, GL_FLOAT, 0, _polyVertices);
	glTexCoordPointer(2, GL_FLOAT, 0, _polyTexCoords);
	glDrawArrays(GL_TRIANGLES, 0, (GLsizei)_nPolyVertices);
  
}

If i comment the bind texture line and the textcoord line, it gives me something strange, that moves, for example :

Attached File  Capture d’écran 2012-07-02 à 13.07.44.png   14.7KB   31 downloads

Attached File  Capture d’écran 2012-07-02 à 13.07.48.png   13.37KB   25 downloads

Would you know something about this?

Thanks

PARTNERS