As discussed in the previous article, we saw how Text can be drawn in multiple fonts, sizes and colors and images can be placed side by side.
Also, the implementation of the TextMesh , TextureUtil and TextImageSketcher were covered.
In this post we will try to draw text and image interactively.
Details
The purpose of Lesson07 is to draw text and image and work with them interactively by changing fonts, colors, resize height and width.
System class diagram
The scene class does use camera. It has an pointer to TextImageSketcher called ptextutl.
Implementation
Scene
The functionality is implemented in the Scene class derived from BaseScene class.
The Init method calls
- BaseScene::Init to create hosting window and OpenGL Context.
- It creates an input dialog to work with text and images interactively.
- It calls init function with texture id GL_TEXTURE0 + 4, height and width of the bitmap. on the TextImageSketcher object to populate VBO/EBO buffers and bind them. Also create texture and bitmap.
- It also compiles and links shader programs.
The DrawScene method draws a string and image.
The Cleanup method releases the resources related to VBO/EBO, Texture related resources and shader programs.
The message handler for IDOK is called when Apply button is pressed after updates are made in the input dialog. It refreshes the display.
The message handler for IDCANCEL is called when in Cancel button is pressed the input dialog. It calls
OnCloseWindow to destroy window.
Finally the WM_CLOSE event is handled in OnCloseWindow function and the window is destroyed and application is shutdown when the window is closed or Escape key is pressed.
Application
Scene class is hosted main.cpp. which creates the scene object and displays it. Message pump is added to process windows messages.
Input dialog
The input dialog as shown below can be used to change settings and understand drawing text and images.Output
The output looks as shown in the top.
No comments:
Post a Comment