Beispiel #1
0
int lua_Drawable_draw(lua_State* state)
{
    // Get the number of parameters.
    int paramCount = lua_gettop(state);

    // Attempt to match the parameters to a valid binding.
    switch (paramCount)
    {
        case 1:
        {
            if ((lua_type(state, 1) == LUA_TUSERDATA))
            {
                Drawable* instance = getInstance(state);
                unsigned int result = instance->draw();

                // Push the return value onto the stack.
                lua_pushunsigned(state, result);

                return 1;
            }

            lua_pushstring(state, "lua_Drawable_draw - Failed to match the given parameters to a valid function signature.");
            lua_error(state);
            break;
        }
        case 2:
        {
            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
                lua_type(state, 2) == LUA_TBOOLEAN)
            {
                // Get parameter 1 off the stack.
                bool param1 = gameplay::ScriptUtil::luaCheckBool(state, 2);

                Drawable* instance = getInstance(state);
                unsigned int result = instance->draw(param1);

                // Push the return value onto the stack.
                lua_pushunsigned(state, result);

                return 1;
            }

            lua_pushstring(state, "lua_Drawable_draw - Failed to match the given parameters to a valid function signature.");
            lua_error(state);
            break;
        }
        default:
        {
            lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
            lua_error(state);
            break;
        }
    }
    return 0;
}
bool InputSample::drawScene(Node* node)
{
    Drawable* drawable = node->getDrawable();
    if (drawable)
        drawable->draw();
    return true;
}
Beispiel #3
0
void BaseLevel::render(){

    
    vector<GameObject *> gameObjects = sceneManager->getObjects();
    
    mat4 cameraMatrix = currentCamera->matrix();
    mat4 identityMatrix = mat4();
    
    windowManager->beforeRender();
    
    for (int i=0; i<gameObjects.size(); i++){
        GameObject *gameObject = gameObjects[i];
        Drawable *mesh = gameObject->getMesh();
        
        vec3 pos = gameObject->getPhysicsObject()->pos;
        mat4 uM = glm::translate(identityMatrix, pos);
        mat4 rot = gameObject->getPhysicsObject()->rot;
        
        mesh->setMatrices(&uM,&cameraMatrix,rot);
        mesh->draw();
    }
    
    hudRenderer->render();
    
    windowManager->afterRender();

}
Beispiel #4
0
bool PostProcessSample::drawScene(Node* node)
{
    Drawable* drawable = node->getDrawable(); 
    if (drawable)
        drawable->draw();
    return true;
}
Beispiel #5
0
void Buffer::createFromDrawable(Drawable &obj) {
   shouldDelete = true;

   if (obj.getW() > 512 || obj.getH() > 512)
      throw RubyException(rb_eRuntimeError, "Drawable too big for a buffer.");

   int width = obj.getW();
   int height = obj.getH();
   img = oslCreateImage(width, height, OSL_IN_VRAM, OSL_PF_8888);
   if (!img) {
      img = oslCreateImage(width, height, OSL_IN_RAM, OSL_PF_8888);
      if (!img)
	 throw RubyException(rb_eRuntimeError, "Buffer could not be created");
   }
   else {
      Buffer::registerInVram(img);
   }

   OSL_IMAGE *old = oslGetDrawBuffer();
   setActual();

   obj.clearMove();
   obj.setPos(0, 0);
   obj.draw();
   obj.cancelMove();

   oslSetDrawBuffer(old);
}
Beispiel #6
0
bool TemplateGame::drawScene(Node* node)
{
    // If the node visited contains a drawable object, draw it
    Drawable* drawable = node->getDrawable(); 
    if (drawable)
        drawable->draw(_wireframe);

    return true;
}
Beispiel #7
0
	void AiEngine::drawScreenDrawables() const
	{
		ScreenDrawablesSet::const_iterator it;
		for (it = screenDrawables.begin(); it != screenDrawables.end(); it++)
		{
			screenCanvas.reset();

			Drawable *drawable = *it;
			drawable->draw(screenCanvas);
		}
	}
Beispiel #8
0
	void AiEngine::drawMapDrawables() const
	{
		MapDrawablesSet::const_iterator it;
		for (it = mapDrawables.begin(); it != mapDrawables.end(); it++)
		{
			mapCanvas.reset();

			Drawable *drawable = *it;
			drawable->draw(mapCanvas);
		}
	}
Beispiel #9
0
	/**
	* Draws an Image at the specified coordinates, with rotation and
	* scaling along both axes.
	* @param x The x-coordinate.
	* @param y The y-coordinate.
	* @param angle The amount of rotation.
	* @param sx The scale factor along the x-axis. (1 = normal).
	* @param sy The scale factor along the y-axis. (1 = normal).
	* @param ox The offset along the x-axis.
	* @param oy The offset along the y-axis.
	**/
	int w_draw(lua_State * L)
	{
		Drawable * drawable = luax_checktype<Drawable>(L, 1, "Drawable", GRAPHICS_DRAWABLE_T);
		float x = (float)luaL_optnumber(L, 2, 0.0f);
		float y = (float)luaL_optnumber(L, 3, 0.0f);
		float angle = (float)luaL_optnumber(L, 4, 0.0f);
		float sx = (float)luaL_optnumber(L, 5, 1.0f);
		float sy = (float)luaL_optnumber(L, 6, sx);
		float ox = (float)luaL_optnumber(L, 7, 0);
		float oy = (float)luaL_optnumber(L, 8, 0);
		drawable->draw(x, y, angle, sx, sy, ox, oy);
		return 0;
	}
Beispiel #10
0
    void draw()
    {
        Rectanglei pos;
        if(self.hasChangedPlace(pos) || !bgBuf->isReady())
        {
            // Update the background quad.
            VertexBuf::Builder bgVerts;
            self.glMakeGeometry(bgVerts);
            bgBuf->setVertices(gl::TriangleStrip, bgVerts, gl::Static);
        }

        // Draw the background.
        background.draw();

        Rectanglei vp = self.viewport();
        if(vp.height() > 0)
        {
            GLState &st = GLState::push();
            // Leave room for the indicator in the scissor.
            st.setScissor(vp.adjusted(Vector2i(), Vector2i(self.rightMargin(), 0)));

            // First draw the shadow of the text.
            uMvpMatrix = projMatrix * Matrix4f::translate(
                         Vector2f(vp.topLeft + Vector2i(0, contentOffsetForDrawing)));
            uShadowColor = Vector4f(0, 0, 0, 1);
            contents.draw();

            // Draw the text itself.
            uMvpMatrix = projMatrix * Matrix4f::translate(
                         Vector2f(vp.topLeft + Vector2i(0, contentOffsetForDrawing - 1)));
            uShadowColor = Vector4f(1, 1, 1, 1);
            contents.draw();

            GLState::pop();
        }

        // We don't need to keep all entries ready for drawing immediately.
        releaseExcessComposedEntries();
    }
Beispiel #11
0
bool SpaceshipGame::drawScene(Node* node, void* cookie)
{
    Drawable* drawable = node->getDrawable();
    if (drawable)
    {
        // Transparent nodes must be drawn last (stage 1)
        bool isTransparent = (node == _glowNode);

        // Skip transparent objects for stage 0
        if ((!isTransparent && (int*)cookie == 0) || (isTransparent && (int*)cookie == (int*)1))
            drawable->draw();
    }

    return true;
}
Beispiel #12
0
bool TerrainSample::drawScene(Node* node)
{
    Camera* camera = _scene->getActiveCamera();
    Drawable* drawable = node->getDrawable();
    if (dynamic_cast<Model*>(drawable))
    {
        if (!node->getBoundingSphere().intersects(camera->getFrustum()))
            return true;
    }
    if (drawable)
    {
        bool wireframe = (node == _sky) ? false : _wireframe;
        drawable->draw(wireframe);
    }

	return true;
}
Beispiel #13
0
int main(int argc, char* argv[]) {
  BMP canvas;
  canvas.SetSize(128, 128);

  const Vector2 truck_center(64, 64);

  /* TODO: Why can't I construct a new Truck?  Is should be a valid Drawable.
   * Could it be missing something that would prevent it from being constructed?
   */
  Drawable* truck = new Truck(truck_center);

  truck->draw(&canvas);

  canvas.WriteToFile("test_pure_virtual.bmp");

  delete truck;
  return 0;
}
Beispiel #14
0
void Scene::draw() {
    
    // This whole process can be VERY optimized if needed
    
    std::vector<Drawable *> autoSort;
    std::vector<Drawable *>::iterator it;
    
    // Gather all auto-sort Drawables in a vector
    for(it = displayList.begin(); it < displayList.end(); ++it) {
        
        Drawable *drawable = (Drawable *) *it;
        
        if (drawable->isVisible() && drawable->isAutoZOrder()) {
            autoSort.push_back(drawable);
        }
    }
    
    // Sort this vector by Y position
    std::sort(autoSort.begin(), autoSort.end(), AutoZOrderSortPredicate);
    
    // Assigns z-order values to elements, starting with Z_ORDER_AUTO_START
    int z = Z_ORDER_AUTO_START;
    
    for(it = autoSort.begin(); it < autoSort.end(); ++it) {
        
        Drawable *drawable = (Drawable *) *it;
        drawable->setZOrder(z);
        z++;
    }
    
    // Sorts the display list based on the z-order values
    std::sort(displayList.begin(), displayList.end(), ZOrderSortPredicate);
    
    // Draws everything in the correct order
    for(it = displayList.begin(); it < displayList.end(); ++it) {
        
        Drawable *drawable = (Drawable *) *it;
        
        if (drawable->isVisible()) {
            drawable->draw();
        }
    }
}
Beispiel #15
0
Buffer::Buffer(Drawable &obj): shouldDelete(true) {
   setClass("Buffer");

   if (obj.getW() > 512 || obj.getH() > 512)
      throw RubyException(rb_eRuntimeError, "Drawable too big for a buffer.");
   
   img = oslCreateImage(obj.getW(), obj.getH(), OSL_IN_VRAM, OSL_PF_8888);
   if (!img)
      throw RubyException(rb_eRuntimeError, "Buffer could not be created");
   
   OSL_IMAGE *old = oslGetDrawBuffer();
   setActual();

   obj.clearMove();
   obj.setPos(0, 0);
   obj.draw();
   obj.cancelMove();

   oslSetDrawBuffer(old);
}
Beispiel #16
0
 void RenderTarget::draw(Drawable& drawable, RenderStates states)
 {
     drawable.draw(*this, states);
 }
Beispiel #17
0
void RenderTarget::draw(const Drawable& drawable, const RenderStates& states)
{
    drawable.draw(*this, states);
}
Beispiel #18
0
void SceneWindow::displayCB()
{    
    // clear window
    glClear(GL_COLOR_BUFFER_BIT);
    
	// gets lists of the active objects to draw them
	Level *level_ = Level::sharedLevel();
	LList movable = level_->getActiveMovable();
	LList drawable = level_->getActiveDrawable();
	LList blocks = level_->getActiveBlocks();
	LListIterator li;
	
	if (start_==true){
		glClearColor(0.4196, 0.549, 1.0, 1.0);
		
		Drawable *item;
	
        //Loops through all active drawable objects
		li.init(drawable);
		while ((item = li.next())) {
			item->draw();
		}
    
        //Loops through all active block objects
		li.init(blocks);
		while ((item = li.next())) {
			item->draw();
		}
    
        //Loops through all active moveable objects
		li.init(movable);
		while ((item = li.next())) {
			item->draw();
		}
        
		// mario isn't in any of the lists, so must be drawn seperately
		mario->draw();
	}
    
    //Game is not started determine why and draw correct screen
	else {
        
        //Mario is out of lives
        //Draw Game over Screen
		if (game->getLives()<0) {
			string name = "GAME OVER";
			glColor3f(255,255,255);
			glRasterPos2f(viewportLeftX_ + 95, 110);
			for (int i=0; i<name.length(); ++i){
				glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, name[i]);
			}
			glutSwapBuffers();
			glutPostRedisplay();
			
			
			//Return to the start screen in 3 sec
			time_t start_time, cur_time;
			time(&start_time);
			do
			{
				time(&cur_time);
			}
			while((cur_time - start_time) < 3);
			
			game = new Game;
			loadLevel();
			}
        
        //User has not yet started a level
        //Draw Load Screen
		else{
			string press = "Press 'S' to start";
			glColor3f(255,255,255);
			glRasterPos2f(viewportLeftX_ + 95, 110);
			for (int i=0; i<press.length(); ++i){
				glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, press[i]);
				}
			string name = "Mario x";
			glRasterPos2f(viewportLeftX_ +95, 100);
			for (int i=0; i<name.length(); ++i){
				glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, name[i]);
			}
        
			//draw lives
			std::stringstream lives;
			lives << game->getLives();
			glColor3f(255,255,255);
			glRasterPos2f(viewportLeftX_ + 130, 100);
			for (int i=0; i<(lives.str()).length(); ++i){
				glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, lives.str()[i]);
				}
		}
	}
	
	
	//draw top line of game information
	string name = "MARIO                                   WORLD           TIME";
	glColor3f(255,255,255);
	glRasterPos2f(viewportLeftX_ + 20, 210);
	for (int i=0; i<name.length(); ++i){
		glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, name[i]);
	}
	//draw point total
	std::stringstream points;
	points << game->getPoints();
	glColor3f(255,255,255);
	glRasterPos2f(viewportLeftX_ + 20, 200);
	for (int i=0; i<(points.str()).length(); ++i){
		glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, points.str()[i]);
	}
	//draw number of coins
	coin->setTop(208);
	coin->setBottom(198);
	coin->setLeft(viewportLeftX_+70);
	coin->setRight(viewportLeftX_ + 82);
	coin->draw();
	std::stringstream coins;
	coins << game->getCoins();
	glColor3f(255,255,255);
	glRasterPos2f(viewportLeftX_ + 82, 200);
	for (int i=0; i<(coins.str()).length(); ++i){
		glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, coins.str()[i]);
	}
	//draw level number
	std::stringstream level;
	level << game->getLevel();
	glColor3f(255,255,255);
	glRasterPos2f(viewportLeftX_ + 145, 200);
	for (int i=0; i<(level.str()).length(); ++i){
		glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, level.str()[i]);
	}
	//draw time
	std::stringstream lives;
	lives << game->getTime();
	glColor3f(255,255,255);
	glRasterPos2f(viewportLeftX_ + 201, 200);
	for (int i=0; i<(lives.str()).length(); ++i){
		glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, lives.str()[i]);
	}
	
    //Game is Paused
    //Overlay Pause on active game
	if (pause_ && !mario->isDead()) {
		string pause = "PAUSE";
		glColor3f(255,255,255);
		glRasterPos2f(viewportLeftX_ + 110, 110);
		for (int i=0; i<pause.length(); ++i){
			glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, pause[i]);
		}
	}
	
    // force screen update
    glFlush();
	glutSwapBuffers();
}
Beispiel #19
0
 void draw(Drawable& drawable) {
     static_assert(is_renderer_drawable<Drawable>::value, "Must provide a void draw(SDL_Renderer*) member function");
     drawable.draw(render.get());
 }
Beispiel #20
0
void Buffer::draw(Drawable &obj) {
   OSL_IMAGE *old = oslGetDrawBuffer();
   setActual();
   obj.draw();
   oslSetDrawBuffer(old);
}