Vous êtes sur la page 1sur 55

Department of Electrical Engineering June, 27th 2018

Korea National University of Transportation

MFC & OPENGL

by
Ulfah Khairiyah Luthfiyani
Hello!
I am Ulfah
I would like to tell you about MFC & OPENGL that I
learned.

Please enjoy it ! 

2
1
Make MFC&OpenGL
Project
Let’s start with the first step to make MFC&OPENGL program
“Here are the steps to make
MFC&OpenGL Project”

4
1. Make a new project :
a. File > New Project or
Click New Project’s
Icon on Toolbar.
b. Installed > Template
> Visual C++ >
MFC Application.
c. Type your project
name.
d. Click OK
Make sure that the
program’s name as
similar as you want,
let’s check it !

Press “Next”
Click MFC Standard as
Choose “Single Project style to
Document” as your provides a standard
Application Type if MFC application
you want that your architecture.
application can hold
only one document.

Press “Next”
Please checklist one
to support Compound
document. But if you
didn’t need it, choose
None
This is your project’s
name. Press Next
Please checklist one
to support Database.
But if you didn’t
need it, choose None
and click Next
You can choose
Advanced Features
that will be
implemented in your
program by check the
list
There are your classes
that generated in
your project. Press
Finish to begin. Have
Fun ! 
2
Mfcgl Window
Let’s begin your program
Understanding
your
Mfcgl window

The main explorer


will be used in that
book are three.
Please check below
You can add :
New Class
New Member Function
New variable
By right-click Mfcgl class view
3
Draw an object
using MFC&OpenGL
Let’s draw what you want by understanding this chapter
Make a Points
Make a Line
Make a Triangle Fan
Color Code
Command Meaning Annotation
glVertex2i(x,y); The point location is located (x, y) Type is integer and 2D (x, y)

glVertex2f(x,y); The point location is located (x, y) Type is float and 2D (x, y)

glVertex3i(x,y,z); The point location is located (x, y, z) Type is integer and 3D (x, y, z)

glVertex3f(x,y,z); The point location is located (x, y, z) Type is float and 3D (x, y, z)

glClearColour(R, G, B, α); The background’s color Four color components (R, G, B, α)

glColor3f(R, G, B); The surface’s color Three color components (R, G, B)

glColor4f(R, G, B, α); The surface’s color Four color components (R, G, B, α)

glBegin(GL_POINTS); Draw a point as an object Primitive object

glBegin(GL_LINES); Draw a line as an object Primitive object

glBegin(GL_LINE_STRIP); Draw a line in strip pattern as an object Primitive object

glBegin(GL_LINE_LOOP); Draw a line loop as an object Primitive object

glBegin(GL_TRIANGLES); Draw a triangle as an object Primitive object

glBegin(GL_TRIANGLE_STRIP); Draw a triangle in strip pattern as an object Primitive object

glBegin(GL_TRIANGLE_FAN); Draw a triangle as an object that have more than 3 points Primitive object

glBegin(GL_QUADS); Draw a rectangular as an object Primitive object

glBegin(GL_QUADS_STRIP); Draw a rectangular in strip pattern as an object Primitive object

glBegin(GL_LINE_STIPPLE); Draw a line in stipple pattern as an object Primitive object

glBegin(GL_POLY); Draw a polygon as an object Primitive object


4
Make a class,
function, and
variable
Let’s make your classes, functions, and variables !
How to add a new class
How to add a new class
How to add a new class

Write your class here


How to add a new variable

Choose a class that


you want to declare
your variable
How to add a new variable

Write your variable


and choose the access
and also variable type
here
How to add a function

Choose a class that


you want to declare
your function and
then right-click your
mouse
How to add a function

Write your function


and choose the return
and also parameter
type here
How to Control the Icon on Toolbar
How to Control the Icon on Toolbar

Search your
1 toolbar’s ID
here

Double click
your toolbar’s Write your toolbar’s function
ID name
How to Make a Menu Bar
How to Make a Menu Bar
How to Make a Tool Bar
Choose a tools to
draw

Draw your icon here

Choose the color


here
How to Make a Tool Bar

Write your toolbar’s ID name and


please make sure that the ID’s
name is similar with the ID’s
name in MENU BAR
How to Make a Tool Bar
How to Make a Tool Bar
How to Make a Dialog Window

Design your
dialog use
the Toolbox
and choose
anything
To add a new dialog, you want
right-click your mouse 
and add a new one
How to Make a Dialog Window

To give a name
of your tools,
click Properties
and change the
caption.

Important!!
Write ID name and
remember it cause it will
be used to code your
program in this project

How to Make a Dialog Window
How to Make a Dialog Window
How to Make a Dialog Window
CHAPTER
10
Color and Lighting Effect

43
HEADER FILE

44
45
46
47
CPP FILE

48
CPP FILE

49
50
6
Run it !
Let’s run your program!
Thanks!
Any questions?
You can find me at:
✗ @ulfahkl (instagram)
✗ ulfahkl@gmail.com

55

Vous aimerez peut-être aussi