Пример #1
0
/** \param frameIn Frame to image.
  * \param bp Box + boundary.
  * \param bm Box - boundary.
  * \param center If true image w.r.t. center of atoms, otherwise first atom.
  * \param useMass If true calc center of mass, otherwise geometric center.
  */
void Image::Ortho(Frame& frameIn, Vec3 const& bp, Vec3 const& bm, Vec3 const& offIn,
                  bool center, bool useMass, PairType const& AtomPairs)
{
  Vec3 Coord;
  Vec3 offset(offIn[0] * frameIn.BoxCrd()[0],
              offIn[1] * frameIn.BoxCrd()[1],
              offIn[2] * frameIn.BoxCrd()[2]);
  // Loop over atom pairs
  for (PairType::const_iterator atom = AtomPairs.begin();
                                atom != AtomPairs.end(); atom++)
  {
    int firstAtom = *atom;
    ++atom;
    int lastAtom = *atom;
    //if (debug>2)
    //  mprintf( "  IMAGE processing atoms %i to %i\n", firstAtom+1, lastAtom);
    // Set up Coord with position to check for imaging based on first atom or 
    // center of mass of atoms first to last.
    if (center) {
      if (useMass)
        Coord = frameIn.VCenterOfMass(firstAtom,lastAtom);
      else
        Coord = frameIn.VGeometricCenter(firstAtom,lastAtom);
    } else 
      Coord = frameIn.XYZ( firstAtom );

    // boxTrans will hold calculated translation needed to move atoms back into box
    Vec3 boxTrans = Ortho(Coord, bp, bm, frameIn.BoxCrd()) + offset;

    // Translate atoms according to Coord
    frameIn.Translate(boxTrans, firstAtom, lastAtom);
  } // END loop over atom pairs
}
Пример #2
0
//std::vector<textitem> textItems;
void drawFinal2DText()
{
	
	//return;
	extern CFont *util_font;

	if (!util_font)
		return;

	util_font->setBatch(true);
	glDisable(GL_FOG);
	// Goto othographic mode	
	Ortho();
	CFont::fontStrings *f = new CFont::fontStrings[textItems.size()];
	std::copy(textItems.begin(), textItems.end(), f);

	util_font->Draw2DStrings(f, textItems.size());

	textItems.clear();
	delete [] f;

	util_font->setBatch(false);

	// Go back to perspective
	Perspective();
}
Пример #3
0
void TextureDrawHelperDraw(
	TEXTURE_DRAW_HELPER* helper,
	float* rect,
	const float* position,
	GLuint texture_name
)
{
	float model_view[16] = {1, 0, 0, position[0], 0, 1, 0, position[1], 0, 0, 1, position[2], 0, 0, 0, 1};
	float projection[16] = IDENTITY_MATRIX;

	if(texture_name == 0)
	{
		return;
	}

	glDisable(GL_DEPTH_TEST);
	TextureDrawHelperUpdateVertexBuffer(helper, rect);
	Ortho(projection, 0, (float)helper->width, 0, (float)helper->height, -1.0f, 1.0f);
	ShaderProgramBind(&helper->program.base_data);
	glActiveTexture(GL_TEXTURE0);
	glBindTexture(GL_TEXTURE_2D, texture_name);
	MulMatrix4x4(projection, model_view, projection);
	//MulMatrix4x4(model_view, projection, projection);
	TextureDrawHelperProgramSetUniformValues(&helper->program, projection, texture_name);
	TextureDrawHelperBindVertexBundle(helper, TRUE);
	glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
	TextureDrawHelperUnbindVertexBundle(helper, TRUE);
	ShaderProgramUnbind(&helper->program.base_data);
	glBindTexture(GL_TEXTURE_2D, 0);
	glEnable(GL_DEPTH_TEST);
}
Пример #4
0
/* test harness */
int
main(int argc, char *argv[])
{
   float m[16], p[16];
   float l, r, b, t, n, f;
   int persp;
   int i;

#if 0
   l = -.9;
   r = 1.2;
   b = -0.5;
   t = 1.4;
   n = 30;
   f = 84;
   printf("  Frustum(%f, %f, %f, %f, %f, %f\n",l+1, r+1.2, b+.5, t+.3, n, f);
   Frustum(l+1, r+1.2, b+.5, t+.3, n, f, p);
   DecomposeProjection(p, &persp, &l, &r, &b, &t, &n, &f);
   printf("glFrustum(%f, %f, %f, %f, %f, %f)\n",
          l, r, b, t, n, f);
   PrintMatrix(p);
#else
   printf("Ortho(-1, 1, -1, 1, 10, 84)\n");
   Ortho(-1, 1, -1, 1, 10, 84, m);
   PrintMatrix(m);
   DecomposeProjection(m, &persp, &l, &r, &b, &t, &n, &f);
   printf("Ortho(%f, %f, %f, %f, %f, %f) %d\n", l, r, b, t, n, f, persp);
#endif

   return 0;
}
Пример #5
0
Camera::Camera() {
	for (int i = 0; i < 2; i++){
		Face f;
		vec4 v(0,0,0.2,1);
		int sign = i % 2 == 0 ? 1 : -1;
		v.x = -sign * 0.1;
		f.addVertex(v);

		v.x = sign * 0.1;
		f.addVertex(v);

		v.z = 0;
		v.x = 0;
		v.y = i % 2 == 0 ? 0.1 : -0.1;
		f.addVertex(v);

		f.calcNorm();
		faces.push_back(f);
	}
	left = bottom = -1.0;
	right = top = 1.0;
	zNear = 0.5;
	zFar = 10.0;

	Ortho();
}
void myReshape(int w, int h)
{

/* adjust clipping box */

        point4 eye = vec4(1.5, 1.0, 1.0, 1.0);
        point4 at = vec4(0.0, 0.0, 0.0, 1.0);
        vec4 up =  vec4(0.0, 1.0, 0.0, 1.0); 
        projection = Ortho(-2.0, 2.0, -2.0, 2.0, -4.0, 4.0);
        model_view = LookAt(eye, at, up);
        glUniformMatrix4fv(model_view_loc, 16, GL_TRUE, model_view);
        glUniformMatrix4fv(projection_loc, 16, GL_TRUE, projection);

       

/* adjust viewport and  clear */

        if(w<h) glViewport(0,0,w,w);
        else glViewport(0,0,h,h);


/* set global size for use by drawing routine */

        ww = w;
        wh = h; 
}
Пример #7
0
void display()
{
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);  /*clear the window */
     model_view =  LookAt(eye, at, up);
     projection = Ortho(left, right, bottom, top, near, far);


     glUniformMatrix4fv(matrix_loc, 1, GL_TRUE, model_view);
     glUniformMatrix4fv(projection_loc, 1, GL_TRUE, projection);

// Draw rectangle in red

     glUniform4fv(color_loc, 1, red);
     glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); 

// rotate light

     light[0] = 1.0*sin((6.28/180.0)*theta);
     light[2] = 1.0*cos((6.28/180.0)*theta);
     
// alter model-view matrix for projection
// draw projected shadow in black

     model_view = model_view*Translate(light[0], light[1], light[2])*m*Translate(-light[0], -light[1], -light[2]);
     glUniformMatrix4fv(matrix_loc, 1, GL_TRUE, model_view);
     glUniform4fv(color_loc, 1, black);
     glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); 
     glutSwapBuffers();
}
void
reshape( int width, int height )
{
    glViewport( 0, 0, width, height );

    GLfloat left = -10.0, right = 10.0;
    GLfloat bottom = -10.0, top = 10.0;
    GLfloat zNear = -10.0, zFar = 10.0;

    GLfloat aspect = GLfloat( width ) / height;

    if ( aspect > 1.0 ) {
        left *= aspect;
        right *= aspect;
    }
    else {
        bottom /= aspect;
        top /= aspect;
    }

    mat4 projection = Ortho( left, right, bottom, top, zNear, zFar );
    glUniformMatrix4fv( Projection, 1, GL_TRUE, projection );

    model_view = mat4( 1.0 );   // An Identity matrix
}
Пример #9
0
void ReferenceFrame(double v[3], double s[3], double t[3])
{
    Ortho(v, s);
    CrossProduct(v, s, t);
    Normalize(s);
    Normalize(t);
}
Пример #10
0
void
reshape( int width, int height )
{
    glViewport( 0, 0, width, height );

    GLfloat left = -10.0, right = 10.0;
    GLfloat top = 10.0, bottom = -10.0;
    GLfloat zNear = -20.0, zFar = 20.0;

    GLfloat aspect = GLfloat(width)/height;

    if ( aspect > 1.0 ) {
		left *= aspect;
		right *= aspect;
    } else {
		top /= aspect;
		bottom /= aspect;
    }

    mat4 projection = Ortho( left, right, bottom, top, zNear, zFar );

	// Bind new projection to each program
	glUseProgram( programP1 );
    glUniformMatrix4fv( pMatrix, 1, GL_TRUE, projection );

	glUseProgram( programP2 );
    glUniformMatrix4fv( pMatrix, 1, GL_TRUE, projection );

	glUseProgram( programB );
    glUniformMatrix4fv( pMatrix, 1, GL_TRUE, projection );
	glUseProgram( 0 );
}
Пример #11
0
void OBS::DrawPreview(const Vect2 &renderFrameSize, const Vect2 &renderFrameOffset, const Vect2 &renderFrameCtrlSize, int curRenderTarget, PreviewDrawType type)
{
    LoadVertexShader(mainVertexShader);
    LoadPixelShader(mainPixelShader);

    Ortho(0.0f, renderFrameCtrlSize.x, renderFrameCtrlSize.y, 0.0f, -100.0f, 100.0f);
    if(type != Preview_Projector
       && (renderFrameCtrlSize.x != oldRenderFrameCtrlWidth
           || renderFrameCtrlSize.y != oldRenderFrameCtrlHeight))
    {
        // User is drag resizing the window. We don't recreate the swap chains so our coordinates are wrong
        SetViewport(0.0f, 0.0f, (float)oldRenderFrameCtrlWidth, (float)oldRenderFrameCtrlHeight);
    }
    else
        SetViewport(0.0f, 0.0f, renderFrameCtrlSize.x, renderFrameCtrlSize.y);

    // Draw background (Black if fullscreen/projector, window colour otherwise)
    if(type == Preview_Fullscreen || type == Preview_Projector)
        ClearColorBuffer(0x000000);
    else
        ClearColorBuffer(GetSysColor(COLOR_BTNFACE));

    if(bTransitioning)
    {
        BlendFunction(GS_BLEND_ONE, GS_BLEND_ZERO);
        DrawSprite(transitionTexture, 0xFFFFFFFF,
                renderFrameOffset.x, renderFrameOffset.y,
                renderFrameOffset.x + renderFrameSize.x, renderFrameOffset.y + renderFrameSize.y);
        BlendFunction(GS_BLEND_FACTOR, GS_BLEND_INVFACTOR, transitionAlpha);
    }

    DrawSprite(mainRenderTextures[curRenderTarget], 0xFFFFFFFF,
            renderFrameOffset.x, renderFrameOffset.y,
            renderFrameOffset.x + renderFrameSize.x, renderFrameOffset.y + renderFrameSize.y);
}
Пример #12
0
/**
 * \param type bit 0: render OSD, bit 1: render EOSD
 */
static void do_render_osd(int type) {
  if (((type & 1) && osdtexCnt > 0) || ((type & 2) && eosdDispList)) {
    // set special rendering parameters
    if (!scaled_osd) {
      MatrixMode(GL_PROJECTION);
      PushMatrix();
      LoadIdentity();
      Ortho(0, vo_dwidth, vo_dheight, 0, -1, 1);
    }
    Enable(GL_BLEND);
    if ((type & 2) && eosdDispList) {
      BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
      CallList(eosdDispList);
    }
    if ((type & 1) && osdtexCnt > 0) {
      Color4ub((osd_color >> 16) & 0xff, (osd_color >> 8) & 0xff, osd_color & 0xff, 0xff - (osd_color >> 24));
      // draw OSD
#ifndef FAST_OSD
      BlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_ALPHA);
      CallLists(osdtexCnt, GL_UNSIGNED_INT, osdaDispList);
#endif
      BlendFunc(GL_SRC_ALPHA, GL_ONE);
      CallLists(osdtexCnt, GL_UNSIGNED_INT, osdDispList);
    }
    // set rendering parameters back to defaults
    Disable(GL_BLEND);
    if (!scaled_osd)
      PopMatrix();
    BindTexture(gl_target, 0);
  }
Пример #13
0
void Camera::reset(){
	LookAt(vec4(0, 0, 1, 1), vec4(0,0,0,1), vec4(0, 1, 0, 1));
	left = bottom = -1;
	right = top = 1;
	zNear = 0.5;
	zFar = 10;
	Ortho();
}
Пример #14
0
//-----------------------------------------------------------------------------
//       Class:  Context
//      Method:  Context
// Description:  constructor
//-----------------------------------------------------------------------------
Context::Context ( GLfloat w, GLfloat h, std::string windowName, Camera cam ) :
    w_(w), h_(h), windowName_(windowName), cam_(cam)
{
    pers_ = Perspective(w_, h_);
    ortho_ = Ortho(w_, h_);
    mainWindow_ = NULL;
    windowOpened_ = true;
}  // -----  end of method Context::Context  (constructor)  -----
Пример #15
0
void EditorViewWindow::SetupProjectionMatrix()
{
	if(mode == MAP_3D) 
	{
		gluPerspective (70.0f, 1, 1.0f, 4000.0f);
		glScalef(1.0f,1.0f,-1.0f);
	}
	else Ortho ();
}
Пример #16
0
	CameraClass::CameraClass()
		:Object()
	{
		up_ = vec4(0.0f,1.0f,0.0f,0.0f);	// 上方向
		eye_ = vec4(0.0f,0.0f,0.0f,0.0f);	// 相机坐标
		look_at_ = vec4(0.0,0.0,1.0f);	// 目标坐标
		projection_mat_= Ortho(-1, 1, -1, 1, -1, 1);	// 投影矩阵
		view_mat_=Identity();			// 视模矩阵
		spin_mat_ = Identity();
	}
Пример #17
0
mat4 Camera::getProjectionMatrix() {
  switch (projectionType) {
    case 1:
      return Ortho(left, right, bottom, top, zNear, zFar);
    case 2:
      return Frustum(left, right, bottom, top, zNear, zFar);
    default:
      return Perspective(fovy, aspect, zNear, zFar);
  }
}
Пример #18
0
mat4 SpelchkCamera::getProjectionMatrix() {
  switch ( _projectionType ) {
  case 1:
    return Ortho( _left, _right, _bottom, _top, _zNear, _zFar );
  case 2:
    return Frustum( _left, _right, _bottom, _top, _zNear, _zFar );
  default:
    return Perspective( _fovy, _aspect, _zNear, _zFar );
  }
}
Пример #19
0
void TrackballCamera::SetOrtho(float left, float right, float bottom, float top,
	float zNear, float zFar, int winWidth, int winHeight)
{
	view.w = abs(right - left);
	view.h = abs(bottom - top);
	view.fw = view.w / winWidth;
	view.fh = view.h / winHeight;
	rot.translate = Vector3f(0);

	rc->SetProjection(Ortho(left, right, bottom, top, zNear, zFar));
	changed = true;
}
Пример #20
0
static void draw(void)
{
    /* send elapsed time to shaders */

    mat4 MVP;
    MVP=Ortho(-0.75,0.75,-0.75,0.75,-5.5,5.5)*LookAt(vec4(2.0, 2.0, 2.0, 1.0), vec4(0.5, 0.0, 0.5, 1.0), vec4(0.0, 1.0, 0.0, 1.0));
    glUniformMatrix4fv(MVP_loc, 1, GL_TRUE, MVP);
    glUniform1f(timeParam, glutGet(GLUT_ELAPSED_TIME));
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    //for(int i =0; i< 4*N*N; i+=3) glDrawArrays(GL_LINE_LOOP, i, 3);
    glDrawArrays(GL_TRIANGLES, 0, 6*N*N);
    glutSwapBuffers();
}
Пример #21
0
void ChangeSize ( int w, int h ) {
    // 防止除0
    if(h == 0)
        h = 1;

    glViewport(0, 0, w, h);		// 视口占满整个窗口

    GLfloat fAspect = (GLfloat)w / (GLfloat)h;	// 计算窗口宽高比

    // 设置正视投影视域体
    mat_projection = Ortho(-10, 970, -10, 550, 200, -200);
    windowsWidth = w;
    windowsHigh = h;
}
Пример #22
0
void
reshape( int width, int height )
{
    glViewport( 0, 0, width, height );
    
    point4 eye = vec4( 1.5, 1.0, 1.0, 1.0 );
    point4 at = vec4( 0.0, 0.0, 0.0, 1.0 );
    vec4 up = vec4( 0.0, 1.0, 0.0, 1.0 );

    mat4 projection = Ortho( -2.0, 2.0, -2.0, 2.0, -4.0, 4.0 );
    mat4 model_view = LookAt( eye, at, up );

    glUniformMatrix4fv( model_view_loc, 1, GL_TRUE, model_view );
    glUniformMatrix4fv( projection_loc, 1, GL_TRUE, projection );
}
Пример #23
0
Файл: gui.c Проект: dmdware/vec
void GUI_draw2(GUI *gui)
{
	unsigned int spi;
	Sprite* sp;
	Widget *bw;

	glClear(GL_DEPTH_BUFFER_BIT);
	glDisable(GL_DEPTH_TEST);
	CHECKGLERROR();
	Ortho(g_width, g_height, 1, 1, 1, 1);
	CHECKGLERROR();

	/* TODO
	in Widget::
	Widget_draw((Widget*)gui);
	CHECKGLERROR();
	Widget_drawover((Widget*)gui);
	*/

	if(g_appmode == APPMODE_PLAY &&
		g_keys[SDL_SCANCODE_TAB])
	{
//		Lobby_DrawPyL();
//		Lobby_DrawState();
	}

	spi = g_cursor[g_curst];
	sp = &g_sp[spi];

	bw = (Widget*)gui;

	bw->crop[0] = 0;
	bw->crop[1] = 0;
	bw->crop[2] = (float)g_width-1;
	bw->crop[3] = (float)g_height-1;

	DrawImage(g_tex[sp->difftexi].texname, 
		g_mouse.x+sp->offset[0], g_mouse.y+sp->offset[1], 
		g_mouse.x+sp->offset[2], g_mouse.y+sp->offset[3], 
		0,0,1,1, bw->crop);
	
	CHECKGLERROR();

	EndS();
	CHECKGLERROR();

	glEnable(GL_DEPTH_TEST);
}
Пример #24
0
void init() 
{
	// Create a vertex array object
	GLuint vao[1];
	#ifdef __APPLE__       // For use with OS X
		glGenVertexArraysAPPLE(1, vao );
		glBindVertexArrayAPPLE(vao[0] );
	#else		       // Other (Linux)
		glGenVertexArrays(1, vao );
		glBindVertexArray(vao[0] );       
	#endif

	// Create and initialize a buffer object
	    GLuint buffer;
	    glGenBuffers( 2, &buffer );
	    glBindBuffer( GL_ARRAY_BUFFER, buffer );
	    glBufferData( GL_ARRAY_BUFFER, sizeof(points) + sizeof(colors),
			  NULL, GL_STATIC_DRAW );
	    glBufferSubData( GL_ARRAY_BUFFER, 0, sizeof(points), points );
	    glBufferSubData( GL_ARRAY_BUFFER, sizeof(points), sizeof(colors), colors );



	// Load shaders and use the resulting shader program
	GLuint program = InitShader( "v_bezier.glsl", "f_bezier.glsl" );
	glUseProgram( program );

	// set up vertex arrays
	    GLuint vPosition = glGetAttribLocation( program, "vPosition" );
	    glEnableVertexAttribArray( vPosition );
	    glVertexAttribPointer( vPosition, 4, GL_FLOAT, GL_FALSE, 0,
				   BUFFER_OFFSET(0) );

	    GLuint vColor = glGetAttribLocation( program, "vColor" ); 
	    glEnableVertexAttribArray( vColor );
	    glVertexAttribPointer( vColor, 4, GL_FLOAT, GL_FALSE, 0,
				   BUFFER_OFFSET(sizeof(points)) );
	
	// Generate the Projection Matrix and send to vertex shader:
	GLuint Projection_loc = glGetUniformLocation( program, "Projection" );
	glUniformMatrix4fv( Projection_loc, 1, GL_TRUE, Ortho( -1,1,-1,1, -1 ,1 ) );

    	glShadeModel(GL_FLAT);
	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
	// set clear color to white
	glClearColor (0.95, 0.95, 0.95, 1.0);

}
Пример #25
0
void
display( void )
{	
	glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
	point4 eye(1,1,1,1);
	point4 at(0,0,0,1);
	point4 up(0,1,0,1);
	mat4 mv = LookAt(eye,at,up);
	
	glUniformMatrix4fv(model_view, 1, GL_TRUE, mv);

	mat4 p= Ortho(left,right,bottom,top,0,10);
	glUniformMatrix4fv(projection, 1, GL_TRUE, p);
	glDrawArrays( GL_TRIANGLES, 0, NumVertices);
	glutSwapBuffers();
}
Пример #26
0
void
init( void )
{
  // Read model in
  woman.LoadMesh( "woman" );

  // Load shaders and use the resulting shader program
  GLuint program = InitShader( "shaders/vshader.glsl", "shaders/fshader.glsl" );
  glUseProgram( program );

  GLuint loc;

  // Initialize shader lighting parameters
  point4 light_position( 0.0, 0.0, 1.0, 0.0 );
  color4 light_ambient( 0.5, 0.5, 0.5, 1.0 );
  color4 light_diffuse( 1.0, 1.0, 1.0, 1.0 );

  // Calculate products
  color4 ambient_product = light_ambient;

  // Pass in light products
  glUniform4fv( glGetUniformLocation( program, "AmbientProduct" ),
                1, ambient_product );
  glUniform4fv( glGetUniformLocation( program, "DiffuseProduct" ),
                1, light_diffuse );
  glUniform4fv( glGetUniformLocation( program, "LightPosition" ),
                1, light_position );
  MaterialColorLoc = glGetUniformLocation( program, "MaterialColor" );

  // Set our vertex projection matrix
  orthoProjection = Ortho( -20.0, 20.0, -20.0, 20.0, -20.0, 20.0 );
  loc = glGetUniformLocation( program, "Projection" );
  glUniformMatrix4fv( loc, 1, GL_TRUE, orthoProjection );

  // Set up our camera
  vec4 eye( 0.0, 0.0, 1.0, 1.0 );
  vec4 at( 0.0, 0.0, 0.0, 1.0 );
  vec4 up( 0.0, 1.0, 0.0, 0.0 );
  N = LookAt( eye, at, up );
  glUniformMatrix4fv( glGetUniformLocation( program, "ModelView" ),
                      1, GL_TRUE, N );

  glEnable( GL_DEPTH );
  glClearColor( 1.0, 1.0, 1.0, 1.0 ); // white background
}
void myReshape(int w, int h)
{
    glViewport(0, 0, w, h);
    if (w <= h)
        //projection = Ortho(-2.0, 2.0, -2.0 * (GLfloat) h / (GLfloat) w,
            //2.0 * (GLfloat) h / (GLfloat) w, -10.0, 10.0);
        // projection = Ortho(-0.4, 0.4, -0.4 * (GLfloat) h / (GLfloat) w,
            // 0.4 * (GLfloat) h / (GLfloat) w, 0.0, 10.0);
        projection = Frustum(-0.4, 0.4, -0.4 * (GLfloat) h / (GLfloat) w,
            0.4 * (GLfloat) h / (GLfloat) w, 0.1, 1.0);
    else
        // projection = Ortho(-2.0 * (GLfloat) w / (GLfloat) h,
            // 2.0 * (GLfloat) w / (GLfloat) h, -2.0, 2.0, -10.0, 10.0);
        //projection = Ortho(-0.4 * (GLfloat) w / (GLfloat) h,
            //0.4 * (GLfloat) w / (GLfloat) h, -0.4, 0.4, 0.0, 10.0);
        projection = Ortho(-0.4 * (GLfloat) w / (GLfloat) h,
            0.4 * (GLfloat) w / (GLfloat) h, -0.4, 0.4, 0.1, 1.0);
     glUniformMatrix4fv(projection_loc, 1, GL_TRUE, projection);
}
Пример #28
0
 void Camera::UpdateProjection() const
 {
     if (isOrtho_)
     {
         if (!hasUserOrthoProjection_)
             orthoProjection_ = CalculateOrthoProjection(zNear_, zFar_);
         matProjection_ = Ortho(orthoProjection_.left_,
                                orthoProjection_.right_,
                                orthoProjection_.bottom_,
                                orthoProjection_.top_,
                                orthoProjection_.near_,
                                orthoProjection_.far_);
     }
     else
     {
         CHECK_ASSERT(zNear_ > 0);
         matProjection_ = Perspective(fovy_, aspectRatio_, zNear_, zFar_);
     }
     SetUniformsNeedUpdate();
 }
Пример #29
0
static void resize(int x,int y){
  mp_msg(MSGT_VO, MSGL_V, "[gl] Resize: %dx%d\n",x,y);
  if (WinID >= 0) {
    int top = 0, left = 0, w = x, h = y;
    geometry(&top, &left, &w, &h, vo_screenwidth, vo_screenheight);
    Viewport(top, left, w, h);
  } else
  Viewport( 0, 0, x, y );

  MatrixMode(GL_PROJECTION);
  LoadIdentity();
  ass_border_x = ass_border_y = 0;
  if (aspect_scaling() && use_aspect) {
    int new_w, new_h;
    GLdouble scale_x, scale_y;
    aspect(&new_w, &new_h, A_WINZOOM);
    panscan_calc_windowed();
    new_w += vo_panscan_x;
    new_h += vo_panscan_y;
    scale_x = (GLdouble)new_w / (GLdouble)x;
    scale_y = (GLdouble)new_h / (GLdouble)y;
    Scaled(scale_x, scale_y, 1);
    ass_border_x = (vo_dwidth - new_w) / 2;
    ass_border_y = (vo_dheight - new_h) / 2;
  }
  Ortho(0, image_width, image_height, 0, -1,1);

  MatrixMode(GL_MODELVIEW);
  LoadIdentity();

  if (!scaled_osd) {
#ifdef CONFIG_FREETYPE
  // adjust font size to display size
  force_load_font = 1;
#endif
  vo_osd_changed(OSDTYPE_OSD);
  }
  Clear(GL_COLOR_BUFFER_BIT);
  redraw();
}
Пример #30
0
void
display( void )
{
    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

    point4  eye( radius*sin(theta)*cos(phi),
		 radius*sin(theta)*sin(phi),
		 radius*cos(theta),
		 1.0 );
    point4  at( 0.0, 0.0, 0.0, 1.0 );
    vec4    up( 0.0, 1.0, 0.0, 0.0 );

    mat4  mv = LookAt( eye, at, up );
    glUniformMatrix4fv( model_view, 1, GL_TRUE, mv );

    mat4  p = Ortho( left, right, bottom, top, zNear, zFar );
    glUniformMatrix4fv( projection, 1, GL_TRUE, p );

    glDrawArrays( GL_TRIANGLES, 0, NumVertices );

    glutSwapBuffers();
}