Scrolling Background Texture

I have a background, I want it to scroll from right to left
horizontally.  The background is just a texture.

The background width is the same size as the size of screen, so it
should just wrap around the screen, it's just a field of grass that
keeps repeating.

I have read about tiles but this seems too complex for this simple
application.

Any help, in any programming language using openGL is appreciated.

Thanks in advance.
0
1/26/2004 1:49:30 PM
comp.graphics.api.opengl 7072 articles. 1 followers. Post Follow

5 Replies
1126 Views

Similar Articles

[PageSpeed] 28
"Sally" <womanontheinside@yahoo.com> schrieb im Newsbeitrag
news:3080cb7f.0401260549.4f584b1c@posting.google.com...
> I have a background, I want it to scroll from right to left
> horizontally.  The background is just a texture.
>
> The background width is the same size as the size of screen, so it
> should just wrap around the screen, it's just a field of grass that
> keeps repeating.
>
> I have read about tiles but this seems too complex for this simple
> application.
>
> Any help, in any programming language using openGL is appreciated.
>
> Thanks in advance.

Draw 2 tiles only and get the position with the mod-result of the
screen width:

x_offset = (mousepos_x() % screen_x);

DrawTexture(Background, x_offset           , 0); // Right part
DrawTexture(Background, x_offset - screen_x, 0); // Left part

HTH,

-- 
-Gernot

Post here, don't email. If you feel you have to mail, revert my
forename from:
tonreG.Frisch.at.Dream-D-Sign.de@invalid.com
________________________________________
Looking for a good game? Do it yourself!
GLBasic - you can do
www.GLBasic.com





0
Gernot
1/26/2004 2:20:26 PM
just manipulate your texturecoords of your background quad in your scrolling
direction.
something like glTexCoord2f(i+1,0) where i is increased every frame.
of cause for every vertex;-)

in c++:
i>1?i=0.0:i+=0.01;

be sure to set the texture environment to GL_REPEAT (IIRC)

hth psy


0
Sebastian
1/26/2004 2:27:37 PM
womanontheinside@yahoo.com (Sally) wrote in message news:<3080cb7f.0401260549.4f584b1c@posting.google.com>...
> I have a background, I want it to scroll from right to left
> horizontally.  The background is just a texture.
> 
> The background width is the same size as the size of screen, so it
> should just wrap around the screen, it's just a field of grass that
> keeps repeating.
> 
> I have read about tiles but this seems too complex for this simple
> application.
> 
> Any help, in any programming language using openGL is appreciated.
> 
> Thanks in advance.

Just change the matrix mode to GL_TEXTURE. Then do ordinary
glTranslate calls to translate the texture coordinates in the
direction you want. Or maybe it is better to texture both sides of
your background geometry (rectangle) and use glRotate (so you will not
"run out of" texture). Dont forget to change the matrix mode back to
GL_MODELVIEW before drawing the geometry again.
This should work.
0
marcus
1/27/2004 9:15:53 AM
> just manipulate your texturecoords of your background quad in your scrolling
> direction.
> something like glTexCoord2f(i+1,0) where i is increased every frame.
> of cause for every vertex;-)

I do that.  The canvas is 600px wide.  But all I get is a 1px wide
texture scrolling accorss the screen from the right to the left, the
rest is black.  Imagine why:

Initial: 0,0.  600,0. 600,600. 0,600.

Then the next after I decrement (scrolling left):

600,0. 599,0. 599,600. 600,600.

Leaving the exture being shown as just 1px wide on the X axis.

> be sure to set the texture environment to GL_REPEAT (IIRC)

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
0
womanontheinside
1/27/2004 1:18:40 PM
Sally wrote:

>>just manipulate your texturecoords of your background quad in your scrolling
>>direction.
>>something like glTexCoord2f(i+1,0) where i is increased every frame.
>>of cause for every vertex;-)
> 
> 
> I do that.  The canvas is 600px wide.  But all I get is a 1px wide
> texture scrolling accorss the screen from the right to the left, the
> rest is black.  Imagine why:
> 
> Initial: 0,0.  600,0. 600,600. 0,600.
> 
> Then the next after I decrement (scrolling left):
> 
> 600,0. 599,0. 599,600. 600,600.
> 
> Leaving the exture being shown as just 1px wide on the X axis.

Repeat mode only works for power-of-two sized textures in 'standard' 
OpenGL. It may work for the extensions, I don't know.

It sounds like you will need to render two quads -- one for the region 0 
to 'g' on the right, and 'g' to 1.0 on the left. 'g' may be 0 or 1.

--
Andy V

0
Andy
1/28/2004 1:20:02 AM
Reply:
Similar artilces about - Scrolling Background Texture:

Simple background sound effect playback
This is a multi-part message in MIME format. ------=_NextPart_000_006C_01D01962.2A75B170 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Would prefer to use something free, that could work somewhat = cross-platform, but, my primary target is for windows OS, and would = primarily just want to be able to easily trigger playback of either .wav = or .mp3 background sound effects, but, yes, would also be nice to be = able to control them a little bit in terms of volume, possibly stereo = panning as well as playback rate/frequency/p...

auto-scrolling problem
Using a Gnome desktop with Ubuntu 10.04 LTS and all applicable upgrades, I've recently (past few days) encountered a problem with applications apparently auto-scrolling, and am wondering how this occurs and especially what to do to disable it. The auto-scrolling occurs with Firefox (auto-scrolling disabled in preferences), Evolution mail, pan, nautilus et.al., causing me to believe that some desktop preference in Gnome has gotten changed somehow. Can anyone advise, please? Greg Russell <me@invalid.org> burped up warm pablum in news:9fuensFhskU1@mid.individual.net: > The ...

SetDIBitsToDevice and scrolling bitmaps
I am using SetDIBitsToDevice or StretchDIBits to paint bitmaps to a window (it has just the bitmap). I'd like to scroll byt bitmap nn pixels right and mm pixels down. What is the easiest way. I've googled for a way but my search keywords don't seem to find an answer. John. > I'd like to scroll byt bitmap nn pixels right and mm pixels down. > What is the easiest way. Change the XDest and YDest values (argument #2 and #3) in either function. They may be set positive, but also negative (making the image move left and up). Regards, Rudy Wieser -- Ori...

Excel Background picture
Hi, I want through vb to open a new excel sheet (works) insert a background picture (works) and load an already prefabed excel table on top of the picture (AND THAT DOES NOT WORK ;-() !!!!! any ideas !!!! When I try it manually in excel it works, but as soon as i start recording a macro to get the right syntax for vb, it blocks completely the picture control to put it into the background. !!!!! please help !!!! THX Thomas ...

PS3 - Elder Scrolls IV: Oblivion
The Elder Scrolls IV: Oblivion Hands-on We escape the gates of Oblivion for these hands-on impressions. by Jeff Haynes February 6, 2007 - Fans of the Elder Scrolls series have always loved the flexibility the franchise afforded them during their adventures, but when the eagerly awaited Elder Scrolls IV: Oblivion was released last March, even they were astounded by its depth. Players could literally choose their own adventure within the massive game, which offered over 200 hours of play. Characters could be customized in various ways, and it was easy for gamers to make powerful magic users, f...

Unable to open file scroll.c
Hi, i installed wine version 20040505 on a Gentoo system. When running a delphi-program I receive an error (see below). It looks strange that the program looks for the file scroll.c in a temporary gentoo folder?!? Has anybody an idea about this problem? Thanks, Armin. wine: Unhandled exception (thread 000a), starting debugger... WineDbg starting on pid 8 .. .. .. 023b: sel=11df base=408cc000 limit=00001fff 32-bit rw- Backtrace: =>0 0x4073cf21 (SCROLL_GetScrollRange+0x31(hwnd=0x10034, nBar=0x2, lpMin=0x45f0, lpMax=0x40e545f4) [scroll.c:1207] in USER32.DLL) (ebp=40e5...

Changing background color -- erase tool (PS, CS4)
When I use the Erase tool, what remains is checkerboard pattern. How can I change this checkerboard to match the solid pattern/color of the surrounding pixels? Thanks. In PS CS5, Edit|Preferences|Transparency&Gamut|Transparency Settings Should be similar in PS CS4 On 6/26/2011 7:50 PM, Gloria West wrote: > When I use the Erase tool, what remains is checkerboard pattern. > > How can I change this checkerboard to match the solid pattern/color of the > surrounding pixels? > > Thanks. > "Jonz" <no.one@ishome.com> wrote in message news:iu8rro$5...

Scroll in KDE
Hi, all May I configure my mause for use scroll in KDE??? How cad I do it? On Thu, 04 Mar 2004 16:20:33 +0000 alex <alex@trinity.ntu-kpi.kiev.ua> wrote: > Hi, all > May I configure my mause for use scroll in KDE??? > How cad I do it? Hi in /etc/X11/XF86Config find Section "InputDevice" Identifier "Mouse0" and add Option "Buttons" "5" Option "ZAxisMapping" "4 5" before EndSection -- Us - http://www.sweet-sorrow.com ----- All trespassers will be ...

REXX using ISPF
Hi, I am looking for some SAMPLE rexx code and diaglogue that shows me how to process an ISPF panel with a dynamic area that validates INPUT fields withion that area (and potentially update colour settings on the fly) I tried to do this via the MODEL lines and TBDISPL but I could n't set "specific" lines hence the need for the dynamic approach... Cheers Jane You'd be better off on an ISPF forum, as none of this has anything REXX-specific to it. Mapping a table into a dynamic area is done the same way any dynamic area is done, except you now have to do the table manipu...

[AD/ANN] NewTek Releases Sixth Free Texture Collection
NewTek has a holiday treat for all digital artists - our Sixth Edition of our Free Texture Collection! As with previous editions, this new set includes fifty high-resolution textures available for free download at NewTek.com. The total number of free textures available from NewTek is now at 300. The sixth edition of the texture collection contains images in the categories Concrete, Nature, Soil, Stone and Wood, and most images in this latest set are at even higher pixel resolutions than NewTek's first five sets. For our complete press release: http://www.newtek.com/n...

Jtable with large columns scrolling issue
In one of my project, the jtable has 160 columns and 100 rows. I have vector as a data model. The problem is the jtable is very slow to scroll. Even if I switch applications and come back to this Jtable it grays out for few seconds as it is printing each cell again. How do i improve this performance. Which is the best data model to use for large tables. How do i restrict the painting to only the visible cells in the viewport rather than all the cells in jtable. I have the jtable.settooltiptext(null) already set but not much improvement please advise thanks Kamlesh njethwa@gmail.com ...

Browser scrolling
I have two bBrowser windows - one for clients and one for inventory. The client browser scrolls with the mouse wheel. The inventory browser does not - and can't find the reason for the difference. Any advice would be greatly appreciated. Kuno Hi Kuno, Is the second bBrw depending on the first? regards Urs (Geoff's standard answer was "What about a little code???)( "Kuno Egger" <kuno@retailsoftware.com> schrieb im Newsbeitrag news:90fa05ef-009a-47c5-bc5e-880f77302cf1@googlegroups.com... >I have two bBrowser windows - one for clients a...

How do I can the background color...
I'm looking for a way to change the background color of a single line of text containing ASCII text. The platform is Win32 (Win2K & XP). TIA. BOOL SetConsoleTextAttribute( HANDLE hConsoleOutput, WORD wAttributes ); Parameters hConsoleOutput [in] Handle to a console screen buffer. The handle must have the GENERIC_READ access right. For more information, see Console Buffer Security and Access Rights. wAttributes [in] Character attributes.Attribute Meaning FOREGROUND_BLUE Text color contains blue. FOREGROUND_GREEN Text color contains green. FORE...

US-TX-Austin: Inside Sales Rep., Inside Sales Background or Cold Calling Exp., c (45356157602)
US-TX-Austin: Inside Sales Rep., Inside Sales Background or Cold Calling Exp., c (45356157602) ============================================================================================== Position: Sales Rep. Reference: ZYD00005 Location: Austin TX Duration: Contract to Perm Skills: Inside Sales Rep Background or Cold Calling Exp. Outgoing Self-Motivated Strong Personal Character Exceptional Values Strong Personality Team Player Good Perseverance ...

Scroll mouse support?
I decided to try out a scroll mouse on OS/2 (finally). But despite having looked back in the newsgroups, I'm not sure what I should be going for driver-wise. I see the IBM Single Mouse Driver (SMOUSE), which I can find and download. I hear about AMOUSE; who provides that, and does it do what I want? Are there any other drivers? Recommendations? Thanks for any information... -- Bob Eager IBM driver works fine but Amouse has much more features and supports more than 2 mouse buttons. It also provides adjustable acceleration, configurable mouse buttons and audio vol...

image with transparent background
how do i generate an image with transparente background? is it possible? thanks in advance, raphael vilamiu Hi, can you give a example ? J�r�me J�r�me wrote: > > > Hi, > > can you give a example ? > > J�r�me i'm doing a presentation with latex and using a color background. it's just not cute to have plots with white background while the presentation background is another colors. raphael > i'm doing a presentation with latex and using a color background. > it's just not cute to have plots with white background while the > presentation backgr...

US-TX-Austin: Inside Sales Rep., Inside Sales Background or Cold Calling Exp., c (45356357619)
US-TX-Austin: Inside Sales Rep., Inside Sales Background or Cold Calling Exp., c (45356357619) ============================================================================================== Position: Sales Rep. Reference: ZYD00005 Location: Austin TX Duration: Contract to Perm Skills: Inside Sales Rep Background or Cold Calling Exp. Outgoing Self-Motivated Strong Personal Character Exceptional Values Strong Personality Team Player Good Perseverance ...

form image background and tab control
I am using Access 2000 and have a form with an image background (the clouds that came with Office). I also have an OnChange event on the Item control. Me.txtLength = 55 - (Len(Me.Item.Text)) Everthing works just fine. I then added a tab control. Now, whenever I add/change/delete data in the Item control, the screen flickers. If I take out the event, there is no flicker. If I use the event and remove the image, there is no flicker. If I remove the tab control and use the event there is no flicker. I am positive that it is the tab control, the OnChange event and the image combined that are ca...

Scrolling
I have a JTextArea associated with a JScrollPort, and everything works fine except the end of the text is initially displayed. How do I reposition the view to the beginning? Thanks Paul Paul Thompson wrote: > I have a JTextArea associated with a JScrollPort, and everything works > fine except the end of the text is initially displayed. How do I > reposition the view to the beginning? > > Thanks > Paul JTextComponent.setCaretPosition(0); -- Knute Johnson email s/nospam/knute/ ...

AJAX and scrolling layers problem
I have a layer, which is a DIV that has overflow set to "auto", so it looks like a little pop-up window, even though it's just a layer. So if the content of that window makes the user scroll down to read it, and the user clicks a link while scrolled down, and the AJAX function calls new data into that DIV, that data, if overflowed, will also be scrolled down. So basically it's like if you scrolled down to the bottom of slashdot.org, clicked a link to usatoday.com, and when you got to usatoday.com, the page was scrolled to the bottom of the page instead of at the top. Any...

set background of uicontrol text box to be transparent?
Hello Is there any way to turn the background of the text box uicontrol to be transparent? ex: I have a figure window which has an image displayed on it. I just want the text part of the uicontrol to be displayed and want the rest of the part to be transparent so that I can see the image displayed in the figure window beneath it. I have tried this but this doesnt help; load trees h1 = figure, h2 = imshow(X,map); h=uicontrol('style','text','string','hello'); set(h,'position',[100 150 50 20]); parentColor = get(get(h, 'parent'...

Scroll view, scrolled by how much?
Hi, I have a simple window based on CScrollView and it works OK. How do I find out how many pixels I've scrolled? Thanks, Paul "pf" <paulfredlein@NOSPAMoptusnet.com.au> wrote in message news:42588736$0$29863$afc38c87@news.optusnet.com.au... > Hi, > > I have a simple window based on CScrollView and it works OK. How do I find > out how many pixels I've scrolled? Hmm.. at least by subclassing the control and checking the update rectangle of WM_PAINT. - Sten Catch the WM_VSCROLL or WM_HSCROLL of the CScrollView, they get call...

Scroll content inside InputField?
Dear Group, Is there a way to make the content of a fixed-sized InputField scrollable? In this example, the list won't fit in the InputField, still I want to make the full content accessible for the user, preferably via some scrollbar, but I'm open to other methods as well. cont = Range@20; Dynamic@InputField[Dynamic@cont, ImageSize -> {150, 40}] Thanks, Istvan ...

scrolling
I always hated how when you scroll PDF it just shows the page numbers and not the actual content, and then a few days ago I noticed that one of my computers actually scrolls the content! So I checked and sure enough, my main computer was badly out-of-date so I updated the version and it's still only scrolling the page numbers. Where is the setting for this? TIA Well now it's scrolling the content after I was clicking around looking at stuff for a bit... but I have no idea why it's not doing the page numbers anymore and waiting until I let go to move. I have no idea wh...

US-TX-Dallas: Acct. Executive Mgr., Telephone sales background, Internet; C-P (45306357603)
US-TX-Dallas: Acct. Executive Mgr., Telephone sales background, Internet; C-P (45306357603) =========================================================================================== Position: Acct. Executive Mgr. Reference: SMC01454 Location: Dallas TX Duration: C-P Skills: 3+yrs in a marketing research environment with a strong telephone sales background. Prior telephone or internet interviewing experience. interviewing experience. Please send your current resume in confidence to <staffing@eurosoft-inc.com&g...