woensdag 18 december 2013
Assimp: one material per mesh
A mesh does use only a single material. If an imported model uses multiple materials, the import splits up the mesh. Use this value as index into the scene's material list.
dinsdag 17 december 2013
Converting OGLDEV samples to SDL using GLM
When you convert OGLDEV samples to SDL using GLM, you might run into trouble. GLM is column-major and the OGLDEV samples are row-major.
This is not a big problem. Just invert the GL_TRUE in glUniformMatrix4fv to GL_FALSE. See this post: http://stackoverflow.com/questions/20578922/cant-display-model-using-glm-lookat-and-glm-perspective
dinsdag 3 december 2013
DDS mipmaps creation
You want to create DDS mipmaps for using compressed textures in OpenGL? Just use Paint.NET 3.5+
No need to download "The Compressonator" for that.
The funny thing is that I tried to convert a JPG to DDS with "The Compressonator", but the JPG format was not supported. So I went to Paint.NET to convert the JPG to an other format. However when choosing the output type I discovered that Paint.NET can save DDS's and create mipmaps! Great free software that Paint.NET.
There also is available a bulk image processor: http://pdnbulkupdater.codeplex.com/
No need to download "The Compressonator" for that.
The funny thing is that I tried to convert a JPG to DDS with "The Compressonator", but the JPG format was not supported. So I went to Paint.NET to convert the JPG to an other format. However when choosing the output type I discovered that Paint.NET can save DDS's and create mipmaps! Great free software that Paint.NET.
There also is available a bulk image processor: http://pdnbulkupdater.codeplex.com/
zaterdag 30 november 2013
SDL: unresolved external symbol _tmainCRTStartup
When compiling a C++ program with SDL, I got the error: unresolved external symbol _tmainCRTStartup
You solve the problem using:
#include <SDL.h>
#undef main
You solve the problem using:
#include <SDL.h>
#undef main
woensdag 27 november 2013
Assimp: merge meshes into one
Assimp is a great library for loading OpenGL models. At the moment I'm using SketchUp to create some 3D models and I export them using the "OBJ" format. Assimp can load this "OBJ" format but does not join all the meshes into one.
If you are using the internet sample "Importing 3D Models with Assimp" you see that the drawing in OpenGL loops over all the meshes. Every drawcall is a roundtrip from the CPU to the GPU and back, so you want to prevent that. So you want to merge all meshes into one.
This is possible in assimp using the flag aiProcess_OptimizeGraph. Some code:
scene = importer.ReadFile( pFile, aiProcessPreset_TargetRealtime_Quality | aiProcess_OptimizeGraph | aiProcess_OptimizeMeshes);
If you are using the internet sample "Importing 3D Models with Assimp" you see that the drawing in OpenGL loops over all the meshes. Every drawcall is a roundtrip from the CPU to the GPU and back, so you want to prevent that. So you want to merge all meshes into one.
This is possible in assimp using the flag aiProcess_OptimizeGraph. Some code:
scene = importer.ReadFile( pFile, aiProcessPreset_TargetRealtime_Quality | aiProcess_OptimizeGraph | aiProcess_OptimizeMeshes);
dinsdag 19 november 2013
OpenGL tutorials
There exist some good OpenGL tutorials on the internet:
http://www.opengl-tutorial.org
http://ogldev.atspace.co.uk/
http://www.arcsynthesis.org/gltut/
http://www.openglbook.com
http://www.spacesimulator.net/
http://www.lighthouse3d.com/
http://www.opengl-tutorial.org
http://ogldev.atspace.co.uk/
http://www.arcsynthesis.org/gltut/
http://www.openglbook.com
http://www.spacesimulator.net/
http://www.lighthouse3d.com/
donderdag 25 juli 2013
C++ copy-by-value problems
In C++, copy-by-value is default. If you do the following:
The &n is the same as &grid[i][j] in this case.
Node n = grid[i][j];
n.x = 100;
you have a new object called n, which is not the same object as grid[i][j].
To solve the situation, you can do:
Node& n = grid[i][j];
n.x = 100;
The &n is the same as &grid[i][j] in this case.
woensdag 26 juni 2013
Oracle: System account resetten
System account resetten op Oracle XE:
> Aanloggen op de server waar Oracle staat.
> De SQL prompt starten.
> connect
> (als username de volgende tekst) /as sysdba
> ALTER USER system ACCOUNT UNLOCK
/
> alter user system identified by NewPasswordHere
/
> exit
> Aanloggen op de server waar Oracle staat.
> De SQL prompt starten.
> connect
> (als username de volgende tekst) /as sysdba
> ALTER USER system ACCOUNT UNLOCK
/
> alter user system identified by NewPasswordHere
/
> exit
vrijdag 31 mei 2013
Using GLFW x64 Visual Studio 2010
Using GLFW x64 Visual Studio 2010:
First compile GLFW with Visual Studio 2010. The solution file is in the support directory. Load the .sln file. Create an x64 active solution platform. Compile with configuration manager option "Release" and your new created "x64" solution platform.
Don't forget to include "GLFW.h".
In ProjectProperties/Linker/System/Subsystem, you can set if the application is a console application or a window application.
If you get: LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
Solve this by setting LIBCMT in the ProjectProperties/Linker/Input/Ignore Specific Default Libraries.
If you get: LNK4075: ignoring '/INCREMENTAL' due to '/LTCG' specification
Solve this by setting the ProjectProperties/Linker/General/Enable Incremental Linking to NO.
First compile GLFW with Visual Studio 2010. The solution file is in the support directory. Load the .sln file. Create an x64 active solution platform. Compile with configuration manager option "Release" and your new created "x64" solution platform.
Don't forget to include "GLFW.h".
In ProjectProperties/Linker/System/Subsystem, you can set if the application is a console application or a window application.
If you get: LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
Solve this by setting LIBCMT in the ProjectProperties/Linker/Input/Ignore Specific Default Libraries.
If you get: LNK4075: ignoring '/INCREMENTAL' due to '/LTCG' specification
Solve this by setting the ProjectProperties/Linker/General/Enable Incremental Linking to NO.
dinsdag 21 mei 2013
QueryPerformanceCounter not reliable
If you have a threaded application running on a multicore computer QueryPerformanceCounter can (and will) return different values depending on which core the code is executing on.
http://stackoverflow.com/questions/1825720/c-high-precision-time-measurement-in-windows
I've tested timeGetTime() , but it is also not accurate.
http://stackoverflow.com/questions/1825720/c-high-precision-time-measurement-in-windows
I've tested timeGetTime() , but it is also not accurate.
dinsdag 7 mei 2013
Bass, a great 64-bit XM MOD player
I'm working on a little demo which uses CUDA. I installed a 64 bit C compiler for it and the 64-bit version of CUDA.
Now I want some music to play, however minifmod and ufmod both use 32-bit assembly code. This results in Linker errors. "LNK2019: unresolved external symbol". The 64-bit linker cannot link the 32-bit Lib's.
I gave it a try to run the 32-bit DOS-prompt with the 32-bit CL.exe, however the CUDA compiler NVCC still generates 64-bit executables. You can determine that by using: dumpbin /headers <exe-file>
Look in de log presented to you and you will find: 8664 machine (x64)
XMPLib:
XMPLib seems to be a total C XM player, so I tried to compile it. However it is Linux oriented, so you need to do the ./configure,make dance which is not supported by Visual Studio. I installed MINGW on my 64-bit machine. The LibXMP.dll is generated without a problem. However after checking with dumpbin it still is a 32-bit DLL!
After checking the MINGW website, I discovered that MINGW is only 32 bit at this moment! Pheww, the installer didn't mention it when installing MINGW on my 64-bit Windows.
BASS:
But now, there is music, maestro!
BASS ships 64-bit DLL's and LIB's compatible with VS2010. Download at: www.un4seen.com/stuff/bass24-x64.zip
To start the music simply do:
HMUSIC TheMod;
BASS_Init(-1,44100,0,0,NULL);
char xmfile[] = "CRACKINT.MOD";
TheMod = BASS_MusicLoad(FALSE,xmfile,0,0,BASS_MUSIC_RAMPS,1);
BASS_ChannelPlay(TheMod,FALSE);
and at exit:
BASS_MusicFree(TheMod);
BASS_Free();
Include the bass.h in your C code and link the bass.lib.
Now I want some music to play, however minifmod and ufmod both use 32-bit assembly code. This results in Linker errors. "LNK2019: unresolved external symbol". The 64-bit linker cannot link the 32-bit Lib's.
I gave it a try to run the 32-bit DOS-prompt with the 32-bit CL.exe, however the CUDA compiler NVCC still generates 64-bit executables. You can determine that by using: dumpbin /headers <exe-file>
Look in de log presented to you and you will find: 8664 machine (x64)
XMPLib:
XMPLib seems to be a total C XM player, so I tried to compile it. However it is Linux oriented, so you need to do the ./configure,make dance which is not supported by Visual Studio. I installed MINGW on my 64-bit machine. The LibXMP.dll is generated without a problem. However after checking with dumpbin it still is a 32-bit DLL!
After checking the MINGW website, I discovered that MINGW is only 32 bit at this moment! Pheww, the installer didn't mention it when installing MINGW on my 64-bit Windows.
BASS:
But now, there is music, maestro!
BASS ships 64-bit DLL's and LIB's compatible with VS2010. Download at: www.un4seen.com/stuff/bass24-x64.zip
To start the music simply do:
HMUSIC TheMod;
BASS_Init(-1,44100,0,0,NULL);
char xmfile[] = "CRACKINT.MOD";
TheMod = BASS_MusicLoad(FALSE,xmfile,0,0,BASS_MUSIC_RAMPS,1);
BASS_ChannelPlay(TheMod,FALSE);
and at exit:
BASS_MusicFree(TheMod);
BASS_Free();
Include the bass.h in your C code and link the bass.lib.
donderdag 25 april 2013
Oracle: Remove duplicate's with a loop
To remove duplicate's using a loop in Oracle:
BEGIN
FOR Lcntr IN 1..560
LOOP
DELETE TABLE WHERE ROWID IN
(
SELECT min(ROWID)
FROM TABLE
GROUP BY COLUMN1, COLUMN2, COLUMN3, ...
HAVING count(1) > 1
);
END LOOP;
END;
And then, COMMIT; or ROLLBACK;
BEGIN
FOR Lcntr IN 1..560
LOOP
DELETE TABLE WHERE ROWID IN
(
SELECT min(ROWID)
FROM TABLE
GROUP BY COLUMN1, COLUMN2, COLUMN3, ...
HAVING count(1) > 1
);
END LOOP;
END;
And then, COMMIT; or ROLLBACK;
Oracle: Regular Expressions in Like
When you want to use regular expressions in the like part of the query in Oracle, use:
SELECT count(*) FROM TABLE WHERE REGEXP_LIKE(COLUMN, '^[0123456789].*$')
Notice that you cannot use '%' any more.
SELECT count(*) FROM TABLE WHERE REGEXP_LIKE(COLUMN, '^[0123456789].*$')
Notice that you cannot use '%' any more.
woensdag 24 april 2013
.NET: Easy way to make ANY_CPU compiled DLL 32-bit
The default configuration in Microsoft .NET is compiling the DLL's as ANY_CPU. This means that in a 64-bit environment the code will look for 64-bit drivers and in a 32-bit environment for 32-bit drivers.
In a professional environment, you typically notice this when moving to Windows 2008 R2. When you do not install 64-bit drivers, your software will not function anymore.
There is a solution, however: Use the Visual Studio tool CorFlags. The CorFlags Conversion tool allows you to configure the CorFlags section of the header of a portable executable image.
The following statement will set the DLL as 32-bit:
CorFlags.exe assembly.dll /32BIT+
Ofcourse, you can also recompile your software as X86, but in some cases which contain modifications in the build-scripts that may not be possible.
Notice that IIS 7.5 (Windows 2008 R2) does contain an advanced property in the Application Pool, which must be set to run 32-bit DLL's in IIS webapplications.
In a professional environment, you typically notice this when moving to Windows 2008 R2. When you do not install 64-bit drivers, your software will not function anymore.
There is a solution, however: Use the Visual Studio tool CorFlags. The CorFlags Conversion tool allows you to configure the CorFlags section of the header of a portable executable image.
The following statement will set the DLL as 32-bit:
CorFlags.exe assembly.dll /32BIT+
Ofcourse, you can also recompile your software as X86, but in some cases which contain modifications in the build-scripts that may not be possible.
Notice that IIS 7.5 (Windows 2008 R2) does contain an advanced property in the Application Pool, which must be set to run 32-bit DLL's in IIS webapplications.
vrijdag 12 april 2013
Oracle: all rows in a tree node
In Oracle 10, if you want to select all rows in een tree node do:
SELECT t.* FROM <table> t
START WITH t.ID = 'startvalue'
CONNECT BY PRIOR t.ID = t.PARENT_ID
SELECT t.* FROM <table> t
START WITH t.ID = 'startvalue'
CONNECT BY PRIOR t.ID = t.PARENT_ID
donderdag 11 april 2013
Oracle: Remove duplicate rows
In Oracle, when there are duplicate rows in a table, use the following piece to remove them:
DELETE <TABLE> WHERE ROWID IN
(
SELECT min(ROWID)
FROM <TABLE>
GROUP BY COLUMN1, COLUMN2, ...
HAVING count(1) > 1
)
Use all the columns in the table in the "group by" clause to ensure that the rows are identical.
DELETE <TABLE> WHERE ROWID IN
(
SELECT min(ROWID)
FROM <TABLE>
GROUP BY COLUMN1, COLUMN2, ...
HAVING count(1) > 1
)
Use all the columns in the table in the "group by" clause to ensure that the rows are identical.
maandag 8 april 2013
Found conflicts between different versions of the same dependent assembly. (MSB3247)
In SharpDevelop 4, you can come accross this warning: Found conflicts between different versions of the same dependent assembly. (MSB3247)
I've seen it the first time when using the .NET 4.0 framework. The error means that you should redirect all references of a DLL to the newest version of that DLL.
Do the following:
Create an app.config that looks like:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="mscorlib" publicKeyToken="b77a5c561934e089" culture="neutral"/>
<bindingRedirect oldVersion="1.0.3300.0 - 2.0.0.0" newVersion="4.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System" publicKeyToken="b77a5c561934e089" culture="neutral"/>
<bindingRedirect oldVersion="1.0.3300.0 - 2.0.0.0" newVersion="4.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="1.0.3300.0 - 3.5.0.0" newVersion="4.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
</startup>
</configuration>
The last entry is the conflicting System.Web DLL that we have found by investigating the output. All versions of the System.Web DLL are now redirected to the 4.0.0.0 version of that DLL.
Now, the warning is gone when rebuilding.
Don't forget to turn off the diagnostic Building! It is much slower!
The mscorlib, System, System.Web assembly redirects are just samples. Redirect as many DLL's as needed.
I've seen it the first time when using the .NET 4.0 framework. The error means that you should redirect all references of a DLL to the newest version of that DLL.
Do the following:
- In SharpDevelop -> Tools/Options/Projects and Solutions/Build Verbosity: Diagnostic
- Now you can see the conflict in detail. Activate the output by -> View/Output.
- Rebuild the project.
- Search for "conflict" in the output.
- The DLL that's resolved before the conflict is the conflicting DLL. For example it prints: Dependency "System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
Create an app.config that looks like:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="mscorlib" publicKeyToken="b77a5c561934e089" culture="neutral"/>
<bindingRedirect oldVersion="1.0.3300.0 - 2.0.0.0" newVersion="4.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System" publicKeyToken="b77a5c561934e089" culture="neutral"/>
<bindingRedirect oldVersion="1.0.3300.0 - 2.0.0.0" newVersion="4.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="1.0.3300.0 - 3.5.0.0" newVersion="4.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
</startup>
</configuration>
The last entry is the conflicting System.Web DLL that we have found by investigating the output. All versions of the System.Web DLL are now redirected to the 4.0.0.0 version of that DLL.
Now, the warning is gone when rebuilding.
Don't forget to turn off the diagnostic Building! It is much slower!
The mscorlib, System, System.Web assembly redirects are just samples. Redirect as many DLL's as needed.
donderdag 14 maart 2013
C# oracle connection pool problems
The Oracle C# driver is not smart enough to check whether a connection is still active in the connection pool. This makes it possible for the C# code to get an disconnected connection when you open een new connection to Oracle.
One possible solution given on the Internet is using the "Validate Connection=true;" in your connection string. However, that does not solve your problem at all.
The only way to solve the problem is to add this string to your connection string:
"Min Pool Size=0;Connection Lifetime=120;Connection Timeout=60;Incr Pool Size=5;Decr Pool Size=3;"
This means: The minimum Pool size is 0, and eventually the Pool size will become 0 when no activity is going on for some time. Works great.
Oracle 10g client datetime errors
In my case the language was incorrectly defined. I had the american NLS_LANG in my registry.
The correct NLS_LANG for me was:
[HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\KEY_OraClient10g_home1]
"NLS_LANG"="DUTCH_THE NETHERLANDS.WE8MSWIN1252"
The correct NLS_LANG for me was:
[HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\KEY_OraClient10g_home1]
"NLS_LANG"="DUTCH_THE NETHERLANDS.WE8MSWIN1252"
zaterdag 2 maart 2013
Shared folders on VirtualBox
A coworker of mine said that VirtualBox shared folders are a lot faster than using a host-only network on VirtualBox. And it is much easier to setup.
dinsdag 5 februari 2013
ORA-06502 numeric or value error at SYS.XMLType
ORA-06502: PL/SQL : numeric or value error
ORA-06502: at "SYS.XMLType", line 254
ORA-06502: at line 1
This error was what I was getting in Oracle.
This was my incorrect query:
SELECT *
FROM
(
SELECT XMLTYPE(p.personxml).extract('//Persons/Person/IsSpecific/text()').GetStringVal() elem
from person p
)
WHERE elem = '1'
However, the column personxml can be NULL. And that is a problem to Oracle.
The solution is a NULL value check, and use an empty XML-string in that case:
SELECT *
FROM
(
SELECT XMLTYPE(nvl(p.personxml, '<Persons></Persons>')).extract('//Persons/Person/IsSpecific/text()').GetStringVal() elem
from person p
)
WHERE elem = '1'
ORA-06502: at "SYS.XMLType", line 254
ORA-06502: at line 1
This error was what I was getting in Oracle.
This was my incorrect query:
SELECT *
FROM
(
SELECT XMLTYPE(p.personxml).extract('//Persons/Person/IsSpecific/text()').GetStringVal() elem
from person p
)
WHERE elem = '1'
However, the column personxml can be NULL. And that is a problem to Oracle.
The solution is a NULL value check, and use an empty XML-string in that case:
SELECT *
FROM
(
SELECT XMLTYPE(nvl(p.personxml, '<Persons></Persons>')).extract('//Persons/Person/IsSpecific/text()').GetStringVal() elem
from person p
)
WHERE elem = '1'
Abonneren op:
Posts (Atom)