Gama C Library
Gama C API Documentation
scene.h File Reference

Defines the 3D scene structure, encompassing lights, cameras, and viewport settings. More...

#include "../position.h"
#include "camera.h"
#include "light.h"

Go to the source code of this file.

Data Structures

struct  gm3Scene
 Represents a complete 3D scene, including its camera, lights, and viewport. More...

Functions

int gm3_scene_create (gm3Scene *s, double w, double h)
 Initializes a gm3Scene struct with default values and a specified viewport.
gm3Scene gm3_scene ()
 Creates and returns a new gm3Scene struct initialized with default values.
int gm3_scene_free (gm3Scene *s)
 Frees any dynamically allocated memory associated with a gm3Scene.

Variables

const gm3Scene gm3_default_scene
 A default gm3Scene instance.

Detailed Description

Defines the 3D scene structure, encompassing lights, cameras, and viewport settings.

This file provides the gm3Scene structure to manage global properties of a 3D rendering environment, making it easier to pass scene context to projection and rendering functions.

Function Documentation

◆ gm3_scene()

gm3Scene gm3_scene ( )

Creates and returns a new gm3Scene struct initialized with default values.

Returns
A new gm3Scene instance.

◆ gm3_scene_create()

int gm3_scene_create ( gm3Scene * s,
double w,
double h )

Initializes a gm3Scene struct with default values and a specified viewport.

Parameters
sA pointer to the gm3Scene struct to initialize.
wThe width of the viewport.
hThe height of the viewport.
Returns
0 on success, -1 if s is NULL.

◆ gm3_scene_free()

int gm3_scene_free ( gm3Scene * s)

Frees any dynamically allocated memory associated with a gm3Scene.

Currently, the gm3Scene struct does not directly manage any dynamically allocated pointers that require explicit freeing, so this function is a placeholder.

Parameters
sA pointer to the gm3Scene to free.
Returns
0 on success.

Variable Documentation

◆ gm3_default_scene

const gm3Scene gm3_default_scene
Initial value:
= {
.viewport = {2, 2},
.camera = gm3_default_camera,
}
const gm3Camera gm3_default_camera
A default gm3Camera instance.
Definition camera.h:21
const gm3Light gm3_default_light
A default gm3Light instance.
Definition light.h:27

A default gm3Scene instance.

Initializes a scene with a default viewport (2,2), a default light, and a default camera.