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

  • Home
  • SEARCH
  • 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 1032215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:02:48+00:00 2026-05-16T14:02:48+00:00

My application is a vector drawing application. It works with OpenGL. I will be

  • 0

My application is a vector drawing application. It works with OpenGL. I will be modifying it to instead use the Cairo 2D graphics library. The issue is with zooming. With openGL camera and scale factor sort of work like this:

 float scalediv = Current_Scene().camera.ScaleFactor / 2.0f;
 float cameraX = GetCameraX();
 float cameraY = GetCameraY();
 glMatrixMode(GL_PROJECTION);
 glLoadIdentity();

 float left = cameraX - ((float)controls.MainGlFrame.Dimensions.x) * scalediv;
 float right = cameraX + ((float)controls.MainGlFrame.Dimensions.x) * scalediv;
 float bottom = cameraY - ((float)controls.MainGlFrame.Dimensions.y) * scalediv;
 float top = cameraY + ((float)controls.MainGlFrame.Dimensions.y) * scalediv;

 glOrtho(left,
  right,
  bottom, 
  top,
  -0.01f,0.01f);

 // Set the model matrix as the current matrix
 glMatrixMode(GL_MODELVIEW);
 glLoadIdentity();

 hdc = BeginPaint(controls.MainGlContext.mhWnd,&ps);

Mouse position is obtained like this:

 POINT _mouse = controls.MainGlFrame.GetMousePos();
vector2f mouse = functions.ScreenToWorld(_mouse.x,_mouse.y,GetCameraX(),GetCameraY(),
             Current_Scene().camera.ScaleFactor,
            controls.MainGlFrame.Dimensions.x,
            controls.MainGlFrame.Dimensions.y );

vector2f CGlEngineFunctions::ScreenToWorld(int x, int y, float camx, float camy, float scale, int width, int height)
{
 // Move the given point to the origin, multiply by the zoom factor and
 // add the model coordinates of the center point (camera position)
 vector2f p;


 p.x =  (float)(x - width / 2.0f) * scale +
  camx;

 p.y = -(float)(y - height / 2.0f) * scale +
  camy;

 return p;
}

From there I draw the VBO’s of triangles. This allows me to pan and zoom in. Given that Cairo only can draw based on coordinates, how can I make it so that a vertex is properly scaled and panned without using transformations. Basically GlOrtho sets the viewport usually but I dont think I could do this with Cairo.

Well GlOrtho is able to change the viewport matrix instead of modifying the verticies but how could I instead modify the verticies to get the same result?

Thanks

*Given vertex P, which was obtained from ScreenToWorld, how could I modify it so that it is scaled and panned accordng to the camera and scale factor? Because usually OpenGL would essentially 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-05-16T14:02:49+00:00Added an answer on May 16, 2026 at 2:02 pm

    I think Cairo can do what you want … see http://cairographics.org/matrix_transform/ . Does that solve your problem, and if not, why ?

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

Sidebar

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.