[r45]: irr_tcc / virtual.c  Maximize  Restore  History

Download this file

153 lines (140 with data), 3.4 kB

  1
  2
  3
  4
  5
  6
  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
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 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
 77
 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
113
114
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
//~ #include <stdio.h>
#include <stdbool.h>
#include <windows.h>
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
typedef signed short s16;
typedef signed int s32;
typedef char c8;
typedef float f32;
typedef double f64;
typedef enum
{
EIDT_WIN32,
EIDT_WINCE,
EIDT_X11,
EIDT_OSX,
EIDT_SDL,
EIDT_FRAMEBUFFER,
EIDT_CONSOLE,
EIDT_BEST
} E_DEVICE_TYPE;
typedef enum
{
EDT_NULL,
EDT_SOFTWARE,
EDT_BURNINGSVIDEO,
EDT_DIRECT3D8,
EDT_DIRECT3D9,
EDT_OPENGL,
EDT_COUNT
} E_DRIVER_TYPE;
typedef enum
{
ELL_INFORMATION,
ELL_WARNING,
ELL_ERROR,
ELL_NONE
} ELOG_LEVEL;
typedef enum
{
ECF_A1R5G5B5 = 0,
ECF_R5G6B5,
ECF_R8G8B8,
ECF_A8R8G8B8,
ECF_R16F,
ECF_G16R16F,
ECF_A16B16G16R16F,
ECF_R32F,
ECF_G32R32F,
ECF_A32B32G32R32F,
ECF_UNKNOWN
} ECOLOR_FORMAT;
typedef struct
{
E_DEVICE_TYPE DeviceType;
E_DRIVER_TYPE DriverType;
void* WindowSize;
u8 Bits;
u8 ZBufferBits;
bool Fullscreen;
bool Stencilbuffer;
bool Vsync;
u8 AntiAlias;
bool WithAlphaChannel;
bool Doublebuffer;
bool IgnoreInput;
bool Stereobuffer;
bool HighPrecisionFPU;
void* EventReceiver;
void* WindowId;
ELOG_LEVEL LoggingLevel;
const c8* const SDK_version_do_not_use;
} SIrrlichtCreationParameters;
typedef struct{u32 Width; u32 Height;} dimension2du;
typedef struct{u32 color;} SColor;
typedef struct IDirect3D9;
typedef struct IDirect3DDevice9;
typedef struct IDirect3D8;
typedef struct IDirect3DDevice8;
typedef struct
{
union
{
struct
{
//~ IDirect3D9* D3D9;
//~ IDirect3DDevice9* D3DDev9;
void* HWnd;
} D3D9;
struct
{
//~ IDirect3D8* D3D8;
//~ IDirect3DDevice8* D3DDev8;
void* HWnd;
} D3D8;
struct
{
void* HDc;
void* HRc;
void* HWnd;
} OpenGLWin32;
struct
{
void* X11Display;
void* X11Context;
unsigned long X11Window;
} OpenGLLinux;
};
} SExposedVideoData;
void* createDevice(E_DRIVER_TYPE deviceType, const dimension2du* windowSize, u32 bits, bool fullscreen, bool stencilbuffer, bool vsync, void* receiver);
void* createDeviceEx(const SIrrlichtCreationParameters* parameters);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
//~ SColor color;
//~ color.color = 0x0000FF;
dimension2du windowSize;
windowSize.Width = 320;
windowSize.Height = 240;
void* device = createDevice(EDT_SOFTWARE, &windowSize, 16, false, false, false, NULL);
int* vptr_device = *(int**)device;
//~ asm volatile ("movl %0, %%ecx;" : : "a" (device));
//~ printf("Irrlicht version %s\n", ((const c8*(*)())vptr_device[22])());
MessageBox(0, ((const c8*(*)())vptr_device[22])(), "Irrlicht version", MB_ICONINFORMATION);
//~ void* video_driver = ((void*(*)())vptr_device[3])();
//~ int* vptr_video_driver = *(int**)video_driver;
//~ asm volatile ("movl %0, %%ecx;" : : "a" (video_driver));
//~ void* scene_manager = ((void*(*)())vptr_device[6])();
//~ int* vptr_scene_manager = *(int**)scene_manager;
//~ while (((bool(*)())vptr_device[0])())
//~ {
//~ ((bool(*)())vptr_video_driver[0])(true, true, color);
//~ ((void(*)())vptr_scene_manager[45])();
//~ ((bool(*)())vptr_video_driver[1])();
//~ ((void(*)())vptr_device[1])();//yield
//~ ((void(*)())vptr_device[2])(100, false);//sleep
//~ }
//~ ((void(*)())vptr_device[21])();
return 0;
}