Blender  V3.3
gpu_shader_builder.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2021 Blender Foundation. All rights reserved. */
3 
10 #include <iostream>
11 
12 #include "GHOST_C-api.h"
13 
14 #include "GPU_context.h"
15 #include "GPU_init_exit.h"
17 
18 #include "CLG_log.h"
19 
21 
23  private:
24  GHOST_SystemHandle ghost_system_;
25  GHOST_ContextHandle ghost_context_;
26  GPUContext *gpu_context_ = nullptr;
27 
28  public:
29  void init();
30  bool bake_create_infos();
31  void exit();
32 };
33 
35 {
37 }
38 
40 {
41  CLG_init();
42 
43  GHOST_GLSettings glSettings = {0};
44  ghost_system_ = GHOST_CreateSystem();
45  ghost_context_ = GHOST_CreateOpenGLContext(ghost_system_, glSettings);
46  GHOST_ActivateOpenGLContext(ghost_context_);
47 
48  gpu_context_ = GPU_context_create(nullptr);
49  GPU_init();
50 }
51 
53 {
54  GPU_exit();
55 
56  GPU_context_discard(gpu_context_);
57 
58  GHOST_DisposeOpenGLContext(ghost_system_, ghost_context_);
59  GHOST_DisposeSystem(ghost_system_);
60 
61  CLG_exit();
62 }
63 
64 } // namespace blender::gpu::shader_builder
65 
67 int main(int argc, const char *argv[])
68 {
69  if (argc < 2) {
70  printf("Usage: %s <data_file_to>\n", argv[0]);
71  exit(1);
72  }
73 
74  int exit_code = 0;
75 
77  builder.init();
78  if (!builder.bake_create_infos()) {
79  exit_code = 1;
80  }
81  builder.exit();
82  exit(exit_code);
83 
84  return exit_code;
85 }
void CLG_exit(void)
Definition: clog.c:703
void CLG_init(void)
Definition: clog.c:696
GHOST C-API function and type declarations.
GHOST_SystemHandle GHOST_CreateSystem(void)
Definition: GHOST_C-api.cpp:25
GHOST_TSuccess GHOST_DisposeOpenGLContext(GHOST_SystemHandle systemhandle, GHOST_ContextHandle contexthandle)
GHOST_TSuccess GHOST_ActivateOpenGLContext(GHOST_ContextHandle contexthandle)
GHOST_ContextHandle GHOST_CreateOpenGLContext(GHOST_SystemHandle systemhandle, GHOST_GLSettings glSettings)
GHOST_TSuccess GHOST_DisposeSystem(GHOST_SystemHandle systemhandle)
Definition: GHOST_C-api.cpp:40
struct GPUContext GPUContext
Definition: GPU_context.h:27
void GPU_context_discard(GPUContext *)
Definition: gpu_context.cc:110
GPUContext * GPU_context_create(void *ghost_window)
Definition: gpu_context.cc:93
void GPU_init(void)
Definition: gpu_init_exit.c:24
void GPU_exit(void)
Definition: gpu_init_exit.c:45
int main(int argc, const char *argv[])
Entry point for the shader_builder.
bool gpu_shader_create_info_compile_all()