I have a question for you. Have you noticed an important boost when using the repeat factor instead of using more vertices?

In your case, I would use something close to [0.5,0.5] [4.5,0.5][4.5,2.5][0.5,2.5] (not tested).

Ok, if i understand it correctly, the 0.5 to 4.5 on the x axis means to draw 4 times the texture on this region starting it at the middle of the texture (0.5f)This way it give the clamp point (0.5) and the scale (number of repetitions in the region).

I will try it this evening, i understand better how texCoord works (all examples found are always the same with texCoord from 0 to 1)

I have the same problem, I want to use this feature but all examples I found are simplistic in comparison to what I plan to achieve. I fear that a part of the texture won't appear anyway with my suggestion because the repetitions are identical, you can only repeat the same "part" of the texture or use mirroring whereas in your case you don't want to do that, the very first and the very fast parts don't use the same part of the texture than the ones in the middle.

I have the same problem, I want to use this feature but all examples I found are simplistic in comparison to what I plan to achieve. I fear that a part of the texture won't appear anyway with my suggestion because the repetitions are identical, you can only repeat the same "part" of the texture or use mirroring whereas in your case you don't want to do that, the very first and the very fast parts don't use the same part of the texture than the ones in the middle.

Maybe I'm just misunderstanding but what are you trying to say? Are you asking for help ("have the same problem" ---> STILL have the same problem?) or are you just saying that the examples available on the internet are not very good? =S

But now, i would texture a quad with a repeat factor but only with a region of a texture

So for the example, Considering that i want to use only the rectangle (0.25,0.25) x (0.75,0.75) of a texture.But i want to repeat i 4 times on a quad that have dimension (100,100) and starting at (50,50)

i would do a things like it

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

// bind texture// enable "repeat" mode // set QUAD operation// begin

// first vertexglTexCoord(0.25,0.25);glVertex2f( 50 , 50 );

// second vertex glTexCoord(3.75,0.25);glVertex2f( 150 , 50);

// third vertexglTexCoord( 3.75 , 3.75 );glVertex2f( 150 , 150);

// last vertexglTexCoord( 0.25 , 3.75 );glVertex2f( 50 , 150);

(the vertices order may be wrong, i do it without my dev pc)So if i understand, it will draw like it

Unless you are pushing hundreds of thousands of vertices per frame, just use multiple quads to define each "repeat" of your tile. The performance difference will be negligible and it will allow you to use texture atlases. Use a single glBegin/glEnd to push all of your quads at once. Ideally you should be using vertex arrays instead of immediate mode.

A pixel shader with a one-line main method does the trick, but just drawing many quads work. Textures only wrap around their edges, so you can't do this with wrapping. You could just cut out the needed part into it's own texture...

It's not much more than writing a vertex and fragment shader and binding it. You don't even need a vertex shader if you use older versions of GLSL.

Problem is creating the classes to load Shaders in opengl. thats the most hard part for me.

ShaderProgram + Shader = 120 lines of code for me, with like 30-40% blank lines, and 50% of the Shader class is loading a text file from disc. All in all it's only like 10 encapsulated OpenGL functions. Well, shaders aren't the easiest part of OpenGL at least, I'll give you that. =S

It's not much more than writing a vertex and fragment shader and binding it. You don't even need a vertex shader if you use older versions of GLSL.

Problem is creating the classes to load Shaders in opengl. thats the most hard part for me.

ShaderProgram + Shader = 120 lines of code for me, with like 30-40% blank lines, and 50% of the Shader class is loading a text file from disc. All in all it's only like 10 encapsulated OpenGL functions. Well, shaders aren't the easiest part of OpenGL at least, I'll give you that. =S

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org