Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8472287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:01:21+00:00 2026-06-10T17:01:21+00:00

I have this code for drawing my parallax background pGLState.pushModelViewGLMatrix(); final float cameraWidth =

  • 0

I have this code for drawing my parallax background

pGLState.pushModelViewGLMatrix();
final float cameraWidth = pCamera.getWidth();
final float cameraHeight = pCamera.getHeight();
final float shapeWidthScaled = this.mShape.getWidthScaled();
final float shapeHeightScaled = this.mShape.getHeightScaled();

//reposition

float baseOffsetX = (pParallaxValueX * this.mParallaxFactorX);
if (this.mRepeatX) {
    baseOffsetX = baseOffsetX % shapeWidthScaled;
    while(baseOffsetX > 0) {
            baseOffsetX -= shapeWidthScaled;
    }
}

float baseOffsetY = (pParallaxValueY * this.mParallaxFactorY);
if (this.mRepeatY) {
    baseOffsetY = baseOffsetY % shapeHeightScaled;
    while(baseOffsetY > 0) {
        baseOffsetY -= shapeHeightScaled;
    }                              
}

//draw

pGLState.translateModelViewGLMatrixf(baseOffsetX, baseOffsetY, 0);
float currentMaxX = baseOffsetX;
float currentMaxY = baseOffsetY;
do {     

    //rows     

    this.mShape.onDraw(pGLState, pCamera);
    if (this.mRepeatY) {
        currentMaxY = baseOffsetY;   

        //columns  

        do {       
            pGLState.translateModelViewGLMatrixf(0, shapeHeightScaled, 0);
            currentMaxY += shapeHeightScaled;                                              
            this.mShape.onDraw(pGLState, pCamera);
        } while(currentMaxY < cameraHeight);      

        //end columns

        pGLState.translateModelViewGLMatrixf(0, -currentMaxY + baseOffsetY, 0);                                    
    }

pGLState.translateModelViewGLMatrixf(shapeWidthScaled, 0, 0);
currentMaxX += shapeWidthScaled;
} while (this.mRepeatX && currentMaxX < cameraWidth); 

//end rows

pGLState.popModelViewGLMatrix();

Everything is working good when camera is not rotated.

When it is rotated, I think tile (this.mShape) should be drawn four more times (top, bottom, left and right) so no empty space in the corner is visible. For example, when rotation is 45 degrees, but I can’t figure out how to do this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T17:01:24+00:00Added an answer on June 10, 2026 at 5:01 pm

    It seems from the explanation that you have a 2×2 set of tiles and you would like to rotate them. But when you do there are gaps in the corners? so instead of doing this

        [][]
        [][]
    

    2×2 tile set do this

        [][][]
        [][][]
        [][][]
    

    3×3 tile set
    and center it on the center tiles, then fill in around it.

    If it is important that you have a 4 tile pattern with the common corner in the center then you will have to do this

        [][][][]
        [][][][]
        [][][][]
        [][][][]
    

    4×4 Tile set. Basically just build around your 2×2. Now when you rotate your background there will be no gap in the corners.

    The rest id just math.

    In opengl you are rotating the world, not the object. So to think of it like this you are rotating the x,y,z planes from

            |
            |
        ---------
            |
            |
    

    too

         \      /
          \    /
           \  /
            ><
           /  \
          /    \
         /      \
    

    so now the geometry will rotated to the position which it was drawn plus rotation. So if i had a sqare with a corner at x,y,z (10,0,0) that point would still be at (10,0,0) but the X axis will have been rotated say 45′ so the object will apear 10 X-units distance from the origin of (0,0,0) at a 45′ angle on the XY plane.

    So all it is is about redrawing your tile, at offsets.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code <div id=main style=background:#aaaaaa;float:left;height:160px;margin:5px;position:relative;display:block;width:630px;> <div id=1 class=item style=background:#ffaacc;float:left;width:200px;height:150px;margin:5px;position:absolute;left:0px;top:0px;> </div> <div id=2
I have this line of code: System.Drawing.Icon icon = System.Drawing.Icon.FromHandle(shinfo.hIcon); A few lines later,
I have this code in XAML <Grid x:Name=LayoutRoot Background=Transparent> <Grid.RowDefinitions> <RowDefinition Height=Auto/> <RowDefinition Height=*/>
I have this code for drawing on a UIImageView , I want to save
I have this working code for animating drawing a line in Raphael JS: var
So far I have this code. $form = New-Object System.Windows.Forms.Form $form.Size = New-Object System.Drawing.Size(900,600)
I have this code : void Main() { System.Timers.Timer t = new System.Timers.Timer (1000);
I have this code for changing the image of a button: - (void)mouseEntered:(NSEvent *)event
I have this code: EditText value = ( EditText )findViewById( R.id.editbox ); Integer int_value
I have this code: ie1.link(:text, /Exception:/) It is producing an error message which I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.