Ejemplo n.º 1
0
Sint32 menuHighScoreMain(void *pArgs) {
	menu_t *this = pArgs;
	char s[64] = "";
	Sint32 i;

	(void)this;

	blitTexture(gVars.pBackground, 0, 0, NULL);

	for (i = 0; i < NB_SCORE; i++) {
		if (gVars.sScore.pPlayer[i].nScore == 0)
			break;

		sprintf(s, "%-6.6s %u",
				gVars.sScore.pPlayer[i].pName, gVars.sScore.pPlayer[i].nScore);

		strncpy(s, gVars.sScore.pPlayer[i].pName, NAME_LEN);
		s[NAME_LEN] = '\0';
		printText(s, MENU_FONT_SIZE, FONT_COL_BLUE_BLUE, MENU_OFFX + 10, MENU_OFFY + 30 * i);

		sprintf(s, "%.6u", gVars.sScore.pPlayer[i].nScore);
		printText(s, MENU_FONT_SIZE, FONT_COL_CYAN_BLUE, MENU_OFFX + 160, MENU_OFFY + 30 * i);
	}
	if (i == 0)
		printText("no high score", MENU_FONT_SIZE, FONT_COL_CYAN_BLUE, MENU_OFFX + 10, MENU_OFFY);

	if (menuHighScoreEvents(pArgs) >= 0)
		return MENU_MAIN;

	return MENU_NULL;
}
Ejemplo n.º 2
0
    /* Always get the actual pointers, because they may change. That is the reason why the datablock pointer cannot be cached.
     * The same seems to apply to the texture pointer.
     */
    Ogre::HlmsDatablock* datablock;
    Ogre::HlmsPbsDatablock* datablockPbs;
    Ogre::TexturePtr texture;
    Ogre::HlmsManager* hlmsManager = Ogre::Root::getSingletonPtr()->getHlmsManager();
    Ogre::HlmsPbs* hlmsPbs = static_cast<Ogre::HlmsPbs*>(hlmsManager->getHlms(Ogre::HLMS_PBS));
    datablock = hlmsPbs->getDatablock(mDatablockId);
    if (!datablock)
        return;

    datablockPbs = static_cast<Ogre::HlmsPbsDatablock*>(datablock);
    try
    {
        // Get texture on GPU
        if (!datablockPbs->getTexture(mTextureType).isNull())
        {
            texture = datablockPbs->getTexture(mTextureType); // TextureType MUST exist, otherwise the application crashes
            mNumMipMaps = texture->getNumMipmaps();
        }
    }
    catch (Ogre::Exception e){}

    if (texture.isNull())
        return;

    Ogre::uint8 maxMipMaps = mNumMipMaps + 1; // Increase with one, because there is always one image to blit
    maxMipMaps = maxMipMaps > PAINT_MAX_MIP_MAPS ? PAINT_MAX_MIP_MAPS : maxMipMaps; // Just paint a few mipmaps (not all)
    Ogre::Image textureOnWhichIsPaintedScaled = mTextureOnWhichIsPainted; // Temporary image must be used, otherwise painting doesn't work
    size_t w = mTextureOnWhichIsPaintedWidth;
    size_t h = mTextureOnWhichIsPaintedHeight;
    Ogre::v1::HardwarePixelBuffer* buffer;
    for (Ogre::uint8 i = 0; i < maxMipMaps; ++i)
    {
        buffer = texture->getBuffer(0, i).getPointer();
        buffer->blitFromMemory(textureOnWhichIsPaintedScaled.getPixelBox(0, 0), Ogre::Box(0, 0, 0, w, h, 1));
        w*=0.5f; // Mipmaps always are half of the previous one
        h*=0.5f;
        if (w < 1.0f || h < 1.0f)
            break; // Stop when the mipmaps are too small

        textureOnWhichIsPaintedScaled.resize(w, h);

    }
    textureOnWhichIsPaintedScaled.freeMemory();
}

//****************************************************************************/
void TextureLayer::setFirstTextureGeneration (void)
{
    // Don't check on existence mTextureFileName, because it does exist
    loadTextureGeneration(mTextureFileName);
}

//****************************************************************************/
void TextureLayer::setLastTextureGeneration (void)
{
    Ogre::String textureFileNameGeneration = getTextureFileNameGeneration (mMaxSequence); // returns full qualified filename
    if (textureFileExists(textureFileNameGeneration))
        loadTextureGeneration(textureFileNameGeneration);
}

//****************************************************************************/
void TextureLayer::loadTextureGeneration (Ogre::ushort sequence)
{
    Ogre::String textureFileNameGeneration = getTextureFileNameGeneration (sequence); // returns full qualified filename
    if (sequence == 0)
        loadTextureGeneration(textureFileNameGeneration); // Don't check the filename if sequence is 0, because it is without path
    else if (textureFileExists(textureFileNameGeneration))
        loadTextureGeneration(textureFileNameGeneration);
}

//****************************************************************************/
void TextureLayer::loadTextureGeneration (const Ogre::String& filename)
{
    // Assume the filename exists
    mTextureOnWhichIsPainted.load(filename, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
    mPixelboxTextureOnWhichIsPainted = mTextureOnWhichIsPainted.getPixelBox(0, 0);
    mTextureOnWhichIsPaintedHasAlpha = mTextureOnWhichIsPainted.getHasAlpha();
    mTextureOnWhichIsPaintedWidth = mPixelboxTextureOnWhichIsPainted.getWidth();
    mTextureOnWhichIsPaintedHeight = mPixelboxTextureOnWhichIsPainted.getHeight();
    // In theory, createCarbonCopyTexture() of all related paintlayers should be called,
    // but the texture size doesn't change in practice.

    blitTexture();
}
Ejemplo n.º 3
0
void QWaylandGLWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
{
    Q_UNUSED(offset);
    Q_UNUSED(region);
    QWaylandWindow *ww = (QWaylandWindow *) widget->platformWindow();

    if (mPaintDevice->isBound())
        mPaintDevice->release();

    QRect rect(0,0,size().width(),size().height());
    QGLContext *ctx = QGLContext::fromPlatformGLContext(ww->glContext());
    blitTexture(ctx,mPaintDevice->texture(),size(),mPaintDevice->size(),rect,rect);
    ww->glContext()->swapBuffers();
}
Ejemplo n.º 4
0
void Sprite::draw() {
	SDL_Rect dest;
	dest.x = x;
	dest.y = y;
	dest.w = w;
	dest.h = h;

	Log::i("sprite blit surface: from (%d, %d, %d, %d) to (%f, %f, %d, %d)", texture->rect.x, texture->rect.y,
			texture->rect.w, texture->rect.h, x, y, w, h);

	blitTexture(texture, &dest);

	/*
	 //glBindTexture(GL_TEXTURE_2D, texture->getId());
	 float vertices[] = { rect.x, rect.y, rect.x, rect.y + rect.h, rect.x
	 + rect.w, rect.y + rect.h, rect.x + rect.w, rect.y };

	 // texture cood
	 float fac_x = (float) texture->getSliceWidth() / texture->getWidth();
	 float fac_y = (float) texture->getSliceHeight() / texture->getHeight();
	 float off_x = (float) texture->getX() / texture->getWidth();
	 float off_y = (float) texture->getY() / texture->getHeight();

	 float textureCoords[] = { off_x, off_y, off_x, fac_y + off_y, fac_x + off_x,
	 fac_y + off_y, fac_x + off_x, off_y };

	 SDL_Rect dest;
	 dest.x = rect.x;
	 dest.y = rect.y;
	 dest.w = rect.w; //texture->getSliceWidth();
	 dest.h = rect.h; //texture->getSliceHeight();

	 // 获取game surface
	 SDL_BlitSurface(texture->getSurface(), &rect, screen, &dest);

	 // 使用sdl显示图片
	 //SDL_blit();
	 //glVertexPointer(2, GL_FLOAT, 0, vertices);
	 //glTexCoordPointer(2, GL_FLOAT, 0, texturecoords);
	 //glDrawArrays(GL_QUADS, 0, 4);
	 */
}
Ejemplo n.º 5
0
Sint32 menuCreditsMain(void *pArgs) {
	menu_t *this = pArgs;
	Uint32 i;
	struct {
		char *s;
		Uint32 nCol;
	} pTab[] = {
		{ "programer", FONT_COL_WHITE_RED },
		{ "pouet", FONT_COL_BLUE_BLUE },
		{ "", FONT_COL_WHITE_RED },
		{ "", FONT_COL_WHITE_RED },
		{ "sprites", FONT_COL_WHITE_RED },
		{ "pouet", FONT_COL_BLUE_BLUE },
		{ "jdaster64", FONT_COL_BLUE_BLUE },
		{ "viiper", FONT_COL_BLUE_BLUE },
		{ "beam luinsir", FONT_COL_BLUE_BLUE },
		{ "and other...", FONT_COL_BLUE_BLUE },
		{ "", FONT_COL_WHITE_RED },
		{ "", FONT_COL_WHITE_RED },
		{ "", FONT_COL_WHITE_RED },
		{ "thanks to", FONT_COL_WHITE_RED },
		{ "joe78", FONT_COL_BLUE_BLUE },
		{ "GurneyH", FONT_COL_BLUE_BLUE },
	};

	(void)this;

	blitTexture(gVars.pBackground, 0, 0, NULL);

	for (i = 0; i < sizeof pTab / sizeof pTab[0]; i++) {
		printText(pTab[i].s, MENU_FONT_SIZE,
				pTab[i].nCol, MENU_OFFX + 10, MENU_OFFY + 30 * i);
	}

	if (menuCreditsEvents(pArgs) >= 0)
		return MENU_MAIN;

	return MENU_NULL;
}
Ejemplo n.º 6
0
	void Canvas::blitTexture(const TexturePtr& tex, float rotation, int x, int y, const Color& color) const
	{
		blitTexture(tex, rect(0,0,0,0), rotation, rect(x,y), color);
	}
Ejemplo n.º 7
0
	void Canvas::blitTexture(const TexturePtr& tex, float rotation, const rect& dst, const Color& color) const
	{
		blitTexture(tex, rect(0,0,0,0), rotation, dst, color);
	}