gl-subsystem.c 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. /******************************************************************************
  2. Copyright (C) 2013 by Hugh Bailey <[email protected]>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. ******************************************************************************/
  14. #include "gl-subsystem.h"
  15. void convert_sampler_info(struct gs_sampler *sampler,
  16. struct gs_sampler_info *info)
  17. {
  18. convert_filter(info->filter, &sampler->min_filter,
  19. &sampler->mag_filter);
  20. sampler->address_u = convert_address_mode(info->address_u);
  21. sampler->address_v = convert_address_mode(info->address_v);
  22. sampler->address_w = convert_address_mode(info->address_w);
  23. sampler->max_anisotropy = info->max_anisotropy;
  24. }
  25. device_t device_create(struct gs_init_data *info)
  26. {
  27. struct gs_device *device = bmalloc(sizeof(struct gs_device));
  28. memset(device, 0, sizeof(struct gs_device));
  29. device->plat = gl_platform_create(device, info);
  30. if (!device->plat) {
  31. blog(LOG_ERROR, "device_create (GL) failed");
  32. bfree(device);
  33. return NULL;
  34. }
  35. return device;
  36. }
  37. void device_destroy(device_t device)
  38. {
  39. if (device) {
  40. gl_platform_destroy(device->plat);
  41. bfree(device);
  42. }
  43. }
  44. swapchain_t device_create_swapchain(device_t device, struct gs_init_data *info)
  45. {
  46. struct gs_swap_chain *swap = bmalloc(sizeof(struct gs_swap_chain));
  47. memset(swap, 0, sizeof(struct gs_swap_chain));
  48. swap->device = device;
  49. swap->info = *info;
  50. swap->wi = gl_windowinfo_create(info);
  51. if (!swap->wi) {
  52. blog(LOG_ERROR, "device_create_swapchain (GL) failed");
  53. swapchain_destroy(swap);
  54. return NULL;
  55. }
  56. return swap;
  57. }
  58. void device_resize(device_t device, uint32_t cx, uint32_t cy)
  59. {
  60. /* GL automatically resizes the device, so it doesn't do much */
  61. device->cur_swap->info.cx = cx;
  62. device->cur_swap->info.cy = cy;
  63. }
  64. void device_getsize(device_t device, uint32_t *cx, uint32_t *cy)
  65. {
  66. *cx = device->cur_swap->info.cx;
  67. *cy = device->cur_swap->info.cy;
  68. }
  69. uint32_t device_getwidth(device_t device)
  70. {
  71. return device->cur_swap->info.cx;
  72. }
  73. uint32_t device_getheight(device_t device)
  74. {
  75. return device->cur_swap->info.cy;
  76. }
  77. texture_t device_create_volumetexture(device_t device, uint32_t width,
  78. uint32_t height, uint32_t depth,
  79. enum gs_color_format color_format, uint32_t levels, void **data,
  80. uint32_t flags)
  81. {
  82. /* TODO */
  83. return NULL;
  84. }
  85. samplerstate_t device_create_samplerstate(device_t device,
  86. struct gs_sampler_info *info)
  87. {
  88. }
  89. vertbuffer_t device_create_vertexbuffer(device_t device,
  90. struct vb_data *data, uint32_t flags)
  91. {
  92. }
  93. indexbuffer_t device_create_indexbuffer(device_t device,
  94. enum gs_index_type type, void *indices, size_t num,
  95. uint32_t flags)
  96. {
  97. }
  98. enum gs_texture_type device_gettexturetype(device_t device,
  99. texture_t texture)
  100. {
  101. }
  102. void device_load_vertexbuffer(device_t device, vertbuffer_t vertbuffer)
  103. {
  104. }
  105. void device_load_indexbuffer(device_t device, indexbuffer_t indexbuffer)
  106. {
  107. }
  108. void device_load_texture(device_t device, texture_t tex, int unit)
  109. {
  110. }
  111. void device_load_cubetexture(device_t device, texture_t cubetex,
  112. int unit)
  113. {
  114. }
  115. void device_load_volumetexture(device_t device, texture_t voltex,
  116. int unit)
  117. {
  118. }
  119. void device_load_samplerstate(device_t device,
  120. samplerstate_t samplerstate, int unit)
  121. {
  122. }
  123. void device_load_vertexshader(device_t device, shader_t vertshader)
  124. {
  125. }
  126. void device_load_pixelshader(device_t device, shader_t pixelshader)
  127. {
  128. }
  129. void device_load_defaultsamplerstate(device_t device, bool b_3d,
  130. int unit)
  131. {
  132. }
  133. shader_t device_getvertexshader(device_t device)
  134. {
  135. }
  136. shader_t device_getpixelshader(device_t device)
  137. {
  138. }
  139. texture_t device_getrendertarget(device_t device)
  140. {
  141. }
  142. zstencil_t device_getzstenciltarget(device_t device)
  143. {
  144. }
  145. void device_setrendertarget(device_t device, texture_t tex,
  146. zstencil_t zstencil)
  147. {
  148. }
  149. void device_setcuberendertarget(device_t device, texture_t cubetex,
  150. int side, zstencil_t zstencil)
  151. {
  152. }
  153. void device_copy_texture(device_t device, texture_t dst, texture_t src)
  154. {
  155. }
  156. void device_beginscene(device_t device)
  157. {
  158. }
  159. void device_draw(device_t device, enum gs_draw_mode draw_mode,
  160. uint32_t start_vert, uint32_t num_verts)
  161. {
  162. }
  163. void device_endscene(device_t device)
  164. {
  165. }
  166. void device_load_swapchain(device_t device, swapchain_t swapchain)
  167. {
  168. }
  169. void device_clear(device_t device, uint32_t clear_flags,
  170. struct vec4 *color, float depth, uint8_t stencil)
  171. {
  172. }
  173. void device_present(device_t device)
  174. {
  175. }
  176. void device_setcullmode(device_t device, enum gs_cull_mode mode)
  177. {
  178. }
  179. enum gs_cull_mode device_getcullmode(device_t device)
  180. {
  181. }
  182. void device_enable_blending(device_t device, bool enable)
  183. {
  184. }
  185. void device_enable_depthtest(device_t device, bool enable)
  186. {
  187. }
  188. void device_enable_stenciltest(device_t device, bool enable)
  189. {
  190. }
  191. void device_enable_stencilwrite(device_t device, bool enable)
  192. {
  193. }
  194. void device_enable_color(device_t device, bool red, bool blue,
  195. bool green, bool alpha)
  196. {
  197. }
  198. void device_blendfunction(device_t device, enum gs_blend_type src,
  199. enum gs_blend_type dest)
  200. {
  201. }
  202. void device_depthfunction(device_t device, enum gs_depth_test test)
  203. {
  204. }
  205. void device_stencilfunction(device_t device, enum gs_stencil_side side,
  206. enum gs_depth_test test)
  207. {
  208. }
  209. void device_stencilop(device_t device, enum gs_stencil_side side,
  210. enum gs_stencil_op fail, enum gs_stencil_op zfail,
  211. enum gs_stencil_op zpass)
  212. {
  213. }
  214. void device_enable_fullscreen(device_t device, bool enable)
  215. {
  216. }
  217. int device_fullscreen_enabled(device_t device)
  218. {
  219. }
  220. void device_setdisplaymode(device_t device,
  221. const struct gs_display_mode *mode)
  222. {
  223. }
  224. void device_getdisplaymode(device_t device,
  225. struct gs_display_mode *mode)
  226. {
  227. }
  228. void device_setcolorramp(device_t device, float gamma, float brightness,
  229. float contrast)
  230. {
  231. }
  232. void device_setviewport(device_t device, int x, int y, int width,
  233. int height)
  234. {
  235. }
  236. void device_getviewport(device_t device, struct gs_rect *rect)
  237. {
  238. }
  239. void device_setscissorrect(device_t device, struct gs_rect *rect)
  240. {
  241. }
  242. void device_ortho(device_t device, float left, float right,
  243. float top, float bottom, float znear, float zfar)
  244. {
  245. }
  246. void device_frustum(device_t device, float left, float right,
  247. float top, float bottom, float znear, float zfar)
  248. {
  249. }
  250. void device_perspective(device_t device, float fovy, float aspect,
  251. float znear, float zfar)
  252. {
  253. }
  254. void device_set_view_matrix(device_t device, struct matrix3 *mat)
  255. {
  256. }
  257. void device_projection_push(device_t device)
  258. {
  259. }
  260. void device_projection_pop(device_t device)
  261. {
  262. }
  263. void swapchain_destroy(swapchain_t swapchain)
  264. {
  265. }
  266. void volumetexture_destroy(texture_t voltex)
  267. {
  268. }
  269. uint32_t volumetexture_getwidth(texture_t voltex)
  270. {
  271. }
  272. uint32_t volumetexture_getheight(texture_t voltex)
  273. {
  274. }
  275. uint32_t volumetexture_getdepth(texture_t voltex)
  276. {
  277. }
  278. enum gs_color_format volumetexture_getcolorformat(texture_t voltex)
  279. {
  280. }
  281. void samplerstate_destroy(samplerstate_t samplerstate)
  282. {
  283. }
  284. void vertexbuffer_destroy(vertbuffer_t vertbuffer)
  285. {
  286. }
  287. void vertexbuffer_flush(vertbuffer_t vertbuffer, bool rebuild)
  288. {
  289. }
  290. struct vb_data *vertexbuffer_getdata(vertbuffer_t vertbuffer)
  291. {
  292. }
  293. void indexbuffer_destroy(indexbuffer_t indexbuffer)
  294. {
  295. }
  296. void indexbuffer_flush(indexbuffer_t indexbuffer)
  297. {
  298. }
  299. void *indexbuffer_getdata(indexbuffer_t indexbuffer)
  300. {
  301. }
  302. size_t indexbuffer_numindices(indexbuffer_t indexbuffer)
  303. {
  304. }
  305. enum gs_index_type indexbuffer_gettype(indexbuffer_t indexbuffer)
  306. {
  307. }