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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T19:52:43+00:00 2026-05-21T19:52:43+00:00

How to draw a HUD using shaders on opengl es 2.0? I have a

  • 0

How to draw a HUD using shaders on opengl es 2.0?

I have a shader which draws a textured quad on screen, it uses MVP matrix. The quad has it own vertices which are independent of view position and so on (cause of MVP matrix)

Matrix.frustumM(mProjMatrix, 0, -ratio, ratio, -1, 1, 3f, 17);
Matrix.setLookAtM(mVMatrix, 0, 0, 0, -5, 0f, 0f, 0f, 0f, 1.0f, 0.0f);

I’d like to show the same quad on the top right corner (like a button or something else, HUD).
As I understand, i need create an ortho matrix instead of “frustumM”, but what should i do later? How vertex shader should use vertices of quad?

  • 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-21T19:52:43+00:00Added an answer on May 21, 2026 at 7:52 pm

    Ok, You have your ortho matrix and quad, so whats the problem, translate modelview matrix of your quad to desired position (x,y,z=0), multiply it by ortho matrix , pass multiplied matrix to vertex shader, multiply vert position by your matrix and done :), i am not using any lookat function in my code to do this, but i have own code for matrices computation its partially code from some bada tutorial, for projection matrix i have other function.

      void
        Letter::Ortho(Matrix* result, float fovy, float aspect, float nearZ, float farZ)
        {
            GLfloat frustumW, frustumH;
    
            frustumH = tanf(fovy / 360.0f * PI) * nearZ;
            frustumW = frustumH * aspect;
    
            Frustum(result, -frustumW, frustumW, -frustumH, frustumH, nearZ, farZ);
        }
    
        void
        Letter::LoadIdentity(Matrix* result)
        {
            memset(result, 0x0, sizeof(Matrix));
            result->m[0][0] = 1.0f;
            result->m[1][1] = 1.0f;
            result->m[2][2] = 1.0f;
            result->m[3][3] = 1.0f;
        }
    
    
        void
        Letter::Frustum(Matrix *result, float left, float right, float bottom, float top, float nearZ, float farZ)
        {
            float   deltaX = right - left;
            float   deltaY = top - bottom;
            float   deltaZ = farZ - nearZ;
            Matrix  frustum;
    
            if ((nearZ <= 0.0f) || (farZ <= 0.0f) ||
                (deltaX <= 0.0f) || (deltaY <= 0.0f) || (deltaZ <= 0.0f))
            {
                 return;
            }
    
            frustum.m[0][0] = 2.0f * nearZ / deltaX;
            frustum.m[0][1] = frustum.m[0][2] = frustum.m[0][3] = 0.0f;
    
            frustum.m[1][1] = 2.0f * nearZ / deltaY;
            frustum.m[1][0] = frustum.m[1][2] = frustum.m[1][3] = 0.0f;
    
            frustum.m[2][0] = (right + left) / deltaX;
            frustum.m[2][1] = (top + bottom) / deltaY;
            frustum.m[2][2] = -(nearZ + farZ) / deltaZ;
            frustum.m[2][3] = -1.0f;
    
            frustum.m[3][2] = -2.0f * nearZ * farZ / deltaZ;
            frustum.m[3][0] = frustum.m[3][1] = frustum.m[3][3] = 0.0f;
    
            Multiply(result, &frustum, result);
        }
    

    So, with this code :

    LoadIdentity(&matPerspective);
    Ortho(&matPerspective, 60.0f, TEXMANAGER.aspect, -1.0f, 20.0f);
    LoadIdentity(&matModelview);
    Translate(&matModelview, x ,y ,z);
    Scale(&matModelview,size);
    //Rotate(&matModelview, 0.0f, 1.0f, 0.0f, 1.0f);
    Multiply(&posMatrix, &matModelview, &matPerspective);
    

    And pass posMatrix to shader 🙂

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

Sidebar

Related Questions

I draw the text using CTFramesetter, I have set kCTParagraphStyleSpecifierParagraphSpacing , kCTParagraphStyleSpecifierLineSpacing , kCTParagraphStyleSpecifierParagraphSpacingBefore
Here is my class I made to draw a HUD: using System; using System.Collections.Generic;
I draw a screen with OpenGL commands. And I must save this screen to
I draw a sphere with OpenGL which will be transformed by glRotate(), glScale(), glTranslate().
I have a YUV overlay that I want to draw a HUD over. Think
To draw a circle on map I have a center GLatLng (A) and a
I draw an arc using onDraw(canvas) : @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
I'm trying to draw a polygon using c# and directx All I get is
I draw an triangle using these piece of code CGPoint center; center = CGPointMake(x1,
I draw a bitmap onto a canvas using the following call: _playerImage = BitmapFactory.decodeResource(getResources(),

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.