Jump to content
  • Advertisement
Sign in to follow this  
phil67rpg

OpenGL opengl 4.5

Recommended Posts

Posted (edited)

Hu, got a downvote for saying "get an introductory book and read the instructions". Strange times ...

 

Anyway, OP has the blue book. It comes with code examples. The setup and initialization of the environment is explained there and it is possible in a few lines of code even on Windows (with glfw for example), though i have not done that myself under windows. But a short search on the internet reveal that this should work.

The above code block is surely brave, but in OP's context unnecessary. The example code should compile with any up to date driver and if not someone still can help.

Edited by Green_Baron

Share this post


Link to post
Share on other sites
Advertisement
Posted (edited)

@phil67rpg, if you don't get the superbible examples to compile, despite of the use of a window handler like glfw3 and an OpenGL loader library like glad2, gl3w or glew and all the tutorials on the internet and the explanations in the accompanying readmes don't help either, then i humbly suggest to not spend any more time on trying and switch to another mode of doing.

Download the Godot Engine (Standard Version with GDScript), play through the tutorials, you can even find a pong demo project in the examples and demo projects. But first, the tutorials. Step by step, every day one step.

I am sure you'll get a feeling of accomplishment much easier (though it might still take a few months) than with all this tedious c++ stuff. Though at any point later you can come back to the lower level C++ and OpenGL, Godot is fully open sauce and c++ ...

 

Edited by Green_Baron

Share this post


Link to post
Share on other sites
Posted (edited)

Dear downvoter: on the danger of derailing, but for the sake of finding out what's possibly wrong, say, what exactly is the problem with my posts ?

- OpenGL 4.5 can be used in windows with the help of a window handler and a loader library without the need of performing OS specific gymnastics. Is that incorrect ? According to the Red Book (using OpenGL 4.5 in many cases) their examples were compiled with this technique. Source code online on github. Use of a window handler also makes input handling much easier and abstracts the platform specifics away. I must admit, since i am on Linux, i can not check that, but there are extensive "how to"s delivered with both the Red and the Blue book and i would assume that if these did not work, we'd know it. (Like was the case with missing code examples of the Vulkan Programming Guide).

- It seems to me that C++/Api programming is probably not the right approach to game programming for the original poster. A game engine could imo lead to success faster, or else we will continue to run in circles. My suggestion to @phil67rpg is to break the circles with the use of a game engine. Where is the problem with that ?

 

Edited by Green_Baron

Share this post


Link to post
Share on other sites
Posted (edited)
2 hours ago, Green_Baron said:

It seems to me that C++/Api programming is probably not the right approach to game programming for the original poster. A game engine could imo lead to success faster, or else we will continue to run in circles

I feel as I need to write again and take an additionl statement to my previous answer. In general you are right but what I absolutely don't like are answers that lead to the need of using some heavy third-party library without the explaination of why you should better use it 😊

The OP explicite asked in his second post how he can link GL 4.5 to Visual Studio and I answered exactly that and also referred to libraries as GLFW already do that for you. Just for notice.

So people be nice to each other and accepting different opinions lead to a better social feeling!

 

EDIT: I didn't downvote anyone but feel free if you think you need to rage downvote my opinion. It dosent matter nor will it change my statement

Edited by Shaarigan

Share this post


Link to post
Share on other sites
Posted (edited)
39 minutes ago, Shaarigan said:

I feel as I need to write again and take an additionl statement to my previous answer. In general you are right but what I absolutely don't like are answers that lead to the need of using some heavy third-party library without the explaination of why you should better use it 😊

This is not correct as stated. The why is explained in length & width in the introductory chapters of the books, especially the one the OP mentioned. I would not expect a reasonable person to not use these libraries and save a few hundred lines of platform specific code for window- and input handling, and that for Windows (different Versions), Linux (different window systems and surfaces), Android, Apple, whatever. GLFW (for example) slides in an abstraction layer to free a programmer from this tedious, time consuming, unproductive tasks and it used in the examples. Programming also means building on the work of others to come to a result quickly. That is my downvote to you.

Quote

The OP explicite asked in his second post how he can link GL 4.5 to Visual Studio and I answered exactly that and also referred to libraries as GLFW already do that for you. Just for notice.

The answer is in the introductory chapter and in the code examples of the book he owns, he only has to read and apply it. Your windowing code in great honour, but it isn't helpful because i doubt it will be understood (i may be wrong here) and it does not solve the problem of further window handling (resize and so on) and input handling (mouse, keyboard), all of which can be solved with a simple include and a few lines of code. A help for the OP will put him on a path of success without too many distractions over tedious sidework that can be avoided.

Quote

So people be nice to each other and accepting different opinions lead to a better social feeling!

I give that back. I have no problem with your way of addressing window code, it is slightly advanced, but unnecessary in this case. There are quicker and less demanding ways of solving the original question, which should be preferred.

 

Edit: clarification, because you accused me to introduce heavy weight third party libs and that is the reason for your downvotes: GLFW is not heavy weight and i didn't introduce anything. I simply said: read the instructions. GLFW is used as window/input handler in the example code of the SuperBilde as well as the Programming Guide, and btw. in learnopengl.com and others.

Edited by Green_Baron

Share this post


Link to post
Share on other sites

Oh. I thought you were the downvoter. A pity that it is not shown who votes what. Would make it easier to estimate people's alignments 😉

I took back my downvote, @Shaarigan.

Seems like our dispute is a perfect example for downvoting in general not being favourable for the quality of posts 😉

Share this post


Link to post
Share on other sites

Just as a small note:

1) moderators can see who downvotes, and can see any abuse of the system being performed. Incorporate that into your mental calculus in these matters.

2) there really is no need for upvotes or downvotes in a phil thread. Please, people, let's keep it civil in the hope that somebody might be able to finally get the light to turn on.

Share this post


Link to post
Share on other sites
Posted (edited)
36 minutes ago, GoliathForge said:

GDNet+ can see clearly also.

It's the only reason some people even get an account. ;)

LOL, Downvoted. Preacher telling the truth and it hurts.

Edited by fleabay

Share this post


Link to post
Share on other sites
Posted (edited)

He got downvoted 9 times alone in this thread, some of them just for posting. He is probably loosing interest - i am losing interest in helping when being cowardly downvoted for mentioning the documentation.

If phil insists on using C++/OpenGL 4.5 the first step is to set up the environment. Download glfw binaries, and either gl3w or glew. When going thru this i freely admit that it is more complicated for Windows than for Linux because of the Linux packaging systems and repositories.

It would be nice @phil67rpg, if you could confirm that this has been done.

Where-ever in VisualStudio you put your linker directives, include GL and GLEW and glfw (using g++ this is -lGLEW -lGL -lglfw) or gl3w instead of glew.

Then try this little program (i am on linux, could a friendly colleague with a windows environment and glew and glfw pls. confirm that this runs or eventually correct this ?) that just opens a window a closes it again, printing the reported version number in between:

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


int main() {	
	if( GL_TRUE != glfwInit() )
		std::cerr << "Error initialising glfw" << std::endl;

	// Window and context; we want OpenGL 4.5
	glfwWindowHint( GLFW_CONTEXT_VERSION_MAJOR, 4 );
	glfwWindowHint( GLFW_CONTEXT_VERSION_MINOR, 5 );
	glfwWindowHint( GLFW_CLIENT_API, GLFW_OPENGL_API );
	glfwWindowHint( GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE );

	GLFWwindow *w{ glfwCreateWindow( 800, 600, "Hello world", nullptr, nullptr ) };
	if( NULL == w )
		std::cerr << "Could not create glfw window\n" << std::endl;
	glfwMakeContextCurrent( w );
	glewExperimental = true;
	GLenum res{ glewInit() };
	if( GLEW_OK != res ) {
		std::cerr << glewGetErrorString( res ) << std::endl;
		std::cerr << "Error initialising glew" << std::endl;
	}

	GLint vmajor, vminor;
	glGetIntegerv( GL_MAJOR_VERSION, &vmajor );
	glGetIntegerv( GL_MINOR_VERSION, &vminor );
	std::cout << "OpenGL version " << vmajor << '.' << vminor << '\n';

  	// Here comes your code later !
  
  
	glfwDestroyWindow( w );
	glfwTerminate();

}	// ctor

If this works, you're ready to use OGL 4.5.

If you have problems at this stage understanding what's going on, then name them. Ignore cowardly downvotes 😉

 

We must find the tubercle 🙂

 

Edited by Green_Baron
took out sb7, too early

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!