Jump to content

  • Log In with Google      Sign In   
  • Create Account


Martins Mozeiko

Member Since 11 Sep 2005
Offline Last Active Aug 22 2014 03:38 PM

#5120882 Alternative to SDL to use with TCC

Posted by Martins Mozeiko on 03 January 2014 - 06:48 AM

You can always compile SDL to shared library - dll or so file. And use that instead of static lib.

 

As for initialization - only Android, iOS and PSP needs special code. Other platforms will work fine without SDL_main.




#5120521 Alternative to SDL to use with TCC

Posted by Martins Mozeiko on 01 January 2014 - 12:31 PM

If you are not worried about Android/iOS/psp platforms, then you can simply define SDL_MAIN_HANDLED preprocessor symbol, and SDL won't override main.




#5120518 Performance problems at ~1,000,000 triangles. Am I doing something wrong?

Posted by Martins Mozeiko on 01 January 2014 - 12:24 PM

First of all - get rid of glGetUniformLocation calls during drawing. Get those uniform locations after shader is linked, and store somewhere. Calling glGetSomething usually is expensive operation in OpenGL.

 

Also drawing only 36 vertices per draw call is very small number. You should be drawing much more to have high performance with large number of triangles. Look into Instancing.

Another thing to look into is uniform buffer object - uploading all uniforms at once could be much better that calling individual glUniformX functions per each uniform.




#5082674 std::vector<> vs cli::array<>

Posted by Martins Mozeiko on 02 August 2013 - 11:31 PM

They are completely different beasts.

 
CLI array is not a "standard C++ array. They are managed arrays. It's like new [] operator in C++, but for managed heap. cli::array allocates memory in managed heap and garbage collects it to free the memory. 

std::vector allocates its memory from regular C++ heap and frees it when it goes out of scope.

 

^ is not for smart pointers. It is for managed pointers - they get garbage collected to free the memory.




#5078201 DirectX 11 maping ID3D11Texture2D

Posted by Martins Mozeiko on 16 July 2013 - 12:29 PM

Verify that calls to CreateTexture2D and Map functions are not giving you error. Basically assign them to HRESULT hr variable. and check that SUCCEEDED(hr) is true.

Or enable debug runtime - either pass D3D11_CREATE_DEVICE_DEBUG flag for D3D11CreateDevice function, or go to DirectX Control Panel. That will show you errors in debugger output.




#5076269 Cross-Distro DirectX Alternative For Linux?

Posted by Martins Mozeiko on 08 July 2013 - 09:31 PM

DirectInput actually is not the most effective way of getting input on Windows. It is deprecated and nobody should be using it anymore.

On Windows you should use regular input/polling functions with standard windows message loop (GetMessage/PeekMessage and DispatchMessage) to process Raw Input messages. That will give you less latency than DirectInput.

 

On Linux you'll be fine with X11.

Of course you can access hardware directly, but as you said - you'll need root for that. To do that you'll need access /dev/input/* devices. Here's some info how:

https://www.kernel.org/doc/Documentation/input/input.txt

http://stackoverflow.com/a/3877020/675078




#5075114 Python 3.3 on Windows 8?

Posted by Martins Mozeiko on 03 July 2013 - 03:27 PM

Python executable is called "python", not "python3". Even for 3.x version.

Open C:\Python33 folder in Explorer and you can see that by yourself.




#5074554 GLFW/GLUT glutBitmapString - high CPU usage?

Posted by Martins Mozeiko on 01 July 2013 - 02:55 PM

glutBitmapString internally uses glBitmap function that is not hardware accelerated on modern hardware. So using this function will make CPU do all the rendering.

 

I suggest you to look into rendering fonts using texture. Look here for generating texure: http://www.angelcode.com/products/bmfont/

Or you can render fonts directly from truetype font file: https://code.google.com/p/freetype-gl/




#5073076 Any good c++ non c++11 sha2 sources?

Posted by Martins Mozeiko on 26 June 2013 - 05:01 PM

W is local variable in sha_compress function - you need to pass it to RND function in argument.




#5065979 Redistributable x86 C++ Compiler for Pipeline

Posted by Martins Mozeiko on 29 May 2013 - 05:44 PM

Currently by default it uses headers and CRT from whatever compiler you used to built it from sources.

If you built clang using Visual Studio or WindowsSDK, then it will use link.exe and headers/libs from Visual Studio/Windows SDK.

If you built clang using MinGW, then it will use ld.exe from binutils and headers/libs provided by mingw.

Of course you can override this and use headers and libraries from whatever folder you wish. Overriding link.exe/ld.exe will require manually calling it - you'll use clang to generate object files, and will call ld.exe/link.exe to produce executable).




#5052341 Bizarre placement new[] operator return address

Posted by Martins Mozeiko on 11 April 2013 - 11:16 PM

I don't think that casting from void* to A* will change address. Cating from B* to A* - yes it can, but not from void*.


I think in this case author is allocating memory with new [] and array allocation stores length in first 4 bytes, that's why it returns address with +4 offset.




#5048671 How to statically link OpenAL-Soft for VC++

Posted by Martins Mozeiko on 31 March 2013 - 02:17 PM

but according to this post, I should be fine.

The information in link is a bit incorrect.

 

LGPL requires (from http://www.gnu.org/copyleft/lesser.html):

d) Do one of the following:

  • 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.
  • 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version.

So you are required to provide sources of your app, so users can link to different implementation of OpenAL library. Or you are required to use shared library when linking to OpenAL.




#5036483 What is the purpose of std::array?

Posted by Martins Mozeiko on 25 February 2013 - 04:18 PM

Try passing int a[10] to a function and getting its size wink.png
 

 

You mean like this?

 

template <class T, int N>
void printSizeOfArray(const T (&)[N])
{
    std::cout << N << std::endl;
}



#5033860 Is this a GCC bug or I am doing something wrong

Posted by Martins Mozeiko on 18 February 2013 - 01:12 PM

You should always post full error message instead of one line. For example "g++ -std=c++11 shows me following":

 

 

a.cpp: In instantiation of 'mfml::Matrix<DATA_TYPE, INT_TYPE, DATA_CONTAINER>::Matrix(mfml::Matrix<DATA_TYPE, INT_TYPE, DATA_CONTAINER>&&) [with DATA_TYPE = double; INT_TYPE = long unsigned int; DATA_CONTAINER = mfml::MatrixMatrixElementWiseOperation<double, long unsigned int, mfml::DataContainer<double, long unsigned int>, mfml::meta::plus<double>, mfml::DataContainer<double, long unsigned int> >]':
a.cpp:326:241:   required from 'mfml::Matrix<DATA_TYPE, INT_TYPE, mfml::MatrixMatrixElementWiseOperation<DATA_TYPE, INT_TYPE, Lhs, mfml::meta::plus<DATA_TYPE>, Rhs> > mfml::operator+(const mfml::Matrix<DATA_TYPE, INT_TYPE, Lhs>&, const mfml::Matrix<DATA_TYPE, INT_TYPE, Rhs>&) [with DATA_TYPE = double; INT_TYPE = long unsigned int; Lhs = mfml::DataContainer<double, long unsigned int>; Rhs = mfml::DataContainer<double, long unsigned int>]'
a.cpp:338:9:   required from here
a.cpp:165:107: error: no matching function for call to 'mfml::MatrixMatrixElementWiseOperation<double, long unsigned int, mfml::DataContainer<double, long unsigned int>, mfml::meta::plus<double>, mfml::DataContainer<double, long unsigned int> >::MatrixMatrixElementWiseOperation()'
a.cpp:165:107: note: candidates are:
a.cpp:299:19: note: mfml::MatrixMatrixElementWiseOperation<DATA_TYPE, INT_TYPE, Lhs, Op, Rhs>::MatrixMatrixElementWiseOperation(const Lhs&, const Rhs&) [with DATA_TYPE = double; INT_TYPE = long unsigned int; Lhs = mfml::DataContainer<double, long unsigned int>; Op = mfml::meta::plus<double>; Rhs = mfml::DataContainer<double, long unsigned int>]
a.cpp:299:19: note:   candidate expects 2 arguments, 0 provided
a.cpp:296:12: note: constexpr mfml::MatrixMatrixElementWiseOperation<double, long unsigned int, mfml::DataContainer<double, long unsigned int>, mfml::meta::plus<double>, mfml::DataContainer<double, long unsigned int> >::MatrixMatrixElementWiseOperation(const mfml::MatrixMatrixElementWiseOperation<double, long unsigned int, mfml::DataContainer<double, long unsigned int>, mfml::meta::plus<double>, mfml::DataContainer<double, long unsigned int> >&)
a.cpp:296:12: note:   candidate expects 1 argument, 0 provided 

 

As you can see it doesn't find following member:

 

error: no matching function for call to 'mfml::MatrixMatrixElementWiseOperation<double, long unsigned int, mfml::DataContainer<double, long unsigned int>, mfml::meta::plus<double>, mfml::DataContainer<double, long unsigned int> >::MatrixMatrixElementWiseOperation()' 

Why?

 

Your Matrix class has following move constructor:

 

    template <class DATA_TYPE,class INT_TYPE,class DATA_CONTAINER>
    inline Matrix<DATA_TYPE,INT_TYPE,DATA_CONTAINER>::Matrix(Matrix<DATA_TYPE,INT_TYPE,DATA_CONTAINER> &&M)
    {
       std::cout<<"move ctr"<<std::endl;
       dc.Data=NULL;
       dc.Rows=0;
       dc.Cols=0;
       std::swap(dc.Data,M.dc.Data);
       std::swap(dc.Rows,M.dc.Rows);
       std::swap(dc.Cols,M.dc.Cols);
    }
 

Which uses default constructor for dc member.

 

In operator + you are instantiating following class "Matrix<DATA_TYPE, INT_TYPE, MatrixMatrixElementWiseOperation<...> >".
So DATA_CONTAINER type will be "MatrixMatrixElementWiseOperation<...>", but it doesn't have default constructor! That's why compiler complains about template instantiation in operator +.
 
You should use std::move in move constructor:
    template <class DATA_TYPE,class INT_TYPE,class DATA_CONTAINER>
    inline Matrix<DATA_TYPE,INT_TYPE,DATA_CONTAINER>::Matrix(Matrix<DATA_TYPE,INT_TYPE,DATA_CONTAINER> &&M)
        : dc(std::move(M.dc))
    {
    }

 

 




#5032845 Why won't this C code compile?

Posted by Martins Mozeiko on 15 February 2013 - 05:22 PM

Variable definitions inside case must be in some scope.

Like this:

 

case RUNNING:
{ // <---- note the new scope
    unsigned char data;
    ...
}
 
case SAMPLING:
...





PARTNERS