no, what i meant is that it can only handle one texture id. so it can show lots of locations but only one texture image.MooZ wrote:If you have multiple texture coordinate per vertex use glClientActiveTexture(GL_TEXTURE0+texUnit) before calling glTexCoordPointer.
And you can have one big VBO that stores all your data (vertices and texture coordinates). The last parameter of gl[Vertex|Normal|Color|TexCoord|Whatever]Pointer is the offset in the VBO.
Check the VBO article on OpenGL wiki for more infos.
ZEdit: the ultimate PCE dev tool
Re: ZEdit: the utilmate PCE dev tool
Re: ZEdit: the utilmate PCE dev tool
You can have multiple textures! The code will more or less look like this:
Code: Select all
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texId[0]);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, texId[1]);
glBindBuffer(GL_ARRAY_BUFFER, vboId);
glVertexPointer(3, GL_FLOAT, 64, BUFFER_OFFSET(0));
glNormalPointer(GL_FLOAT, 64, BUFFER_OFFSET(12));
glClientActiveTexture(GL_TEXTURE0);
glTexCoordPointer(2, GL_FLOAT, 64, BUFFER_OFFSET(24));
glClientActiveTexture(GL_TEXTURE1);
glTexCoordPointer(2, GL_FLOAT, 64, BUFFER_OFFSET(32));
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexId);
glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_SHORT, BUFFER_OFFSET(0));
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glActiveTexture(GL.GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, 0);
glActiveTexture(GL.GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, 0);
Re: ZEdit: the utilmate PCE dev tool
And another [LINK].
By the way don't forget to call glEnableClientState( GL_TEXTURE_COORD_ARRAY ) during OpenGL init.
By the way don't forget to call glEnableClientState( GL_TEXTURE_COORD_ARRAY ) during OpenGL init.
Re: ZEdit: the utilmate PCE dev tool
that code is for layering textures. i dont want layer them at all. what i do want is something like this:MooZ wrote:You can have multiple textures! The code will more or less look like this:
Code: Select all
glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, texId[0]); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, texId[1]); glBindBuffer(GL_ARRAY_BUFFER, vboId); glVertexPointer(3, GL_FLOAT, 64, BUFFER_OFFSET(0)); glNormalPointer(GL_FLOAT, 64, BUFFER_OFFSET(12)); glClientActiveTexture(GL_TEXTURE0); glTexCoordPointer(2, GL_FLOAT, 64, BUFFER_OFFSET(24)); glClientActiveTexture(GL_TEXTURE1); glTexCoordPointer(2, GL_FLOAT, 64, BUFFER_OFFSET(32)); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexId); glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_SHORT, BUFFER_OFFSET(0)); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glBindBuffer(GL_ARRAY_BUFFER, 0); glActiveTexture(GL.GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, 0); glActiveTexture(GL.GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, 0);
Code: Select all
GLint coords[] = { 0, 0, // x, y coordinants
16, 16,
64, 0 };
GLint indexes[3];
indexes[0] = texture_ids[7]; // texture #7 will be at 0, 0
indexes[1] = texture_ids[1]; // texture #1 will be at 16,16
indexes[2] = texture_ids[18]; // texture #18 will be at 64, 0
glDrawTextures2i(target, coords, indexes);
Re: ZEdit: the utilmate PCE dev tool
ok, so mooz explained to me that that all the tiles should be on a single texture which is where everything got screwed up. it's doing the same trick as the single multiple images from a single image using css.
anyway, i FINALLY got a framebuffer to display SOMETHING.
this will be sweet when it works completely.
anyway, i FINALLY got a framebuffer to display SOMETHING.
this will be sweet when it works completely.
Re: ZEdit: the utilmate PCE dev tool
while qt has it's own opengl module that can do fancy stuff, it also limits what you can do. unfortunately, the widget creates a framebuffer for itself and so when i made one of my own, there were some conflicts and the result was update wonkyness, i have finally managed to make it so that there is an empty space and i can just do anything in opengl that i want. initial results of doing this arent great but it's a proof of concept.
oh and for the record, getting it to just show that was a pain in the ass.
oh and for the record, getting it to just show that was a pain in the ass.
Re: ZEdit: the utilmate PCE dev tool
i seem to have found the root of the latest display wonkyness. this is a small opengl demo with two copies of the same widget. both panes "should" be identical.
however, the current code is for X11 only, so you windows and mac people are screwed.
however, the current code is for X11 only, so you windows and mac people are screwed.
-
- Posts: 38
- Joined: Sun Jun 22, 2008 5:18 pm
- Contact:
Re: ZEdit: the utilmate PCE dev tool
One step closer, good job!My To Do List:
1. Fix gears demo. << DONE
2. ???
3. Conquer the world.
So how did you fix it?
Don't forget your two NOPs after CSH.
Re: ZEdit: the utilmate PCE dev tool
i forgot to set the "context" before drawing as each opengl widget has it's own. in the constructor, the the context is created and bound. the result was that the last widget created was the only one to have the context it needed bound. it was a one line fix.Charles MacDonald wrote: So how did you fix it?
i plan to add buffer and texture sharing so that changes using one widget will change them all at once which is good when editng tiles.
textures however are proving difficult and i'm struggling. using framebuffers has once again proved itself to be completely non-functional.
im working out opengl problems using external example code that uses GLUT. i dont want to use GLUT due to it's additional library dependency and some windowing issues but i may have to reconsider should the external example work well.
yep, my geek level is increasing.
i almost forgot to mention it, i've spent lots of time playing Darksiders for PS3 so my nerd level is increasing too.