Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


streamer

Member Since 03 Jun 2005
Offline Last Active Oct 01 2013 11:54 AM

Posts I've Made

In Topic: Convert std::string to WCHAR ?

21 May 2013 - 12:03 PM

Here is one nice small snippet.

const wchar_t* to_wide( const std::string& strToConvert ) {
  return std::wstring( strToConvert.begin(), strToConvert.end() ).c_str();
}
 

 

This code is deeply broken. You're returning a pointer to memory that is freed when the function exits (because the temporary wstring will be destructed). It may seem to work, but that's the horrifying reality of undefined behavior - it often seems to work until it bites you viciously.

 

You are right! :)

 

+1 for noticing it.


In Topic: Convert std::string to WCHAR ?

21 May 2013 - 12:36 AM

Here is one nice small snippet. 

const wchar_t* to_wide( const std::string& strToConvert ) {
  return std::wstring( strToConvert.begin(), strToConvert.end() ).c_str();
}
 

 

Notice: not working, skip it. I just leave it as is, to be here as warning how NOT to do some things.


In Topic: Isometric/Demitric view - Need help

28 July 2012 - 05:47 AM

Do you want to use 2D representation or real 3D isometric view? Both of approaches use different kind of programming.

In Topic: Geometry Shader Only Outputs 3 Vertices

20 July 2012 - 12:58 AM

I am not familiar with geometry shaders but here are few thoughts:
- you are using two triangles with unappropriated culling, switch culling off if there is a second triangle shown (easy to debug)
- you are try to render triangles with triangle fan method, and output is expected to be two triangles. Add two more vertices, or render with triangle fan

Anyway 3d APIs usually work with triangles not quads. However, OpenGL have GL_QUADS rendering method, but that is not geometry shader.

In Topic: Spritesheets vs Individual Sprites

10 July 2012 - 11:44 PM

I don't think there is any restriction about it (not 100% sure), probably the memory is the limit.

However if I remember well, I have read somewhere that 3th dimension on texture also should be power of 2. So it is wise to have 1,2,4,8,16 etc layers.

PARTNERS