Page 1 of 1

OpenGL with vertex arrays

Posted: Thu Aug 25, 2011 2:37 pm
by N64vSNES
EDIT:
See newest post...

Re: OpenGL texture question

Posted: Thu Aug 25, 2011 4:49 pm
by Nokurn
N64vSNES wrote:I can't seem to find an answer for this so hopefully you guys could help.

Suppose I have a 32x32 texture and a 64x64 quad. Now if I render this then the texture gets "stretched" as you would imagine because you've specified the texture coords where the vertices are.

I'm fairly sure that using GL_REPEAT would do this IF I go past 1.0 with the texture coords however this isn't much using part of a texture atlas.

Any advice?

Thanks.
I am not quite sure what you are asking here. There is no question, and it looks like there's supposed to be a sentence between the second and third. If you could rephrase, someone might be able to provide some insight.

Re: OpenGL texture question

Posted: Thu Aug 25, 2011 4:52 pm
by Falco Girgis
Krolgar wrote:
N64vSNES wrote:I can't seem to find an answer for this so hopefully you guys could help.

Suppose I have a 32x32 texture and a 64x64 quad. Now if I render this then the texture gets "stretched" as you would imagine because you've specified the texture coords where the vertices are.

I'm fairly sure that using GL_REPEAT would do this IF I go past 1.0 with the texture coords however this isn't much using part of a texture atlas.

Any advice?

Thanks.
I am not quite sure what you are asking here. There is no question, and it looks like there's supposed to be a sentence between the second and third. If you could rephrase, someone might be able to provide some insight.
That's exactly what I was going to say.

You never asked us a question.

Re: OpenGL texture question

Posted: Thu Aug 25, 2011 5:29 pm
by N64vSNES
Yes I see where I went wrong there :oops:
I'll start from the beginning :lol:

Suppose this is my texture:
Image

I want to use this texture on a quad like this:
Image

I could break the quad into 4 different quads but then I'm losing performance.


Short and simple as possible :)

Re: OpenGL texture question

Posted: Thu Aug 25, 2011 9:43 pm
by qpHalcy0n
This can not be done as you describe within the fixed function. Sorry.

The texture or the geometry must be split or you must write the functionality into a shader program.

Re: OpenGL texture question

Posted: Fri Aug 26, 2011 7:15 am
by N64vSNES
qpHalcy0n wrote:This can not be done as you describe within the fixed function. Sorry.

The texture or the geometry must be split or you must write the functionality into a shader program.
Well this is going to cause problems :lol:

Thanks for the help though.

Re: OpenGL texture question

Posted: Fri Aug 26, 2011 10:06 am
by Falco Girgis
N64vSNES wrote:
qpHalcy0n wrote:This can not be done as you describe within the fixed function. Sorry.

The texture or the geometry must be split or you must write the functionality into a shader program.
Well this is going to cause problems :lol:

Thanks for the help though.
I'm guessing you're just trying to optimize some shit? ...you could always pick up shaders. :)

Re: OpenGL texture question

Posted: Fri Aug 26, 2011 1:05 pm
by N64vSNES
GyroVorbis wrote:
N64vSNES wrote:
qpHalcy0n wrote:This can not be done as you describe within the fixed function. Sorry.

The texture or the geometry must be split or you must write the functionality into a shader program.
Well this is going to cause problems :lol:

Thanks for the help though.
I'm guessing you're just trying to optimize some shit? ...you could always pick up shaders. :)
Yep. The only alternative would be dropping the whole texture atlas buissness but then I doubt I'd gain much performance having to switch textures. in fact, I might even make it slower that way :lol:

I'll look into shaders...Probably won't end pretty xD

Re: OpenGL texture question

Posted: Fri Aug 26, 2011 6:01 pm
by qpHalcy0n
...or you could just split up the geometry. You know that the vertex transformation pipeline is extremely optimized and that you should have no problem pushing dozens of thousands and thousands and thousands of polys through it.

Re: OpenGL texture question

Posted: Fri Aug 26, 2011 7:00 pm
by N64vSNES
qpHalcy0n wrote:...or you could just split up the geometry. You know that the vertex transformation pipeline is extremely optimized and that you should have no problem pushing dozens of thousands and thousands and thousands of polys through it.
Vertex transformation pipeline, optimized. I was about to say the same thing! :shock:

Re: OpenGL with vertex arrays

Posted: Wed Aug 31, 2011 8:29 am
by N64vSNES
I decided to edit this topic since I didn't want to spam the forum with tedious questions like this.

So I finally took qpHalcy0n's advice...Or reality slap and actually implemented a vertex array for Crafter. (Yes I was stupid enough to render the entire map with the immediate pipeline)

Now it works and perfectly with a much higher poly count as expected. But I did hit a problem with the textures.

Now here is how I render the map:

Code: Select all

		glEnable(GL_TEXTURE_2D);
		glBindTexture(GL_TEXTURE_2D,t_BlockSet.GetTex());
		glColor3f(1,1,1);
		glEnableClientState(GL_VERTEX_ARRAY);
		glEnableClientState(GL_TEXTURE_COORD_ARRAY);

		glVertexPointer(3, GL_FLOAT, 0, &Verts[0].x);
		glTexCoordPointer(2,GL_FLOAT, 0, &TexChoords[0].x);

		glDrawArrays(GL_QUADS,0,i_FacesDrawn * 4);

		glDisableClientState(GL_TEXTURE_COORD_ARRAY);
		glDisableClientState(GL_VERTEX_ARRAY);
The map renders correctly, but the textures are pretty screwed:
Image

So, help? :lol:

The texture coords are definitely correct, there are a equal number of vertices as there are texture coords, all the basic stuff seems fine.

Am I missing something obvious?

Re: OpenGL with vertex arrays

Posted: Wed Aug 31, 2011 10:47 pm
by Ginto8
It looks like some of the edges are slanted, so you might not be feeding some vertices into the pipeline that you should be, or you're feeding them in incorrectly.
The only thing that could make those kinds of texture errors, to my knowledge, is wrong texture coordinates :|

Re: OpenGL with vertex arrays

Posted: Mon Sep 05, 2011 12:24 am
by TheBuzzSaw
Did you switch to indexed rendering? Or are you still repeating vertices?