资源简介
利用opengl 组件的基础上使用VC++编写的球体光照模型
代码片段和文件信息
#include
#include
#include
#include
#include
#include
#include
#define PI_OVER_180 0.01745329F
#define DEG2RAD( a ) ( (a) * PI_OVER_180 )
#define ELEMENTS_PER_VERTEX 3
#define ELEMENTS_PER_NORMAL 3
#define BYTES_PER_CACHELINE 32
/* struct used to manage color ramps */
struct colorIndexState {
GLfloat amb[3]; /* ambient color / bottom of ramp */
GLfloat diff[3]; /* diffuse color / middle of ramp */
GLfloat spec[3]; /* specular color / top of ramp */
GLfloat ratio; /* ratio of diffuse to specular in ramp */
GLint indexes[3]; /* where ramp was placed in palette */
};
#define NUM_COLORS (sizeof(s_colors) / sizeof(s_colors[0]))
struct colorIndexState s_colors[] = {
{
{ 0.0F 0.0F 0.0F }
{ 1.0F 0.0F 0.0F }
{ 1.0F 1.0F 1.0F }
0.75F { 0 0 0 }
}
{
{ 0.0F 0.05F 0.05F }
{ 0.9F 0.0F 1.0F }
{ 1.0F 1.0F 1.0F }
1.0F { 0 0 0 }
}
{
{ 0.0F 0.0F 0.0F }
{ 1.0F 0.9F 0.1F }
{ 1.0F 1.0F 1.0F }
0.75F { 0 0 0 }
}
{
{ 0.0F 0.0F 0.0F }
{ 0.1F 1.0F 0.9F }
{ 1.0F 1.0F 1.0F }
0.75F { 0 0 0 }
}
};
static void (APIENTRY *LockArraysSGI)(GLint first GLsizei count);
static void (APIENTRY *UnlockArraysSGI)(void);
static void (APIENTRY *CullParameterfvSGI)( GLenum pname GLfloat *params );
static GLint s_lit_tex_indexes[3];
static int s_num_rows = 16;
static int s_num_cols = 16;
static int s_winwidth = 320;
static int s_winheight = 240;
#define MS_TO_RENDER 5000
#define DRAW_VERTEX3FV 0
#define DRAW_DRAW_ELEMENTS 1
#define DRAW_DRAW_ARRAYS 2
#define DRAW_ARRAY_ELEMENT 3
static const char *s_class_name = “GL Sphere“;
static const char *s_window_name = “GL Sphere“;
static BOOL s_rgba = TRUE;
static BOOL s_lighting = TRUE;
static BOOL s_benchmark = FALSE;
static BOOL s_remote = FALSE;
static BOOL s_lock_arrays = TRUE;
static BOOL s_vcull = TRUE;
static HPALETTE s_hPalette = NULL;
static HWND s_hWnd = NULL;
static HGLRC s_hglrc = NULL;
static HDC s_hDC = NULL;
static int s_bpp = 8;
static int s_draw_method = DRAW_VERTEX3FV;
static unsigned long s_vertices_processed = 0L;
static unsigned long s_triangles_processed = 0L;
static float s_elapsed_time;
static unsigned long s_start s_stop;
/*
** this maintains the data for drawing stuff via tristrips
*/
static float **s_sphere_points;
static float **s_sphere_normals;
/*
** this maintains the data for drawing stuff via vertex arrays and array elements
*/
static float *s_sphere_point_array;
static float *s_sphere_normal_array;
/*
** this stores the data for drawing stuff using interleaved arrays with
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 407 1997-10-31 02:18 sphere\makefile
文件 30372 1997-11-21 16:55 sphere\sphere.c
目录 0 2010-05-30 20:00 sphere
----------- --------- ---------- ----- ----
30779 3
- 上一篇:0-1背包问题C语言源码
- 下一篇:MFC编写的五子棋程序源代码
评论
共有 条评论