---
title: "OpenGL syntax: 3D vertex"
subject: "Computer Graphics"
chapter: 9
key: "semester_5/computer_graphics:opengl-3d-float-vertex-syntax"
source: https://www.bctengineer.com/q/semester_5/computer_graphics/opengl-3d-float-vertex-syntax
site: BCT Engineering
---

# OpenGL syntax: 3D vertex

Computer Graphics · Chapter 9: Introduction to Open GL

- Asked in: 2069 Asar, 4 marks
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_5/computer_graphics/opengl-3d-float-vertex-syntax
- Whole chapter: https://www.bctengineer.com/md/semester_5/computer_graphics/chapter-9

## Question

Explain OpenGL syntax to draw a three dimensional, floating point vectored vertex.

## Short answer

Specify a 3D float vertex with glVertex3f(x, y, z) inside glBegin/glEnd. The command name indicates library 'gl', command 'Vertex', 3 coordinates, and float type ('f'); the 'v' version (e.g., glVertex3fv) takes an array pointer.

## Answer

A three-dimensional vertex with floating-point coordinates is specified with the `glVertex3f` command. In the OpenGL command name `glVertex3f`:
- `gl` is the library prefix, `Vertex` the command, `3` the number of coordinates (x, y, z), and `f` the data type (float; `d` = double, `i` = int, `s` = short).
- Adding `v` (as in `glVertex3fv`) means the argument is a pointer to an array (a vector).

**Syntax**

```c
void glVertex3f(GLfloat x, GLfloat y, GLfloat z);
void glVertex3fv(const GLfloat *v);
```

**Example**

```c
GLfloat p[3] = {1.0f, 2.5f, -3.0f};

glBegin(GL_POINTS);
    glVertex3f(0.5f, 0.5f, 0.0f);   // separate values
    glVertex3fv(p);                  // using an array (vector form)
glEnd();
```

A vertex call must appear between `glBegin()` and `glEnd()`. If a four-coordinate form `glVertex4f(x, y, z, w)` is used, w is the homogeneous coordinate (1.0 by default in the 3-coordinate form).

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. In glVertex3f, what does '3' mean?
   A. Three vertices
   B. Three colours
   C. Three coordinates (x, y, z)
   D. Three bytes
   Answer: C. The digit is the number of coordinates. (Key point: Name parts)

2. What does 'f' mean?
   A. The function is fast
   B. Fill mode
   C. Fixed point
   D. The data type is float
   Answer: D. d = double, i = int, s = short. (Key point: Type suffix)

3. What does adding 'v' (glVertex3fv) mean?
   A. The argument is a pointer to an array
   B. Vertical
   C. Variable count
   D. Visible
   Answer: A. It takes a vector. (Key point: Vector form)

4. Where must a vertex call appear?
   A. Before glutInit
   B. Between glBegin() and glEnd()
   C. After glFlush
   D. Anywhere
   Answer: B. Vertices are valid only within glBegin/glEnd. (Key point: Placement)

## Related in Computer Graphics

- [OpenGL syntax: parallelogram](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Aopengl-parallelogram-syntax) — Computer Graphics, chapter 9
- [3D scaling about arbitrary point](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Ascale-3d-arbitrary-point) — Computer Graphics, chapter 4
- [Drawing primitives in OpenGL](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Aopengl-draw-primitives-2d) — Computer Graphics, chapter 9, asked 4×
- [Boundary representation of 3D objects](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Aboundary-representation-technique) — Computer Graphics, chapter 6, asked 4×
- [3D world to viewing coordinate matrix](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Aworld-to-viewing-3d-matrix) — Computer Graphics, chapter 4, asked 2×

## Related in other subjects

- [Floating point addition and subtraction](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_organization_and_architecture%3Afp-add-sub) — Computer Organization and Architecture, chapter 5, asked 6×
- [Floating point division algorithm](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_organization_and_architecture%3Afp-division) — Computer Organization and Architecture, chapter 5, asked 4×
- [Floating point multiplication](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_organization_and_architecture%3Afp-multiplication) — Computer Organization and Architecture, chapter 5, asked 3×
- [Parametric line in 3D: point and plane intersection](https://www.bctengineer.com/question.md?key=semester_4%2Fcomputer_aided_design%3Aparametric-line-segment-plane) — Computer Aided Design, chapter 3
