🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: cn.bbs.comp.program
1 messages
1 total messages Started by ���� Tue, 05 May 1998 00:00
OPENGL(5)
#966
Author: ����
Date: Tue, 05 May 1998 00:00
152 lines
5490 bytes
BBSˮľ�廪վ�þ�����
������: yxy (��˿˿#���ߵ�С��ӥ), ����: GAME_Designer 
��  ��: OPENGL(5) 
����վ: BBS ˮľ�廪վ (Fri Jan 16 09:13:13 1998) 
 
��ؿ�����OPENGL��򵥵����ݣ���ɫ�� 
һ RGBģʽ 
һ������ʵ�ֲ�ɫ����RGB���ɫ������ġ������ 
RGBģʽ������ǰ��һֱ�����ַ��� 
�����磺 
         glColor3f(1.0,0.0,0.0); 
         glVertex3f(0.0,0.0,0/0); 
  ����һ����ɫ�㡣�� 
void glColor3{b s i f d ub us ui}(TYPE r,TYPE g, TYPE b); 
void glColor4{b s i f d ub us ui}(TYPE r,TYPE g, TYPE b,TYPE a); 
void glColor3{b s i f d ub us ui}v(TYPE *v); 
void glColor4{b s i f d ub us ui}v(TYPE *v); 
{}������ѡһ����ֵ���ȣ���ǰ��Ľ��ܣ��� 
����a�DZ���͸���ȵ�Alphaֵ�� 
��������v��׺�ĺ���������ǵIJ�������������ϸʹ�ÿ���ƪ�����ӣ��� 
��glColor3fΪ�������ȡֵ��Χ-1.0--1.0��������ֵ���͵ĺ��� 
�Զ��Ѳ������Ӱ�䵽�����䣬���磺 
 
��׺   ����       MIN    MINӳ��      MAX       MAXӳ�� 
b      1byte����  -128   -1.0         127       1.0 
 
�� ��ɫ����ģʽ 
ʹ�� 
void glIndex{s i f d}(TYPE c); 
void glIndex{s i f d}(TYPE *c); 
������ɫ�������ѡȡ��ɫ�����õ�ǰ��ɫ����ֵ����ɫ��ţ������� 
����ʱȡģ�� 
 
ǰ���������Ӷ���RGBģʽ������������һ����ɫ��������ӣ� 
 
 
 
 
//sample.cpp 
//////////////////////////////                                
#include "glos.h" 
#include <GL/gl.h> 
#include <GL/glaux.h> 
#include "windows.h" 
void myinit(void); 
void InitPalette(void); 
void CALLBACK  display(void); 
void CALLBACK  reshape(GLsizei w,GLsizei h); 
 
void myinit(void) 
{ 
    auxInitDisplayMode(AUX_SINGLE|AUX_INDEX); 
        auxInitPosition(0,0,500,500); 
        auxInitWindow("sample1"); 
        glClearColor(0.0,0.0,0.0,0.0); 
        glClear(GL_COLOR_BUFFER_BIT); 
        glShadeModel(GL_FLAT);//GL_FLAT��ɫģʽ 
} 
 
void CALLBACK reshape(GLsizei w,GLsizei h) 
{ 
if(w<=500&&h<=500) 
glViewport(0,0,w,h); 
if(w>500&&h<=500) 
glViewport(0,0,500,h); 
if(w<=500&&h>500) 
glViewport(0,0,w,500); 
if(w>500&&h>500) 
glViewport(0,0,500,500); 
 
 
glMatrixMode(GL_PROJECTION); 
glLoadIdentity(); 
if(w<=h) 
 glOrtho(-20.0,20.0,-20.0*(GLfloat)h/(GLfloat)w, 
         20.0*(GLfloat)h/(GLfloat)w,-50.0,50.0); 
else 
  glOrtho(-20.0*(GLfloat)h/(GLfloat)w, 
         20.0*(GLfloat)h/(GLfloat)w,-20.0,20.0,-50.0,50.0); 
 
glMatrixMode(GL_MODELVIEW); 
glLoadIdentity(); 
} 
 
void draw(void) 
{ 
GLint n; 
 
//���ȸ�����ȵ������Ϣ 
GLfloat pp[8][2]={{7.0,-7.0},{0.0,-10.0},{-7.0,-7.0},{-10.0,0.0}, 
{-7.0,7.0},{0.0,10.0},{7.0,7.0},{10.0,0.0}}; 
 
//�Ȼ�ǰ�����㣬Ȼ����ѭ����ȡǰ������������飩��Ϣ���� 
//����ͼ�� 
glBegin(GL_TRIANGLE_FAN); 
 glVertex2f(0.0,0.0); 
 glVertex2f(10.0,0.0); 
 for(n=0;n<8;n++) 
 { 
 
//ÿ�δ���ɫ���ұ����ҳ�����ɫ��Ȼ���������ɫ��������� 
//ע��glVertex2fv()��v��׺��ʹ�ã���ǰû��������v��׺��� 
//�����Ǹ����������飩 
 glIndexi(n+1); 
 glVertex2fv(pp[n]); 
 } 
 glEnd(); 
} 
 
void InitPalette(void) 
{ 
//���DZ����ӵĹؼ��ʼ����ɫ���ұ?����һ������ 
//��8����ɫ���Ǵ�������Ľ��� 
GLint i; 
static GLfloat rgb[][3]={{0.0,0.0,0.2},{0.0,0.0,0.4},{0.0,0.0,0.6}, 
{0.0,0.0,1.0},{0.0,0.2,1.0},{0.0,0.4,1.0},{0.0,0.8,1.0},{0.0,1.0,1.0}}; 
 
//���ü򵥵ĸ���⺯������ϵͳ��ɫ�壬�Ѹղ�8����ɫ��Ϊȫ�� 
//��ɫ��������� 
for(i=0;i<8;i++) 
auxSetOneColor(i+1,rgb[i][0],rgb[i][1],rgb[i][2]); 
} 
 
void CALLBACK display(void) 
{ 
//���ȵ����Զ����InitPalette()��ʼ����ɫ�� 
InitPalette(); 
glClearColor(0.0,0.0,0.0,1.0); 
glClear(GL_COLOR_BUFFER_BIT); 
 
glLoadIdentity(); 
draw(); 
glFlush(); 
} 
 
void main(void) 
{ 
    myinit(); 
    auxReshapeFunc(reshape); 
    auxMainLoop(display); 
} 
//end of sample 
�´ν�����OPENGL�Ĺ��պͲ���Ч��һ������3D�Ľ��ݣ� 
��ҿ���ѽ ...... 
 
-- 
�� ��Դ:��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