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   |
 |
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,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.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
|
|
|
 |
|
UltimateOpenGL [BETA] 3D engine
By: Xemuth on Mon, 18 November 2019 15:45
|
 |
|
Re: UltimateOpenGL [BETA] 3D motor
By: koldo on Mon, 18 November 2019 19:53
|
 |
|
Re: UltimateOpenGL [BETA] 3D Engine
By: Xemuth on Mon, 18 November 2019 20:06
|
 |
|
Re: UltimateOpenGL [BETA] 3D motor
By: Klugier on Mon, 18 November 2019 22:42
|
 |
|
Re: UltimateOpenGL [BETA] 3D motor
By: koldo on Tue, 19 November 2019 08:10
|
 |
|
Re: UltimateOpenGL [BETA] 3D motor
By: koldo on Tue, 19 November 2019 09:06
|
 |
|
Re: UltimateOpenGL [BETA] 3D Engine
By: Xemuth on Tue, 19 November 2019 21:44
|
 |
|
Re: UltimateOpenGL [BETA] 3D Engine
By: Xemuth on Tue, 19 November 2019 21:43
|
 |
|
Re: UltimateOpenGL [BETA] 3D Engine
By: Xemuth on Tue, 19 November 2019 21:32
|
 |
|
Re: UltimateOpenGL [BETA] 3D Engine
By: Xemuth on Fri, 22 November 2019 21:41
|
 |
|
Re: UltimateOpenGL [BETA] 3D engine
By: Xemuth on Mon, 02 December 2019 14:56
|
 |
|
Re: UltimateOpenGL [BETA] 3D engine
By: Xemuth on Tue, 03 December 2019 23:42
|
 |
|
Re: UltimateOpenGL [BETA] 3D engine
By: koldo on Thu, 02 January 2020 18:16
|
 |
|
Re: UltimateOpenGL [BETA] 3D engine
By: Xemuth on Thu, 02 January 2020 18:22
|
Goto Forum:
Current Time: Sun Aug 31 02:58:29 CEST 2025
Total time taken to generate the page: 0.05464 seconds
|