当前位置: 首页>>代码示例>>C++>>正文


C++ LoadTexture函数代码示例

本文整理汇总了C++中LoadTexture函数的典型用法代码示例。如果您正苦于以下问题:C++ LoadTexture函数的具体用法?C++ LoadTexture怎么用?C++ LoadTexture使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了LoadTexture函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: m_pos

Renderer::Renderer()
	: m_pos(0),
	m_numParticles(0),
	m_pointSize(1.0f),
	m_particleRadius(0.125f * 0.5f),
	//m_program(0),
	m_vbo(0),
	m_colorVBO(0),
	mWindowW(1024),
	mWindowH(768),
	mFov(60.0f),
	m_downSample(1),
	m_imageTex(0),
	m_postprocessingTex(0),
	m_depthTex(0),
	m_imageFbo(0),
	m_postprocessingFbo(0)
	  //m_indexBuffer(0)
{
	txParticle = LoadTexture("data/water.bmp");
	m_displayTexProg = new GLSLProgram(passThruVS, texture2DPS);
	m_postprocessing = new GLSLProgram(passThruVS, postprocessingPS);
    _initGL();
}
开发者ID:Alan-ZhangDaixi,项目名称:fluid,代码行数:24,代码来源:render.cpp

示例2: LoadTexture

bool ParticleSystemClass::Initialize(ID3D11Device* device, WCHAR* textureFilename)
{
	bool result;

	result = LoadTexture(device, textureFilename); //load the texture that is used for the particles
	if(!result)
	{
		return false;
	}

	result = InitializeParticleSystem();
	if(!result)
	{
		return false;
	}

	result = InitializeBuffers(device);
	if(!result)
	{
		return false;
	}

	return true;
}
开发者ID:NukePie,项目名称:Engine,代码行数:24,代码来源:ParticleSystemClass.cpp

示例3: LoadModel

bool StaticMeshComponent::Initialise(ID3D11Device* device, char* modelFilename, WCHAR* textureFilename)
{
	bool result;
	
	result = LoadModel(modelFilename);
	if (!result)
	{
		return false;
	}

	result = InitialiseBuffers(device);
	if (!result)
	{
		return false;
	}

	result = LoadTexture(device, textureFilename);
	if (!result)
	{
		return false;
	}

	return true;
}
开发者ID:AkselS,项目名称:The-Lab,代码行数:24,代码来源:StaticMeshComponent.cpp

示例4: convertMesh

bool CWall::create(IDirect3DDevice9* pDevice,
	float iwidth,
	float iheight,
	float idepth,
	Type type){
	m_width = iwidth;
	m_depth = idepth;
	m_height = iheight;
	if (FAILED(D3DXCreateBox(pDevice, iwidth, iheight, idepth, &m_pMesh, 0))) return false;

	LPD3DXMESH newMesh = convertMesh(pDevice, m_pMesh);
	if (newMesh == nullptr){
		m_pMesh->Release();
		return false;
	}
	switch (type){
	case Plane:
		textureFile = PLANE_TEXTURE;
		effectFile = PLANE_EFFECT;
		break;
	case Edge:
		effectFile = EDGE_EFFECT;
		textureFile = EDGE_TEXTURE;
		break;
	}
	m_texture = LoadTexture(pDevice, textureFile);
	m_effect = LoadShader(pDevice, effectFile);


	if (m_texture == nullptr || m_effect == nullptr)
		return false;
	m_pMesh->Release();
	m_pMesh = newMesh;

	return true;
}
开发者ID:neropsys,项目名称:DX9_0_Billiard,代码行数:36,代码来源:CWall.cpp

示例5: GetTexture

////////////////////////////////////////
//		PUBLIC UTILITY FUNCTIONS
////////////////////////////////////////
unsigned int TextureManager::GetTexture(string fileName)
{
	Texture* texture = nullptr;
	map<string,Texture*>::iterator iter = m_textureMap.find(fileName);

	if(iter == m_textureMap.end())
	{
		if(LoadTexture(fileName))
		{
			texture = m_textureMap[fileName];
		}
		else
		{
			LOG("Couldn't load texture: " << fileName);
			texture = m_textureMap[TextureManager::DEFAULT_TEXTURE_FILENAME];
		}
	}
	else
	{
		texture = m_textureMap[fileName];
	}

	return reinterpret_cast<unsigned int>(texture);
}
开发者ID:CSPshala,项目名称:dangerzone,代码行数:27,代码来源:TextureManager.cpp

示例6: glGenTextures

// Create the plane, including its geometry, texture mapping, normal, and colour
void CCubemap::Create(string sPositiveX, string sNegativeX, string sPositiveY, string sNegativeY, string sPositiveZ, string sNegativeZ)
{
	int iWidth, iHeight;

	// Generate an OpenGL texture ID for this texture
	glGenTextures(1, &m_uiTexture);
	glBindTexture(GL_TEXTURE_CUBE_MAP, m_uiTexture);

	// Load the six sides
	BYTE *pbImagePosX, *pbImageNegX, *pbImagePosY, *pbImageNegY, *pbImagePosZ, *pbImageNegZ;

	LoadTexture(sPositiveX, &pbImagePosX, iWidth, iHeight);
	LoadTexture(sNegativeX, &pbImageNegX, iWidth, iHeight);
	LoadTexture(sPositiveY, &pbImagePosY, iWidth, iHeight);
	LoadTexture(sNegativeY, &pbImageNegY, iWidth, iHeight);
	LoadTexture(sPositiveZ, &pbImagePosZ, iWidth, iHeight);
	LoadTexture(sNegativeZ, &pbImageNegZ, iWidth, iHeight);

	glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, iWidth, iHeight, 0, GL_BGR, GL_UNSIGNED_BYTE, pbImagePosX);
	glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, iWidth, iHeight, 0, GL_BGR, GL_UNSIGNED_BYTE, pbImageNegX);
	glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, iWidth, iHeight, 0, GL_BGR, GL_UNSIGNED_BYTE, pbImagePosY);
	glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, iWidth, iHeight, 0, GL_BGR, GL_UNSIGNED_BYTE, pbImageNegY);
	glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, iWidth, iHeight, 0, GL_BGR, GL_UNSIGNED_BYTE, pbImagePosZ);
	glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, iWidth, iHeight, 0, GL_BGR, GL_UNSIGNED_BYTE, pbImageNegZ);

	delete[] pbImagePosX;
	delete[] pbImageNegX;
	delete[] pbImagePosY;
	delete[] pbImageNegY;
	delete[] pbImagePosZ;
	delete[] pbImageNegZ;

	glGenSamplers(1, &m_uiSampler);
	glSamplerParameteri(m_uiSampler, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glSamplerParameteri(m_uiSampler, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);

	glSamplerParameteri(m_uiSampler, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
	glSamplerParameteri(m_uiSampler, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
	glSamplerParameteri(m_uiSampler, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);

	glGenerateMipmap(GL_TEXTURE_CUBE_MAP);

}
开发者ID:addrum,项目名称:ComputerGraphicsLabs,代码行数:44,代码来源:Cubemap.cpp

示例7: SDL_Init

void ClassDemoApp::Setup() {
	SDL_Init(SDL_INIT_VIDEO);
	displayWindow = SDL_CreateWindow("SoundInvaders", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 360, SDL_WINDOW_OPENGL);
	SDL_GLContext context = SDL_GL_CreateContext(displayWindow);
	SDL_GL_MakeCurrent(displayWindow, context);
	Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 4096);

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

#ifdef _WINDOWS
	glewInit();
#endif
	done = false;

	program = new ShaderProgram(RESOURCE_FOLDER"vertex_textured.glsl", RESOURCE_FOLDER"fragment_textured.glsl");
//	program = new ShaderProgram(RESOURCE_FOLDER"vertex.glsl", RESOURCE_FOLDER"fragment.glsl");
	spritetexture = LoadTexture("p1_front.png");
	font = LoadTexture("Capword.png");
	hitSound = Mix_LoadWAV("Get_Rupee.wav");
	shootSound = Mix_LoadWAV("Trident.wav");
	death1Sound = Mix_LoadWAV("Boss_Hit.wav");
	death2Sound = Mix_LoadWAV("Boss_Death.wav");
	music = Mix_LoadMUS("Dark_World.ogg");

	projectionMatrix.setOrthoProjection(-3.55f, 3.55f, -2.0f, 2.0f, -1.0f, 1.0f);

	lives = 10;
	spaceship = new Spaceship(program, 0.21f, 0.21f, LoadTexture("Zelda.png"));
	invaders = new Invaders(program, 0.21f, 0.21f, LoadTexture("Links.png"), LoadTexture("Arrow.png"));
	tank = new Tank(program, 0.19f, 0.19f, LoadTexture("Ganon.png"), LoadTexture("Trident.png"));
	highscore = 0;
	state = STATE_MAIN_MENU;

	musicTicks = 16;
	Mix_PlayMusic(music, -1);
}
开发者ID:tastyegg,项目名称:CS3113_Student,代码行数:37,代码来源:ClassDemoApp.cpp

示例8: Setup

void Setup() {
	SDL_Init(SDL_INIT_VIDEO);
	displayWindow = SDL_CreateWindow("Rob Chiarelli's Pong V", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE);
	SDL_GLContext context = SDL_GL_CreateContext(displayWindow);
	SDL_GL_MakeCurrent(displayWindow, context);

	glViewport(0, 0, 800, 600);
	glMatrixMode(GL_PROJECTION);
	glOrtho(-1.33, 1.33, -1.0, 1.0, -1.0, 1.0);

	ball.textureID = LoadTexture("green_panel.png");
	paddle1.textureID = LoadTexture("green_panel.png");
	paddle2.textureID = LoadTexture("green_panel.png");
	top.textureID = LoadTexture("green_panel.png");
	bottom.textureID = LoadTexture("green_panel.png");
	space.textureID = LoadTexture("grey_button02.png");

	srand(time(NULL));

	ball.setSize(0.1, 0.1);
	ball.setPosition(0.0, 0.0, 0.0);
	ball.setMovement(2.0, rand() % 50 - 25);
	//The ball is set to move right at a random angle between 
	//-25 and 25 degrees for maximum playability

	paddle1.setSize(0.1, 0.5);
	paddle1.setPosition(-1.2, 0.0, 0.0);
	paddle1.setMovement(2.0, 0);

	paddle2.setSize(0.1, 0.5);
	paddle2.setPosition(1.2, 0.0, 0.0);
	paddle2.setMovement(2.0, 0);

	top.setSize(2.66, 0.1);
	top.setPosition(0.0, 1.0, 0.0);

	bottom.setSize(2.66, 0.1);
	bottom.setPosition(0.0, -1.0, 0.0);

	space.setSize(1.0, 0.3);
	space.setPosition(0.0, 0.8, 0.0);
}
开发者ID:robchiarelli,项目名称:CS3113,代码行数:42,代码来源:pong.cpp

示例9: InitGameplayScreen

// Gameplay Screen Initialization logic
void InitGameplayScreen(void)
{
    // TODO: Initialize GAMEPLAY screen variables here!
    framesCounter = 0;
    finishScreen = 0;
    
    // MAP LAODING
        // TODO: Read .bmp file propierly in order to get image width & height
    Color *mapPixels = malloc(GRID_WIDTH*GRID_HEIGHT * sizeof(Color));
    mapPixels = GetImageData(LoadImage("assets/gameplay_screen/maps/map.bmp"));
    
    maxTriangles = 0;
    maxPlatforms = 0;
    
    for (int i=0; i<GRID_WIDTH*GRID_HEIGHT; i++)
    {
        /*
        printf("r: %i\n", mapPixels[i].r);
        printf("g: %i\n", mapPixels[i].g);
        printf("b: %i\n\n", mapPixels[i].b);
        */
        if (mapPixels[i].r == 255 && mapPixels[i].g == 0 && mapPixels[i].b == 0) maxTriangles++;
        else if (mapPixels[i].r == 0 && mapPixels[i].g == 255 && mapPixels[i].b == 0) maxPlatforms++;
    }
    
    triangles = malloc(maxTriangles * sizeof(TriangleObject));
    platforms = malloc(maxPlatforms * sizeof(SquareObject));
    
    int trianglesCounter=0;
    int platformsCounter=0;
    
    
    for (int y=0; y<GRID_HEIGHT; y++)
    {
        for (int x=0; x<GRID_WIDTH; x++)
        {
            if (mapPixels[y*GRID_WIDTH+x].r == 255 && mapPixels[y*GRID_WIDTH+x].g == 0 && mapPixels[y*GRID_WIDTH+x].b == 0) 
            {
                InitializeTriangle(&triangles[trianglesCounter], (Vector2){x, y});
                trianglesCounter++;
            }
            else if (mapPixels[y*GRID_WIDTH+x].r == 0 && mapPixels[y*GRID_WIDTH+x].g == 255 && mapPixels[y*GRID_WIDTH+x].b == 0) 
            {
                InitializePlatform(&platforms[platformsCounter], (Vector2){x, y});
                platformsCounter++;
            }
        }
    }
    
    free(mapPixels);
    
    //DEBUGGING && TESTING variables
    pause = FALSE;
    srand(time(NULL)); 
    
    // Textures loading
    player.texture = LoadTexture("assets/gameplay_screen/cube_main.png");
    triangleTexture = LoadTexture("assets/gameplay_screen/triangle_main.png");
    platformTexture = LoadTexture("assets/gameplay_screen/platform_main.png");
    player.pEmitter.texture = LoadTexture("assets/gameplay_screen/particle_main.png");
    
    bg = LoadTexture("assets/gameplay_screen/bg_main.png");
    
    // Sound loading
    InitAudioDevice();
    PlayMusicStream("assets/gameplay_screen/music/Flash_Funk_MarshmelloRemix.ogg");
    PauseMusicStream();
    SetMusicVolume(0.5f);
    
    // Did player win?
    startGame = FALSE;
    
    /*
    player.texture = LoadTexture("assets/gameplay_screen/debug.png");
    triangleTexture = LoadTexture("assets/gameplay_screen/debug.png");
    platformTexture = LoadTexture("assets/gameplay_screen/debug.png");
    player.pEmitter.texture = LoadTexture("assets/gameplay_screen/particle_main.png");
    */
    
    // Camera initialization
    mainCamera = (Camera2D){Vector2Right(), (Vector2){6.5f, 6.5f}, Vector2Zero(), TRUE};
    
    // Gravity initialization
    gravity = (GravityForce){Vector2Up(), 1.5f};
    
    // Ground position and coordinate
    groundCoordinadeY = GetScreenHeight()/CELL_SIZE-1;
    groundPositionY = GetOnGridPosition((Vector2){0, groundCoordinadeY}).y;
    
    // Player initialization
    InitializePlayer(&player, (Vector2){4, groundCoordinadeY-1}, (Vector2){0, 15}, 0.35f*GAME_SPEED);
    
    /*
    // Triangles initialization
    InitializeTriangle(&triangles[0], (Vector2){40, groundCoordinadeY-1});
    InitializeTriangle(&triangles[1], (Vector2){50, groundCoordinadeY-1});
    InitializeTriangle(&triangles[2], (Vector2){85, groundCoordinadeY-1});
    
    // Platforms initialization
//.........这里部分代码省略.........
开发者ID:MarcMDE,项目名称:TapToJump,代码行数:101,代码来源:screen_gameplay.c

示例10: main

//----------------------------------------------------------------------------------
// Main entry point
//----------------------------------------------------------------------------------
int main(void) 
{
	// Initialization (Note windowTitle is unused on Android)
	//---------------------------------------------------------
    InitWindow(screenWidth, screenHeight, "KOALA SEASONS");

    // Load global data here (assets that must be available in all screens, i.e. fonts)
    font = LoadFont("resources/graphics/mainfont.png");

    atlas01 = LoadTexture("resources/graphics/atlas01.png");
    atlas02 = LoadTexture("resources/graphics/atlas02.png");
    
#if defined(PLATFORM_WEB) || defined(PLATFORM_RPI) || defined(PLATFORM_ANDROID)
    colorBlend = LoadShader("resources/shaders/glsl100/base.vs", "resources/shaders/glsl100/blend_color.fs");
#else
    colorBlend = LoadShader("resources/shaders/glsl330/base.vs", "resources/shaders/glsl330/blend_color.fs");
#endif

    InitAudioDevice();
    
    // Load sounds data
    fxJump = LoadSound("resources/audio/jump.ogg");
    fxDash = LoadSound("resources/audio/dash.ogg");
    fxEatLeaves = LoadSound("resources/audio/eat_leaves.ogg");
    fxHitResin = LoadSound("resources/audio/resin_hit.ogg");
    fxWind = LoadSound("resources/audio/wind_sound.ogg");
    fxDieSnake = LoadSound("resources/audio/snake_die.ogg");
    fxDieDingo = LoadSound("resources/audio/dingo_die.ogg");
    fxDieOwl = LoadSound("resources/audio/owl_die.ogg");
    
    
    music = LoadMusicStream("resources/audio/jngl.xm");
    PlayMusicStream(music);
    SetMusicVolume(music, 1.0f);

    // Define and init first screen
    // NOTE: currentScreen is defined in screens.h as a global variable
    currentScreen = TITLE;

    InitLogoScreen();
    //InitOptionsScreen();
    InitTitleScreen();
    InitGameplayScreen();
    InitEndingScreen();

#if defined(PLATFORM_WEB)
    emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
#else
    SetTargetFPS(60);   // Set our game to run at 60 frames-per-second
    //--------------------------------------------------------------------------------------
    
    // Main game loop
    while (!WindowShouldClose()) UpdateDrawFrame();
#endif

    // De-Initialization
    //--------------------------------------------------------------------------------------
    UnloadEndingScreen();
    UnloadTitleScreen();
    UnloadGameplayScreen();
    UnloadLogoScreen();
    
    UnloadTexture(atlas01);
    UnloadTexture(atlas02);
    UnloadFont(font);
    
    UnloadShader(colorBlend);   // Unload color overlay blending shader
    
    UnloadSound(fxJump);
    UnloadSound(fxDash);
    UnloadSound(fxEatLeaves);
    UnloadSound(fxHitResin);
    UnloadSound(fxWind);
    UnloadSound(fxDieSnake);
    UnloadSound(fxDieDingo);
    UnloadSound(fxDieOwl);
    
    UnloadMusicStream(music);
    
    CloseAudioDevice();         // Close audio device

    CloseWindow();              // Close window and OpenGL context
    //--------------------------------------------------------------------------------------

    return 0;
}
开发者ID:raysan5,项目名称:raylib,代码行数:89,代码来源:koala_seasons.c

示例11: InitLivingroomScreen

// Gameplay Screen Initialization logic
void InitLivingroomScreen(void)
{
    ResetPlayer();
    
    // Reset Screen variables
    monsterHover = false;
    monsterCheck = -1;
    msgState = 0;
    msgCounter = 0;
    lettersCounter = 0;
    for (int i = 0; i < 256; i++) msgBuffer[i] = '\0';
    
    framesCounter = 0;
    finishScreen = 0;
    
    background = LoadTexture("resources/textures/background_livingroom.png");
    
    // Initialize doors
    doorLeft.position = (Vector2) { -45, 140};
    doorLeft.facing = 0;
    doorLeft.locked = true;
    doorLeft.frameRec =(Rectangle) {((doors.width/3)*doorLeft.facing), doors.height/2, doors.width/3, doors.height/2};
    doorLeft.bound = (Rectangle) { doorLeft.position.x, doorLeft.position.y, doors.width/3, doors.height/2};
    doorLeft.selected = false;
    
    doorCenter.position = (Vector2) { 830, 108 };
    doorCenter.facing = 1;
    doorCenter.locked = true;
    doorCenter.frameRec =(Rectangle) {((doors.width/3)*doorCenter.facing), doors.height/2, doors.width/3, doors.height/2};
    doorCenter.bound = (Rectangle) { doorCenter.position.x, doorCenter.position.y, doors.width/3, doors.height/2};
    doorCenter.selected = false;

    // Monster init: lamp
    candle.position = (Vector2){ 154, 256 };
    candle.texture = LoadTexture("resources/textures/monster_candle.png");
    candle.currentFrame = 0;
    candle.framesCounter = 0;
    candle.numFrames = 4;
    candle.bounds = (Rectangle){ candle.position.x + 90, candle.position.y + 30, 185, 340 };
    candle.frameRec = (Rectangle) { 0, 0, candle.texture.width/candle.numFrames, candle.texture.height };
    candle.selected = false;
    candle.active = false;
    candle.spooky = false;
    
    // Monster init: arc
    picture.position = (Vector2){ 504, 164 };
    picture.texture = LoadTexture("resources/textures/monster_picture.png");
    picture.currentFrame = 0;
    picture.framesCounter = 0;
    picture.numFrames = 4;
    picture.bounds = (Rectangle){ picture.position.x + 44, picture.position.y, 174, 264 };
    picture.frameRec = (Rectangle) { 0, 0, picture.texture.width/picture.numFrames, picture.texture.height };
    picture.selected = false;
    picture.active = false;
    picture.spooky = true;
    
    // Monster init: phone
    phone.position = (Vector2){ 1054, 404 };
    phone.texture = LoadTexture("resources/textures/monster_phone.png");
    phone.currentFrame = 0;
    phone.framesCounter = 0;
    phone.numFrames = 4;
    phone.bounds = (Rectangle){ phone.position.x + 64, phone.position.y +120, 100, 160 };
    phone.frameRec = (Rectangle) { 0, 0, phone.texture.width/phone.numFrames, phone.texture.height };
    phone.selected = false;
    phone.active = false;
    phone.spooky = true;
}
开发者ID:AdanBB,项目名称:raylib,代码行数:69,代码来源:screen_livingroom.c

示例12: main

int main()
{    
    // Initialization
    //--------------------------------------------------------------------------------------
    int screenWidth = 800;
    int screenHeight = 450;

    InitWindow(screenWidth, screenHeight, "Floppy Bird");
    
    InitAudioDevice();      // Initialize audio device
    
    Sound coin = LoadSound("resources/coin.wav");
    Sound jump = LoadSound("resources/jump.wav");
    
    Texture2D background = LoadTexture("resources/background.png");
    Texture2D tubes = LoadTexture("resources/tubes.png");
    Texture2D floppy = LoadTexture("resources/floppy.png");
    
    Vector2 floppyPos = { 80, screenHeight/2 - floppy.height/2 };
    
    Vector2 tubesPos[MAX_TUBES];
    int tubesSpeedX = 2;
    
    for (int i = 0; i < MAX_TUBES; i++)
    {
        tubesPos[i].x = 400 + 280*i;
        tubesPos[i].y = -GetRandomValue(0, 120);
    }
    
    Rectangle tubesRecs[MAX_TUBES*2];
    bool tubesActive[MAX_TUBES];
    
    for (int i = 0; i < MAX_TUBES*2; i += 2)
    {
        tubesRecs[i].x = tubesPos[i/2].x;
        tubesRecs[i].y = tubesPos[i/2].y;
        tubesRecs[i].width = tubes.width;
        tubesRecs[i].height = 255;
        
        tubesRecs[i+1].x = tubesPos[i/2].x;
        tubesRecs[i+1].y = 600 + tubesPos[i/2].y - 255;
        tubesRecs[i+1].width = tubes.width;
        tubesRecs[i+1].height = 255;
        
        tubesActive[i/2] = true;
    }
 
    int backScroll = 0;
    
    int score = 0;
    int hiscore = 0;
    
    bool gameover = false;
    bool superfx = false;
    
    SetTargetFPS(60);
    //---------------------------------------------------------------------------------------
    
    // Main game loop
    while (!WindowShouldClose())    // Detect window close button or ESC key
    {
        // Update
        //----------------------------------------------------------------------------------
        backScroll--;
        
        if (backScroll <= -800) backScroll = 0; 
        
        for (int i = 0; i < MAX_TUBES; i++) tubesPos[i].x -= tubesSpeedX;
        
        for (int i = 0; i < MAX_TUBES*2; i += 2)
        {
            tubesRecs[i].x = tubesPos[i/2].x;
            tubesRecs[i+1].x = tubesPos[i/2].x;
        }

        if (IsKeyDown(KEY_SPACE) && !gameover) floppyPos.y -= 3;
        else floppyPos.y += 1;
        
        if (IsKeyPressed(KEY_SPACE) && !gameover) PlaySound(jump);
        
        // Check Collisions
        for (int i = 0; i < MAX_TUBES*2; i++)
        {
            if (CheckCollisionCircleRec((Vector2){ floppyPos.x + floppy.width/2, floppyPos.y + floppy.height/2 }, floppy.width/2, tubesRecs[i])) 
            {
                gameover = true;
            }
            else if ((tubesPos[i/2].x < floppyPos.x) && tubesActive[i/2] && !gameover)
            {
                score += 100;
                tubesActive[i/2] = false;
                PlaySound(coin);
                
                superfx = true;
                
                if (score > hiscore) hiscore = score;
            }
        }
        
        if (gameover && IsKeyPressed(KEY_ENTER))
//.........这里部分代码省略.........
开发者ID:MarcMDE,项目名称:raylib,代码行数:101,代码来源:floppy.c

示例13: textures

void CBspMapResourceProvider::LoadTextures(const CBspFile& bspFile, CPakFile& pakFile)
{
	const Bsp::TextureArray& textures(bspFile.GetTextures());
	m_materials.resize(textures.size());
	for(uint32 i = 0; i < textures.size(); i++)
	{
		const Bsp::TEXTURE& texture(textures[i]);

		auto resultMaterial = BspMapMaterialPtr(new CBspMapMaterial());
		m_materials[i] = resultMaterial;

		ShaderMap::const_iterator shaderIterator = m_shaders.find(texture.name);
		if(shaderIterator == m_shaders.end())
		{
			//Create a basic material with this texture
			std::string fullName;
			if(!pakFile.TryCompleteFileName(texture.name, fullName))
			{
				continue;
			}

			LoadTexture(fullName.c_str(), pakFile);

			{
				auto pass = BspMapPassPtr(new CBspMapPass());
				pass->SetTexture(GetTexture(fullName.c_str()));
				pass->SetTextureSource(CBspMapPass::TEXTURE_SOURCE_DIFFUSE);
				pass->SetBlendingFunction(Palleon::TEXTURE_COMBINE_MODULATE);
				resultMaterial->AddPass(pass);
			}

			{
				auto pass = BspMapPassPtr(new CBspMapPass());
				pass->SetTextureSource(CBspMapPass::TEXTURE_SOURCE_LIGHTMAP);
				pass->SetBlendingFunction(Palleon::TEXTURE_COMBINE_MODULATE);
				resultMaterial->AddPass(pass);
			}
		}
		else
		{
			const QUAKE_SHADER& shader = shaderIterator->second;

			resultMaterial->SetIsSky(shader.isSky);

			for(QuakeShaderPassArray::const_iterator passIterator(shader.passes.begin());
				passIterator != shader.passes.end(); passIterator++)
			{
				const QUAKE_SHADER_PASS& passData(*passIterator);
				if(passData.mapName.length() < 4) continue;

				auto pass = BspMapPassPtr(new CBspMapPass());

				{
					Palleon::TEXTURE_COMBINE_MODE blendingFunction = Palleon::TEXTURE_COMBINE_MODULATE;
					switch(passData.blendFunc)
					{
					case QUAKE_SHADER_BLEND_BLEND:
						blendingFunction = Palleon::TEXTURE_COMBINE_LERP;
						break;
					case QUAKE_SHADER_BLEND_ADD:
						blendingFunction = Palleon::TEXTURE_COMBINE_ADD;
						break;
					case QUAKE_SHADER_BLEND_FILTER:
						blendingFunction = Palleon::TEXTURE_COMBINE_MODULATE;
						break;
					}
					pass->SetBlendingFunction(blendingFunction);
				}

				if(passData.mapName == "$lightmap")
				{
					pass->SetTextureSource(CBspMapPass::TEXTURE_SOURCE_LIGHTMAP);
				}
				else
				{
					std::string fileName(passData.mapName.begin(), passData.mapName.begin() + passData.mapName.length() - 4);
					
					std::string fullName;
					if(!pakFile.TryCompleteFileName(fileName.c_str(), fullName))
					{
						continue;
					}

					LoadTexture(fullName.c_str(), pakFile);
					pass->SetTexture(GetTexture(fullName.c_str()));
					pass->SetTextureSource(CBspMapPass::TEXTURE_SOURCE_DIFFUSE);
				}

				for(unsigned int i = 0; i < passData.tcMods.size(); i++)
				{
					const QUAKE_SHADER_TCMOD& tcMod(passData.tcMods[i]);
					BspMapTcModPtr result;
					switch(tcMod.type)
					{
					case QUAKE_SHADER_TCMOD_SCROLL:
						result = BspMapTcModPtr(new CBspMapTcMod_Scroll(
									tcMod.params[0],
									tcMod.params[1]));
						break;
					case QUAKE_SHADER_TCMOD_SCALE:
//.........这里部分代码省略.........
开发者ID:jpd002,项目名称:Palleon,代码行数:101,代码来源:BspMapResourceProvider.cpp

示例14: main

int main(int argc, char *argv[])
{
	SDL_Init(SDL_INIT_VIDEO);
	displayWindow = SDL_CreateWindow("My Game", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 360, SDL_WINDOW_OPENGL);
	SDL_GLContext context = SDL_GL_CreateContext(displayWindow);
	SDL_GL_MakeCurrent(displayWindow, context);
	

	SDL_Event event;
	bool done = false;
#ifdef _WINDOWS
	glewInit();
#endif

	Matrix projectionMatrix;
	Matrix modelMatrix;
	Matrix viewMatrix;

	ShaderProgram program(RESOURCE_FOLDER"vertex_textured.glsl", RESOURCE_FOLDER"fragment_textured.glsl");



	GLuint dogTexture = LoadTexture("dog.png");
	GLuint ballTexture = LoadTexture("ball.png");
	GLuint boneTexture = LoadTexture("bone.png");

	projectionMatrix.setOrthoProjection(-3.55, 3.55, -2.0f, 2.0f, -1.0f, 1.0f);
	glUseProgram(program.programID);

	float lastFrameTicks = 0.0f;

	double movement = 0.0;

	double ballBounce = 0.0;

	bool bounceHigh = false;

	bool firstHit = false;

	const Uint8 *keys = SDL_GetKeyboardState(NULL);

	while (!done) {
		while (SDL_PollEvent(&event)) {
			if (event.type == SDL_QUIT || event.type == SDL_WINDOWEVENT_CLOSE) {
				done = true;
			}
		}
		

		glClear(GL_COLOR_BUFFER_BIT);
		program.setModelMatrix(modelMatrix);
		program.setProjectionMatrix(projectionMatrix);
		program.setViewMatrix(viewMatrix);
		glBindTexture(GL_TEXTURE_2D, ballTexture);

		float ticks = (float)SDL_GetTicks() / 1000.0f;

		float elapsed = ticks - lastFrameTicks;
			
		lastFrameTicks = ticks;

		if (firstHit == false){
			movement = movement + elapsed;
		}

		//makes the ball bounce
		if ((ballBounce * 0.75) >= 1){
			bounceHigh = true;
		}

		if ((ballBounce * 0.75) <= -1){
			bounceHigh = false;
		}
		
		if (bounceHigh == false){
			ballBounce = ballBounce + elapsed;
		}
		else if (bounceHigh == true){
			ballBounce = ballBounce - elapsed;
		}

		
		float vertices[] = { -1.4 + (movement * 0.25), -0.4 + (ballBounce * 0.25), -0.4 + (movement * 0.25), -0.4 + (ballBounce * 0.25),
			-0.4 + (movement * 0.25), 0.4 + (ballBounce * 0.25), -1.4 + (movement * 0.25), -0.4 + (ballBounce * 0.25),
			-0.4 + (movement * 0.25), 0.4 + (ballBounce * 0.25), -1.4 + (movement * 0.25), 0.4 + (ballBounce * 0.25) };
		
		glVertexAttribPointer(program.positionAttribute, 2, GL_FLOAT, false, 0, vertices);
		glEnableVertexAttribArray(program.positionAttribute);
		float texCoords[] = { 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0 };
		glVertexAttribPointer(program.texCoordAttribute, 2, GL_FLOAT, false, 0, texCoords);
		glEnableVertexAttribArray(program.texCoordAttribute);
		glDrawArrays(GL_TRIANGLES, 0, 6);
		glDisableVertexAttribArray(program.positionAttribute);
		glDisableVertexAttribArray(program.texCoordAttribute);


		if (keys[SDL_SCANCODE_A]) {
			--p1X;
		}
		else if (keys[SDL_SCANCODE_D]) {
//.........这里部分代码省略.........
开发者ID:ts2562,项目名称:NYUCodebase-HW-1,代码行数:101,代码来源:main.cpp

示例15: WatchJoystick

static SDL_bool
WatchJoystick(SDL_Joystick * joystick)
{
    SDL_Window *window = NULL;
    SDL_Renderer *screen = NULL;
    SDL_Texture *background, *button, *axis, *marker;
    const char *name = NULL;
    SDL_bool retval = SDL_FALSE;
    SDL_bool done = SDL_FALSE, next=SDL_FALSE;
    SDL_Event event;
    SDL_Rect dst;
    int s, _s;
    Uint8 alpha=200, alpha_step = -1;
    Uint32 alpha_ticks;
    char mapping[4096], temp[4096];
    MappingStep *step;
    MappingStep steps[] = {
        {342, 132,  0.0,  MARKER_BUTTON, "x", -1, -1, -1, -1, ""},
        {387, 167,  0.0,  MARKER_BUTTON, "a", -1, -1, -1, -1, ""},
        {431, 132,  0.0,  MARKER_BUTTON, "b", -1, -1, -1, -1, ""},
        {389, 101,  0.0,  MARKER_BUTTON, "y", -1, -1, -1, -1, ""},
        {174, 132,  0.0,  MARKER_BUTTON, "back", -1, -1, -1, -1, ""},
        {233, 132,  0.0,  MARKER_BUTTON, "guide", -1, -1, -1, -1, ""},
        {289, 132,  0.0,  MARKER_BUTTON, "start", -1, -1, -1, -1, ""},        
        {116, 217,  0.0,  MARKER_BUTTON, "dpleft", -1, -1, -1, -1, ""},
        {154, 249,  0.0,  MARKER_BUTTON, "dpdown", -1, -1, -1, -1, ""},
        {186, 217,  0.0,  MARKER_BUTTON, "dpright", -1, -1, -1, -1, ""},
        {154, 188,  0.0,  MARKER_BUTTON, "dpup", -1, -1, -1, -1, ""},
        {77,  40,   0.0,  MARKER_BUTTON, "leftshoulder", -1, -1, -1, -1, ""},
        {91, 0,    0.0,  MARKER_BUTTON, "lefttrigger", -1, -1, -1, -1, ""},
        {396, 36,   0.0,  MARKER_BUTTON, "rightshoulder", -1, -1, -1, -1, ""},
        {375, 0,    0.0,  MARKER_BUTTON, "righttrigger", -1, -1, -1, -1, ""},
        {75,  154,  0.0,  MARKER_BUTTON, "leftstick", -1, -1, -1, -1, ""},
        {305, 230,  0.0,  MARKER_BUTTON, "rightstick", -1, -1, -1, -1, ""},
        {75,  154,  0.0,  MARKER_AXIS,   "leftx", -1, -1, -1, -1, ""},
        {75,  154,  90.0, MARKER_AXIS,   "lefty", -1, -1, -1, -1, ""},        
        {305, 230,  0.0,  MARKER_AXIS,   "rightx", -1, -1, -1, -1, ""},
        {305, 230,  90.0, MARKER_AXIS,   "righty", -1, -1, -1, -1, ""},
    };

    /* Create a window to display joystick axis position */
    window = SDL_CreateWindow("Game Controller Map", SDL_WINDOWPOS_CENTERED,
                              SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH,
                              SCREEN_HEIGHT, 0);
    if (window == NULL) {
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError());
        return SDL_FALSE;
    }

    screen = SDL_CreateRenderer(window, -1, 0);
    if (screen == NULL) {
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError());
        SDL_DestroyWindow(window);
        return SDL_FALSE;
    }
    
    background = LoadTexture(screen, "controllermap.bmp", SDL_FALSE);
    button = LoadTexture(screen, "button.bmp", SDL_TRUE);
    axis = LoadTexture(screen, "axis.bmp", SDL_TRUE);
    SDL_RaiseWindow(window);

    /* scale for platforms that don't give you the window size you asked for. */
    SDL_RenderSetLogicalSize(screen, SCREEN_WIDTH, SCREEN_HEIGHT);

    /* Print info about the joystick we are watching */
    name = SDL_JoystickName(joystick);
    SDL_Log("Watching joystick %d: (%s)\n", SDL_JoystickInstanceID(joystick),
           name ? name : "Unknown Joystick");
    SDL_Log("Joystick has %d axes, %d hats, %d balls, and %d buttons\n",
           SDL_JoystickNumAxes(joystick), SDL_JoystickNumHats(joystick),
           SDL_JoystickNumBalls(joystick), SDL_JoystickNumButtons(joystick));
    
    SDL_Log("\n\n\
    ====================================================================================\n\
    Press the buttons on your controller when indicated\n\
    (Your controller may look different than the picture)\n\
    If you want to correct a mistake, press backspace or the back button on your device\n\
    To skip a button, press SPACE or click/touch the screen\n\
    To exit, press ESC\n\
    ====================================================================================\n");
    
    /* Initialize mapping with GUID and name */
    SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(joystick), temp, SDL_arraysize(temp));
    SDL_snprintf(mapping, SDL_arraysize(mapping), "%s,%s,platform:%s,",
        temp, name ? name : "Unknown Joystick", SDL_GetPlatform());

    /* Loop, getting joystick events! */
    for(s=0; s<SDL_arraysize(steps) && !done;) {
        /* blank screen, set up for drawing this frame. */
        step = &steps[s];
        SDL_strlcpy(step->mapping, mapping, SDL_arraysize(step->mapping));
        step->axis = -1;
        step->button = -1;
        step->hat = -1;
        step->hat_value = -1;
        SDL_SetClipboardText("TESTING TESTING 123");
        
        switch(step->marker) {
            case MARKER_AXIS:
                marker = axis;
//.........这里部分代码省略.........
开发者ID:nlguillemot,项目名称:LD48-Beneath-The-Surface,代码行数:101,代码来源:controllermap.c


注:本文中的LoadTexture函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。