Felics

1

votes
0

answer
29

views

How to get glyph metrics in C#

I'm creating a Font object like this: var font = new Font(font_name, font_size); Where font_name is obtained from System.Drawing.FontFamily.Families. I render a char into an image using: var char_renderer = Graphics.FromImage(char_image); char_renderer.DrawString(ch.ToString(), font, new SolidBrush(...
Felics
1

votes
1

answer
127

views

iPhone events handling

does anybody know how can I handle the events(touch, drag) in UIApplicationDelegate instead of UIView?
Felics
1

votes
1

answer
331

views

Xcode equivalent for Visual Studio environment variables

I use premake to build solutions for Visual Studio and Xcode. Does anybody knows the equivalent environment variables in Xcode for Visual Studio $(ConfigurationName) and $(SolutionName)? Thank you
Felics
1

votes
1

answer
1.3k

views

ZLib.lib(d000062.o) : warning LNK4078: multiple '.text' sections found with different attributes

I downloaded zlib from their website and I have the link warning from the title. I also compiled zlib and still have same warning. Do you know how may I fix this? I don't like warning of any kind in my projects:) I use Visual Studio 2010.
Felics
1

votes
2

answer
286

views

FPS stabilization iPhone

I have, most of the time, 50+ FPS, but when I load resources(background tread) it drops to 30 FPS. I want to have constant FPS, 30 or even 20, it's not a problem for me. What is the best way to make FPS constant?
Felics
1

votes
1

answer
316

views

Crash with SBJSON library

following code is copied from Stig Brautaset JSON library - I removed the comments to be more clear. @interface NSString (NSString_SBJSON) - (id)JSONFragmentValue; - (id)JSONValue; @end I have a crash when I call: NSString *jsonString = [request responseString]; ... NSDictionary *results = [jsonStri...
Felics
1

votes
1

answer
424

views

How to add mouse event handler on MenuItem

I have this code: System::Windows::Forms::MenuItem^ item = gcnew System::Windows::Forms::MenuItem('text'); item->Click += ... How can I add a mouse event handler to item?
Felics
1

votes
1

answer
923

views

WinHttpGetDefaultProxyConfiguration returns wrong Proxy Info

I want to retrieve default proxy settings. To do this I use next code: WINHTTP_PROXY_INFO ProxyInfo; ZeroMemory( &ProxyInfo, sizeof(ProxyInfo) ); BOOL result = WinHttpGetDefaultProxyConfiguration(&ProxyInfo); if (result) { //... } The function returns TRUE, but in ProxyInfo I have: WINHTTP_ACCESS_TY...
Felics
1

votes
1

answer
153

views

Check if type uses multiple inheritance or not

I have these classes: class A{}; class B{}; class C : public A{}; class D : public A, public B{}; I want to make a template function like this: template void f(T* arg); And to make 2 specializations for it: one when T doesn't uses inheritance or uses single inheritance one when T uses multiple inher...
Felics
1

votes
1

answer
121

views

Fill all available stack with specific value [duplicate]

This question already has an answer here: How to determine Stack size of a Program in linux? 2 answers I need to fill all available stack space with specific character for profiling purposes. First of all, is there a safe way to do this on Android(some compiler specific functions maybe) in C++? If...
Felics
1

votes
1

answer
803

views

mklink fails from Visual Studio

I have next pre build event: cmd /C mklink /D /J '$(ProjectDir)SomeDir' '$(ProjectDir)' This is expanded in(copied from MSBuild output): cmd /C mklink /D /J 'C:\Dir-1\Dir-2\other-dirs-here\SomeDir' 'C:\Dir-1\Dir-2\other-dirs-here\' When running the build with this build event the symbolic link is n...
Felics
1

votes
1

answer
125

views

Definition of “small object” in C++ when passing arguments [duplicate]

This question already has an answer here: What is considered a small object in C++? 4 answers In the new 'C++ Programming Language' book(and probably in previous versions), Bjarne Stroustrup recommends: Use pass-by-value for small objects Use pass-by-const-reference to pass large values that you do...
Felics
1

votes
1

answer
0

views

OpengGL ES vertex buffer

I have the fallowing situation using vertex buffers in OpenGL on iPad: - render some objects with 30 FPS - delete the objects and create new ones(kill all entities and spawn others) - render the new objects The FPS drops to 10 for few seconds and slowly recovers to 30. I used some timers and I saw t...
Felics
1

votes
3

answer
0

views

How to see multi-byte strings in Xcode

Is it possible to see strings that use 16 bits chars in Xcode debugger? I use a custom string class, not NSString. The strings are NULL terminated. The only way I can see the strings is if I see them as memory, but they are hard to read. Thank you!
Felics
1

votes
1

answer
0

views

CMFCPropertyGridCtrl add editable string property

I derived a class from CMFCPropertyGridCtrl to add a simple interface for my needs. I want to add a new string value so I can edit it: void CPropertyGrid::AddString(const char* tag, const char* defaultValue) { COleVariant valueType(defaultValue); CMFCPropertyGridProperty *stringProperty = new CMFCPr...
Felics
1

votes
1

answer
0

views

bjam scripts output a define

Is it possible to write to console a define from a bjam script? I have something like $(PROJECT_ROOT) and I want to echo it.
Felics
1

votes
1

answer
1.2k

views

OpenGL ES presentRenderBuffer duration depends on frameInterval value

I'm using CADisplayLink to fire the 'update' event for a very simple OpenGL ES animation on iOS. The animation has around 10 textured quads. I tried to run this at 60 FPS and I saw some glitches. When changing this to 30 FPS the animation runs smoother. After profiling this I saw that the most of th...
Felics
1

votes
1

answer
641

views

Where to sign in for VS 2013 Express Preview

I don't know if this question is proper for stackoverflow or for other Stack site, so please migrate it to the correct place:) I got VS 2013 Express Preview and after 15 days it expired. I have this message: Where may I sign in to extend the license? I'm already signed in with my MS account(you can...
Felics
1

votes
3

answer
96

views

Type aware string to number conversion in C++

Let's assume all the numbers in this world are positive integers and they can be represented by uintX_t C++ types. Let's consider next awesome code to convert a std::string to a number: #include #include #include template T MyAwsomeConversionFunction(const std::string& value) { T result = 0; for...
Felics
1

votes
1

answer
497

views

Visual studio equivalent for __attribute__ ((warn_unused_result))

Considering following code: struct MyType{}; MyType myFunction() __attribute__ ((warn_unused_result)) { return MyType{}; } int main() { myFunction(); auto storMyType = myFunction(); } Not storing the return value of myFunction is a logical error and I want to have a compilation error on all compile...
Felics
1

votes
1

answer
84

views

constexpr to construct objects with private members

I have the following code that compiles and behaves as expected: struct A { //private: int v; friend constexpr A f(int v); }; constexpr A f(int v) { return A{v}; } constexpr A operator''_A(unsigned long long v) { return f(static_cast(v)); } I can construct objects of type A like this: auto a = 1_A;...
Felics
1

votes
2

answer
4k

views

Mouse state winapi

Is there any way to get mouse state (position, buttons states) using winapi in C++? I don't want to use windows messages (WM_MOUSEMOVE, WM_LBUTTONDOWN, etc). Thank you!
Felics
1

votes
1

answer
64

views

How to call member function using function pointers for a specific object

I have this code: #include class foo { public: foo(int yy){y = yy;} void f(int x){std::cout
Felics
1

votes
1

answer
323

views

Message received when Window gets activated

I'm trying to pause a DirectX game when the windows loses focus, but the messages seem to be inconsistent. When using windows mode WM_SETFOCUS and WM_KILLFOCUS messages are received and everything works fine, but these messages are not received when using full screen mode. WM_NCACTIVATE is received...
Felics
1

votes
2

answer
6.3k

views

API for capturing sound on Windows

I need a C++ API to enumerate input devices and capture sound for Windows Vista, Windows 7 and Windows 8. If there is no common API I can use OS specific API for different versions of Windows. I found some references on Microsoft site, but I don't know what to chose. What do you recommend?
Felics
1

votes
1

answer
1.9k

views

How to get gtest TYPED_TEST parameter type

I have some unit tests written on Windows (Visual Studio 2017) and I need to port them on Linux (GCC 4.9.2 - I'm stuck with this version...). I've come with a simple example for my problem which compiles fine on Windows (I don't think it should compile as MyParamType is a dependent type from e templ...
Felics
1

votes
1

answer
139

views

Mechanism to create “template” objects in C++

I want to be able to initialize objects with some default values, but to do this from external code(not embedded in the class itself). The objects are exposed to external editor and I don't want to set the same values again and again and change only some values that are different. As I have already...
Felics
1

votes
1

answer
179

views

C++ standard way to check if type has function with specific signature

This question is related to: Check if a class has a member function of a given signature Is this functionality implemented by C++11 standard or do I need to use custom implementation?
Felics
1

votes
1

answer
162

views

Get pointer to function declared into namespace

I wanted to count the spaces from a std::string. Very simple task for std::count_if so I wrote this code: std::cout
Felics
1

votes
2

answer
692

views

C++ algorithm to advance iterator while condition is true

Having a pair of iterators [begin, end) I want to advance begin while a condition is true and I didn't reach end. As I don't know any 'direct' algorithm from the standard library to do this I'm using: std::find_if_not(begin, end, condition); but my problem is that the name of the function does't exp...
Felics
1

votes
1

answer
97

views

Order of destruction for stack/heap allocated arrays

Considering following code: struct A{...}; A a[100]; A* pa = new A[100]; delete[] pa; Is the order of destruction for the elements of a/pa defined by the standard or it is implementation defined (for the second case operator delete[] is not user defined).
Felics
1

votes
1

answer
197

views

Safe lock/unlock without scope guard

I have to deal with a design restriction(dependency issues) to not use scope guard for a mutex. Sample code: template class Test { MutexType myMutex; public: void f() { myMutex.Lock(); //code with many returns here depending on conditions myMutex.Unlock(); } }; Is there other safe way of dealing wi...
Felics
13

votes
2

answer
924

views

C++ const correctness with string literals [duplicate]

This question already has an answer here: What is the type of string literals in C and C++? 4 answers According to the C++ standard a string literal type is array of const char auto constStr = 'aaa'; char* nonConstStr = constStr; //Error here, cannot convert from 'const char *' to 'char *' char* st...
Felics
1

votes
1

answer
185

views

C++ uniform initialization with default values

Considering following structs: struct A { int i; }; struct B { int i = 0; }; Why I can initialize objects of type A using uniform initializers and I can't initialize objects of type B? A a{1}; B b{1}; //ill formed What is the compiler doing when a default value is used to initialize members?
Felics
1

votes
4

answer
201

views

Signalize thread to start specific function

I want to split some CPU intensive jobs to multiple threads. I want to make a thread pool with, let's say, 4 threads. I want to know very fast ways to do following: Check if one thread is free for receiving processing Signalize one thread to start specific function Wait for all the threads to finish...
Felics
3

votes
1

answer
124

views

Qt refreshes at 60 FPS and eats GPU

I have a Qt application that starts refreshing at 60FPS, but I can't detect why. I used QML profiler and I can't see any event that triggers redraw. Using: QSG_RENDERER_DEBUG=debug QSG_RENDER_TIMING=1 I see Gui Thread: window=0x7fffffffe400, polish=0, lock=0, block/sync=15 -- animations=0 written...
Felics
20

votes
4

answer
26.5k

views

How to redirect stdout to output window from visual studio

Is it possible to redirect stdout to output window from Visual Studio? I use in my program OutputDebugString but I use some libraries that have output debug messages with printf's or cout's.
Felics
5

votes
4

answer
1.9k

views

C++ template function that receives std::vector as argument

I need to make a template function that receives as parameter a std::container of some type - let's say std::vector and deletes all elements from that container. I need a function equivalent to this: for_each(some_vector.begin(), some_vector.end(), [](some_vector_type* element){delete element;}); T...
Felics
5

votes
3

answer
345

views

Macro to repeat almost the same code

I have to write same code dependent on compile time constant parameter, something like: map['text 0'] = vec[0]; map['text 1'] = vec[1]; ... map['text n'] = vec[n]; The problem is that I don't know n when I'm writing the code, I receive it as template parameter. The obvious solution is to use one loo...
Felics
2

votes
2

answer
173

views

How to specialize template function with template types

Is it possible to specialize a template function for template types? I don't know if my terminology is correct, so I'll provide a simple sample with what I want to achieve: #include #include #include template void f() { std::cout
Felics

View additional