Two from Nigel:
* Updated shapes.c. I think that it's just reformatting and the addition of some comments. * Added shapes.dsp, a Microsoft Visual C++ Developer Studio Project file for building shapes on WIN32 with MSVC++. git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@381 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
parent
a9d59e0c78
commit
3ae658e166
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -55,6 +55,7 @@ freeglut/freeglut/progs/demos/One/one.dsp svn_keywords=Author+Date+Id+Revision
|
|||||||
freeglut/freeglut/progs/demos/demos.dsw svn_keywords=Author+Date+Id+Revision
|
freeglut/freeglut/progs/demos/demos.dsw svn_keywords=Author+Date+Id+Revision
|
||||||
freeglut/freeglut/progs/demos/shapes/Makefile.am svn_keywords=Author+Date+Id+Revision
|
freeglut/freeglut/progs/demos/shapes/Makefile.am svn_keywords=Author+Date+Id+Revision
|
||||||
freeglut/freeglut/progs/demos/shapes/shapes.c svn_keywords=Author+Date+Id+Revision
|
freeglut/freeglut/progs/demos/shapes/shapes.c svn_keywords=Author+Date+Id+Revision
|
||||||
|
freeglut/freeglut/progs/demos/shapes/shapes.dsp svn_keywords=Author+Date+Id+Revision
|
||||||
freeglut/freeglut/src/Makefile.am svn_keywords=Author+Date+Id+Revision
|
freeglut/freeglut/src/Makefile.am svn_keywords=Author+Date+Id+Revision
|
||||||
freeglut/freeglut/src/freeglut_callbacks.c svn_keywords=Author+Date+Id+Revision
|
freeglut/freeglut/src/freeglut_callbacks.c svn_keywords=Author+Date+Id+Revision
|
||||||
freeglut/freeglut/src/freeglut_cursor.c svn_keywords=Author+Date+Id+Revision
|
freeglut/freeglut/src/freeglut_cursor.c svn_keywords=Author+Date+Id+Revision
|
||||||
|
@ -1,143 +1,157 @@
|
|||||||
|
/*
|
||||||
|
* FreeGLUT Shapes Demo
|
||||||
|
*
|
||||||
|
* Written by Nigel Stewart November 2003
|
||||||
|
*
|
||||||
|
* This program is test harness for the sphere, cone
|
||||||
|
* and torus shapes in FreeGLUT.
|
||||||
|
*
|
||||||
|
* Spinning wireframe and smooth shaded shapes are
|
||||||
|
* displayed until the ESC or q key is pressed. The
|
||||||
|
* number of geometry stacks and slices can be adjusted
|
||||||
|
* using the + and - keys.
|
||||||
|
*/
|
||||||
|
|
||||||
#include <GL/freeglut.h>
|
#include <GL/freeglut.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
static int slices = 16;
|
static int slices = 16;
|
||||||
static int stacks = 16;
|
static int stacks = 16;
|
||||||
|
|
||||||
|
/* GLUT callback Handlers */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
reshape(int width, int height)
|
resize(int width, int height)
|
||||||
{
|
{
|
||||||
float ar;
|
const float ar = (float) width / (float) height;
|
||||||
|
|
||||||
glViewport( 0, 0, width, height);
|
glViewport(0, 0, width, height);
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
ar = (float) width / (float) height;
|
glFrustum(-ar, ar, -1.0, 1.0, 2.0, 100.0);
|
||||||
glFrustum ( -ar, ar, -1.0, 1.0, 2.0, 100.0);
|
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glMatrixMode(GL_MODELVIEW) ;
|
glLoadIdentity() ;
|
||||||
glLoadIdentity() ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
display(void)
|
display(void)
|
||||||
{
|
{
|
||||||
float t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
|
const double t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
|
||||||
float a = t*90.0;
|
const double a = t*90.0;
|
||||||
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
glColor3d(1,0,0);
|
||||||
|
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef(-2.4,1.2,-6);
|
glTranslated(-2.4,1.2,-6);
|
||||||
glRotatef(60,1,0,0);
|
glRotated(60,1,0,0);
|
||||||
glRotatef(a,0,0,1);
|
glRotated(a,0,0,1);
|
||||||
glColor3f(1,0,0);
|
glutSolidSphere(1,slices,stacks);
|
||||||
glutSolidSphere(1,slices,stacks);
|
glPopMatrix();
|
||||||
glPopMatrix();
|
|
||||||
|
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef(0,1.2,-6);
|
glTranslated(0,1.2,-6);
|
||||||
glRotatef(60,1,0,0);
|
glRotated(60,1,0,0);
|
||||||
glRotatef(a,0,0,1);
|
glRotated(a,0,0,1);
|
||||||
glColor3f(1,0,0);
|
glutSolidCone(1,1,slices,stacks);
|
||||||
glutSolidCone(1,1,slices,stacks);
|
glPopMatrix();
|
||||||
glPopMatrix();
|
|
||||||
|
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef(2.4,1.2,-6);
|
glTranslated(2.4,1.2,-6);
|
||||||
glRotatef(60,1,0,0);
|
glRotated(60,1,0,0);
|
||||||
glRotatef(a,0,0,1);
|
glRotated(a,0,0,1);
|
||||||
glColor3f(1,0,0);
|
glutSolidTorus(0.2,0.8,slices,stacks);
|
||||||
glutSolidTorus(0.2,0.8,slices,stacks);
|
glPopMatrix();
|
||||||
glPopMatrix();
|
|
||||||
|
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef(-2.4,-1.2,-6);
|
glTranslated(-2.4,-1.2,-6);
|
||||||
glRotatef(60,1,0,0);
|
glRotated(60,1,0,0);
|
||||||
glRotatef(a,0,0,1);
|
glRotated(a,0,0,1);
|
||||||
glColor3f(1,0,0);
|
glutWireSphere(1,slices,stacks);
|
||||||
glutWireSphere(1,slices,stacks);
|
glPopMatrix();
|
||||||
glPopMatrix();
|
|
||||||
|
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef(0,-1.2,-6);
|
glTranslated(0,-1.2,-6);
|
||||||
glRotatef(60,1,0,0);
|
glRotated(60,1,0,0);
|
||||||
glRotatef(a,0,0,1);
|
glRotated(a,0,0,1);
|
||||||
glColor3f(1,0,0);
|
glutWireCone(1,1,slices,stacks);
|
||||||
glutWireCone(1,1,slices,stacks);
|
glPopMatrix();
|
||||||
glPopMatrix();
|
|
||||||
|
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef(2.4,-1.2,-6);
|
glTranslated(2.4,-1.2,-6);
|
||||||
glRotatef(60,1,0,0);
|
glRotated(60,1,0,0);
|
||||||
glRotatef(a,0,0,1);
|
glRotated(a,0,0,1);
|
||||||
glColor3f(1,0,0);
|
glutWireTorus(0.2,0.8,slices,stacks);
|
||||||
glutWireTorus(0.2,0.8,slices,stacks);
|
glPopMatrix();
|
||||||
glPopMatrix();
|
|
||||||
|
|
||||||
glutSwapBuffers();
|
glutSwapBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
key(unsigned char key, int x, int y)
|
key(unsigned char key, int x, int y)
|
||||||
{
|
{
|
||||||
switch (key) {
|
switch (key)
|
||||||
case 27 :
|
{
|
||||||
case 'q':
|
case 27 :
|
||||||
exit(0);
|
case 'q':
|
||||||
break;
|
exit(0);
|
||||||
|
break;
|
||||||
|
|
||||||
case '+':
|
case '+':
|
||||||
slices++;
|
slices++;
|
||||||
stacks++;
|
stacks++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '-':
|
case '-':
|
||||||
slices--;
|
if (slices>3 && stacks>3)
|
||||||
stacks--;
|
{
|
||||||
break;
|
slices--;
|
||||||
}
|
stacks--;
|
||||||
|
}
|
||||||
glutPostRedisplay();
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
glutPostRedisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
idle()
|
idle(void)
|
||||||
{
|
{
|
||||||
glutPostRedisplay();
|
glutPostRedisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
GLfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 };
|
const GLfloat light_ambient[] = { 0.0f, 0.0f, 0.0f, 1.0f };
|
||||||
GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 };
|
const GLfloat light_diffuse[] = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||||
GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 };
|
const GLfloat light_specular[] = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||||
GLfloat light_position[] = { 2.0, 5.0, 5.0, 0.0 };
|
const GLfloat light_position[] = { 2.0f, 5.0f, 5.0f, 0.0f };
|
||||||
|
|
||||||
GLfloat mat_ambient[] = { 0.7, 0.7, 0.7, 1.0 };
|
const GLfloat mat_ambient[] = { 0.7f, 0.7f, 0.7f, 1.0f };
|
||||||
GLfloat mat_diffuse[] = { 0.8, 0.8, 0.8, 1.0 };
|
const GLfloat mat_diffuse[] = { 0.8f, 0.8f, 0.8f, 1.0f };
|
||||||
GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
|
const GLfloat mat_specular[] = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||||
GLfloat high_shininess[] = { 100.0 };
|
const GLfloat high_shininess[] = { 100.0f };
|
||||||
|
|
||||||
|
/* Program entry point */
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
glutInit(&argc, argv);
|
glutInit(&argc, argv);
|
||||||
glutInitWindowSize(640,480);
|
glutInitWindowSize(640,480);
|
||||||
glutInitWindowPosition (40,40);
|
glutInitWindowPosition (40,40);
|
||||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||||
|
|
||||||
glutCreateWindow("FreeGLUT Shapes");
|
glutCreateWindow("FreeGLUT Shapes");
|
||||||
|
|
||||||
glutReshapeFunc(reshape);
|
glutReshapeFunc(resize);
|
||||||
glutDisplayFunc(display);
|
glutDisplayFunc(display);
|
||||||
glutKeyboardFunc(key);
|
glutKeyboardFunc(key);
|
||||||
glutIdleFunc(idle);
|
glutIdleFunc(idle);
|
||||||
|
|
||||||
glClearColor(1,1,1,1);
|
glClearColor(1,1,1,1);
|
||||||
glEnable(GL_CULL_FACE);
|
glEnable(GL_CULL_FACE);
|
||||||
glCullFace(GL_BACK);
|
glCullFace(GL_BACK);
|
||||||
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
@ -146,7 +160,7 @@ main(int argc, char *argv[])
|
|||||||
glEnable(GL_LIGHT0);
|
glEnable(GL_LIGHT0);
|
||||||
glEnable(GL_NORMALIZE);
|
glEnable(GL_NORMALIZE);
|
||||||
glEnable(GL_COLOR_MATERIAL);
|
glEnable(GL_COLOR_MATERIAL);
|
||||||
glEnable(GL_LIGHTING);
|
glEnable(GL_LIGHTING);
|
||||||
|
|
||||||
glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
|
glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
|
||||||
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
|
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
|
||||||
@ -158,7 +172,8 @@ main(int argc, char *argv[])
|
|||||||
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
|
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
|
||||||
glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess);
|
glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess);
|
||||||
|
|
||||||
glutMainLoop();
|
glutMainLoop();
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
101
freeglut/freeglut/progs/demos/shapes/shapes.dsp
Normal file
101
freeglut/freeglut/progs/demos/shapes/shapes.dsp
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
# Microsoft Developer Studio Project File - Name="shapes" - Package Owner=<4>
|
||||||
|
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||||
|
# ** DO NOT EDIT **
|
||||||
|
|
||||||
|
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||||
|
|
||||||
|
CFG=shapes - Win32 Debug
|
||||||
|
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||||
|
!MESSAGE use the Export Makefile command and run
|
||||||
|
!MESSAGE
|
||||||
|
!MESSAGE NMAKE /f "shapes.mak".
|
||||||
|
!MESSAGE
|
||||||
|
!MESSAGE You can specify a configuration when running NMAKE
|
||||||
|
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||||
|
!MESSAGE
|
||||||
|
!MESSAGE NMAKE /f "shapes.mak" CFG="shapes - Win32 Debug"
|
||||||
|
!MESSAGE
|
||||||
|
!MESSAGE Possible choices for configuration are:
|
||||||
|
!MESSAGE
|
||||||
|
!MESSAGE "shapes - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||||
|
!MESSAGE "shapes - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||||
|
!MESSAGE
|
||||||
|
|
||||||
|
# Begin Project
|
||||||
|
# PROP AllowPerConfigDependencies 0
|
||||||
|
# PROP Scc_ProjName ""
|
||||||
|
# PROP Scc_LocalPath ""
|
||||||
|
CPP=cl.exe
|
||||||
|
RSC=rc.exe
|
||||||
|
|
||||||
|
!IF "$(CFG)" == "shapes - Win32 Release"
|
||||||
|
|
||||||
|
# PROP BASE Use_MFC 0
|
||||||
|
# PROP BASE Use_Debug_Libraries 0
|
||||||
|
# PROP BASE Output_Dir "Release"
|
||||||
|
# PROP BASE Intermediate_Dir "Release"
|
||||||
|
# PROP BASE Target_Dir ""
|
||||||
|
# PROP Use_MFC 0
|
||||||
|
# PROP Use_Debug_Libraries 0
|
||||||
|
# PROP Output_Dir "Release"
|
||||||
|
# PROP Intermediate_Dir "Release"
|
||||||
|
# PROP Target_Dir ""
|
||||||
|
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||||
|
# ADD CPP /nologo /W3 /GX /O2 /I "../../../include" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "FREEGLUT_STATIC" /YX /FD /c
|
||||||
|
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||||
|
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||||
|
BSC32=bscmake.exe
|
||||||
|
# ADD BASE BSC32 /nologo
|
||||||
|
# ADD BSC32 /nologo
|
||||||
|
LINK32=link.exe
|
||||||
|
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||||
|
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /libpath:"../../../ReleaseStatic"
|
||||||
|
|
||||||
|
!ELSEIF "$(CFG)" == "shapes - Win32 Debug"
|
||||||
|
|
||||||
|
# PROP BASE Use_MFC 0
|
||||||
|
# PROP BASE Use_Debug_Libraries 1
|
||||||
|
# PROP BASE Output_Dir "Debug"
|
||||||
|
# PROP BASE Intermediate_Dir "Debug"
|
||||||
|
# PROP BASE Target_Dir ""
|
||||||
|
# PROP Use_MFC 0
|
||||||
|
# PROP Use_Debug_Libraries 1
|
||||||
|
# PROP Output_Dir "Debug"
|
||||||
|
# PROP Intermediate_Dir "Debug"
|
||||||
|
# PROP Target_Dir ""
|
||||||
|
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||||
|
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../include" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "FREEGLUT_STATIC" /YX /FD /GZ /c
|
||||||
|
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||||
|
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||||
|
BSC32=bscmake.exe
|
||||||
|
# ADD BASE BSC32 /nologo
|
||||||
|
# ADD BSC32 /nologo
|
||||||
|
LINK32=link.exe
|
||||||
|
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||||
|
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"../../../DebugStatic"
|
||||||
|
|
||||||
|
!ENDIF
|
||||||
|
|
||||||
|
# Begin Target
|
||||||
|
|
||||||
|
# Name "shapes - Win32 Release"
|
||||||
|
# Name "shapes - Win32 Debug"
|
||||||
|
# Begin Group "Source Files"
|
||||||
|
|
||||||
|
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\shapes.c
|
||||||
|
# End Source File
|
||||||
|
# End Group
|
||||||
|
# Begin Group "Header Files"
|
||||||
|
|
||||||
|
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||||
|
# End Group
|
||||||
|
# Begin Group "Resource Files"
|
||||||
|
|
||||||
|
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||||
|
# End Group
|
||||||
|
# End Target
|
||||||
|
# End Project
|
||||||
|
|
Reference in New Issue
Block a user