Click “Read the original text” to access more VxWorks resources
1. Introduction
OpenGL is a well-known API primarily used to render geometric primitives into a frame buffer based on camera settings.
Mesa is a specific implementation of OpenGL, with the current version being 7.0.2
DRI stands for Direct Rendering Infrastructure, which includes subprojects such as the ATI r300 graphics card.
Mesa was originally designed for UNIX/X11 and is a pure software implementation of OpenGL without hardware acceleration, resulting in low frame rates when running 3D graphics.
DRI provides a secure interface that allows Mesa (and other OpenGL implementations) to safely utilize the hardware acceleration capabilities provided by the graphics card.
Wind River’s support for Mesa seems to have stopped updating at version 5.0, and the code for running 3D in windml in Mesa 7.0.2 is still several years old.
However, for beginners learning OpenGL concepts such as space, projection transformations, lighting, textures, and display lists, this is sufficient.
This post is written to inform everyone how to start entering the OpenGL world under VxWorks and to learn the basic concepts of OpenGL.
To truly develop applications, DRI must be used, which is beyond the scope of this article.
2. Preparation
My development environment is
-
Tornado 2.2
-
VxWorks 5.5
-
WindML 3.0
-
Mesa 4.0 (download link provided later)
3. Compiling Mesa for WindML 3D Graphics Library
After downloading MESA 4.0, unzip it to c:\Tornado 2.2\target\src, with the directory structure as shown.
In Tornado, create a downloadable project based on SIMNTgnu, then add all the source files listed below to your project; do not miss any.
#### GL #####
(The main graphics library)
GL_SOURCES = \
api_arrayelt.c \(located at C:\Tornado2.2\target\src\Mesa\src)
api_loopback.c \
api_noop.c \
api_validate.c \
accum.c \
attrib.c \
blend.c \
buffers.c \
clip.c \
colortab.c \
config.c \
context.c \
convolve.c \
debug.c \
depth.c \
dispatch.c \
dlist.c \
drawpix.c \
enable.c \
enums.c \
eval.c \
extensions.c \
feedback.c \
fog.c \
get.c \
glapi.c \
glthread.c \
hash.c \
hint.c \
histogram.c \
image.c \
imports.c \
light.c \
lines.c \
matrix.c \
mem.c \
mmath.c \
pixel.c \
points.c \
polygon.c \
rastpos.c \
state.c \
stencil.c \
texformat.c \
teximage.c \
texobj.c \
texstate.c \
texstore.c \
texutil.c \
varray.c \
vtxfmt.c \
X86/x86.c \(located at C:\Tornado2.2\target\src\Mesa\src\X86)
X86/common_x86.c \
X86/3dnow.c \
X86/sse.c \
math/m_debug_clip.c \(located at C:\Tornado2.2\target\src\Mesa\src\math)
math/m_debug_norm.c \
math/m_debug_vertex.c \
math/m_debug_xform.c \
math/m_eval.c \
math/m_matrix.c \
math/m_translate.c \
math/m_vector.c \
math/m_vertices.c \
math/m_xform.c \
array_cache/ac_context.c \(located at C:\Tornado2.2\target\src\Mesa\src\array_cache)
array_cache/ac_import.c \
swrast/s_aaline.c \(located at C:\Tornado2.2\target\src\Mesa\src\swrast)
swrast/s_aatriangle.c \
swrast/s_accum.c \
swrast/s_alpha.c \
swrast/s_alphabuf.c \
swrast/s_bitmap.c \
swrast/s_blend.c \
swrast/s_buffers.c \
swrast/s_copypix.c \
swrast/s_context.c \
swrast/s_depth.c \
swrast/s_drawpix.c \
swrast/s_feedback.c \
swrast/s_fog.c \
swrast/s_histogram.c \
swrast/s_imaging.c \
swrast/s_lines.c \
swrast/s_logic.c \
swrast/s_masking.c \
swrast/s_pb.c \
swrast/s_pixeltex.c \
swrast/s_points.c \
swrast/s_readpix.c \
swrast/s_scissor.c \
swrast/s_span.c \
swrast/s_stencil.c \
swrast/s_texture.c \
swrast/s_texstore.c \
swrast/s_triangle.c \
swrast/s_zoom.c \
swrast_setup/ss_context.c \
swrast_setup/ss_triangle.c \
swrast_setup/ss_vb.c \(located at C:\Tornado2.2\target\src\Mesa\src\tnl)
tnl/t_array_api.c \(located at C:\Tornado2.2\target\src\Mesa\src\tnl)
tnl/t_array_import.c \
tnl/t_context.c \
tnl/t_eval_api.c \
tnl/t_imm_alloc.c \
tnl/t_imm_api.c \
tnl/t_imm_debug.c \
tnl/t_imm_dlist.c \
tnl/t_imm_elt.c \
tnl/t_imm_eval.c \
tnl/t_imm_exec.c \
tnl/t_imm_fixup.c \
tnl/t_pipeline.c \
tnl/t_vb_fog.c \
tnl/t_vb_light.c \
tnl/t_vb_normals.c \
tnl/t_vb_points.c \
tnl/t_vb_render.c \
tnl/t_vb_texgen.c \
tnl/t_vb_texmat.c \
tnl/t_vb_vertex.c
##### UGL #####
UGL_SOURCES = \
windml/ugl_api.c \(located at C:\Tornado2.2\target\src\Mesa\src\windml)
windml/ugl_dd.c \
windml/ugl_span.c \
windml/ugl_line.c \
windml/ugl_tri.c \
windml/tornado/torMesaUGLInit.c(located at C:\Tornado2.2\target\src\Mesa\src\windml\tornado)
##### OS #####
OS_SOURCES = \
OSmesa/osmesa.c \(located at C:\Tornado2.2\target\src\Mesa\src\OSmesa)
windml/tornado/torMesaOSInit.c(located at C:\Tornado2.2\target\src\Mesa\src\windml\tornado)
##### GLUTSHAPES #####
GLUTSHAPES_SOURCES = \
windml/ugl_glutshapes.c \(located at C:\Tornado2.2\target\src\Mesa\src\windml)
windml/tornado/torGLUTShapesInit.c(located at C:\Tornado2.2\target\src\Mesa\src\windml\tornado)
##### GLU #####
GLU_SOURCES = \
glu.c \(located at C:\Tornado2.2\target\src\Mesa\src-glu)
mipmap.c \
nurbs.c \
nurbscrv.c \
nurbssrf.c \
nurbsutl.c \
polytest.c \
project.c \
quadric.c \
tess.c \
tesselat.c \
../src/windml/tornado/torMesaGLUInit.c(located at C:\Tornado2.2\target\src\Mesa\src\windml\tornado)
Then create a GL folder under C:\Tornado2.2\target\h (to store OpenGL header files).
Copy gl.h, glext.h, glu.h, osmesa.h, uglglutshapes.h, uglmesa.h from C:\Tornado2.2\target\src\Mesa\include\ to the newly created GL folder.
After completing the above steps, modify the C/C++ compiler options in the Builds tab of the Tornado project to add the include path…
Add the following paths:
C:\Tornado2.2\target\src\Mesa\include
C:\Tornado2.2\target\src\Mesa\src
Then change the Rules tab to archive, which generates .a files.
Now you can compile, and upon successful compilation, a .a file will be generated in your project directory.
4. Create a VxWorks Project
Create a VxWorks project based on the simpc BSP
Include the complete 2D graphics library of WindML and the simulator host devices, Simulator graphics components into VxWorks.
Compile your VxWorks
If you are unclear about this step, you can search the forum for information on installing and compiling WINDML, which will not be discussed here.
5. Run the DEMO Program
Create a downloadable project based on the SIMNTgnu toolchain.
Using uglteapot as an example,
Add ugLTEapot.c from C:\Tornado2.2\target\src\Mesa\windmldemos to the project.
Change UGL_FALSE to UGL_TRUE in taskSpawn as follows:
void uglteapot (void)
{
taskSpawn ("tTeapot", 210, VX_FP_TASK, 100000, (FUNCPTR)windMLTeapot,
UGL_TRUE,1,2,3,4,5,6,7,8,9);
}
Modify the Marcos options in the Builds tab of the Tornado project.
Add the path of the generated .a file in PRJ_LIBS.
My path is C:/Tornado2.2/target/proj/MesaLib/SIMNTgnu/MesaLib.a
Then compile the project to generate the .out file.
Run the generated VxWorks.
Open a shell.
Download the .out file.
In the shell, enter the command uglteapot.
Below are the results of the run:
You can rotate the teapot using the left and right keys, press the K key to turn lighting 1 on and off, etc.
Press ESC to exit.
Here are some screenshots of the running DEMO.
6. Conclusion
You can also test your DEMO under VxWorks on VMware.
However, due to the lack of double buffering, there are some issues with graphics display.
Under simpc, the display is normal, but the speed is quite slow.
The environment has been set up.
Everyone can refer to the process in the DEMO to write their own demo and learn OpenGL.