Skip to content

Commit

Permalink
example 0027
Browse files Browse the repository at this point in the history
  • Loading branch information
devel0 committed Aug 21, 2023
1 parent ba64af6 commit 86e41ff
Show file tree
Hide file tree
Showing 8 changed files with 115 additions and 30 deletions.
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/examples/example-0025/bin/Debug/net7.0/example-0025.dll",
"program": "${workspaceFolder}/examples/example-0027/bin/Debug/net7.0/example-0027.dll",
"args": [],
"cwd": "${workspaceFolder}/examples/example-0025",
"cwd": "${workspaceFolder}/examples/example-0027",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
Expand Down
6 changes: 3 additions & 3 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"type": "process",
"args": [
"build",
"${workspaceFolder}/examples/example-0025/example-0025.csproj",
"${workspaceFolder}/examples/example-0022/example-0022.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
Expand All @@ -19,7 +19,7 @@
"type": "process",
"args": [
"publish",
"${workspaceFolder}/examples/example-0025/example-0025.csproj",
"${workspaceFolder}/examples/example-0022/example-0022.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
Expand All @@ -33,7 +33,7 @@
"watch",
"run",
"--project",
"${workspaceFolder}/examples/example-0025/example-0025.csproj"
"${workspaceFolder}/examples/example-0022/example-0022.csproj"
],
"problemMatcher": "$msCompile"
}
Expand Down
60 changes: 35 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,37 @@

<hr/>

<!-- TOC -->
* [Introduction](#introduction)
* [Quickstart](#quickstart)
* [Build solution](#build-solution)
* [Examples](#examples)
+ [Running examples from console](#running-examples-from-console)
+ [Running examples from vscode](#running-examples-from-vscode)
+ [List of examples](#list-of-examples)
* [Development key notes](#development-key-notes)
+ [Coordinate spaces](#coordinate-spaces)
+ [GL Dev inspect tool](#gl-dev-inspect-tool)
+ [Primitives, figures interaction](#primitives-figures-interaction)
- [Introduction](#introduction)
- [Quickstart](#quickstart)
- [Build solution](#build-solution)
- [Examples](#examples)
- [Running examples from console](#running-examples-from-console)
- [Running examples from vscode](#running-examples-from-vscode)
- [List of examples](#list-of-examples)
- [Development key notes](#development-key-notes)
- [Coordinate spaces](#coordinate-spaces)
- [GL Dev inspect tool](#gl-dev-inspect-tool)
- [Primitives, figures interaction](#primitives-figures-interaction)
- [Selection and coord identify](#selection-and-coord-identify)
- [Removal](#removal)
- [SimpleCmd](#simplecmd)
- [Change rotation center](#change-rotation-center)
+ [Send notification](#send-notification)
+ [View invalidation model](#view-invalidation-model)
+ [Opengl debugging tools](#opengl-debugging-tools)
+ [Multiplatform](#multiplatform)
+ [Docker (mesa)](#docker-mesa)
+ [Software rendered (mesa)](#software-rendered-mesa)
+ [C# global usings (full)](#c%23-global-usings-full)
+ [Gestures](#gestures)
- [Send notification](#send-notification)
- [View invalidation model](#view-invalidation-model)
- [Opengl debugging tools](#opengl-debugging-tools)
- [Multiplatform](#multiplatform)
- [Docker (mesa)](#docker-mesa)
- [Software rendered (mesa)](#software-rendered-mesa)
- [C# global usings (full)](#c-global-usings-full)
- [Gestures](#gestures)
- [Mouse gestures](#mouse-gestures)
- [Keybindings](#keybindings)
* [Unit tests](#unit-tests)
* [How this project was built](#how-this-project-was-built)
+ [Documentation (github pages)](#documentation-github-pages)
- [Unit tests](#unit-tests)
- [How this project was built](#how-this-project-was-built)
- [Documentation (github pages)](#documentation-github-pages)
- [Build and view locally](#build-and-view-locally)
- [Build and commit into docs branch](#build-and-commit-into-docs-branch)
* [References](#references)
<!-- TOCEND -->
- [References](#references)

<hr/>

Expand Down Expand Up @@ -396,6 +394,14 @@ Shows 2 triangle intersection and SimpleCmd management.

[![img][e26]][e26]

<hr/>

Code: [0027][es27]

Shows earth representation through a textured uv sphere.

[![img][e27]][e27]

## Development key notes

Most of technical documentation is directly integrated with [API documentation](https://devel0.github.io/netcore-opengl/html/annotated.html).
Expand Down Expand Up @@ -821,6 +827,8 @@ Configured through Settings/Pages on Branch docs ( path /docs ).
[es24]: examples/example-0024/Program.cs
[es25]: examples/example-0025/Program.cs
[es26]: examples/example-0026/Views/MainWindow.axaml.cs
[es27]: examples/example-0027/Program.cs

[e0]: data/images/examples/0000.png
[e1]: data/images/examples/0001.png
[e2]: data/images/examples/0002.png
Expand All @@ -847,4 +855,6 @@ Configured through Settings/Pages on Branch docs ( path /docs ).
[e24]: data/images/examples/0024.png
[e25]: data/images/examples/0025.png
[e26]: data/images/examples/0026.png
[e27]: data/images/examples/0027.png

[FeasibleTriIntersectionTests]: https://github.com/devel0/netcore-opengl/blob/0ce534f6fcbb62279d814b0eca08f5be97ec8f98/src/core/primitive/IGLTriangle.cs#L113
Binary file added data/images/examples/0027.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions examples/example-0027/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// example-0027
// earth sphere ( console program )
//
// - rotate earth sphere

InitAvalonia();

var w = GLWindow.Create(
onFocusedControlChanged: (split, AvaloniaGLControl, isInitial) =>
{
if (isInitial)
{
split.LoadViewLayout();
}
}
);

static string texturePathfilename(string name) => Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "texture", name);

w.GLModel.BuildModel = (glCtl, isInitial) =>
{
if (!isInitial) return;

var glModel = glCtl.GLModel;
var glCtx = glCtl.GLContext;

glModel.Clear();

// lights loaded from layout.json ( saved using SHIFT+F2 )
// note: ambient is set to Black in order to make dark side effective

var earthTexture = new GLTexture2D(glCtx, SKBitmap.Decode(texturePathfilename("earth.jpg")));

var sphere = new UVSphere(center: Vector3.Zero, radius: 1);
// use of setUVTexture to map uv sphere texture coords
var fig = sphere.Figure(divisions: 20, setUVTexture: true);
fig.Texture2D = earthTexture;

glModel.AddFigure(fig);
};

w.ShowSync();
26 changes: 26 additions & 0 deletions examples/example-0027/example-0027.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<RootNamespace>example</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<None Include="../textures/**/*" CopyToOutputDirectory="PreserveNewest" Link="texture/%(RecursiveDir)/%(Filename)%(Extension)" />
<None Include="layout.json" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\gui\netcore-opengl-gui.csproj" />
<ProjectReference Include="..\..\src\shapes\netcore-opengl-shapes.csproj" />

<Compile Include="../../src/core/usings.core.cs" />
<Compile Include="../../src/gui/usings.gui.cs" />
<Compile Include="../../src/shapes/usings.shapes.cs" />
</ItemGroup>

</Project>
Binary file added examples/textures/earth.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions netcore-opengl.sln
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-0025", "examples\ex
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-0026", "examples\example-0026\example-0026.csproj", "{D902D9FB-DAF3-4092-BABE-099E3EF7A045}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-0027", "examples\example-0027\example-0027.csproj", "{0C2C3AC0-035F-473C-B086-A68D6E6700BF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -232,6 +234,10 @@ Global
{D902D9FB-DAF3-4092-BABE-099E3EF7A045}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D902D9FB-DAF3-4092-BABE-099E3EF7A045}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D902D9FB-DAF3-4092-BABE-099E3EF7A045}.Release|Any CPU.Build.0 = Release|Any CPU
{0C2C3AC0-035F-473C-B086-A68D6E6700BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0C2C3AC0-035F-473C-B086-A68D6E6700BF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0C2C3AC0-035F-473C-B086-A68D6E6700BF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0C2C3AC0-035F-473C-B086-A68D6E6700BF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{F5E3CDDB-F28F-45D9-9660-B2740CF8CD14} = {89EC3276-D9A8-472D-BF5F-4B51E2FF5F09}
Expand Down Expand Up @@ -270,5 +276,6 @@ Global
{59DC2D75-F7C5-4B80-B1FB-CDF1A157345E} = {89EC3276-D9A8-472D-BF5F-4B51E2FF5F09}
{D5FB460B-00A0-4654-8524-1B4E40F545CB} = {FD57C411-3D0B-49DB-8C1E-B7CDBE17D462}
{D902D9FB-DAF3-4092-BABE-099E3EF7A045} = {FD57C411-3D0B-49DB-8C1E-B7CDBE17D462}
{0C2C3AC0-035F-473C-B086-A68D6E6700BF} = {FD57C411-3D0B-49DB-8C1E-B7CDBE17D462}
EndGlobalSection
EndGlobal

0 comments on commit 86e41ff

Please sign in to comment.