buffer

MemoryStream does not contain a definition for GetBuffer()

☆樱花仙子☆ 提交于 2019-12-11 05:55:53
问题 I've started working with C# and .NET Core and I'm trying to implement the code in the answer at https://stackoverflow.com/a/23739932/1459684 However, I have a problem with lines writer.Write(innerStream.GetBuffer(), 0, length); and var base64 = Convert.ToBase64String(stream.GetBuffer(), 0, (int)stream.Length).ToCharArray(); where the method getBuffer() no longer appears to be available. I receive the error: "'MemoryStream' does not contain a definition for 'GetBuffer' and no extension method

OpenGL uniform nof found if uniform block gets too big

徘徊边缘 提交于 2019-12-11 05:34:26
问题 I´m trying to implement a Uniform Block. This is how the block looks like in my fragment shader: struct Light { uint LightType; vec3 Direction; float SpotBlur; vec3 AmbientColor; float LinearAttenuation; vec3 DiffuseColor; float QuadraticAttenuation; vec3 SpecularColor; float CubicAttenuation; vec3 Position; float SpotCutoff; }; layout(std140) uniform LightBlock { Light values; } lights[32]; As you can see, I defined an array of the Light struct with a fixed size of 32. I can upload the data

Creating accessing shared memory in C

 ̄綄美尐妖づ 提交于 2019-12-11 05:26:22
问题 So I have a problem that I don't really know how to go about. I was hoping maybe you could let me know how to deal with it. I need to allocate N number of buffers in shared memory. Each buffer should be initialized to 0. Then I must fork N/2 number of child processes. Each child(i) then writes value (i) into buffer (i), sleeps for one second. Then reads the value at the current buffer, if the value changed in the mean time then it displays a message. The child then moves i-positions N/2

DirectX Crash When Resizing Tiny

家住魔仙堡 提交于 2019-12-11 05:23:19
问题 I am trying to make my program more bullet proof. My program resizes fine until I make it super tiny like this: A method to prevent that from happening is to set a minimum size, which I know how to do already. I want to look deeper into the problem before I do that. The following is where the functions start to crash. hr=swapChain->ResizeBuffers(settings.bufferCount, settings.width, settings.height, DXGI_FORMAT_UNKNOWN, 0); if(FAILED(hr)) return 0; I figured it was because the buffer was too

Python 3 : TypeError: Type str doesn't support the buffer API

余生颓废 提交于 2019-12-11 05:06:54
问题 I'm getting the error : TypeError: Type str doesn't support the buffer API when trying to run the following code : import random import string WORDLIST_FILENAME = "words.txt" def loadWords(): """ Returns a list of valid words. Words are strings of lowercase letters. Depending on the size of the word list, this function may take a while to finish. """ print ("Loading word list from file...") # inFile: file inFile = open(WORDLIST_FILENAME, 'rb', 0) # line: string line = inFile.readline() #

How to chunk shell script input by time, not by size?

左心房为你撑大大i 提交于 2019-12-11 04:33:03
问题 In a bash script I am using a many-producer single-consumer pattern. Producers are background processes writing lines into a fifo (via GNU Parallel). The consumer reads all lines from the fifo, then sorts, filters, and prints the formatted result to stdout. However, it could take a long time until the full result is available. Producers are usually fast on the first few results but then would slow down. Here I am more interested to see chunks of data every few seconds, each sorted and

metal shading language - change buffer size

99封情书 提交于 2019-12-11 04:19:36
问题 Is it possible to change the buffer size at runtime? We allocate the buffer size during the register our device : device = MTLCreateSystemDefaultDevice() queue = device!.makeCommandQueue() do { let library = device!.newDefaultLibrary()! let kernel = library.makeFunction(name: "compute")! cps = try device!.makeComputePipelineState(function: kernel) } catch let e { Swift.print("\(e)") } paramBuffer = device!.makeBuffer(length: MemoryLayout<Float>.size*2, options: []) then we update it

Cancel a live stream “fast motion” catch-up in Flash

淺唱寂寞╮ 提交于 2019-12-11 03:49:08
问题 When streaming a live stream, if you hide the browser window/tab (e.g. by going to a different tab or minimizing the browser) - where the live stream is playing in and then after awhile you go back to it - then everything that 'happened' in the stream since the window was hidden is played back in fast motion until it reaches to the "live point". How can I cancel this functionality? I'm assuming this relates to the 'smart seeking' functionality that the NetStream have, however, even when I set

unknown value <Buffer d2 f3 f0 e0 e5 e2 e0 20> when select from firebird in Node.js

拈花ヽ惹草 提交于 2019-12-11 03:35:11
问题 I'm new at firebird. I am trying to fetch the name from DB, but it returns: <Buffer d2 f3 f0 e0 e5 e2 e0 20> What does it mean? How to convert it to readable characters? Thanks in advance db.query('SELECT FIRST 10 * FROM client', function(err, result) { // IMPORTANT: close the connection console.log(result[0].name) db.detach(); }); 回答1: It is a Buffer object (NodeJS docu), which is the usual return value for data, whose type is not predetermined. To convert it to a string again, use its

Why does moving the buffer pointer slow down fread (C programming language)?

牧云@^-^@ 提交于 2019-12-11 03:23:15
问题 I am reading a 1 GB file using fread in C. I am reading the file in 1MB chunks, using the following loop: FILE *fp; fp = fopen(filename, "rb"); unsigned char* buf; buf = malloc(CHUNK_SIZE); for(i = 0; i < NUMBER_OF_CHUNKS; ++i) { fread(buf, CHUNK_SIZE, 1, fp); //Do something with contents of buffer } fclose(fp); Reading the file this way takes ~2 seconds. However, I decided that I wanted to allocate one big buffer for the contents of the whole file instead and "move the buffer pointer" inside