graphics-imports.c 6.2 KB
Newer Older
J
jp9000 已提交
1 2 3 4 5
/******************************************************************************
    Copyright (C) 2013 by Hugh Bailey <obs.jim@gmail.com>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
6
    the Free Software Foundation, either version 2 of the License, or
J
jp9000 已提交
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/

#include "../util/base.h"
#include "../util/dstr.h"
#include "../util/platform.h"
#include "graphics-internal.h"

#define GRAPHICS_IMPORT(func) \
	do { \
		exports->func = os_dlsym(module, #func); \
		if (!exports->func) { \
			success = false; \
			blog(LOG_ERROR, "Could not load function '%s' from " \
			                "module '%s'", #func, module_name); \
		} \
	} while (false)

33 34 35 36 37
#define GRAPHICS_IMPORT_OPTIONAL(func) \
	do { \
		exports->func = os_dlsym(module, #func); \
	} while (false)

J
jp9000 已提交
38 39 40 41 42
bool load_graphics_imports(struct gs_exports *exports, void *module,
		const char *module_name)
{
	bool success = true;

J
jp9000 已提交
43
	GRAPHICS_IMPORT(device_preprocessor_name);
J
jp9000 已提交
44 45
	GRAPHICS_IMPORT(device_create);
	GRAPHICS_IMPORT(device_destroy);
46 47
	GRAPHICS_IMPORT(device_entercontext);
	GRAPHICS_IMPORT(device_leavecontext);
J
jp9000 已提交
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
	GRAPHICS_IMPORT(device_create_swapchain);
	GRAPHICS_IMPORT(device_resize);
	GRAPHICS_IMPORT(device_getsize);
	GRAPHICS_IMPORT(device_getwidth);
	GRAPHICS_IMPORT(device_getheight);
	GRAPHICS_IMPORT(device_create_texture);
	GRAPHICS_IMPORT(device_create_cubetexture);
	GRAPHICS_IMPORT(device_create_volumetexture);
	GRAPHICS_IMPORT(device_create_zstencil);
	GRAPHICS_IMPORT(device_create_stagesurface);
	GRAPHICS_IMPORT(device_create_samplerstate);
	GRAPHICS_IMPORT(device_create_vertexshader);
	GRAPHICS_IMPORT(device_create_pixelshader);
	GRAPHICS_IMPORT(device_create_vertexbuffer);
	GRAPHICS_IMPORT(device_create_indexbuffer);
	GRAPHICS_IMPORT(device_gettexturetype);
	GRAPHICS_IMPORT(device_load_vertexbuffer);
	GRAPHICS_IMPORT(device_load_indexbuffer);
	GRAPHICS_IMPORT(device_load_texture);
	GRAPHICS_IMPORT(device_load_samplerstate);
	GRAPHICS_IMPORT(device_load_vertexshader);
	GRAPHICS_IMPORT(device_load_pixelshader);
	GRAPHICS_IMPORT(device_load_defaultsamplerstate);
	GRAPHICS_IMPORT(device_getvertexshader);
	GRAPHICS_IMPORT(device_getpixelshader);
	GRAPHICS_IMPORT(device_getrendertarget);
	GRAPHICS_IMPORT(device_getzstenciltarget);
	GRAPHICS_IMPORT(device_setrendertarget);
	GRAPHICS_IMPORT(device_setcuberendertarget);
B
BtbN 已提交
77
	GRAPHICS_IMPORT(device_copy_texture_region);
J
jp9000 已提交
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
	GRAPHICS_IMPORT(device_copy_texture);
	GRAPHICS_IMPORT(device_stage_texture);
	GRAPHICS_IMPORT(device_beginscene);
	GRAPHICS_IMPORT(device_draw);
	GRAPHICS_IMPORT(device_load_swapchain);
	GRAPHICS_IMPORT(device_endscene);
	GRAPHICS_IMPORT(device_clear);
	GRAPHICS_IMPORT(device_present);
	GRAPHICS_IMPORT(device_setcullmode);
	GRAPHICS_IMPORT(device_getcullmode);
	GRAPHICS_IMPORT(device_enable_blending);
	GRAPHICS_IMPORT(device_enable_depthtest);
	GRAPHICS_IMPORT(device_enable_stenciltest);
	GRAPHICS_IMPORT(device_enable_stencilwrite);
	GRAPHICS_IMPORT(device_enable_color);
	GRAPHICS_IMPORT(device_blendfunction);
	GRAPHICS_IMPORT(device_depthfunction);
	GRAPHICS_IMPORT(device_stencilfunction);
	GRAPHICS_IMPORT(device_stencilop);
	GRAPHICS_IMPORT(device_setviewport);
	GRAPHICS_IMPORT(device_getviewport);
	GRAPHICS_IMPORT(device_setscissorrect);
	GRAPHICS_IMPORT(device_ortho);
	GRAPHICS_IMPORT(device_frustum);
	GRAPHICS_IMPORT(device_projection_push);
	GRAPHICS_IMPORT(device_projection_pop);

	GRAPHICS_IMPORT(swapchain_destroy);

	GRAPHICS_IMPORT(texture_destroy);
	GRAPHICS_IMPORT(texture_getwidth);
	GRAPHICS_IMPORT(texture_getheight);
	GRAPHICS_IMPORT(texture_getcolorformat);
	GRAPHICS_IMPORT(texture_map);
	GRAPHICS_IMPORT(texture_unmap);
113
	GRAPHICS_IMPORT_OPTIONAL(texture_isrect);
114
	GRAPHICS_IMPORT(texture_getobj);
J
jp9000 已提交
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165

	GRAPHICS_IMPORT(cubetexture_destroy);
	GRAPHICS_IMPORT(cubetexture_getsize);
	GRAPHICS_IMPORT(cubetexture_getcolorformat);

	GRAPHICS_IMPORT(volumetexture_destroy);
	GRAPHICS_IMPORT(volumetexture_getwidth);
	GRAPHICS_IMPORT(volumetexture_getheight);
	GRAPHICS_IMPORT(volumetexture_getdepth);
	GRAPHICS_IMPORT(volumetexture_getcolorformat);

	GRAPHICS_IMPORT(stagesurface_destroy);
	GRAPHICS_IMPORT(stagesurface_getwidth);
	GRAPHICS_IMPORT(stagesurface_getheight);
	GRAPHICS_IMPORT(stagesurface_getcolorformat);
	GRAPHICS_IMPORT(stagesurface_map);
	GRAPHICS_IMPORT(stagesurface_unmap);

	GRAPHICS_IMPORT(zstencil_destroy);

	GRAPHICS_IMPORT(samplerstate_destroy);

	GRAPHICS_IMPORT(vertexbuffer_destroy);
	GRAPHICS_IMPORT(vertexbuffer_flush);
	GRAPHICS_IMPORT(vertexbuffer_getdata);

	GRAPHICS_IMPORT(indexbuffer_destroy);
	GRAPHICS_IMPORT(indexbuffer_flush);
	GRAPHICS_IMPORT(indexbuffer_getdata);
	GRAPHICS_IMPORT(indexbuffer_numindices);
	GRAPHICS_IMPORT(indexbuffer_gettype);

	GRAPHICS_IMPORT(shader_destroy);
	GRAPHICS_IMPORT(shader_numparams);
	GRAPHICS_IMPORT(shader_getparambyidx);
	GRAPHICS_IMPORT(shader_getparambyname);
	GRAPHICS_IMPORT(shader_getparaminfo);
	GRAPHICS_IMPORT(shader_getviewprojmatrix);
	GRAPHICS_IMPORT(shader_getworldmatrix);
	GRAPHICS_IMPORT(shader_setbool);
	GRAPHICS_IMPORT(shader_setfloat);
	GRAPHICS_IMPORT(shader_setint);
	GRAPHICS_IMPORT(shader_setmatrix3);
	GRAPHICS_IMPORT(shader_setmatrix4);
	GRAPHICS_IMPORT(shader_setvec2);
	GRAPHICS_IMPORT(shader_setvec3);
	GRAPHICS_IMPORT(shader_setvec4);
	GRAPHICS_IMPORT(shader_settexture);
	GRAPHICS_IMPORT(shader_setval);
	GRAPHICS_IMPORT(shader_setdefault);

P
Palana 已提交
166
	/* OSX/Cocoa specific functions */
J
jp9000 已提交
167
#ifdef __APPLE__
P
Palana 已提交
168 169 170
	GRAPHICS_IMPORT_OPTIONAL(texture_create_from_iosurface);
	GRAPHICS_IMPORT_OPTIONAL(texture_rebind_iosurface);

J
jp9000 已提交
171 172 173 174 175 176 177 178
	/* win32 specific functions */
#elif _WIN32
	GRAPHICS_IMPORT(gdi_texture_available);
	GRAPHICS_IMPORT_OPTIONAL(device_create_gdi_texture);
	GRAPHICS_IMPORT_OPTIONAL(texture_get_dc);
	GRAPHICS_IMPORT_OPTIONAL(texture_release_dc);
#endif

J
jp9000 已提交
179 180
	return success;
}