OpenGL with vertex arrays
Moderator: Coders of Rage
OpenGL with vertex arrays
EDIT:
See newest post...
See newest post...
Last edited by N64vSNES on Wed Aug 31, 2011 8:36 am, edited 2 times in total.
- Nokurn
- Chaos Rift Regular
- Posts: 164
- Joined: Mon Jan 31, 2011 12:08 pm
- Favorite Gaming Platforms: PC, SNES, Dreamcast, PS2, N64
- Programming Language of Choice: Proper C++
- Location: Southern California
- Contact:
Re: OpenGL texture question
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.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.
- Falco Girgis
- Elysian Shadows Team
- Posts: 10294
- Joined: Thu May 20, 2004 2:04 pm
- Current Project: Elysian Shadows
- Favorite Gaming Platforms: Dreamcast, SNES, NES
- Programming Language of Choice: C/++
- Location: Studio Vorbis, AL
- Contact:
Re: OpenGL texture question
That's exactly what I was going to say.Krolgar wrote: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.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.
You never asked us a question.
Re: OpenGL texture question
Yes I see where I went wrong there
I'll start from the beginning
Suppose this is my texture:
I want to use this texture on a quad like this:
I could break the quad into 4 different quads but then I'm losing performance.
Short and simple as possible
I'll start from the beginning
Suppose this is my texture:
I want to use this texture on a quad like this:
I could break the quad into 4 different quads but then I'm losing performance.
Short and simple as possible
-
- Respected Programmer
- Posts: 387
- Joined: Fri Dec 19, 2008 3:33 pm
- Location: Dallas
- Contact:
Re: OpenGL texture question
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.
The texture or the geometry must be split or you must write the functionality into a shader program.
Re: OpenGL texture question
Well this is going to cause problemsqpHalcy0n 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.
Thanks for the help though.
- Falco Girgis
- Elysian Shadows Team
- Posts: 10294
- Joined: Thu May 20, 2004 2:04 pm
- Current Project: Elysian Shadows
- Favorite Gaming Platforms: Dreamcast, SNES, NES
- Programming Language of Choice: C/++
- Location: Studio Vorbis, AL
- Contact:
Re: OpenGL texture question
I'm guessing you're just trying to optimize some shit? ...you could always pick up shaders.N64vSNES wrote:Well this is going to cause problemsqpHalcy0n 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.
Thanks for the help though.
Re: OpenGL texture question
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 wayGyroVorbis wrote:I'm guessing you're just trying to optimize some shit? ...you could always pick up shaders.N64vSNES wrote:Well this is going to cause problemsqpHalcy0n 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.
Thanks for the help though.
I'll look into shaders...Probably won't end pretty xD
-
- Respected Programmer
- Posts: 387
- Joined: Fri Dec 19, 2008 3:33 pm
- Location: Dallas
- Contact:
Re: OpenGL texture question
...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
Vertex transformation pipeline, optimized. I was about to say the same thing!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.
Re: OpenGL with vertex arrays
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:
The map renders correctly, but the textures are pretty screwed:
So, help?
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?
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);
So, help?
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?
- Ginto8
- ES Beta Backer
- Posts: 1064
- Joined: Tue Jan 06, 2009 4:12 pm
- Programming Language of Choice: C/C++, Java
Re: OpenGL with vertex arrays
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
The only thing that could make those kinds of texture errors, to my knowledge, is wrong texture coordinates
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
- TheBuzzSaw
- Chaos Rift Junior
- Posts: 310
- Joined: Wed Dec 02, 2009 3:55 pm
- Current Project: Paroxysm
- Favorite Gaming Platforms: PC
- Programming Language of Choice: C++
- Contact:
Re: OpenGL with vertex arrays
Did you switch to indexed rendering? Or are you still repeating vertices?