5

I was trying to figure out how to use the image library in vlib, in which there was a variable C:

pub fn (img Image) tex_image_2d() {
    mut rgb_flag := GL_RGB
    if img.ext == 'png' {
        rgb_flag = GL_RGBA
    }
    C.glTexImage2D(GL_TEXTURE_2D, 0, rgb_flag, img.width, 
        img.height, 0, rgb_flag, GL_UNSIGNED_BYTE, img.data)
}

On the 6th line the function calls a method that belongs to the variable C. What kind of object is C, and where could I find the source code for it?

Thanks in advance!

Lee Garcon
  • 182
  • 10
  • 3
    `C` is not an object, but rather is simply a syntax for instantiating C structs and calling C functions from V code. It's documented [here](https://vlang.io/docs#calling_c). – nanofarad Jul 05 '19 at 03:09

1 Answers1

2

It's a C function call from imported #include "stb_image.h"

See the code here for example

Ilya Kaznacheev
  • 168
  • 1
  • 4