Thread View: cn.bbs.comp.program
1 messages
1 total messages
Started by ����
Tue, 05 May 1998 00:00
OPENGL(13)
Author: ����
Date: Tue, 05 May 1998 00:00
Date: Tue, 05 May 1998 00:00
135 lines
5641 bytes
5641 bytes
BBSˮľ�廪վ�þ�����
������: yxy (��˿˿#���ߵ�С��ӥ), ����: GAME_Designer
�� ��: OPENGL(13)
����վ: BBS ˮľ�廪վ (Mon Feb 16 21:40:42 1998)
���イ��OPENGL���������
1.���߶���
void glMap1{fd}(GLenum target,TYPE u1,TYPE u2,GLint stride,
GLint order,const TYPE *points);
targetָ�����Ƶ�������Լ���points��������Ҫ����ֵ���������£�
target ����
GL_MAP1_VERTEX_3 X Y Z�������
GL_MAP1_VERTEX_4 X Y Z W�������
GL_MAP1_INDEX ��ɫ����
GL_MAP1_COLOR_4 R G B A
GL_MAP1_NORMAL ������
GL_MAP1_TEXTURE_COORD_1 S �������
GL_MAP1_TEXTURE_COORD_2 S T�������
GL_MAP1_TEXTURE_COORD_3 S T R�������
u1,u2�����߱���U�ķ�Χ��������Բ���ͼ��ѧ�鼮��һ����0��1
stride�ǿ�ȣ���ʾpoints�п��Ƶ�ƫ��������˵�ǿ��Ƶ��ά��
order�ǽ�������Ƶ���һ��
points�ǿ��Ƶ����
���߶����Ҫ���ò��ܽ��л��ƣ�ͬ����glEnable(),glDisable()��
2.���������
void glEvalCoord1{fd}[v](TYPE u);
���ÿ��Ƶ��������U�����ij�����꣬����һ��ֻ�ܲ���һ����ꡣ
һ������ߵĻ��Ʒ�������U�仯��0��1�������Զ���Ȼ�����Щ���
��ֱ������������
����������������Ϳ�����ɻ������ߵĹ��ܡ�
����������������ʵ�����ƹ��ܣ�
void glMapGrid1{fd}(GLint n,TYPE u1,TYPE u2);
����һ���ռ����u1��u2��Ϊn�����ǵȼ���ģ����߲���
void glEvalMesh1(GLenum mode,GLint p1,GLint p2);
���㲢�������㡣mode������GL_POINT��GL_LINE��������������ֱ�߶�
��ȼ��ڣ�
glBegin(GL_POINT);
for(i=p1;i<=p2;i++)
glEvalCoord1(u1+i*(u2-u1)/n);
glEnd();
������һ��BEZIER���ߵ����ӣ�
////////////////////////////////////////////////////////////////////
//sample.cpp
#include "glos.h"
#include <GL/gl.h>
#include <GL/glaux.h>
#include "windows.h"
void myinit(void);
void CALLBACK display(void);
void CALLBACK reshape(GLsizei w,GLsizei h);
//�����ĸ����Ƶ�����
GLfloat points[4][3]={
{-4.0,-4.0,0.0},{-2.0,4.0,0.0},{2.0,-4.0,0.0},{4.0,4.0,0.0}};
void myinit(void)
{
auxInitDisplayMode(AUX_SINGLE|AUX_RGBA);
auxInitPosition(0,0,500,500);
auxInitWindow("sample1");
glClearColor(0.0,0.0,0.0,0.0);
glClear(GL_COLOR_BUFFER_BIT);
//�������ߣ������û������ߵ�ģʽ
glMap1f(GL_MAP1_VERTEX_3,0.0,1.0,3,4,&points[0][0]);
glEnable(GL_MAP1_VERTEX_3);
glShadeModel(GL_FLAT);
}
void CALLBACK reshape(GLsizei w,GLsizei h)
{
glViewport(0,0,w,h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if(w<=h)
glOrtho(-5.0,5.0,-5.0*(GLfloat)h/(GLfloat)w,
5.0*(GLfloat)h/(GLfloat)w,-5.0,5.0);
else
glOrtho(-5.0*(GLfloat)h/(GLfloat)w,
5.0*(GLfloat)h/(GLfloat)w,-5.0,5.0,-5.0,5.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void CALLBACK display(void)
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glColor3f(0.0,0.0,1.0);
glBegin(GL_LINE_STRIP);
//������30����ֱ�߶����ӣ����������ߣ�ע��ʹ��GL_LINE_STRIP������ֱ�߶�
int i;
for(i=0;i<=30;i++)
glEvalCoord1f((GLfloat)i/30.0);
glEnd();
//������Ƴ�4�����Ƶ�
glPointSize(4.0);
glColor3f(1.0,0.0,0.0);
glBegin(GL_POINTS);
for(i=0;i<4;i++)
glVertex3fv(&points[i][0]);
glEnd();
glFlush();
}
void main(void)
{
myinit();
auxReshapeFunc(reshape);
auxMainLoop(display);
}
//end of sample
�����ӻ��Ƴ�һ����4�����Ƶ��BEZIER���ߡ����߾���ͷβ�������Ƶ�
�м�������״�ɿ��Ƶ�����λ�þ�������֮�������Χ���ı������ڡ�
�´ν����ô�ƪ������������ɺ���������?��ɫ��Ӧ��
--
�� ��Դ:��BBS ˮľ�廪վ bbs.net.tsinghua.edu.cn��[FROM: 166.111.74.90]
BBSˮľ�廪վ�þ�����
�� ��Դ: �й�ƴ�BBSվ [bbs.ustc.edu.cn]
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads