Beispiel #1
0
//procedura inicjuj¹ca ró¿ne sprawy zwi¹zane z rysowaniem w OpenGL
void initOpenGL() {
	tex0 = readTexture("metal.tga");
	tex1 = readTexture("stones2.tga");
	tex2 = readTexture("latarka.tga");
	setupShaders();
	setupVBO();
	setupVAO();
	glEnable(GL_DEPTH_TEST);
}
Beispiel #2
0
void Polyhedron::init(GLuint program)
{
	//Generate the vertices needed for VBO and VAO
	draw();
	//Setup the VBO
	setupVBO();
	//Setup the VAO
	setupVAO(program);
}
Beispiel #3
0
bool init() {

/*	Matrix4f t;
	t.identity();
	Matrix4f t2;
	t2.Ortho(0, 100, 0, 100, -1, 1);
	
	testMatrices(t, t2);*/
	if( configKinect() != XN_STATUS_OK ){
		std::cout<<"failed to configure kinect";
		return false;
	}

    if(SDL_Init(SDL_INIT_EVERYTHING) < 0) {
        return false;
    }

    if((Surf_Display = SDL_SetVideoMode(640, 480, 32, SDL_HWSURFACE | SDL_GL_DOUBLEBUFFER | SDL_OPENGL)) == NULL) {
        return false;
    }

	GLenum err = glewInit();
	if (GLEW_OK != err)
	{
	  /* Problem: glewInit failed, something is seriously wrong. */
	  fprintf(stderr, "Error: %s\n", glewGetErrorString(err));
	  exit(1);
	}

	glClearColor(0, 0, 0, 0);

    glViewport(0, 0, 640, 480);

	// Create and compile the GLSL program from the shaders
	programObject = ShaderLoader::createShader( "vertexTest.txt", "fragmentTest.txt" );
	vPos = glGetAttribLocation(programObject, "position");
	matLoc = glGetUniformLocation(programObject, "modelViewProjectionMatrix");

	setupVAO();


    return true;
}
Beispiel #4
0
void initOpenGL() {
	setupShaders();
	setupVBO();
	setupVAO();
	glEnable(GL_DEPTH_TEST);
}
bool YUV420PGrabber::setup(int winW, int winH, int framerate) {

  if(!winW || !winH) {
    printf("error: invalid win_w or win_h: %dx%d\n", winW, winH);
    return false;
  }

  if(!framerate) {
    printf("error: invalid fps: %d\n", framerate);
    return false;
  }

  win_w = winW;
  win_h = winH;
  uv_w = vid_w * 0.5;
  uv_h = vid_h * 0.5;
  fps = framerate;

  if(!setupSizes()) {
    printf("error: cannot setup the sizes. did you add any? make sure to call addSize()\n");
    return false;
  }

  if(!setupTextures()) {
    printf("error: cannot setup textures.\n");
    return false;
  }

#if 0
  if(!setupPBO()) {
    printf("error: cannot setup pbox.\n");
    return false;
  }
#endif

  if(!setupFBO()) {
    printf("error: cannot setup fbo.\n");
    return false;
  }

  if(!setupVAO()) {
    printf("error: cannot setup vao.\n");
    return false;
  }

  if(!setupShaders()) {
    printf("error: cannot setup shaders.\n");
    return false;
  }


  image = new unsigned char[tex_w * tex_h];
  if(!image) {
    printf("error: cannot allocate image buffer.\n");
    return false;
  }

  // set the pointers to the image
  for(std::vector<YUV420PSize>::iterator it = sizes.begin(); it != sizes.end(); ++it) {
    YUV420PSize& s = *it;
    s.planes[0] = &image[s.y_offset];
    s.planes[1] = &image[s.u_offset];
    s.planes[2] = &image[s.v_offset];
  }

  frame_delay = (1.0/fps) * 1000 * 1000 * 1000;

  return true;
}