And finnaly i use winapi for do use graphic and remove sdl.
I do like that for draw:
// include the basic windows header file
#include <windows.h>
#include <stdio.h>
#include <math.h>
#include <time.h>
// Indice video for rotation's matrix
#define REPERE (LENGTH * (WIDTH/2 - 1)) + ((LENGTH/2 - 1))
#define BPP 4
#define LENGTH 1920 // x
#define WIDTH 1080 // y
#define DEPTH 800 // z
#define PITCH LENGTH * BPP
#define DEG2RAD(angle) angle * 0.01745329 // angle * (PI/180) (0.01745329)
#define RAPPORT (LENGTH/WIDTH)
#define FOCALE 45
#define PROFONDEUR 200
// Standard color for rendering scene (copy through ColorPic program)
#define WHITE 0x00FFFFFF
#define BLACK 0x00000000
#define RED 0x00FF0000
#define GREEN 0x0000FF00
#define BLUE 0x000000FF
#define BLUE_SCENE 0x0000204D
#define GREY_SCENE 0x001E1E22
#define MAP_GRID_SCENE 0x00585858
#define SELECT_OBJECT_SCENE 0x00FFA700
// Indice for array
#define _x 0
#define _y 1
#define _z 2
#define _color 3
#define __x 0
#define __y 4
#define __z 8
#define __color 12
int screen[LENGTH*WIDTH] = { 0 };
int FPS_COUNTER_DATA[3] = { 0 }; // 0: compteur_boucle & affiche_fps , 1: last_time
HINSTANCE instance;
HBITMAP texture;
PAINTSTRUCT paint_struct;
HDC device_context_screen;
HDC device_context_texture;
WNDCLASS windows_class;
HWND windows_handle;
MSG event;
LRESULT anwser;
LRESULT windows_procedure(HWND windows_handle, UINT message, WPARAM w_param_message, LPARAM l_param_message)
{
switch (message)
{
case WM_KEYDOWN:
switch (w_param_message)
{
case VK_ESCAPE:
PostMessage(windows_handle, WM_KEYUP, VK_ESCAPE, 0);
//SendMessage(windows_handle, WM_KEYUP, 0, 0);
break;
}
break;
}
anwser = DefWindowProc(windows_handle, message, w_param_message, l_param_message);
return anwser;
}
void upload_screen()
{
SetBitmapBits(texture, LENGTH * WIDTH * 4, screen);
SelectObject(device_context_texture, texture);
}
void init_video(void)
{
windows_class.cbClsExtra = 0;
windows_class.cbWndExtra = 0;
windows_class.hbrBackground = 0;
windows_class.hCursor = 0;
windows_class.hIcon = 0;
windows_class.hInstance = instance;
windows_class.lpfnWndProc = windows_procedure;
windows_class.lpszClassName = "Classe 1";
windows_class.lpszMenuName = NULL;
windows_class.style = CS_HREDRAW | CS_VREDRAW;
RegisterClass(&windows_class);
windows_handle = CreateWindow( "Classe 1",
"3D engine(HackOS)",
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
CW_USEDEFAULT, CW_USEDEFAULT, LENGTH, WIDTH,
NULL,
NULL,
instance,
NULL);
device_context_screen = GetDC(windows_handle);
texture = CreateCompatibleBitmap(device_context_screen, LENGTH, WIDTH);
device_context_texture = CreateCompatibleDC(device_context_screen);
}
int main(HINSTANCE _instance, HINSTANCE _previous_instance, LPSTR cmd_line, int cmd_show)
{
instance = _instance;
init_video();
while (1)
{
PeekMessage(&event, windows_handle, 0, 0, PM_REMOVE);
windows_procedure(windows_handle, event.message, event.wParam, event.lParam);
{...} /// Modify screen[]
BeginPaint(windows_handle, &paint_struct);
upload_screen();
BitBlt(device_context_screen, 0, 0, LENGTH, WIDTH, device_context_texture, 0, 0, SRCCOPY);
EndPaint(windows_handle, &paint_struct);
calculate_fps:
{
FPS_COUNTER_DATA[0]++;
if (clock() - FPS_COUNTER_DATA[1] >= 1000)
{
printf("FPS = %d\n", FPS_COUNTER_DATA[0]);
FPS_COUNTER_DATA[0] = 0;
FPS_COUNTER_DATA[1] = clock();
}
}
}
}
PS: Sorry for long waiting time for answer, it just take on my nerve all those problem :x