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 8996193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:43:18+00:00 2026-06-15T23:43:18+00:00

If I use fixed-point (or integers with 1 describing the smallest game unit) to

  • 0

If I use fixed-point (or integers with 1 describing the smallest game unit) to describe my vertex vectors, how can I setup OpenGL/eigen transformations to work with it? If I’m doing this in my vertex shader:

gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(in_Position, 1.0)

If I pass in_Position in as a vec3 of GL_INT, while I pass in the matrices as GL_FLOAT mat4, will the proper casting be done? Is there a performance cost?

Is it possible to prepare my transformation matrices to be in fixed-point as well?

This is being done with a 2D game, which I think makes it more feasible than with 3D. I would really prefer the accuracy, since it seems there is degradation of position on large maps when things get far away from the origin. I realize I could probably get away with only object position being an integer while the vertices are still described as floats. However, I think my collision scheme will work better with fixed-point vertices. What is generally the performance difference?

  • 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-15T23:43:19+00:00Added an answer on June 15, 2026 at 11:43 pm

    Ok, after some experimentation, I’ve settled on a solution.

    gl_Position = projviewMatrix * vec4(ivec3(in_Position - camera), 1.0);
    

    camera is a uniform uvec3, and in_Position is the uvec3 position input. Translation is performed as a separate operation, while the view scaling, rotation, and projection is done with a mat4 of floats (projviewMatrix) as usual.

    Care must be taken to ensure the proper types and input commands (glVertexAttribIPointer) are used. OpenGL seems very eager to cast to float yet leave the data in an integer type, so any small error will result in mangled input.

    It simply is not feasible to perform the projviewMatrix multiply in fixed-point, since you do not have access to an intermediary 64-bit storage for the multiplications. Only if the bits used by in_Position and projviewMatrix sum to 32 would it approach usability, but considering that coords for rendering will be so close to the origin and no extra ops are gained (still need to shift after multiply, GPU will take as long for floats as ints), there is no reason to perform fixed-point arithmetic after the position has been centered by camera.

    Of course, this is ignoring the royal pain it is to actually manipulate the integer position data. I really wouldn’t recommend it.

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

Sidebar

Related Questions

Most examples of the use of fixed point combinators involve functions that take integers
First off I use this code to make the navigation bar always stay fixed;
Context: I use an ArrayCollection object as follows: 1) Number of elements is fixed.
I'm looking to use a physics engine for a 3D mobile game that I'm
I am looking to remodel an existing library for fixed point numbers. Currently the
I am trying to implement a fixed-point class in C++, but I face problems
I have a 16 bit fixed point processor and I want to do fixed
I've got a fixed point class (10.22) and I have a need of a
In my application I'm going to use floating point values to store geographical coordinates
In C++ you can use std::numeric_limits<FloatingPointType>::digits10 to find out exactly how many places of

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.