Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Extra libraries, Code snippets, applications etc. » Applications created with U++ » UltimateOpenGL [BETA] 3D engine (A 3D engine to make game)
Re: UltimateOpenGL [BETA] 3D Engine [message #52774 is a reply to message #52752] Fri, 22 November 2019 21:41 Go to previous messageGo to previous message
Xemuth is currently offline  Xemuth
Messages: 387
Registered: August 2018
Location: France
Senior Member
Hello !

Here you can find an exemple of UltimateOpenGL working with GLCtrl of Upp :
#include <CtrlLib/CtrlLib.h>
#include <GLCtrl/GLCtrl.h>
#include <UltimateOpenGL_V2/UltimateOpenGL.h>
using namespace Upp;

struct OpenGLExample : GLCtrl {
	Point point;
	
	String TransformFilePath(String FilePath){
		String FilePathBuffer = String(__FILE__);
		String FilePathTempory ="";
		FilePathBuffer = Replace(FilePathBuffer,Vector<String>{"\\"},Vector<String>{"/"});
		
		Replace(FilePath,Vector<String>{"\\"},Vector<String>{"/"});
		FilePathTempory  = FilePathBuffer.Left(FilePathBuffer.ReverseFind("/")) + FilePath;
		if(!FileExists(FilePathTempory)){
			return (GetExeFolder()  +FilePath);	
		}
		return FilePathTempory;
	}
		
	Vector<float> CubeVertices{
	    -0.2f, -0.2f, -0.2f, 0.0f,0.0f,-0.4f, 0.0f, 0.0f,
	     0.2f, -0.2f, -0.2f, 0.0f,0.0f,-0.4f, 1.0f, 0.0f,
	     0.2f,  0.2f, -0.2f, 0.0f,0.0f,-0.4f, 1.0f, 1.0f,
	     0.2f,  0.2f, -0.2f, 0.0f,0.0f,-0.4f, 1.0f, 1.0f,
	    -0.2f,  0.2f, -0.2f, 0.0f,0.0f,-0.4f, 0.0f, 1.0f,
	    -0.2f, -0.2f, -0.2f, 0.0f,0.0f,-0.4f, 0.0f, 0.0f,
	
	    -0.2f, -0.2f,  0.2f, 0.0f,0.0f, 0.4f, 0.0f, 0.0f,
	     0.2f, -0.2f,  0.2f, 0.0f,0.0f, 0.4f, 1.0f, 0.0f,
	     0.2f,  0.2f,  0.2f, 0.0f,0.0f, 0.4f, 1.0f, 1.0f,
	     0.2f,  0.2f,  0.2f, 0.0f,0.0f, 0.4f, 1.0f, 1.0f,
	    -0.2f,  0.2f,  0.2f, 0.0f,0.0f, 0.4f, 0.0f, 1.0f,
	    -0.2f, -0.2f,  0.2f, 0.0f,0.0f, 0.4f, 0.0f, 0.0f, 
	
	    -0.2f,  0.2f,  0.2f,  -0.4f,  0.0f,  0.0f, 1.0f, 0.0f,
	    -0.2f,  0.2f, -0.2f,   -0.4f,  0.0f,  0.0f,1.0f, 1.0f,
	    -0.2f, -0.2f, -0.2f,   -0.4f,  0.0f,  0.0f,0.0f, 1.0f,
	    -0.2f, -0.2f, -0.2f,   -0.4f,  0.0f,  0.0f,0.0f, 1.0f,
	    -0.2f, -0.2f,  0.2f,   -0.4f,  0.0f,  0.0f,0.0f, 0.0f,
	    -0.2f,  0.2f,  0.2f,   -0.4f,  0.0f,  0.0f,1.0f, 0.0f,
	
	     0.2f,  0.2f,  0.2f,   0.4f,  0.0f,  0.0f,1.0f, 0.0f,
	     0.2f,  0.2f, -0.2f,   0.4f,  0.0f,  0.0f,1.0f, 1.0f,
	     0.2f, -0.2f, -0.2f,   0.4f,  0.0f,  0.0f,0.0f, 1.0f,
	     0.2f, -0.2f, -0.2f,   0.4f,  0.0f,  0.0f,0.0f, 1.0f,
	     0.2f, -0.2f,  0.2f,   0.4f,  0.0f,  0.0f,0.0f, 0.0f,
	     0.2f,  0.2f,  0.2f,   0.4f,  0.0f,  0.0f,1.0f, 0.0f,
	
	    -0.2f, -0.2f, -0.2f,    0.0f, -0.4f,  0.0f,0.0f, 1.0f,
	     0.2f, -0.2f, -0.2f,    0.0f, -0.4f,  0.0f,1.0f, 1.0f,
	     0.2f, -0.2f,  0.2f,    0.0f, -0.4f,  0.0f,1.0f, 0.0f,
	     0.2f, -0.2f,  0.2f,    0.0f, -0.4f,  0.0f,1.0f, 0.0f,
	    -0.2f, -0.2f,  0.2f,    0.0f, -0.4f,  0.0f,0.0f, 0.0f,
	    -0.2f, -0.2f, -0.2f,    0.0f, -0.4f,  0.0f,0.0f, 1.0f,
	
	    -0.2f,  0.2f, -0.2f,    0.0f,  0.4f,  0.0f,0.0f, 1.0f,
	     0.2f,  0.2f, -0.2f,    0.0f,  0.4f,  0.0f,1.0f, 1.0f,
	     0.2f,  0.2f,  0.2f,   0.0f,  0.4f,  0.0f,1.0f, 0.0f, 
	     0.2f,  0.2f,  0.2f,   0.0f,  0.4f,  0.0f, 1.0f, 0.0f,
	    -0.2f,  0.2f,  0.2f,    0.0f,  0.4f,  0.0f,0.0f, 0.0f,
	    -0.2f,  0.2f, -0.2f,    0.0f,  0.4f,  0.0f,0.0f, 1.0f
	};
	
	UltimateOpenGL_Context context;
	bool isLoaded = false;


	virtual void GLPaint() {
		if(!isLoaded){
			glEnable(GL_DEPTH_TEST);
   		    glEnable(GL_MULTISAMPLE);   
    		context.SetScreenSize(GetSize().cx,GetSize().cy);
			Scene& presentation = context.AddScene("presentation"); //Create Scene 
		    unsigned int camera = presentation.AddCamera(); //Adding camera to the scene
		    Object3D& cube = presentation.CreateGameObject<Object3D>("cube",CubeVertices); //Adding the cube
		    context.AddTextures("upp",TransformFilePath("/texture/upp.png"),SAMPLE_RGB);
		    cube.BindTexture("upp",0.64f);
		    
		    cube.GetTransform().SetNewPosition(glm::vec3(0.0f,0.0f,-1.0f)); // move the cube forward the camera
		    presentation.Load(); //Loading the scene
		    
		    cube.SetOnDrawFunction([](GameObject& myGameObject){
	    		myGameObject.GetTransform(). RotateFromEulerAngles(0.5* myGameObject.GetScene()->GetContext()->GetDeltaTime(),glm::vec3(1.0f,1.0f,1.0f)); // rotating of 0.001 degree every frame1
	    	});	
	   
	    	GameObject& sun =  presentation.CreateGameObject<GameObject>("sun");
	
			sun.AddDirLight("lightSun",DirLight(glm::vec3(0.0f,-1.0f,0.0f),glm::vec3( 0.5f, 0.5f, 0.5f),glm::vec3(0.9f, 0.9f, 0.9f) ,glm::vec3(0.5f, 0.5f, 0.5f)));
			sun.GetTransform().SetNewPosition(glm::vec3(0.0f,3.0f,0.0f));
	    	
	    	isLoaded=true;
		}
		this->GetTopWindow()->Title("UltimateOpenGL UPP GLCtrl - " + AsString(context.GetFPS())  + " FPS");
		
		context.Draw(); //Drawing the context (active scene)
		Refresh();
	
		glEnd();
	}
};

GUI_APP_MAIN
{
	Ctrl::GlobalBackPaint();
	TopWindow win;
	OpenGLExample gl;
	gl.SetFrame(InsetFrame());
	win.Add(gl.HSizePos(10, 10).VSizePos(10, 10));
	win.NoSizeable();
	
	win.SetRect(0, 0, 320, 320);
	win.Open();
	win.Run();
}


Here you can find package with texture and .exe :

[Updated on: Thu, 05 December 2019 13:06]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Bot library for discord, bombs example adapted.
Next Topic: BEMRosetta
Goto Forum:
  


Current Time: Sun Aug 31 02:58:29 CEST 2025

Total time taken to generate the page: 0.05464 seconds