-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
115 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters