Reference OpenGL Programming Guide P17Directly on the code:Some new functions are encountered during the writing process:1.glShadeModel (Gl_flat); One more parameter is Gl_smooth (the default value). The difference is that when you assign a different color to the vertex of a polygon, the color in the matrix is single (Gl_flat), orSmoothing Over (Gl_smooth).2. glrotated function, rotation function, operation
pressedxspeed-=0.01f; Press to reduce the speed of rotation around the x-axisif (Keys[vk_right])//RIGHT ARROW key is pressedyspeed+=0.01f; Press to increase the speed of rotation along the Y axisif (Keys[vk_left])//LEFT ARROW key is pressedyspeed-=0.01f; Press to decrease the speed of rotation along the y-axisif (keys[' Q '))//q key is pressedcz-=0.01f; Yes, move it to the screen.if (keys[' z '])//z key is pressedcz+=0.01f; Yes, move it out of the screen.if (keys[' W '))//W key is pressedcy+=0.
Go from "translation" Nehe OpenGL tutorialObjectiveStatement, this Nehe OpenGL tutorial series of articles by 51 blog yarin Translation (2010-08-19), this blog for reprint and a little collation and modification. Thank you for compiling Nehe's OpenGL pipeline tutorial, as w
to, and using the same iterative method for the next judgment. In addition to drawing lines and circles, you can also draw ellipses, hyperbolic curves, and so on.There is a little more experience is that this problem must be seen in foreign forums to find a good explanation.Code:#include #includevoidMyinit (void) {Glclearcolor (1.0f,1.0f,1.0f,0.0f); glcolor3f (1.0,0.0,0.0); Glmatrixmode (gl_projection); Glloadidentity (); Gluortho2d (0.0,500.0,0.0,500.0); Glmatrixmode (Gl_modelview);}void
making objects move according to a preset program, such as a rotating triangle, can draw attention. But what if you want users to interact with your OpenGL ES graphics? The key to making your OpenGL ES app Touch Interactive is to extend the Glsurfaceview, Ontouchevent () method to listen for touch events. This tutorial shows how to listen for a revealing event an
been explained at the beginning of the article
// Caching using vertex buffer objects
int VBO, VAO;
Glgenvertexarrays (1, VAO);
Glgenbuffers (1, VBO);
// buffering objects for binding
Glbindvertexarray (VAO);
Glbindbuffer (Gl_array_buffer, VBO);
Use of Buffered objects
1 //Copy the defined vertex data into buffered memory2 /
the camera position and specify it through the point pointed by the camera. You also need to specify an upward vector. For convenience, the vector is usually set to (0, 1, 0) or the Y axis in the coordinate system.
Void glulookat (gldouble eyex, gldouble eyey, gldouble Eyez,
Gldouble ATX, gldouble Aty, gldouble atz,
Gldouble UPX, gldouble upy, gldouble upz)
// Determine a matrix that can be used for camera positioning and targeting. The parameters in
'd like to tell you that people use cameras to observe things in 3D, although OpenGL does not actually have a camera. So when you move on the screen, you are actually moving all objects, and the feeling of motion is not caused by the creation of a camera to watch movies, instead, all objects in the world are moved with the relative coordinates (0, 0.
It sounds like this is a huge workload, but it is not. According to your application, you will perfor
Go from "translation" Nehe OpenGL tutorialObjectiveStatement, this Nehe OpenGL tutorial series of articles by 51 blog yarin Translation (2010-08-19), this blog for reprint and a little collation and modification. Thank you for compiling Nehe's OpenGL pipeline tutorial, as w
encapsulates the interface of the OpenGL underlying. For example, this is the corresponding uniform2f .Gl.bindbuffer (GL. Array_buffer, This. Squarevertexpositionbuffer); Gl.vertexattribpointer (CC. Vertex_attrib_position,2, GL. FLOAT,false, 0, 0);//Setting the attribute parameterParameter reference:http://msdn.microsoft.com/zh-cn/library/ie/dn302460 (v=vs.85). aspxThe first parameter of the function: Indicates the attribute parameter of the shader p
on the screen and is independent from the platform, please let me know, I will rewrite a tutorial on font.
We started from the typical code of Lesson 1 and added the stdio. h header file for standard input/output operations. In addition, the stdarg. h header file is used to parse text and convert variables into text. Add the math. h header file so that we can use the sin and cos functions to move text on t
Original article: Lesson 4: RotationTranslated by: cker
In the previous lesson, I will teach you how to color triangles and quadrilateral. This lesson will teach you how to rotate these color objects around the axis.In fact, you only need to add a few lines to the code of the previous lesson. Next I will rewrite the entire routine. So that you can know what is added and what is modified. We add two variables to control the rotation of these two objects. These two variables are added after the ot
This time, OpenGL is used to draw a circle, and a solid pentagram is drawn in the middle.
1. Draw solid five corners:
Since the previous use of polygen painting will fail, maybe the GPU hardware will be different, so the use of polygen to draw a solid five-pointed star is not reliable;
Therefore, polygen is not required to draw a star using a triangle.
2 circles
Because there is no circular shape
Lesson 1Fog:
This course is based on the Code of Lesson 7th. You will learn three different calculation methods for fog and how to set the fog color and scope.This tutorial is written by Chris aliotta.Do you want to add fog effects to your OpenGL program? I will teach you how to do this in this tutorial. This is my first tuto
/////////////////////////////////////////////////////////////////////////////bool CopenGLMFCView:: Setuppixelformat () {static Pixelformatdescriptor PFD = {sizeof (pixelformatdescriptor),//size of this PFD 1,//version number Pfd_draw_to_window | Support Window Pfd_support_opengl | Support OpenGL Pfd_doublebuffer,//Double buffered Pfd_type_rgba,//RGB A type,//24-bit color depth 0
Ubuntu + opengl program design (1) Preparations-- Lihn1987
Environment: ubuntu10.04
Creating an opengl development environment in ubuntu should be equivalent to esay.
As shown below
Install the basic library sudo apt-get install build-essential
Install opengl toolbox
Sudo apt-get install freeglut3-dev
Finished
First compile and run a simple example so we can have an intuitive impression. From this example we can see what OpenGL can do, and of course This example does just one simple thing-draw a colored triangle. In addition, we can see the typical OpenGL program structure and the operation sequence of OpenGL.
Example 1: Th
GLUTTutorial
Prepare for transformation window
Download the following vcpus and run the program (glu0.zip) (this is the project in the previous section ). You will see two windows: a console window and an OpenGL window. Change the window size so that the height and width are no longer equal, and the triangle is deformed. This occurs because you have not correctly set the projection matrix. The default value is the Perspective Projection Matrix and t
name is very intuitive, reference blog: http://www.cppblog.com/doing5552/archive/2009/01/08/71532.htmlThe simple code only needs to change the key draw function, so I wrote an OpenGL code template generator with bash#!/bin/bash# File name:opengl.sh# Created time:thu 06:48:03 AM pstif [$#-lt 1]; Then echo "Usage:./opengl.sh You can copy the code first. When writing echo, you can call the VIM command to add
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.