OpenGL Road (i) the difference between OpenGL, GL, Glu, glut + glut environment construction

Source: Internet
Author: User
Tags mongodb php download postgresql redis win32 win32 window firewall


The GL Library in OpenGL is the core library, Glu is a utility library, glut is a utility library, GL is the core, Glu is part of the package for GL, glut is OpenGL's cross-platform tool Library, GL contains the most basic 3D functions, and Glu seems to support GL, if the arithmetic is good, The same effect can be done without the glu of the case. Glut is the basic window interface, is independent of GL and Glu, if you do not like to use glut can use MFC and Win32 window, etc., but glut is cross-platform, which ensures that our program is a cross-platform, If you use MFC or WIN32 only on Windows operating systems. One of the big reasons for choosing OpenGL is that it's cross-platform, so we can use the glut library as much as possible.






Construction of GLUT:

1.Download for glut:



(1). to http://www.ibiblio.org/pub/packages/development/graphics/glut/download glut3.7



(2). To http://www.opengl.org/resources/libraries/glut/glut_downloads.php download glut35.zip for compilation (note that Glutmake.bat is executed before compiling).



2.Configuration of glut


(1). Place the glut.h in the Microsoft Visual STUDIO\VC\INCLUDE\GL directory. (depending on your compiler and installation location, there may be a Microsoft Sdks\windows\v7.1a\include\gl or Windows KITS\8.1\INCLUDE\UM\GL, where there may be a number change in the path, If the sample compiles all the time but can be placed in these three locations)



(2). Place Glut.lib and Glut32.lib in the VC\bin directory (depending on your compiler and installation location)



(3). 32-bit system: Put Glut.dll and Glut32.dll in c:\Windows\System32\



64-bit system: Put Glut.dll and Glut32.dll in c:\Windows\SysWOW64\



3. Compiler settings


Add Glut32.lib and Glut.lib to the connection items in the project properties






4. First instance of the program


The project option should be sure that Windows is not the console







#include <GL/glut.h>

#pragma comment (linker, "/subsystem:\" windows\ "/entry:\" Maincrtstartup\ "")//Remove the console

void Renderscene (void)  //Render function
{
	glclear (gl_color_buffer_bit);
	Glbegin (gl_triangles);
	glvertex3f (0.0, 0.0, 0.0);
	glvertex3f (0.5, 0.0, 0.0);
	glvertex3f (0.0, 0.5, 0.0);
	Glend ();
	Glflush ();
}
int main (int argc, char **argv)
{
	glutinit (&ARGC, argv);
	Glutinitdisplaymode (glut_depth | Glut_single | GLUT_RGBA);
	Glutinitwindowposition (+);
	Glutinitwindowsize (a);
	Glutcreatewindow ("GLUT");
	Glutdisplayfunc (renderscene);  Set the Render function
	glutmainloop ();
}


If you still can't solve the problem, try the following code







#include <gl/glut.h>
#include <gl/GLU.h>
#include <gl/GL.h>
#pragma comment (lib, " Opengl32.lib ")
#pragma comment (lib," Glut32.lib ")  //If you do not find these files can use absolute path, note that the path ' \ ' to change to ' \ \ '
#pragma Comment (lib, "Glu32.lib")
#pragma comment (lib, "Glut.lib")
void Renderscene (void)
{
	glclear (gl_ Color_buffer_bit | Gl_depth_buffer_bit);
	Glloadidentity ();
	Glbegin (gl_triangles);
	glvertex3f (6.0f, 2.0f, 0.0f);
	glvertex3f ( -1.0f, -1.0f, 0.0f);
	glvertex3f (1.0f, -1.0f, 0.0f);
	Glend ();
	Gltranslatef (3.0f, 0.0f, -1.0f);

	Glutswapbuffers ();
}
int main (int argc, char * argv[])
{
	glutinit (&ARGC, (char**) argv);
	Glutinitdisplaymode (glut_depth | glut_double | GLUT_RGBA);
	Glutinitwindowposition (+);
	Glutinitwindowsize (+/-);
	Glutcreatewindow ("Hello OpenGL");
	Glutdisplayfunc (renderscene);
	Glutidlefunc (renderscene);

	Glenable (gl_depth_test);
	Glutmainloop ();
	return 0;
}














Alibaba Cloud Hot Products

Elastic Compute Service (ECS) Dedicated Host (DDH) ApsaraDB RDS for MySQL (RDS) ApsaraDB for PolarDB(PolarDB) AnalyticDB for PostgreSQL (ADB for PG)
AnalyticDB for MySQL(ADB for MySQL) Data Transmission Service (DTS) Server Load Balancer (SLB) Global Accelerator (GA) Cloud Enterprise Network (CEN)
Object Storage Service (OSS) Content Delivery Network (CDN) Short Message Service (SMS) Container Service for Kubernetes (ACK) Data Lake Analytics (DLA)

ApsaraDB for Redis (Redis)

ApsaraDB for MongoDB (MongoDB) NAT Gateway VPN Gateway Cloud Firewall
Anti-DDoS Web Application Firewall (WAF) Log Service DataWorks MaxCompute
Elastic MapReduce (EMR) Elasticsearch

Alibaba Cloud Free Trail

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.