Keeping quads size when using VBO and glScale

I want to draw many quads with textures - And on the right of them few more small quad with textures. (for ex. Image and text on the side)

I’ve mapped my window as pixels 2D and made it work with VBO. works great.

the problem is that i want to zoom in into area of quads without scaling the size of them. When i use glScale its affecting the quads size also (which is logically). I need just to affect their position.

Is there a way to do that?

Thanks.

Can you not just multiply the position of the text quads by the scale factor to calculate their positions without using glScalef?

I guess you mean to update the vertex array.

I could, but then i would have to update my 100,000 or more quads in the VBO which mean 4 vertexes each… and its takes CPU time which will affect the drawing in the end.

I guess you mean to update the vertex array.

No, he means that you compute a positional offset, that represents the scaled location of the text, to your vertex shader and have it add that to each of the vertex positions. Your shader need not know that this offset came from a scaled coordinate system.

First of all, thanks for the help so far.

but,
i didn’t quite understand. Can you give me an example for what you meant ?

By the way, I don’t use (or know) shader on my program.
(I know the concept but not too much, I will learn more about it now)

there is not a “none-shader way” to do that?

The non shader approach is to build and supply a model matrix to OpenGL. This is exactly what glScalef does. However using the fixed function pipe line is limited and for what you need to do vertex shader code is required.

Ok…

I will read allot more now about shaders and hopefully will understand it and your answers :slight_smile:

Most thanks guys…

Hi again,
Read allot about GLSL again.
And i guess i will have to ask for an hint or direction.

I narrowed my problem only to two quads, and my goal is to zoom in between them with out affecting their sizes, just their pos.

Each quad vertexes had been calculated before from its center point, so the quad will be in the center of the real position.

As i got it, i need to calculate the new gl_position(s) of all the new points. I removed the glscale from from the code and i sent the factor as uniform to the shader, but now what? each multiply is affecting all and i got the same result like glScale.

I’m hopeless here.

thanks.

OK, found a solution! just to close this issue in case someone need an answer but me.

I filled my quads vertexes array with the centers of the quads.
Meaning that all 4 vertexes of each quad will be its center.

In addition, I’v add a vertex attribute to each which indicates the vertex position - TopLeft\TopRight\BottomRight\BottomLeft (-1,-1)(1,-1)(1,1)(-1,1)

To make it play together, I’ve build vertex shader which computes each vertex, using the attribute and the center of the quad (with additional scale params - just to see the quad bigger or smaller).

That’s it.

this is what you meant? or there is an easier way ? (Now that i speak GLSL :smiley: )

Thanks all for reply.
and the rest for ignoring :stuck_out_tongue: