🚀 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(12)
#973
Author: ����
Date: Tue, 05 May 1998 00:00
237 lines
7590 bytes
BBSˮľ�廪վ�þ�����
������: yxy (��˿˿#���ߵ�С��ӥ), ����: GAME_Designer 
��  ��: OPENGL(12) 
����վ: BBS ˮľ�廪վ (Sun Feb 15 15:41:17 1998) 
 
�˴ν���OPENGL���ӽ�ģ��ʽ�����ּ���������ɣ���ƪ�Ƚ���ͼԭ��չ�� 
�������ר�ú���ȷ����ƽ��ͼ�Ρ��´λὲ��������÷�����������档 
1.����� 
void glPointSize(GLfloat size); 
���õ�Ŀ�ȣ�size����>0��ȱʡ1 
 
void glLineWidth(GLfoat width); 
�����߿?width>0��ȱʡΪ1 
 
void glLineStipple(GLint factor,GLushort pattern); 
�����ߵ�ģʽ��factor���ڶ�ģʽ��������ı������ӣ�pattern���ߵ�ģʽ 
����11001100�����ߣ�1���ƣ�0�����ƣ� 
 
����Ҫ����glEnable(GL_LINE_STIPPLE)����ʹ�����Ϻ�����ʹ��ʱ���� 
glDisable(GL_LINE_STIPPLE)�رգ�������ǰ��glEnable();glDisable();�� 
�÷��������Ƶġ��뿴�������ӣ� 
/////////////////////////////////////////////////////////////////// 
//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); 
 
 
void myinit(void) 
{ 
        auxInitDisplayMode(AUX_SINGLE|AUX_RGBA); 
        auxInitPosition(0,0,600,500); 
        auxInitWindow("sample1"); 
        glClearColor(0.0,0.0,0.0,0.0); 
        glClear(GL_COLOR_BUFFER_BIT); 
 
        glShadeModel(GL_FLAT); 
} 
/* 
void CALLBACK reshape(GLsizei w,GLsizei h) 
{ 
 
glViewport(0,0,w,h); 
glMatrixMode(GL_PROJECTION); 
glLoadIdentity(); 
 
if(w<=h) 
 glOrtho(-4.0,4.0,-4.0*(GLfloat)h/(GLfloat)w, 
         4.0*(GLfloat)h/(GLfloat)w,-4.0,4.0); 
else 
  glOrtho(-4.0*(GLfloat)h/(GLfloat)w, 
         4.0*(GLfloat)h/(GLfloat)w,-4.0,4.0,-4.0,4.0); 
glMatrixMode(GL_MODELVIEW); 
glLoadIdentity(); 
} 
*/ 
 
//�Զ���Ļ���ֱ�ߵĺ������Ϊ��ʼ�����ֹ����� 
void line2i(GLint x1,GLint y1,GLint x2,GLint y2) 
{ 
glBegin(GL_LINES); 
glVertex2f(x1,y1); 
glVertex2f(x2,y2); 
glEnd(); 
} 
 
void CALLBACK display(void) 
{ 
  glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); 
 
//���Ȼ���һϵ�е㣬��Ĵ�С�������� 
  int i; 
  glColor3f(0.8,0.6,0.4); 
  for(i=1;i<=10;i++) 
  { 
          glPointSize(i*2); 
          glBegin(GL_POINTS); 
          glVertex2f(30.0+((GLfloat)i*50.0),330.0); 
          glEnd(); 
  } 
//�ٻ����������ߣ��ڶ����ȵ�һ����ɢһЩ����pattern����ɿ���  
  glEnable(GL_LINE_STIPPLE); 
  glLineStipple(1,0x0101);//���1λ 
  glColor3f(1.0,0.0,0.0); 
  line2i(20,250,250,250); 
  glLineStipple(1,0x00ff);//���2λ 
  glColor3f(0.0,0.0,1.0); 
  line2i(300,250,550,250); 
 
//�ı��ߵĻ��ƿ�ȵ�Ч��--�ӿ� 
//���»��������������� 
  glLineWidth(5.0); 
  glEnable(GL_LINE_STIPPLE); 
  glLineStipple(1,0x0101); 
  glColor3f(1.0,0.0,0.0); 
  line2i(50,150,250,150); 
  glLineStipple(1,0x00ff); 
  glColor3f(0.0,0.0,1.0); 
  line2i(300,150,550,150); 
 
  glFlush(); 
} 
void main(void) 
{ 
        myinit(); 
     
//    auxReshapeFunc(reshape); 
    auxMainLoop(display); 
} 
//end of sample 
////////////////////////////////////////////// 
 
2.����� 
void glPolygonMode(GLenum face,GLenum mode); 
���ƶ����ָ����Ļ�ͼģʽ�� 
face��GL_FRONT GL_BACK��GL_FRONT_AND BACK 
modeΪ��GL_POINT GL_LINE��GL_FILL��ʾ����͵������㡢�����ߺ����ģʽ 
�Ļ��Ʒ�ʽ��ȱʡ����䷽ʽ�� 
 
void glPolygonStipple(const GLubyte *mask); 
����mask������ָ��32*32��λͼָ�룬1�ǻ��ơ�0������ 
 
ʹ����������ҲҪ���ã� 
glEnable(GL_POLYGON-STIPPLE); 
glDisable(GL_POLYGON_STIPPLE); 
�뿴�������ӣ� 
///////////////////////////////////////////// 
//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); 
 
//�������ģʽ32*32���� 
GLubyte pattern[]={ 
        0x00,0x01,0x80,0x00, 
        0x00,0x03,0xc0,0x00, 
        0x00,0x07,0xe0,0x00, 
        0x00,0x0f,0xf0,0x00, 
        0x00,0x1f,0xf8,0x00, 
        0x00,0x3f,0xfc,0x00, 
        0x00,0x7f,0xfe,0x00, 
        0x00,0xff,0xff,0x00, 
        0x01,0xff,0xff,0x80, 
        0x03,0xff,0xff,0xc0, 
        0x07,0xff,0xff,0xe0, 
        0x0f,0xff,0xff,0xf0, 
        0x1f,0xff,0xff,0xf8, 
        0x3f,0xff,0xff,0xfc, 
        0x7f,0xff,0xff,0xfe, 
        0xff,0xff,0xff,0xff, 
     
        0xff,0xff,0xff,0xff, 
        0x7f,0xff,0xff,0xfe, 
        0x3f,0xff,0xff,0xfc, 
        0x1f,0xff,0xff,0xf8, 
        0x0f,0xff,0xff,0xf0, 
        0x07,0xff,0xff,0xe0, 
        0x03,0xff,0xff,0xc0, 
        0x01,0xff,0xff,0x80, 
        0x00,0xff,0xff,0x00, 
        0x00,0x7f,0xfe,0x00, 
        0x00,0x3f,0xfc,0x00, 
        0x00,0x1f,0xf8,0x00, 
        0x00,0x0f,0xf0,0x00, 
        0x00,0x07,0xe0,0x00, 
        0x00,0x03,0xc0,0x00, 
        0x00,0x01,0x80,0x00 
}; 
 
void myinit(void) 
{ 
    auxInitDisplayMode(AUX_SINGLE|AUX_RGBA); 
        auxInitPosition(0,0,400,400); 
        auxInitWindow("sample1"); 
        glClearColor(0.0,0.0,0.0,0.0); 
        glClear(GL_COLOR_BUFFER_BIT); 
 
        glShadeModel(GL_FLAT); 
} 
/* 
void CALLBACK reshape(GLsizei w,GLsizei h) 
{ 
 
glViewport(0,0,w,h); 
glMatrixMode(GL_PROJECTION); 
glLoadIdentity(); 
 
if(w<=h) 
 glOrtho(-4.0,4.0,-4.0*(GLfloat)h/(GLfloat)w, 
         4.0*(GLfloat)h/(GLfloat)w,-4.0,4.0); 
else 
  glOrtho(-4.0*(GLfloat)h/(GLfloat)w, 
         4.0*(GLfloat)h/(GLfloat)w,-4.0,4.0,-4.0,4.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); 
//���ö���λ���ģʽ 
  glEnable(GL_POLYGON_STIPPLE);   
//���ö���õ����ģʽ���ƶ���� 
  glPolygonStipple(pattern); 
//���Ƴ����� 
  glRectf(48.0,80.0,210.0,305.0); 
 
  glFlush(); 
} 
void main(void) 
{ 
        myinit(); 
     
//    auxReshapeFunc(reshape); 
    auxMainLoop(display); 
} 
//end of sample 
�����е����н���Ǹ��һ�������ж���ͼ��ij����� 
 
-- 
�� ��Դ:��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