OpenGL | Getting Started - Fragmentary Summary

1.powf power function

        The Pow function is a mathematical function that can quickly calculate nonlinear relationships, and its characteristic is that the nth power of any non-negative integer x can be quickly calculated. The Pow function can simply calculate the square root, cube root or any order root of a number mathematically. It is mainly used to calculate continuous, non-linear complex expressions, and one of its most convenient and easy-to-use functions is to calculate square roots. For example, to achieve a particle effect with a gradient of transparency.

2. Draw text

  • glRasterPos2f

void APIENTRY glRasterPos2f (GLfloat x, GLfloat y);

        glRasterPos2f is the function used to set the raster position in OpenGL. It specifies the starting position of the next raster operation (such as drawing pixels or bitmaps). glRasterPos2f accepts two parameters, which respectively indicate the x and y coordinates of the raster position in the window coordinate system. This function is usually used to draw scenes such as pixels, bitmaps or texts. It allows us to freely specify the starting position of the raster without relying on vertex arrays or texture coordinates.

  • reference article

        (Old) Setting fonts and displaying text on OpenGL - Programmer Sought

3. Drawing time

  • _strtime

        _strtime is a C/C++ function, which is used to obtain the current system time and return the "hour:minute:second" part of the time in the form of a string. This function needs to pass in a character pointer parameter, which points to a buffer that stores the time string. After the function is executed, the character string stored in the buffer is the "hour:minute:second" part of the current time.

char * _strtime(char * buffer);
  • buffer: A pointer representing the buffer where the time string is stored.
#include <iostream>
#include <ctime>

using namespace std;

int main()
{
    char buffer[10];
    _strtime(buffer);
    cout << "Current time: " << buffer << endl;
    return 0;
}

Guess you like

Origin blog.csdn.net/weixin_39766005/article/details/130574476
Recommended