<commit_before>//#include <stdio.h>
//#include<Model.hpp>
//
//
//int main()
//{
//	printf("Hello World!\n");
//	Model model;
//	model.Import("spider.fbx");
//	model.Import("spider.fbx");
//	getchar();
//	return 0;
//}


#include <stdio.h>
#include <GL/glew.h>

#include <SDL/SDL.h>
#include <SDL/SDL_image.h>

#include <Camera.hpp>
#include<Model.hpp>
#include<VAO.hpp>
#include <VBO.hpp>
#include <ShaderProgram.hpp>
//extern "C" { FILE __iob_func[3] = { *stdin,*stdout,*stderr }; }
//#pragma comment(lib, "legacy_stdio_definitions.lib") 

#include<vector>

void renderTexture(SDL_Texture *tex, SDL_Renderer *ren, int x, int y){
	//Setup the destination rectangle to be at the position we want
	SDL_Rect dst;
	dst.x = x;
	dst.y = y;
	//Query the texture to get its width and height to use
	SDL_QueryTexture(tex, NULL, NULL, &dst.w, &dst.h);
	SDL_RenderCopy(ren, tex, NULL, &dst);
}

static const float vertex_list[] =
{
	-0.5f, -0.5f, -0.5f,
	0.5f, -0.5f, -0.5f,
	-0.5f, 0.5f, -0.5f,
	0.5f, 0.5f, -0.5f,
	-0.5f, -0.5f, 0.5f,
	0.5f, -0.5f, 0.5f,
	-0.5f, 0.5f, 0.5f,
	0.5f, 0.5f, 0.5f,
};


static const GLint index_list[] =
{
	0, 1,
	2, 3,
	4, 5,
	6, 7,
	0, 2,
	1, 3,
	4, 6,
	5, 7,
	0, 4,
	1, 5,
	7, 3,
	2, 6
};
Camera *camera;
void initCamera(){
	Vector3d pos(0.0, 0.0, 12.0);
	Vector3d target(0.0, 0.0, 0.0);
	Vector3d up(0.0, 1.0, 0.0);
	camera = new Camera(pos, target, up);

}


void RotateX(float angle)
{
	float d = camera->getDist();
	int cnt = 100;
	float theta = angle / cnt;
	float slide_d = -2 * d*sin(theta*3.14159265 / 360);
	camera->yaw(theta / 2);
	for (; cnt != 0; --cnt)
	{
		camera->slide(slide_d, 0, 0);
		camera->yaw(theta);
	}
	camera->yaw(-theta / 2);
}

void RotateY(float angle)
{
	float d = camera->getDist();
	int cnt = 100;
	float theta = angle / cnt;
	float slide_d = 2 * d*sin(theta*3.14159265 / 360);
	camera->pitch(theta / 2);
	for (; cnt != 0; --cnt)
	{
		camera->slide(0, slide_d, 0);
		camera->pitch(theta);
	}
	camera->pitch(-theta / 2);
}

int main(int argc, char* args[])
{
	SDL_Window	*pWindow = NULL;
	SDL_Renderer*pRenderer = NULL;
	int win_width = 640, win_height = 480;
	// 1. initialize SDL
	if (SDL_Init(SDL_INIT_EVERYTHING) < 0)
	{
		printf("SDL initialize fail:%s\n", SDL_GetError());
		return 1;
	}

	SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
	SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
	// 2. create window
	pWindow = SDL_CreateWindow("LuaSDL",
		SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
		win_width, win_height,
		SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN);
	if (NULL == pWindow)
	{
		printf("Create window fail:%s\n", SDL_GetError());
	}

	SDL_GLContext glcontext = SDL_GL_CreateContext(pWindow);
	pRenderer = SDL_CreateRenderer(pWindow, -1, 0);
	glewInit();

	initCamera();

	glEnable(GL_DEPTH_TEST);
	glDepthRange(0.0, 10.0);
	glDepthFunc(GL_LEQUAL);
	glClearDepth(10.0);
	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

	Model model;
	model.Import("spider.fbx");

	//float tmp[100] = { 0 };
	//memcpy((void *)tmp, loder.mesh.buff.data, loder.mesh.buff.data_size);

	VAO g_vao;
	g_vao.init();
	const aiMesh* paiMesh = model.scene->mMeshes[0];
	cout << " "<<paiMesh->mNumVertices <<endl;

	int index = g_vao.newVBO(paiMesh->mNumVertices * 3*sizeof(float), (void *)paiMesh->mVertices);
	//int index = g_vao.newVBO(sizeof(vertex_list)*sizeof(float),(void *) vertex_list);

	glEnableVertexAttribArray(0);//????vbo
	glVertexAttribPointer((GLuint)0, 3, GL_FLOAT, true, 0, 0);
	//
	//	int ele_index[] = { 0, 1, 2, 4,5,6  ,7};
	ShaderProgram SP;
	int programShader = SP.buildShader("vert.txt", "frag.txt");
	glUseProgram(programShader);

	float uv1[] = {<commit_msg>只支持 单个mesh 的代码<commit_after>//#include <stdio.h>
//#include<Model.hpp>
//
//
//int main()
//{
//	printf("Hello World!\n");
//	Model model;
//	model.Import("spider.fbx");
//	model.Import("spider.fbx");
//	getchar();
//	return 0;
//}


#include <stdio.h>
#include <GL/glew.h>

#include <SDL/SDL.h>
#include <SDL/SDL_image.h>

#include <Camera.hpp>
#include<Model.hpp>
#include<VAO.hpp>
#include <VBO.hpp>
#include <ShaderProgram.hpp>
//extern "C" { FILE __iob_func[3] = { *stdin,*stdout,*stderr }; }
//#pragma comment(lib, "legacy_stdio_definitions.lib") 

#include<vector>

void renderTexture(SDL_Texture *tex, SDL_Renderer *ren, int x, int y){
	//Setup the destination rectangle to be at the position we want
	SDL_Rect dst;
	dst.x = x;
	dst.y = y;
	//Query the texture to get its width and height to use
	SDL_QueryTexture(tex, NULL, NULL, &dst.w, &dst.h);
	SDL_RenderCopy(ren, tex, NULL, &dst);
}

static const float vertex_list[] =
{
	-0.5f, -0.5f, -0.5f,
	0.5f, -0.5f, -0.5f,
	-0.5f, 0.5f, -0.5f,
	0.5f, 0.5f, -0.5f,
	-0.5f, -0.5f, 0.5f,
	0.5f, -0.5f, 0.5f,
	-0.5f, 0.5f, 0.5f,
	0.5f, 0.5f, 0.5f,
};


static const GLint index_list[] =
{
	0, 1,
	2, 3,
	4, 5,
	6, 7,
	0, 2,
	1, 3,
	4, 6,
	5, 7,
	0, 4,
	1, 5,
	7, 3,
	2, 6
};
Camera *camera;
void initCamera(){
	Vector3d pos(0.0, 0.0, 12.0);
	Vector3d target(0.0, 0.0, 0.0);
	Vector3d up(0.0, 1.0, 0.0);
	camera = new Camera(pos, target, up);

}


void RotateX(float angle)
{
	float d = camera->getDist();
	int cnt = 100;
	float theta = angle / cnt;
	float slide_d = -2 * d*sin(theta*3.14159265 / 360);
	camera->yaw(theta / 2);
	for (; cnt != 0; --cnt)
	{
		camera->slide(slide_d, 0, 0);
		camera->yaw(theta);
	}
	camera->yaw(-theta / 2);
}

void RotateY(float angle)
{
	float d = camera->getDist();
	int cnt = 100;
	float theta = angle / cnt;
	float slide_d = 2 * d*sin(theta*3.14159265 / 360);
	camera->pitch(theta / 2);
	for (; cnt != 0; --cnt)
	{
		camera->slide(0, slide_d, 0);
		camera->pitch(theta);
	}
	camera->pitch(-theta / 2);
}

int main(int argc, char* args[])
{
	SDL_Window	*pWindow = NULL;
	SDL_Renderer*pRenderer = NULL;
	int win_width = 640, win_height = 480;
	// 1. initialize SDL
	if (SDL_Init(SDL_INIT_EVERYTHING) < 0)
	{
		printf("SDL initialize fail:%s\n", SDL_GetError());
		return 1;
	}

	SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
	SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
	// 2. create window
	pWindow = SDL_CreateWindow("LuaSDL",
		SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
		win_width, win_height,
		SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN);
	if (NULL == pWindow)
	{
		printf("Create window fail:%s\n", SDL_GetError());
	}

	SDL_GLContext glcontext = SDL_GL_CreateContext(pWindow);
	pRenderer = SDL_CreateRenderer(pWindow, -1, 0);
	glewInit();

	initCamera();

	glEnable(GL_DEPTH_TEST);
	glDepthRange(0.0, 10.0);
	glDepthFunc(GL_LEQUAL);
	glClearDepth(10.0);
	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

	Model model;
	model.Import("box.fbx");

	//float tmp[100] = { 0 };
	//memcpy((void *)tmp, loder.mesh.buff.data, loder.mesh.buff.data_size);

	VAO g_vao;
	g_vao.init();
	const aiMesh* paiMesh = model.scene->mMeshes[0];
	cout << " "<<paiMesh->mNumVertices <<endl;

	int index = g_vao.newVBO(paiMesh->mNumVertices * 3*sizeof(float), (void *)paiMesh->mVertices);
	//int index = g_vao.newVBO(sizeof(vertex_list)*sizeof(float),(void *) vertex_list);

	glEnableVertexAttribArray(0);//????vbo
	glVertexAttribPointer((GLuint)0, 3, GL_FLOAT, true, 0, 0);
	//
	//	int ele_index[] = { 0, 1, 2, 4,5,6  ,7};
	ShaderProgram SP;
	int programShader = SP.buildShader("vert.txt", "frag.txt");
	glUseProgram(programShader);

	float uv1[] = {
{'fraction_non_alphanumeric': 0.18903957929698312, 'fraction_numerical': 0.049820094104622195, 'mean_word_length': 3.8864097363083165, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1099223', 'n_tokens_mistral': 3508, 'n_tokens_neox': 3203, 'n_words': 682}