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:
rkrolib 2003-12-07 10:12:22 +00:00
parent a9d59e0c78
commit 3ae658e166
3 changed files with 218 additions and 101 deletions

1
.gitattributes vendored
View File

@ -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/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.dsp 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_cursor.c svn_keywords=Author+Date+Id+Revision

View File

@ -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 <stdio.h>
#include <stdlib.h>
#include <math.h>
static int slices = 16;
static int stacks = 16;
/* GLUT callback Handlers */
static void
reshape(int width, int height)
resize(int width, int height)
{
float ar;
glViewport( 0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
ar = (float) width / (float) height;
glFrustum ( -ar, ar, -1.0, 1.0, 2.0, 100.0);
glMatrixMode(GL_MODELVIEW) ;
glLoadIdentity() ;
const float ar = (float) width / (float) height;
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-ar, ar, -1.0, 1.0, 2.0, 100.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity() ;
}
static void
display(void)
{
float t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
float a = t*90.0;
const double t = glutGet(GLUT_ELAPSED_TIME) / 1000.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();
glTranslatef(-2.4,1.2,-6);
glRotatef(60,1,0,0);
glRotatef(a,0,0,1);
glColor3f(1,0,0);
glutSolidSphere(1,slices,stacks);
glPopMatrix();
glPushMatrix();
glTranslated(-2.4,1.2,-6);
glRotated(60,1,0,0);
glRotated(a,0,0,1);
glutSolidSphere(1,slices,stacks);
glPopMatrix();
glPushMatrix();
glTranslatef(0,1.2,-6);
glRotatef(60,1,0,0);
glRotatef(a,0,0,1);
glColor3f(1,0,0);
glutSolidCone(1,1,slices,stacks);
glPopMatrix();
glPushMatrix();
glTranslated(0,1.2,-6);
glRotated(60,1,0,0);
glRotated(a,0,0,1);
glutSolidCone(1,1,slices,stacks);
glPopMatrix();
glPushMatrix();
glTranslatef(2.4,1.2,-6);
glRotatef(60,1,0,0);
glRotatef(a,0,0,1);
glColor3f(1,0,0);
glutSolidTorus(0.2,0.8,slices,stacks);
glPopMatrix();
glPushMatrix();
glTranslated(2.4,1.2,-6);
glRotated(60,1,0,0);
glRotated(a,0,0,1);
glutSolidTorus(0.2,0.8,slices,stacks);
glPopMatrix();
glPushMatrix();
glTranslatef(-2.4,-1.2,-6);
glRotatef(60,1,0,0);
glRotatef(a,0,0,1);
glColor3f(1,0,0);
glutWireSphere(1,slices,stacks);
glPopMatrix();
glPushMatrix();
glTranslated(-2.4,-1.2,-6);
glRotated(60,1,0,0);
glRotated(a,0,0,1);
glutWireSphere(1,slices,stacks);
glPopMatrix();
glPushMatrix();
glTranslatef(0,-1.2,-6);
glRotatef(60,1,0,0);
glRotatef(a,0,0,1);
glColor3f(1,0,0);
glutWireCone(1,1,slices,stacks);
glPopMatrix();
glPushMatrix();
glTranslated(0,-1.2,-6);
glRotated(60,1,0,0);
glRotated(a,0,0,1);
glutWireCone(1,1,slices,stacks);
glPopMatrix();
glPushMatrix();
glTranslatef(2.4,-1.2,-6);
glRotatef(60,1,0,0);
glRotatef(a,0,0,1);
glColor3f(1,0,0);
glutWireTorus(0.2,0.8,slices,stacks);
glPopMatrix();
glPushMatrix();
glTranslated(2.4,-1.2,-6);
glRotated(60,1,0,0);
glRotated(a,0,0,1);
glutWireTorus(0.2,0.8,slices,stacks);
glPopMatrix();
glutSwapBuffers();
glutSwapBuffers();
}
static void
key(unsigned char key, int x, int y)
{
switch (key) {
case 27 :
case 'q':
exit(0);
break;
switch (key)
{
case 27 :
case 'q':
exit(0);
break;
case '+':
slices++;
stacks++;
break;
case '-':
slices--;
stacks--;
break;
}
glutPostRedisplay();
case '+':
slices++;
stacks++;
break;
case '-':
if (slices>3 && stacks>3)
{
slices--;
stacks--;
}
break;
}
glutPostRedisplay();
}
void
idle()
static void
idle(void)
{
glutPostRedisplay();
glutPostRedisplay();
}
GLfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 };
GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat light_position[] = { 2.0, 5.0, 5.0, 0.0 };
const GLfloat light_ambient[] = { 0.0f, 0.0f, 0.0f, 1.0f };
const GLfloat light_diffuse[] = { 1.0f, 1.0f, 1.0f, 1.0f };
const GLfloat light_specular[] = { 1.0f, 1.0f, 1.0f, 1.0f };
const GLfloat light_position[] = { 2.0f, 5.0f, 5.0f, 0.0f };
GLfloat mat_ambient[] = { 0.7, 0.7, 0.7, 1.0 };
GLfloat mat_diffuse[] = { 0.8, 0.8, 0.8, 1.0 };
GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat high_shininess[] = { 100.0 };
const GLfloat mat_ambient[] = { 0.7f, 0.7f, 0.7f, 1.0f };
const GLfloat mat_diffuse[] = { 0.8f, 0.8f, 0.8f, 1.0f };
const GLfloat mat_specular[] = { 1.0f, 1.0f, 1.0f, 1.0f };
const GLfloat high_shininess[] = { 100.0f };
/* Program entry point */
int
main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitWindowSize(640,480);
glutInitWindowPosition (40,40);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutInit(&argc, argv);
glutInitWindowSize(640,480);
glutInitWindowPosition (40,40);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("FreeGLUT Shapes");
glutCreateWindow("FreeGLUT Shapes");
glutReshapeFunc(reshape);
glutDisplayFunc(display);
glutKeyboardFunc(key);
glutIdleFunc(idle);
glutReshapeFunc(resize);
glutDisplayFunc(display);
glutKeyboardFunc(key);
glutIdleFunc(idle);
glClearColor(1,1,1,1);
glEnable(GL_CULL_FACE);
glClearColor(1,1,1,1);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glEnable(GL_DEPTH_TEST);
@ -146,7 +160,7 @@ main(int argc, char *argv[])
glEnable(GL_LIGHT0);
glEnable(GL_NORMALIZE);
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHTING);
glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
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_SHININESS, high_shininess);
glutMainLoop();
glutMainLoop();
return EXIT_SUCCESS;
return EXIT_SUCCESS;
}

View 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