title: How to use clCreateImage
body: <p>I am trying to create a cl_mem using clCreateImage but the program keeps crashing. I am following my book as close as possible but it's been a pretty bump road so far.</p>
  
  <pre><code>#include "stdafx.h"
  #include &lt;iostream&gt;
  #include &lt;CL\cl.h&gt;
  
  using namespace std;
  
  int _tmain(int argc, _TCHAR* argv[])
  {
      cl_int status;
  
      cl_platform_id platform;
      status = clGetPlatformIDs(1, &amp;platform, NULL);
      cl_device_id device;
      clGetDeviceIDs(platform, CL_DEVICE_TYPE_ALL, 1, &amp;device, NULL);
      cl_context_properties props[3] = { CL_CONTEXT_PLATFORM, (cl_context_properties) (platform), 0 };
      cl_context context = clCreateContext(props, 1, &amp;device, NULL, NULL, &amp;status);
  
      cl_image_desc desc;
      desc.image_type = CL_MEM_OBJECT_IMAGE2D;
      desc.image_width = 100;
      desc.image_height = 100;
      desc.image_depth = 0;
      desc.image_array_size = 0;
      desc.image_row_pitch = 0;
      desc.image_slice_pitch = 0;
      desc.num_mip_levels = 0;
      desc.num_samples = 0;
      desc.buffer = NULL;
  
      cl_image_format format;
      format.image_channel_order = CL_R;
      format.image_channel_data_type = CL_FLOAT;
  
      // crashes on the next line with -- Unhandled exception at 0x72BCC9F1 in Convolution.exe: 0xC0000005: Access violation executing location 0x00000000.
      cl_mem d_inputImage = clCreateImage(context, CL_MEM_READ_ONLY, &amp;format, &amp;desc, NULL, &amp;status);
      // never gets here
  
      cout &lt;&lt; "---&gt;"; int exit; cin &gt;&gt; exit;
      return 0;
  }
  </code></pre>