Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,885 questions

51,811 answers

573 users

How to create window with specific size and color using OpenGL with C

1 Answer

0 votes
#include <stdio.h>

#include <GL/glew.h>
#include <GLFW/glfw3.h>

const GLint WIDTH = 800, HEIGHT = 600;

void error_callback(int error, const char* description) {
	puts(description);
}

int main() {

	glfwSetErrorCallback(error_callback);

	if (!glfwInit()) {
		printf("ERROR: GLFW failed to Initialize\n");
		return 1;
	}

	glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
	glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);

	GLFWwindow* window = glfwCreateWindow(WIDTH, HEIGHT, "Test Window", NULL, NULL);

		if (!window) {
		printf("ERROR: GLFW window creation falied!\n");
		glfwTerminate();
		return 1;
	}

	int bufferWidth, bufferHeigth;
	glfwGetFramebufferSize(window, &bufferWidth, &bufferHeigth);

	glfwMakeContextCurrent(window);

	if (glewInit() != GLEW_OK) {
		printf("ERROR: GLEW initialize falied!\n");
		glfwDestroyWindow(window);
		glfwTerminate();
		return 1;
	}

	glViewport(0, 0, bufferWidth, bufferHeigth);

	while (!glfwWindowShouldClose(window)) {
		glfwPollEvents();

		glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
		glClear(GL_COLOR_BUFFER_BIT);

		glfwSwapBuffers(window);
	}

	return 0;



	/*
	run:


	
	*/
}

 



answered May 13, 2021 by avibootz
...