SetUV for OpenGL ?

BlitzMax Forums/BlitzMax Programming/SetUV for OpenGL ?

Stu_ovine(Posted 2008) [#1]
I've looked around the forum to find a way of scrolling a basic square (2d) texture.

i.e. draw a quad in max2D, scroll the texture in a constant direction.


I found SetUV for directX but do we have a counterpart for openGL ?


Gabriel(Posted 2008) [#2]
I haven't done any OpenGL in ages, but I think the UV coordinates are supplied with the command glTexCoord2f, something like this :

glTexCoord2f(0.0f, 1.0f)

It goes right before your call to glVertex3f to draw the vertex.


Stu_ovine(Posted 2008) [#3]
I want to still use drawimage (max2D), so the scrolling textures can be placed in front and behind other drawimage images.


If thats possible of course.


Yan(Posted 2008) [#4]
This should contain all you need...



Stu_ovine(Posted 2008) [#5]
Thats what I was after, many thanks


Stu_ovine(Posted 2008) [#6]
Does anyone have a version of this that will work with non ^2 images ?

I have a small banner that I want to scroll , but its 78 pixels high :S


ImaginaryHuman(Posted 2008) [#7]
Are you just scrolling horizontally with no vertical wrapping?


Bremer(Posted 2008) [#8]
This seems to work fine, its the code posted by Yan but cut down to only have the openGL part. And with the example title image, which is much wider than its heigh, it seems to work just fine on my computer.




Stu_ovine(Posted 2008) [#9]
I just want to scroll the Y.

> Zawran - that doesn't wrap the none ^ 2 texture - it leaves a border around the outside of the picture when it wraps


Yan(Posted 2008) [#10]
Scale the original image (pixmap) up to the nearest ^2 vertically, then scale the image's Y axis down by the relevant amount when you draw it.

78 -> 128 = Y * (78 / 128) = SetScale 1, 0.6094


Bremer(Posted 2008) [#11]
hmm, there are no border on the outside here, but it might be that I do not know exactly what you are refereing to. Sorry I couldn't help then.


ImaginaryHuman(Posted 2008) [#12]
How big is the border? 1 pixel wide?


Stu_ovine(Posted 2008) [#13]
Scaling works a treat - Many thanks