Ejemplo n.º 1
0
 void EndS3DRender()
 {
    setOrtho(0, mWidth, 0, mHeight);
    #ifdef ANDROID
    mS3D.EndS3DRender(mWidth, mHeight, mTrans);
    #endif
 }
Ejemplo n.º 2
0
void reshape(int w, int h)
{
	glViewport(0, 0, w, h);

	glLoadIdentity();
	setOrtho(w, h);

	display();
}
Ejemplo n.º 3
0
 void SetViewport(const Rect &inRect)
 {
    if (inRect!=mViewport)
    {
       setOrtho(inRect.x,inRect.x1(), inRect.y1(),inRect.y);
       mViewport = inRect;
       glViewport(inRect.x, mHeight-inRect.y1(), inRect.w, inRect.h);
    }
 }
Ejemplo n.º 4
0
void MxCore::reset()
{
    _viewUp = _initialUp;
    _viewDir = _initialDir;
    orthonormalize();

    _position = _initialPosition;
    _fovy = _initialFovy;
    setOrtho( false );
}
Ejemplo n.º 5
0
void Scene::drawBackground()
{
	setOrtho();

	// draw a nice orange-to-yellow gradient
	glBindTexture(GL_TEXTURE_2D, GL_NONE);
	glBegin(GL_QUADS);
	{
		glColor3ub(255, 128, 0);   glVertex2i(639, 0);            
		glColor3ub(255, 128, 0);   glVertex2i(0, 0);
		glColor3ub(247, 215, 107); glVertex2i(0, 479);
		glColor3ub(247, 215, 107); glVertex2i(639, 479);
	}
	glEnd();

	unsetOrtho();
}
Ejemplo n.º 6
0
bool TCompCamera::load(MKeyValue& atts) {
	float znear = atts.getFloat("znear", 0.01f);
	float zfar = atts.getFloat("zfar", 1000.f);
	float fov_in_degs = atts.getFloat("fov", 70.f);
	float size_x = atts.getFloat("size_x", 10.f);
	float size_y = atts.getFloat("size_y", 10.f);
	bool use_ar = atts.getBool("use_ar", true);

	bool is_ortho = atts.getBool("is_ortho", false);
	float x = CApp::get().getXRes();
	float y = CApp::get().getYRes();
	if (is_ortho) setOrtho(size_x, size_y, znear, zfar, use_ar ? x / y : 1.f);
	else setProjection(deg2rad(fov_in_degs), znear, zfar);

	//setProjection(deg2rad(fov_in_degs), znear, zfar);

	return true;
}
Ejemplo n.º 7
0
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------
GLvoid ChessGame::drawScene(GLvoid)
{
	chessCam();	
	drawChessBoard();

	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	glDisable(GL_TEXTURE_2D);
	glEnable(GL_LIGHTING);

	for(int i = 0; i < (int)Lighting::lights.size(); i++)
		Lighting::lights[i]->updateLight();


	glEnable(GL_BLEND);	



	//drawGrid();	

	glEnable(GL_LIGHTING);
	glDisable(GL_TEXTURE_2D);

	//TODO:: GET EMITTER WORKING
	//emitter->Update( SDL_GetTicks() );

	glDisable(GL_LIGHTING);
	setOrtho(windowWidth, windowHeight); //ortho for 2D text

	glMatrixMode(GL_MODELVIEW); //back to 3D
	glLoadIdentity();


	displayFPS();
	drawControls();


	glFlush();

	//This line IS MODIFIED in different interfaces
	SDL_GL_SwapBuffers();

}
Ejemplo n.º 8
0
void render()
{
    // Clear frame buffer and depth buffer
   glClear(GL_COLOR_BUFFER_BIT);
   
   glLoadIdentity();
   
   glColor3f(1.0,1.0,1.0);
   setOrtho();
   glPushMatrix();
   drawMiddleLine();
   drawPaddle(100,startX);
   drawPaddle(1280-100,startY);
   drawBall(ballX,ballY);
   glPopMatrix();
   
   glFlush();
   glutSwapBuffers();
}
Ejemplo n.º 9
0
bool ViewData::_handleEvent( const eq::Event& event )
{
    switch( event.type )
    {
      case eq::Event::CHANNEL_POINTER_BUTTON_RELEASE:
      {
          const eq::PointerEvent& releaseEvent =
              event.pointerButtonRelease;
          if( releaseEvent.buttons == eq::PTR_BUTTON_NONE )
          {
              if( releaseEvent.button == eq::PTR_BUTTON1 )
              {
                  _spinX = releaseEvent.dy;
                  _spinY = releaseEvent.dx;
                  return true;
              }
              if( releaseEvent.button == eq::PTR_BUTTON2 )
              {
                  _advance = -releaseEvent.dy;
                  return true;
              }
          }
          return false;
      }
      case eq::Event::CHANNEL_POINTER_MOTION:
          switch( event.pointerMotion.buttons )
          {
            case eq::PTR_BUTTON1:
                _spinX = 0;
                _spinY = 0;
                spinModel( -0.005f * event.pointerMotion.dy,
                           -0.005f * event.pointerMotion.dx, 0.f );
                return true;

            case eq::PTR_BUTTON2:
                _advance = -event.pointerMotion.dy;
                moveModel( 0.f, 0.f, .005f * _advance );
                return true;

            case eq::PTR_BUTTON3:
                moveModel(  .0005f * event.pointerMotion.dx,
                           -.0005f * event.pointerMotion.dy, 0.f );
                return true;

            default:
                return false;
          }

      case eq::Event::CHANNEL_POINTER_WHEEL:
          moveModel( -0.05f * event.pointerWheel.xAxis, 0.f,
                      0.05f * event.pointerWheel.yAxis );
          return true;

      case eq::Event::MAGELLAN_AXIS:
          _spinX = 0;
          _spinY = 0;
          _advance = 0;
          spinModel(  0.0001f * event.magellan.zRotation,
                     -0.0001f * event.magellan.xRotation,
                     -0.0001f * event.magellan.yRotation );
          moveModel(  0.0001f * event.magellan.xAxis,
                     -0.0001f * event.magellan.zAxis,
                      0.0001f * event.magellan.yAxis );
          return true;

      case eq::Event::KEY_PRESS:
          switch( event.keyPress.key )
          {
            case 's':
                showStatistics( !getStatistics( ));
                return true;
            case 'o':
                setOrtho( !useOrtho( ));
                return true;
          }
          return false;

      default:
          return false;
    }
}
Ejemplo n.º 10
0
int piInitVideo()
{
	bcm_host_init();

	// get an EGL display connection
	display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
	if (display == EGL_NO_DISPLAY) {
		fprintf(stderr, "eglGetDisplay() failed: EGL_NO_DISPLAY\n");
		return 0;
	}

	// initialize the EGL display connection
	EGLBoolean result = eglInitialize(display, NULL, NULL);
	if (result == EGL_FALSE) {
		fprintf(stderr, "eglInitialize() failed: EGL_FALSE\n");
		return 0;
	}

	// get an appropriate EGL frame buffer configuration
	EGLint numConfig;
	EGLConfig config;
	static const EGLint attributeList[] = {
		EGL_RED_SIZE, 8,
		EGL_GREEN_SIZE, 8,
		EGL_BLUE_SIZE, 8,
		EGL_ALPHA_SIZE, 8,
		EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
		EGL_NONE
	};
	result = eglChooseConfig(display, attributeList, &config, 1, &numConfig);
	if (result == EGL_FALSE) {
		fprintf(stderr, "eglChooseConfig() failed: EGL_FALSE\n");
		return 0;
	}

	result = eglBindAPI(EGL_OPENGL_ES_API);
	if (result == EGL_FALSE) {
		fprintf(stderr, "eglBindAPI() failed: EGL_FALSE\n");
		return 0;
	}

	// create an EGL rendering context
	static const EGLint contextAttributes[] = {
		EGL_CONTEXT_CLIENT_VERSION, 2,
		EGL_NONE
	};
	context = eglCreateContext(display, config, EGL_NO_CONTEXT, contextAttributes);
	if (context == EGL_NO_CONTEXT) {
		fprintf(stderr, "eglCreateContext() failed: EGL_NO_CONTEXT\n");
		return 0;
	}

	// create an EGL window surface
	int32_t success = graphics_get_display_size(0, &screenWidth, &screenHeight);
	if (result < 0) {
		fprintf(stderr, "graphics_get_display_size() failed: < 0\n");
		return 0;
	}

	fprintf(stderr, "Width/height: %d/%d\n", screenWidth, screenHeight);

	VC_RECT_T dstRect;
	dstRect.x = 0;
	dstRect.y = 0;
	dstRect.width = screenWidth;
	dstRect.height = screenHeight;

	VC_RECT_T srcRect;
	srcRect.x = 0;
	srcRect.y = 0;
	srcRect.width = screenWidth << 16;
	srcRect.height = screenHeight << 16;

	DISPMANX_DISPLAY_HANDLE_T dispManDisplay = vc_dispmanx_display_open(0);
	DISPMANX_UPDATE_HANDLE_T dispmanUpdate = vc_dispmanx_update_start(0);
	DISPMANX_ELEMENT_HANDLE_T dispmanElement = vc_dispmanx_element_add(dispmanUpdate,
		dispManDisplay, 0, &dstRect, 0, &srcRect,
		DISPMANX_PROTECTION_NONE, NULL, NULL, DISPMANX_NO_ROTATE);

	nativeWindow.element = dispmanElement;
	nativeWindow.width = screenWidth;
	nativeWindow.height = screenHeight;
	vc_dispmanx_update_submit_sync(dispmanUpdate);

	fprintf(stderr, "Initializing window surface...\n");

	surface = eglCreateWindowSurface(display, config, &nativeWindow, NULL);
	if (surface == EGL_NO_SURFACE) {
		fprintf(stderr, "eglCreateWindowSurface() failed: EGL_NO_SURFACE\n");
		return 0;
	}

	fprintf(stderr, "Connecting context to surface...\n");

	// connect the context to the surface
	result = eglMakeCurrent(display, surface, surface, context);
	if (result == EGL_FALSE) {
		fprintf(stderr, "eglMakeCurrent() failed: EGL_FALSE\n");
		return 0;
	}

	fprintf(stderr, "Initializing shaders...\n");

	// Init shader resources
	memset(&shader, 0, sizeof(ShaderInfo));
	shader.program = createProgram(vertexShaderSrc, fragmentShaderSrc);
	if (!shader.program) {
		fprintf(stderr, "createProgram() failed\n");
		return 0;
	}

	fprintf(stderr, "Initializing textures/buffers...\n");

	shader.a_position	= glGetAttribLocation(shader.program,	"a_position");
	shader.a_texcoord	= glGetAttribLocation(shader.program,	"a_texcoord");
	shader.u_vp_matrix	= glGetUniformLocation(shader.program,	"u_vp_matrix");
	shader.u_texture	= glGetUniformLocation(shader.program,	"u_texture");

	glGenTextures(1, textures);
	glBindTexture(GL_TEXTURE_2D, textures[0]);
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, TEX_WIDTH, TEX_HEIGHT, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, NULL);

	glGenBuffers(3, buffers);
	glBindBuffer(GL_ARRAY_BUFFER, buffers[0]);
	glBufferData(GL_ARRAY_BUFFER, kVertexCount * sizeof(GLfloat) * 3, vertices, GL_STATIC_DRAW);
	glBindBuffer(GL_ARRAY_BUFFER, buffers[1]);
	glBufferData(GL_ARRAY_BUFFER, kVertexCount * sizeof(GLfloat) * 2, uvs, GL_STATIC_DRAW);
	glBindBuffer(GL_ARRAY_BUFFER, 0);
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffers[2]);
	glBufferData(GL_ELEMENT_ARRAY_BUFFER, kIndexCount * sizeof(GL_UNSIGNED_SHORT), indices, GL_STATIC_DRAW);
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

	glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
	glDisable(GL_DEPTH_TEST);
	glDisable(GL_DITHER);

	float sx = 1.0f;
	float sy = 1.0f;
	float zoom = (float)ZOOM;

	// Screen aspect ratio adjustment
	float a = (float)screenWidth / screenHeight;
	float a0 = (float)WIDTH / (float)HEIGHT;

	if (a > a0) {
		sx = a0/a;
	} else {
		sy = a/a0;
	}

	setOrtho(projection, -0.5f, +0.5f, +0.5f, -0.5f, -1.0f, 1.0f,
		sx * zoom, sy * zoom);

	fprintf(stderr, "Setting up screen...\n");

	msxScreenPitch = WIDTH * BIT_DEPTH / 8;
	msxScreen = (char*)calloc(1, BIT_DEPTH / 8 * TEX_WIDTH * TEX_HEIGHT);
	if (!msxScreen) {
		fprintf(stderr, "Error allocating screen texture\n");
		return 0;
	}

	fprintf(stderr, "Initializing SDL video...\n");

	// We're doing our own video rendering - this is just so SDL-based keyboard
	// can work
	sdlScreen = SDL_SetVideoMode(0, 0, 0, 0);

	return 1;
}
Ejemplo n.º 11
0
  /** Simpler accessors for the pointer on the data (i,j) in the scalar array.

      There are 2 types to allow matrix modification or not (const or not).
   */
  inline T* ptr(int i=0, int j=0) const {
    // here I might modify the data with this pointer
    setOrtho(0);
    return &m[i + ((size_t) lda) * j];
  }
Ejemplo n.º 12
0
  /** Simpler accessors for the data.

      There are 2 types to allow matrix modification or not.
   */
  inline T& get(int i=0, int j=0) {
    // here I might modify the data with this
    setOrtho(0);
    return m[i + ((size_t) lda) * j];
  }
Ejemplo n.º 13
0
void Frustum::setOrtho(const AABB& volume)
{
  float minX, minY, minZ, maxX, maxY, maxZ;
  volume.bounds(minX, minY, minZ, maxX, maxY, maxZ);
  setOrtho(minX, minY, minZ, maxX, maxY, maxZ);
}
Ejemplo n.º 14
0
void setOrtho2D(Mat4x4 m, float l, float r, float b, float t) {
  setOrtho(m,l,r,b,t,-1.0f,1.0f);
}