示例#1
0
void initGL(int argc, char **argv)
{
int i;
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_RGBA|GLUT_DEPTH|GLUT_DOUBLE);
glutInitWindowSize(768,768);
glutInitWindowPosition(100,50);
glutCreateWindow("my_cool_cube");
setup_the_viewvol();
do_lights();
glClearColor(0.45,0.45,0.45,1.0);
glewInit();
glBindBuffer(GL_ARRAY_BUFFER,OGL_VBO);
glBufferData(GL_ARRAY_BUFFER,VCOUNT*3*2*sizeof(float),vertices,GL_DYNAMIC_DRAW);
glVertexPointer(3,GL_FLOAT,3*sizeof(GLfloat),(GLfloat *)0);
glColorPointer(3,GL_FLOAT,3*sizeof(GLfloat),(GLfloat *)(VCOUNT*3*sizeof(GLfloat)));
for(i=0;i<LENGTH-1;i++){
	first[i] = 2*WIDTH*i;
	count[i] = 2*WIDTH;
	}
glNewList(BLOCKLIST,GL_COMPILE);
do_material_block();
block_geometry();
glEndList();
}
示例#2
0
void init(const char* model_path, const char* vshader_path, 
    const char* fshader_path) {
  camera = new GraphicCamera::GraphicCamera(Vec3d(0, 2, 4),
                                            Vec3d(0, 1, 0),
                          Vec3d(0, 1 , 0), 0.02, 20, 60, focus);
  camera->PerspectiveDisplay(WIDTH, HEIGHT);
  do_lights();
  SetShadersOrDie(selected_shader_id, vshader_path, fshader_path);
  model->InitModelData(selected_shader_id);
  ground->InitModelData(selected_shader_id);
  skydome->InitModelData(selected_shader_id);
}
示例#3
0
文件: mt.c 项目: hikaruxujin/cpsc605
int main(int argc, char** argv){
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_RGBA|GLUT_DEPTH);
    glutInitWindowSize(640,640);
    glutInitWindowPosition(100,50);
    glutCreateWindow("multi-textured cube");
    glEnable(GL_DEPTH_TEST);
    load_textures();
    setup_the_viewlolume();
    do_lights();
    do_material();
    glutDisplayFunc(draw_stuff);
    glutMainLoop();
    return 0;
}
示例#4
0
void draw_stuff(){
  SwitchLight();
  glEnable(GL_DEPTH_TEST);
  glClearColor(0.4, 0.4, 0.4, 0);
  glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
  do_lights();
  glUseProgram(selected_shader_id);
  if (selected_shader_id) {
   // if not using fixed shading
   GLint light_switch_loc = glGetUniformLocation(
                         selected_shader_id, "LtSwitch");
   glUniform1i(light_switch_loc, LightSwitch); 
  }
  model->DrawModel((int) DrawNormal, selected_shader_id);
  ground->DrawModel((int) DrawNormal, selected_shader_id);
  skydome->DrawModel((int) DrawNormal, selected_shader_id);
  // printf("Using shader %d\n", selected_shader_id);
}
示例#5
0
文件: va.c 项目: hikaruxujin/cpsc605
void initOGL(int argc,char** argv)
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_RGBA|GLUT_DEPTH);
    glutInitWindowSize(512,512);
    glutInitWindowPosition(100,50);
    glutCreateWindow("my_cube");
    glClearColor(0.35,0.35,0.35,0.0);
    glEnable(GL_DEPTH_TEST);
    setup_the_viewlolume();
    do_lights();
    do_material();
    glBindBuffer(GL_ARRAY_BUFFER,mybuf[0]);
    glBufferData(GL_ARRAY_BUFFER,sizeof(vertices),vertices,GL_STATIC_DRAW);
    glVertexPointer(3,GL_FLOAT,3*sizeof(GLfloat),0);
    glEnableClientState(GL_VERTEX_ARRAY);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,mybuf[1]);
    glBufferData(GL_ELEMENT_ARRAY_BUFFER,sizeof(face),face,GL_STATIC_DRAW);
}
int main()
{
	tranzport_t *z;
	uint8_t status;
	uint32_t buttons;
	uint8_t datawheel;
	int val;

	z = open_tranzport();

	do_lcd(z);

	for(;;) {

	do_lcd(z);
	lights_on(z);
	do_lcd2(z);
	lights_off(z);

//		val = tranzport_read(z, &status, &buttons, &datawheel, 60000);
 		val = -1;
		if (val < 0)
			continue;

		if (status == STATUS_OFFLINE) {
			printf("offline: ");
			continue;
		}

		if (status == STATUS_ONLINE) {
			printf("online: ");
			do_lcd(z);
		}

		do_lights(z, buttons);
		do_buttons(z, buttons, datawheel);
	}

	close_tranzport(z);

	return 0;
}
示例#7
0
void initOGL(int argc, char **argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_RGBA|GLUT_DEPTH|GLUT_DOUBLE);
glutInitWindowSize(512,512);
glutInitWindowPosition(100,50);
glutCreateWindow("my_cool_cube");
setup_the_viewvol();
do_lights();
do_material();
glBindBuffer(GL_ARRAY_BUFFER,mybuf);
glBufferData(GL_ARRAY_BUFFER,sizeof(vertices),vertices,GL_STATIC_DRAW);
// When using VBOs, the final arg is a byte offset in buffer, not the address,
// but gl<whatever>Pointer still expects an address type, hence the NULL.
glVertexPointer(3,GL_FLOAT,3*sizeof(GLfloat),NULL+0);
glNormalPointer(GL_FLOAT,3*sizeof(GLfloat),NULL+3*24*sizeof(GLfloat));
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
/* gray background */
glClearColor(0.35,0.35,0.35,0.0);
}
示例#8
0
int main(int argc, char **argv)
{
srandom(123456789);
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_RGBA|GLUT_DEPTH|GLUT_ACCUM);
glutInitDisplayMode(GLUT_RGBA|GLUT_DEPTH);
glutInitWindowSize(768,768);
glutInitWindowPosition(100,50);
glutCreateWindow("my_cool_cube");
glClearColor(0.35,0.35,0.35,0.0);
glClearAccum(0.0,0.0,0.0,0.0);
glEnable(GL_DEPTH_TEST);
viewvolume_shape();
jitter_view();
do_lights();
do_material();
glutDisplayFunc(go);
glutKeyboardFunc(getout);
glutMainLoop();
return 0;
}
示例#9
0
void KeyBoardHandler(unsigned char key, int x, int y){
  switch (key) {
    case 'q':
      glDeleteBuffers(2, /*(GLuint*)*/ mybuf);
      exit(1);
      break;
    case 'a':
      if ((RENDER_MODE & (~GL_CONTROL_DEF::KAA_MARKER)) != 0 )
        RENDER_MODE = 0;
      RENDER_MODE ^= GL_CONTROL_DEF::KAA_MARKER;
      printf("Set AA to %d \n", (RENDER_MODE & GL_CONTROL_DEF::KAA_MARKER) > 0);
      WantToRedraw = true;
      break;
    case 'w':
      AALevel = (AALevel + 4)%16;
      if (AALevel == 0) {
        AALevel = 16;
      }
      WantToRedraw = true;
      break;
    case 'b':
      if ((RENDER_MODE & (~GL_CONTROL_DEF::KDOF_MARKER)) != 0 )
        RENDER_MODE = 0;
      RENDER_MODE ^= GL_CONTROL_DEF::KDOF_MARKER;
      printf("Set DoF to %d \n", (RENDER_MODE & GL_CONTROL_DEF::KDOF_MARKER) > 0);
      WantToRedraw = true;
      break;
    case 'z':
      if(camera->focus() > 0.2) camera->focus() -= 0.03;
      WantToRedraw = true;
      fprintf(stderr, "current_focus: %f\n", camera->focus());
      break;
    case 'x':
      if(camera->focus() < 100.0) camera->focus() += 0.03;
      WantToRedraw = true;
      
      fprintf(stderr, "current_focus: %f\n", camera->focus());
      break;
    case 's':
      (++selected_shader_id) %= 2;
      break;
    case 'n':
      DrawNormal = !DrawNormal;
      break;
    case 'f':
      IsDrawFrame = !IsDrawFrame;
      break;
    case 'g':
      IsDrawGrid = !IsDrawGrid;
      break;
    case '2':
      IsFillLight = !IsFillLight;
      break;
    case '1':
      IsKeyLight = !IsKeyLight;
      break;
    case '3':
      IsBgLight = !IsBgLight;
      break;
    case 'i':
      shininess += 0.1f;
      // do_material();
      break;
    case 'o':
      shininess -= 0.1f;
      // do_material();
      break;
    case 'k':
      l0brightness +=0.1f;
      do_lights();
      break;
    case 'l':
      l0brightness -=0.1f;
      do_lights();
      break;
    default:
      break;
  }
//  printf("Shininess: %f\n", shininess);
  WantToRedraw = true;
}