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/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
|
||||
|
@ -1,80 +1,88 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
static void
|
||||
reshape(int width, int height)
|
||||
{
|
||||
float ar;
|
||||
/* GLUT callback Handlers */
|
||||
|
||||
glViewport( 0, 0, width, height);
|
||||
static void
|
||||
resize(int width, int height)
|
||||
{
|
||||
const float ar = (float) width / (float) height;
|
||||
|
||||
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);
|
||||
glFrustum(-ar, ar, -1.0, 1.0, 2.0, 100.0);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW) ;
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
glTranslated(2.4,-1.2,-6);
|
||||
glRotated(60,1,0,0);
|
||||
glRotated(a,0,0,1);
|
||||
glutWireTorus(0.2,0.8,slices,stacks);
|
||||
glPopMatrix();
|
||||
|
||||
@ -85,7 +93,8 @@ display(void)
|
||||
static void
|
||||
key(unsigned char key, int x, int y)
|
||||
{
|
||||
switch (key) {
|
||||
switch (key)
|
||||
{
|
||||
case 27 :
|
||||
case 'q':
|
||||
exit(0);
|
||||
@ -97,29 +106,34 @@ key(unsigned char key, int x, int y)
|
||||
break;
|
||||
|
||||
case '-':
|
||||
if (slices>3 && stacks>3)
|
||||
{
|
||||
slices--;
|
||||
stacks--;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
void
|
||||
idle()
|
||||
static void
|
||||
idle(void)
|
||||
{
|
||||
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[])
|
||||
@ -131,7 +145,7 @@ main(int argc, char *argv[])
|
||||
|
||||
glutCreateWindow("FreeGLUT Shapes");
|
||||
|
||||
glutReshapeFunc(reshape);
|
||||
glutReshapeFunc(resize);
|
||||
glutDisplayFunc(display);
|
||||
glutKeyboardFunc(key);
|
||||
glutIdleFunc(idle);
|
||||
@ -162,3 +176,4 @@ main(int argc, char *argv[])
|
||||
|
||||
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