incrementing unsigned char *image

void draw(unsigned char *image) { for (int y = 0; y < HEIGHT; y++) { for (int x = 0; x < WIDTH; x++) { if (someCondition) { int red = x * 256 / WIDTH; int green = 255; int blue = y * 256 / HEIGHT; image[0] = (unsigned char)blue; image[1] = (unsigned… Read More incrementing unsigned char *image

How to call the Win32 GetCurrentDirectory function from C#?

The prototype of GetCurrentDirectory DWORD GetCurrentDirectory( [in] DWORD nBufferLength, [out] LPTSTR lpBuffer ); DWORD is unsigned long, LPTSTR is a pointer to wchar buffer in Unicode environment. It can be called from C++ #define MAX_BUFFER_LENGTH 256 int main() { TCHAR buffer[MAX_BUFFER_LENGTH]; GetCurrentDirectory(MAX_BUFFER_LENGTH, buffer); return 0; } I tried to encapsulate this win32 function in C#,… Read More How to call the Win32 GetCurrentDirectory function from C#?

Type of identifier does not agree with its usage as "boolean" type – VHDL in Quartus

I’m developing a simple buffering system in VHDL. I get the error I mentioned in the title for "empty" whenever I try to compile. I don’t know why it won’t let me invert a std_logic type. I’ve also been getting errors about the comparisons. For some reason, it doesn’t recognize the ">" and "<" operators… Read More Type of identifier does not agree with its usage as "boolean" type – VHDL in Quartus

How to use Insert in Set for Custom Data Type ? C++

class Game() { void add(set<Velocity> & v); } class Velocity() { private: // Member Variables public: // Constructors and methods } void Game::add(set<Velocity> &velocities) { Velocity v; v.setVelocity(); v.setSource(); velocities.insert(v); } As you can see I have a custom class called Game and it has a public method called Add which adds a velocity object… Read More How to use Insert in Set for Custom Data Type ? C++

overflow instead of saturation on 16bit add AVX2

I want to add 2 unsigned vectors using AVX2 __m256i i1 = _mm256_loadu_si256((__m256i *) si1); __m256i i2 = _mm256_loadu_si256((__m256i *) si2); __m256i result = _mm256_adds_epu16(i2, i1); however I need to have overflow instead of saturation that _mm256_adds_epu16 does to be identical with the non-vectorized code, is there any solution for that? >Solution : Use normal… Read More overflow instead of saturation on 16bit add AVX2

How to overload + operator in a Template array class to add every element with the same Index together

I somewhat successfully overloaded the + operator to add 2 arrays of the same size together. This is my current code //.h #pragma once #include <iostream> template<typename T, size_t S> class MyArray { public: T dataArray[S]; T& operator[](size_t arrayIndex); const T& operator[](size_t arrayIndex) const; MyArray<T, S> operator+(const MyArray& secondSummand) const; constexpr size_t getSize() const; const… Read More How to overload + operator in a Template array class to add every element with the same Index together

opengl won't overlap more than 1 texture

I’m trying to create an opengl program that creates a 2d square, and applies 2 textures on it. I followed this tutorial: https://learnopengl.com/Getting-started/Textures This is my fragment shader: #version 330 core //in vec3 Color; in vec2 TexCoord; out vec4 FragColor; uniform sampler2D Texture1; uniform sampler2D Texture2; void main() { FragColor = mix(texture(Texture1, TexCoord), texture(Texture2, TexCoord),… Read More opengl won't overlap more than 1 texture