Beispiel #1
0
void CPSampleManager::copy_to(CPSample_ID p_from,CPSample_ID &p_to) {
	
	ERR_FAIL_COND(!check( p_from ));

	
	if (p_to.is_null()) {
		
		p_to=create( is_16bits( p_from), is_stereo( p_from), get_size(p_from));
	} else {
		
		recreate( p_to, is_16bits( p_from), is_stereo( p_from), get_size(p_from));
		
	}
	
	int len=get_size( p_from );
	int ch=is_stereo( p_from ) ? 2 : 1;
	
	for (int c=0;c<ch;c++) {
		
		for (int i=0;i<len;i++) {
			
			int16_t s=get_data( p_from, i, c );
			set_data( p_to, i, s, c );
		}
	}
	
	set_loop_type( p_to, get_loop_type( p_from ) );
	set_loop_begin( p_to, get_loop_begin( p_from ) );
	set_loop_end( p_to, get_loop_end( p_from ) );
	set_c5_freq( p_to, get_c5_freq( p_from ) );
	
		
	
}
Beispiel #2
0
void	select_level(void)
{
    t_uint	i;
    t_lmap	*map;
    int		x;

    x = 0;
    i = 0;
    if (g_arka.map_count == 0)
        return ;
    map = g_arka.map_list;
    while (i != g_arka.menu.selection)
    {
        i++;
        map = map->next;
    }
    g_arka.current_map = map;
    if (g_arka.map)
        x = 1;
    free_map(g_arka.map);
    g_arka.map = parse_map(map->path);
    recreate();
    g_arka.players[0]->life = 3;
    g_arka.players[0]->score = 0;
    resume_game();
}
/*---------------------------------------------------------------------*//**
	スロットを作成 ⇒ js_AllocSlot
**//*---------------------------------------------------------------------*/
bool EsObjectSlots::create()
{
	EsScope* scope = _objParentRef->getScope();
	const EsClass* cls = _objParentRef->getClass();

	u16 numReservedSlot;
	if(cls->getAdditionalReservedSlotNum(&numReservedSlot, _objParentRef))
	{
		if(scope->getFreeSlotIndex() == cls->getFreeSlotIndex())
		{
			scope->setFreeSlotIndex(scope->getFreeSlotIndex() + numReservedSlot);
		}
	}

	if(scope->getFreeSlotIndex() >= getNum())
	{
		if(!recreate(scope->getFreeSlotIndex() + 1))
		{
			return false;
		}
	}

	ASSERT(getValue(scope->getFreeSlotIndex())->isVoid());
	scope->setFreeSlotIndex(scope->getFreeSlotIndex() + 1);
	return true;
}
Beispiel #4
0
static void	lost(t_ball *ball)
{
	t_ball	*tmp;

	if (g_arka.balls == ball)
		g_arka.balls = ball->next;
	else if (g_arka.balls)
	{
		tmp = g_arka.balls;
		while (tmp && tmp->next != ball)
			tmp = tmp->next;
		tmp->next = ball->next;
	}
	free(ball);
	if (g_arka.balls)
		return ;
	g_arka.players[0]->life -= 1;
	if (g_arka.players[0]->life < 0)
	{
		g_arka.players[0]->life = 3;
		g_arka.players[0]->score = 0;
		action_escape();
	}
	recreate();
}
Beispiel #5
0
void DynamicBufferTexture::update(texture::Format format, core::Bytes data){
	auto renderer = services::rendering();
	if(buffer.isNull()){
		buffer = renderer->create(Buffer::Vertex,true,data.length(),data.begin);
		textureView = renderer->create(uint32(format),buffer);
	} else
		renderer->recreate(Buffer::Vertex,buffer,true,data.length(),data.begin);
}
Beispiel #6
0
void DynamicConstantBuffer::update(core::Bytes data){
	auto renderer = services::rendering();
	if(buffer.isNull()){
		buffer = renderer->create(Buffer::Constant,true,data.length(),data.begin);
	} else {
		renderer->recreate(Buffer::Constant,buffer,true,data.length(),data.begin);
	}
}
Beispiel #7
0
Texture2& Texture2::create(GLsizei width, GLsizei height, GLvoid * pixs){
	if(!id() || w!=width || h!=height || pixs != mPixels){
		w = width;
		h = height;
		mPixels = pixs;
		recreate();
	}
	return *this;
}
Beispiel #8
0
GfxTerrain::GfxTerrain(float chunkSize_,
                       size_t sizeInChunks_,
                       GfxTexture *heightmap_) : chunkSize(chunkSize_),
                                                 sizeInChunks(sizeInChunks_),
                                                 heightmap(heightmap_),
                                                 scale(1.0f)
{
    mesh = NEW(GfxMesh);

    recreate();
}
Beispiel #9
0
bool OpenGLProgram::bind () {

    if (gTextureContextVersion != mContextVersion)
        recreate ();

    if (mProgramId == 0)
        return false;

    glUseProgram (mProgramId);
    return true;

}
Beispiel #10
0
void GWater::onPropertyChangeEnd ( void* cur )
{
	__super::onPropertyChangeEnd ( cur );

	if (
		cur == &mCellCount
		|| cur == &mCellWidth
		|| cur == &mQuakeCount
		|| cur == &mQuakeAngleVelocity
		)
	{
		recreate();
	}
}
Beispiel #11
0
    void
    resize(int w, int h) {
        if (w == width && h == height) {
            return;
        }

        eglWaitClient();

        // We need to ensure that pending events are processed here, and XSync
        // with discard = True guarantees that, but it appears the limited
        // event processing we do so far is sufficient
        //XSync(display, True);

        Drawable::resize(w, h);

        XResizeWindow(display, window, w, h);

        // Tell the window manager to respect the requested size
        XSizeHints size_hints;
        size_hints.max_width  = size_hints.min_width  = w;
        size_hints.max_height = size_hints.min_height = h;
        size_hints.flags = PMinSize | PMaxSize;
        XSetWMNormalHints(display, window, &size_hints);

        waitForEvent(ConfigureNotify);

        eglWaitNative(EGL_CORE_NATIVE_ENGINE);

        /*
         * Some implementations won't update the backbuffer unless we recreate
         * the EGL surface.
         */

        int eglWidth;
        int eglHeight;

        eglQuerySurface(eglDisplay, surface, EGL_WIDTH, &eglWidth);
        eglQuerySurface(eglDisplay, surface, EGL_HEIGHT, &eglHeight);

        if (eglWidth != width || eglHeight != height) {
            recreate();

            eglQuerySurface(eglDisplay, surface, EGL_WIDTH, &eglWidth);
            eglQuerySurface(eglDisplay, surface, EGL_HEIGHT, &eglHeight);
        }

        assert(eglWidth == width);
        assert(eglHeight == height);
    }
Beispiel #12
0
void service::install()
{
   logmsg(kLDEBUG, "Installing " + getName() + " at " + getPath() + ", using image " + getImageName());
	if (utils::fileexists(getPath()))
		logmsg(kLERROR, "Service already exists. Try:   drunner update " + getName());

	// make sure we have the latest version of the service.
   utils_docker::pullImage(mParams, mSettings, getImageName());

	logmsg(kLDEBUG, "Attempting to validate " + getImageName());
   validateImage(mParams,mSettings,getImageName());

   recreate(false);

   servicehook hook(this, "install", mParams);
   hook.endhook();

   logmsg(kLINFO, "Installation complete - try running " + getName()+ " now!");
}
Beispiel #13
0
qMirrorModel::qMirrorModel(const QAbstractItemModel *src_mdl, QObject *parent):
  srcModel(src_mdl),
  QStandardItemModel(parent)
{
  recreate();

  if(src_mdl)
  {
    connect(src_mdl, SIGNAL(columnsInserted(QModelIndex,int,int)), this, SLOT(on_columnsInserted(QModelIndex,int,int)));
    connect(src_mdl, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)), this, SLOT(on_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
    connect(src_mdl, SIGNAL(columnsRemoved(QModelIndex,int,int)), this, SLOT(on_columnsRemoved(QModelIndex,int,int)));
    connect(src_mdl, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_dataChanged(QModelIndex,QModelIndex)));
    connect(src_mdl, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)), this, SLOT(on_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
    connect(src_mdl, SIGNAL(headerDataChanged(Qt::Orientation,int,int)), this, SLOT(on_headerDataChanged(Qt::Orientation,int,int)));
    connect(src_mdl, SIGNAL(modelReset()), this, SLOT(on_modelReset()));
    connect(src_mdl, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(on_rowsInserted(QModelIndex,int,int)));
    connect(src_mdl, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)), this, SLOT(on_rowsMoved(QModelIndex,int,int,QModelIndex,int)));
    connect(src_mdl, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(on_rowsRemoved(QModelIndex,int,int)));
  }
}
Beispiel #14
0
    void
    resize(int w, int h) {
        if (w == width && h == height) {
            return;
        }

        eglWaitClient();

        // We need to ensure that pending events are processed here, and XSync
        // with discard = True guarantees that, but it appears the limited
        // event processing we do so far is sufficient
        //XSync(display, True);

        Drawable::resize(w, h);

        resizeWindow(window, w, h);

        eglWaitNative(EGL_CORE_NATIVE_ENGINE);

        /*
         * Some implementations won't update the backbuffer unless we recreate
         * the EGL surface.
         */

        int eglWidth;
        int eglHeight;

        eglQuerySurface(eglDisplay, surface, EGL_WIDTH, &eglWidth);
        eglQuerySurface(eglDisplay, surface, EGL_HEIGHT, &eglHeight);

        if (eglWidth != width || eglHeight != height) {
            recreate();

            eglQuerySurface(eglDisplay, surface, EGL_WIDTH, &eglWidth);
            eglQuerySurface(eglDisplay, surface, EGL_HEIGHT, &eglHeight);
        }

        assert(eglWidth == width);
        assert(eglHeight == height);
    }
Beispiel #15
0
COpenGLGPUProgram::COpenGLGPUProgram(u32 uniforms, u32 attributes, u32 lights_count,
	E_VERTEX_SHADER_VERSION vertex_shader_ver, const c8 *vertex_shader,
	E_PIXEL_SHADER_VERSION pixel_shader_ver, const c8 *pixel_shader)
{
#if MY_DEBUG_MODE 
	setClassName("COpenGLGPUProgram");
#endif

	m_Program.u = m_VertexShader.u = m_PixelShader.u = 0;

	do
	{
		if (!VIDEO_DRIVER.queryFeature(vid::EVDF_SHADER_LANGUAGE))
		{
			LOGGER.logErr("Your video hardware not support GLSL feature");
			break;
		}
		if (!recreate(uniforms, attributes, lights_count,
				vertex_shader_ver, vertex_shader,
				pixel_shader_ver, pixel_shader))
			break;
	}
	while (0);
}
Beispiel #16
0
void NodeTransformationBuffer::upload() {
	size_t totalMemory = 0;
	for(size_t i = 0;i < threadStorageCount_;++i){
		totalMemory += threadStorage_[i].size();
	}
	if(!totalMemory) return;
	
	auto renderer = services::rendering();
	if(constantBuffer_.isNull()) {
		constantBuffer_  = renderer->create(rendering::Buffer::Constant,true,totalMemory);
	} else {
		renderer->recreate(rendering::Buffer::Constant,constantBuffer_,true,totalMemory);
	}
	auto mapping = renderer->map(rendering::Buffer::Constant,constantBuffer_);
	uint8* ptr = (uint8*) mapping.data;
	for(size_t i = 0;i < threadStorageCount_;++i){
		auto size = threadStorage_[i].size();
		if(size){
			memcpy(ptr,threadStorage_[i].bufferBase(),size);
			ptr += size;
		}
	}
	renderer->unmap(mapping);
}
Beispiel #17
0
 void swapBuffers(void) {
     if (update())
         recreate();
     bindAPI(api);
     eglSwapBuffers(eglDisplay, surface);
 }
Beispiel #18
0
void qMirrorModel::on_rowsMoved(const QModelIndex &/*parent*/, int /*start*/, int /*end*/, const QModelIndex &/*destination*/, int /*row*/)
{
  qDebug() << "QMirrorModel::on_rowsMoved";
  recreate();
}
Beispiel #19
0
void qMirrorModel::on_columnsRemoved(const QModelIndex &/*parent*/, int /*first*/, int /*last*/)
{
  qDebug() << "QMirrorModel::on_columnsRemoved";
  recreate();
}
Beispiel #20
0
void Scrollpad::resize(size_t new_width, size_t new_height)
{
	adjustDimensions(new_width, new_height);
	recreate(new_width, new_height);
	flush();
}
Beispiel #21
0
void Scrollpad::flush()
{
	auto &w = static_cast<Window &>(*this);
	const auto &s = m_buffer.str();
	const auto &ps = m_buffer.properties();
	auto p = ps.begin();
	size_t i = 0;
	
	auto load_properties = [&]() {
		for (; p != ps.end() && p->position() == i; ++p)
			w << *p;
	};
	auto write_whitespace = [&]() {
		for (; i < s.length() && iswspace(s[i]); ++i)
		{
			load_properties();
			w << s[i];
		}
	};
	auto write_word = [&](bool load_properties_) {
		for (; i < s.length() && !iswspace(s[i]); ++i)
		{
			if (load_properties_)
				load_properties();
			w << s[i];
		}
	};
	auto write_buffer = [&](bool generate_height_only) -> size_t {
		int new_y;
		size_t height = 1;
		size_t old_i;
		auto old_p = p;
		int x, y;
		i = 0;
		p = ps.begin();
		y = getY();
		while (i < s.length())
		{
			// write all whitespaces.
			write_whitespace();
			
			// if we are generating height, check difference
			// between previous Y coord and current one and
			// update height accordingly.
			if (generate_height_only)
			{
				new_y = getY();
				height += new_y - y;
				y = new_y;
			}
			
			if (i == s.length())
				break;
			
			// save current string position state and get current
			// coordinates as we are before the beginning of a word.
			old_i = i;
			old_p = p;
			x = getX();
			y = getY();
			
			// write word to test if it overflows, but do not load properties
			// yet since if it overflows, we do not want to load them twice.
			write_word(false);
			
			// restore previous indexes state
			i = old_i;
			p = old_p;
			
			// get new Y coord to see if word overflew into next line.
			new_y = getY();
			if (new_y != y)
			{
				if (generate_height_only)
				{
					// if it did, let's update height...
					++height;
				}
				else
				{
					// ...or go to old coordinates, erase
					// part of the string from previous line...
					goToXY(x, y);
					wclrtoeol(m_window);
				}
				
				// ...start at the beginning of next line...
				++y;
				goToXY(0, y);
				
				// ...write word again, this time with properties...
				write_word(true);
				
				if (generate_height_only)
				{
					// ... and check for potential
					// difference in Y coordinates again.
					new_y = getY();
					height += new_y - y;
				}
			}
			else
			{
				// word didn't overflow, rewrite it with properties.
				goToXY(x, y);
				write_word(true);
			}
			
			if (generate_height_only)
			{
				// move to the first line, since when we do
				// generation, m_real_height = m_height and we
				// don't have many lines to use.
				goToXY(getX(), 0);
				y = 0;
			}
		}
		// load remaining properties if there are any
		for (; p != ps.end(); ++p)
			w << *p;
		return height;
	};
	m_real_height = std::max(write_buffer(true), m_height);
	if (m_real_height > m_height)
		recreate(m_width, m_real_height);
	else
		werase(m_window);
	write_buffer(false);
}
Beispiel #22
0
 void recreate(x_coord_t width, y_coord_t height, unsigned alignment=1) { recreate(point2<std::ptrdiff_t>(width,height),alignment); }
Beispiel #23
0
CSMWorld::Resources::Resources (const VFS::Manager* vfs, const std::string& baseDirectory, UniversalId::Type type,
    const char * const *extensions)
: mBaseDirectory (baseDirectory), mType (type)
{
    recreate(vfs, extensions);
}
Beispiel #24
0
LRESULT CALLBACK main::WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
    PAINTSTRUCT ps;
    HDC hdc;
	RECT rc,rec;
	GetClientRect(hWnd,&rc);
	FLOAT width = rc.right - rc.left;
	FLOAT height = rc.bottom - rc.top;
	static POINT pt;
	static FLOAT a, a2, da = XM_PIDIV2;
	static FLOAT x, y, z, dx, dy;
	static int accelerator = 1;
	static bool move_forward = false, move_backward = false, move_left = false, move_right = false;
	srand(time(NULL));
    switch( message )
    {
        case WM_PAINT:
                hdc = BeginPaint( hWnd, &ps );
                EndPaint( hWnd, &ps );
                break;
		case WM_KEYDOWN:
			switch(wParam)
			{
			    case 0x10:
					if (accelerator == 1)
						accelerator = 3;
					else
						accelerator = 1;
				    break;
			    case 0x31:
					if (!Gravity_center::g_c)
					    Gravity_center::g_c = new Gravity_center(pow(10,15));
					else
						MessageBox(hWnd, L"Gravity center has been created already!", L"wow!", MB_OK);
				    break;
				case 0x32:
					if (Gravity_center::g_c)
					{
						if (Gravity_center::gravity_on)
							MessageBox(hWnd, L"You can't create objects while gravity is on!", L"oops!", MB_OK);
						else
						{
							float x = GenRandNum(1000);
							float y = GenRandNum(1000);
							float z = GenRandNum(1000);
							new physic_object(x, y, z, 1000000);
						}
					}
					else MessageBox(hWnd, L"Create gravity center first!", L"oops!", MB_OK);
					break;
				case 0x33:
					if (Gravity_center::g_c)
					{
						Gravity_center::gravity_on = true;
					}
					else MessageBox(hWnd, L"Create gravity center first!", L"oops!", MB_OK);
					break;
			    case 0x0D:
					if (Fullscreen)
						Fullscreen = false;
					else
						Fullscreen = true;
					recreate();
					break;
				case 0x1B:
					quit = true;
					PostQuitMessage(0);
					break;
				default:
					break;
			}
		case WM_KEYUP:
			switch (wParam)
			{
			case 0x41:
				move_left = false;
				break;
			case 0x44:
				move_right = false;
				break;
			case 0x57:
				move_forward = false;
				break;
			case 0x53:
				move_backward = false;
				break;
			}
		case WM_SIZE:
			GetClientRect(hWnd, &rc);
			width = rc.right - rc.left;
			height = rc.bottom - rc.top;
			break;
		case WM_MOVE:
			GetClientRect(hWnd, &rc);
			width = rc.right - rc.left;
			height = rc.bottom - rc.top;
			break;
		case WM_MOUSEMOVE:
			pt.x = LOWORD(lParam);
			pt.y = HIWORD(lParam); 

			if (pt.x >= width - 2)
			{
				GetWindowRect(hWnd, &rec);
				ClientToScreen(hWnd, &pt);
				SetCursorPos(rec.left+11, pt.y);
				da *= -1.0f;
				ScreenToClient(hWnd, &pt);
			}
			if (pt.x <= 2)
			{
				GetWindowRect(hWnd, &rec);
				ClientToScreen(hWnd, &pt);
				SetCursorPos(rec.right-11, pt.y);
				da *= -1.0f;
				ScreenToClient(hWnd, &pt);
			}
			a = -XM_PI*(pt.x / width)+da;
			a2 = -XM_PI*(pt.y / height)+XM_PIDIV2;

		    vx = xx + cos(a)*cos(a2);
			vy = yy + sin(a2);
			vz = zz + cos(a2)*sin(a);

			dx = pt.x;
			dy = pt.y;
			break;
		case WM_TIMER:
	    	case CAMERA_MOVE_TIMER:
				if (GetAsyncKeyState(0x41) & 0x8000)
					move_left = true;
				if (GetAsyncKeyState(0x44) & 0x8000)
					move_right = true;
				if (GetAsyncKeyState(0x57) & 0x8000)
					move_forward = true;
				if (GetAsyncKeyState(0x53) & 0x8000)
					move_backward = true;
				if (move_forward)
				{
					x = xx;
					z = zz;
					y = yy;
					xx += (vx - xx)*accelerator;
					yy += (vy - yy)*accelerator;
					zz += (vz - zz)*accelerator;
					vx += (vx - x)*accelerator;
					vy += (vy - y)*accelerator;
					vz += (vz - z)*accelerator;
				}
				if (move_backward)
				{
					x = xx;
					z = zz;
					y = yy;
					xx -= (vx - xx)*accelerator;
					yy -= (vy - yy)*accelerator;
					zz -= (vz - zz)*accelerator;
					vx -= (vx - x)*accelerator;
					vy -= (vy - y)*accelerator;
					vz -= (vz - z)*accelerator;
				}
				if (move_left)
				{
					xx = (xx - cos(a - XM_PIDIV2));
					zz = (zz - sin(a - XM_PIDIV2));
					vx = (vx - cos(a - XM_PIDIV2));
					vz = (vz - sin(a - XM_PIDIV2));
				}
				if (move_right)
				{
					xx = (xx + cos(a - XM_PIDIV2));
					zz = (zz + sin(a - XM_PIDIV2));
					vx = (vx + cos(a - XM_PIDIV2));
					vz = (vz + sin(a - XM_PIDIV2));
				}
				break;
			break;
        case WM_DESTROY:
			if (quit)
			{
				KillTimer(hwnd, CAMERA_MOVE_TIMER);
				PostQuitMessage(0);
			}
            break;
		case WM_CLOSE:
			quit = true;
			PostQuitMessage( 0 );
			break;

        default:
            return DefWindowProc( hWnd, message, wParam, lParam );
    }

    return 0;
}
Beispiel #25
0
void RecreatorImpl::recreateOneCode()
{
    auto code = program_reader.getInstruction();
    code_value = code->getValue();
    code->recreate(*this);
}