Advertisement

How can I mix the VertexArray and MultiTexturing Extentions ?

Started by October 17, 2003 05:19 AM
5 comments, last by Feaber 21 years, 4 months ago
I writing now some engine I need to know how to mix the VertexArray and MultiTexturing Extentions ? The problem is that I dont know how to implement meny textres' coordinances in VertexArray... [edited by - Feaber on October 17, 2003 6:22:28 AM]
By using the glClientActiveTextureARB extension.
For example:

glEnableClientState(GL_VERTEX_ARRAY);glEnableClientState(GL_TEXTURE_COORD_ARRAY); glVertexPointer(3,GL_FLOAT,0,vertexArray);glClientActiveTextureARB(GL_TEXTURE0_ARB); glTexCoordPointer(2, GL_FLOAT, 0,texCoordArray);glClientActiveTextureARB(GL_TEXTURE1_ARB); glTexCoordPointer(2, GL_FLOAT, 0,texCoordArray);glDrawArrays(GL_TRIANGLES,0,triangleCount*3);	
Advertisement
quote:
Original post by Feaber
The problem is that I dont know how to implement meny textres' coordinances in VertexArray...
[edited by - Feaber on October 17, 2003 6:22:28 AM


Maybe you'll find it way too ugly but I used an array of pointers to structs. Each struct contains all the informations about the texCoord array for texUnit[n] and the texCoord array itself, which is in fact not an array.

As a side note, everything will be easier (and potentially even **faster**) if you drop the old fixed function pipe and you do everything using generic vertex attributes.

EDIT: last statement in italic. Why? Messed up quote. Fixed.
EDIT: italic fixed. Mental note to self: do not use 'i' as an index in array notation.

[edited by - Krohm on October 17, 2003 12:12:57 PM]

Previously "Krohm"

Thx for youre quick answer.
This help me a lot.




[edited by - Feaber on October 17, 2003 6:51:55 PM]
Krohm : while using generic vertex attributes, you pretend that vertex programs are supported and used, which is a pretty big deal to say the least. At first glance, I''d rather begin without vp''s if I were him no offense intended of course
quote:
Original post by vincoof
Krohm : while using generic vertex attributes, you pretend that vertex programs are supported and used, which is a pretty big deal to say the least. At first glance, I''d rather begin without vp''s if I were him no offense intended of course

Yes, this is the really big part. I am somewhat happy you pointed out this, no problem at all for that.

Now, the decision was very hard. Vertex programs allows to have a faster api and a faster development by turn, I am forced to use vertex programs in every application and to drop support for older fixed function vertex pipes.
About the support: there''s really no problem. A lot of people is getting ARB_vp supported (maybe in software, this is the case of NV1x hardware) I am fine there. Dropping the old fixed pipe still hurts a bit however, there would be no point in making it compatible. When my technology will be ready everyone will have GLslang in hardware.
About using VPs: this is THE real pain. It turns out however that writing the VP I need is really not too bad. As soon as the whole thing will be running, the shading subsystem will take care of writing the VP automatically.

So, to sum up, using VPs instead of fixed pipe is foward looking. The bad point is that it makes development of little experiments a real pain.

Now, this is a choice you are encouraged to evaluate yourself. Will you like faster performance on the finished product or design a vertex management api so you can develop mid projects easily. For me, the former pays more as for you, you only know how much you need to experiment and practice your skills.

About beginning on the fixed pipe and moving to VP: not usre about that. If possible, I would just jump on the programmable pipe bandwagon and forget about fixed pipe... Having a generalized interface sounds somewhat better to me. For example, you just need to remember that ''position'' (v[0] or vertex.attrib[0]) is the only special attribute while the others can be whatever you want. In the fixed pipe you need to remember that normal has only 3 components (I must admit this is quite easy to remember, I am doing a very stupid example ), that NormalPointer has different sintax from VertexPointer and so go on.

I suggest everyone to experiment, to think at solutions with their own head, to go off the beaten path (possibly learning something in the most painful way but this will turn always useful) because this is how you will really enjoy (personal opinion).

Thank you for reading a long post!

Previously "Krohm"

Advertisement
If all hardware supported VP, I would only write VP's and forget about the fixed pipe too, but that's me with few years of OpenGL behind. When I started to learn OpenGL I'm not sure if I would have liked learning the generalized VP interface. Maybe VP's help you understand more deeply some important graphics design, but in the short run I think it would confuse before all.

And VP's have con's too, not only pro's. For instance, if you switch on/off texgen you have to write two vertex program strings.

[edited by - vincoof on October 20, 2003 3:39:46 PM]

This topic is closed to new replies.

Advertisement