OpenGL学习资料

OpenGL Tutorial

https://www.opengl-tutorial.org/
https://github.com/opengl-tutorials/ogl

https://www.leapreal.com/categories/theory/

GLTF

  • https://gltf-viewer-tutorial.gitlab.io/
  • https://gitlab.com/gltf-viewer-tutorial/gltf-viewer/-/tree/tutorial-cheat-v1/src?ref_type=heads

Documentation

  • https://docs.gl/

Text Rendering

  • https://devcodef1.com/news/1170796/qt-opengl-text-rendering

WebGL

  • https://webglfundamentals.org/webgl/lessons/zh_cn/webgl-fundamentals.html

Other OpenGL References

  • https://github.com/topics/modern-opengl
  • https://github.com/hotstreams/limitless-engine
  • https://github.com/ABRG-Models/morphologica
  • https://github.com/douysu/graphics-algorithm
  • https://github.com/wlxklyh/SoftRenderer
  • https://github.com/micro-gl/micro-gl
  • https://github.com/patriciogonzalezvivo/ada
  • https://github.com/a-e-k/canvas_ity
  • https://github.com/OGRECave/ogre-next
  • https://github.com/keith2018/SoftGLRender
  • https://github.com/ssloy/tinyrenderer
  • https://github.com/ssloy/tinyraytracer
  • https://github.com/mosra/magnum
  • https://github.com/GameFoundry/bsf
  • https://solarianprogrammer.com/2013/05/22/opengl-101-matrices-projection-view-model/
  • https://github.com/jehugaleahsa/mogl
  • https://github.com/rougier/tiny-renderer
  • https://github.com/bkaradzic/bgfx
  • https://ogldev.org/www/tutorial29/tutorial29.html
  • https://github.com/leaf3d/leaf3d
  • https://github.com/vikasgola/EaseOpenGL
  • https://micro-gl.github.io/docs/microgl/getting-started/features
  • https://github.com/huxingyi/dust3d
  • https://github.com/keith2018/SoftGLRender
  • https://github.com/Gargaj/Foxotron

Examples

A simple example on GLFW and GLEW:

MyWidget* w = nullptr;

static void cursor_position_callback(GLFWwindow* window, double xpos, double ypos)
{
	if (!w)
	{
		return;
	}

	//std::cout << "Cursor position: (" << xpos << ", " << ypos << ")\n";
	w->cursor_position_callback(xpos, ypos);
}

void mouse_button_callback(GLFWwindow* window, int button, int action, int mods)
{
	if (!w)
	{
		return;
	}

	double xpos, ypos;
	glfwGetCursorPos(window, &xpos, &ypos);

	if (button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_PRESS)
	{
		w->mousePressEvent(xpos, ypos);
	}
	else if (button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_RELEASE)
	{
		w->mouseReleaseEvent(xpos, ypos);
	}
}

int main(void)
{
	// Initialize GLFW
	glfwInit();

	// Open a window and create its OpenGL context
	window = glfwCreateWindow(1024, 768, "Tutorial 01", NULL, NULL);
	glfwMakeContextCurrent(window);

	// Initialize GLEW
	glewExperimental = true; // Needed for core profile
	glewInit();

	// Ensure we can capture the escape key being pressed below
	glfwSetInputMode(window, GLFW_STICKY_KEYS, GL_TRUE);
	glfwSetCursorPosCallback(window, cursor_position_callback);
	glfwSetMouseButtonCallback(window, mouse_button_callback);

	if (!w)
	{
		w = new MyWidget();
		//w.resizeGL(800, 600);
	}

	// Background color
	glClearColor(0.5f, 0.6f, 0.5f, 0.5f);

	do
	{
		// Clear the screen
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

		if (w)
		{
			w->paintGL();
		}

		// Swap buffers
		glfwSwapBuffers(window);
		glfwPollEvents();

	} // Check if the ESC key was pressed or the window was closed
	while ((glfwGetKey(window, GLFW_KEY_ESCAPE) != GLFW_PRESS) && glfwWindowShouldClose(window) == 0);

	// Close OpenGL window and terminate GLFW
	glfwTerminate();

	return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值