public void Run() { BBUtil _util; using (var nav = new Navigator()) using (var ctx = new Context(ContextType.SCREEN_APPLICATION_CONTEXT)) using (var win = new Window(ctx)) { _util = new BBUtil(ctx); Egl.QuerySurface(_util.Display, _util.Surface, Egl.WIDTH, out viewportWidth); Egl.QuerySurface(_util.Display, _util.Surface, Egl.HEIGHT, out viewportHeight); Console.WriteLine("viewportWidth: " + viewportWidth); Console.WriteLine("viewportHeight: " + viewportHeight); this.OnLoad(_util); nav.OnExit += () => { Console.WriteLine("I am asked to shutdown!?!"); PlatformServices.Shutdown(0); }; PlatformServices.Run(null); } }
public override void ToCString(StringBuilder builder, string macroName) { builder.AppendLine(string.Format("BBSeriesMacro {0} = new BBSeriesMacro();", macroName)); string[] fieldNames = new string[] { "times", "duration", "delay" }; foreach (string fieldName in fieldNames) { FieldInfo fieldInfo = GetType().GetField(fieldName, BindingFlags.GetField | BindingFlags.Instance | BindingFlags.Public); builder.Append(string.Format("{0}.{1} = ", macroName, fieldName)); BBUtil.ConcatMemberString(builder, fieldInfo.FieldType, fieldInfo.GetValue(this)); builder.AppendLine(";"); } builder.AppendLine(string.Format("{0}.items = new BBMacro[{1}];", macroName, items.Length)); for (int i = 0; i < items.Length; i++) { string itemMacroName = macroName + "_" + i; items[i].ToCString(builder, itemMacroName); builder.AppendLine(string.Format("{0}.items[{1}] = {2};", macroName, i, itemMacroName)); } if (next != null) { string nextMacroName = macroName + "_n"; next.ToCString(builder, nextMacroName); builder.AppendLine(string.Format("{0}.next = {1};", macroName, nextMacroName)); } }
void RenderCube(BBUtil util) { GL.Viewport(0, 0, _viewportWidth, _viewportHeight); GL.MatrixMode(All.Projection); GL.LoadIdentity(); if (_viewportWidth > _viewportHeight) { GL.Ortho(-1.5f, 1.5f, 1.0f, -1.0f, -1.0f, 1.0f); } else { GL.Ortho(-1.0f, 1.0f, -1.5f, 1.5f, -1.0f, 1.0f); } GL.MatrixMode(All.Modelview); GL.LoadIdentity(); GL.Rotate(_rot[0], 1.0f, 0.0f, 0.0f); GL.Rotate(_rot[1], 0.0f, 1.0f, 0.0f); GL.Rotate(_rot[2], 0.0f, 1.0f, 0.0f); GL.ClearColor(0, 0, 0, 1.0f); GL.Clear((int)ClearBufferMask.ColorBufferBit); GL.VertexPointer(3, All.Float, 0, _cube); GL.EnableClientState(All.VertexArray); GL.ColorPointer(4, All.Float, 0, _cubeColors); GL.EnableClientState(All.ColorArray); GL.DrawElements(All.Triangles, 36, All.UnsignedByte, _triangles); util.Swap(); }
public void Run() { _rateOfRotationPS = new float[] { 30, 45, 60 }; _rot = new float[] { 0, 0, 0 }; BBUtil util; using (var nav = new Navigator()) using (var ctx = new Context(ContextType.SCREEN_APPLICATION_CONTEXT)) using (var win = new Window(ctx)) { util = new BBUtil(ctx, BBUtil.OpenGLESVersion.ES11); Egl.QuerySurface(util.Display, util.Surface, Egl.WIDTH, out _viewportWidth); Egl.QuerySurface(util.Display, util.Surface, Egl.HEIGHT, out _viewportHeight); this.OnLoad(util); nav.OnExit += () => { Console.WriteLine("I am asked to shutdown!?!"); PlatformServices.Shutdown(0); }; } }
private bool IsNiceSnapshot(BBInputSnapshot snapshot) { bool ret = false; if (BBUtil.IsStrokeInputType(snapshot.type)) { if (snapshot.type == BBInputType.Move || snapshot.type == BBInputType.Wheel) { if (mRecordButtons > 0) { ret = true; } } else if ((mRecordButtons & snapshot.button) > 0) { ret = true; } } else if (BBUtil.IsKeyboardInputType(snapshot.type) && mRecordKeyboard) { ret = true; } return(ret); }
public void ToCString(StringBuilder builder, string configName) { builder.AppendLine(string.Format("BBConfig {0} = new BBConfig();", configName)); string[] fieldNames = new string[] { "axisType", "clipRatio", "screenWidth", "screenHeight", "device", "monitoringButtons", "monitoringKeyboard" }; foreach (string fieldName in fieldNames) { FieldInfo fieldInfo = GetType().GetField(fieldName, BindingFlags.GetField | BindingFlags.Instance | BindingFlags.Public); builder.Append(string.Format("{0}.{1} = ", configName, fieldName)); BBUtil.ConcatMemberString(builder, fieldInfo.FieldType, fieldInfo.GetValue(this)); builder.AppendLine(";"); } }
protected void OnLoad(BBUtil util) { GL.Enable(All.CullFace); GL.ShadeModel(All.Smooth); GL.Hint(All.PerspectiveCorrectionHint, All.Nicest); // Run the render loop PlatformServices.Run(delegate { for (int j = 0; j < 3; j++) _rot[j] += (float)(_rateOfRotationPS[j] * 0.02); this.RenderCube(util); return 1; }); }
void OnLoad(BBUtil util) { // Vertex and fragment shaders string vertexShaderSrc = "attribute vec4 vPosition; \n" + "void main() \n" + "{ \n" + " gl_Position = vPosition; \n" + "} \n"; string fragmentShaderSrc = "precision mediump float;\n" + "void main() \n" + "{ \n" + " gl_FragColor = vec4 (1.0, 0.0, 0.0, 1.0); \n" + "} \n"; int vertexShader = LoadShader(ShaderType.VertexShader, vertexShaderSrc); int fragmentShader = LoadShader(ShaderType.FragmentShader, fragmentShaderSrc); program = GL.CreateProgram(); if (program == 0) throw new InvalidOperationException("Unable to create program"); GL.AttachShader(program, vertexShader); GL.AttachShader(program, fragmentShader); GL.BindAttribLocation(program, 0, "vPosition"); GL.LinkProgram(program); int linked = 0; GL.GetProgram(program, ProgramParameter.LinkStatus, out linked); if (linked == 0) { // link failed int length = 0; GL.GetProgram(program, ProgramParameter.InfoLogLength, out length); if (length > 0) { var log = new StringBuilder(length); GL.GetProgramInfoLog(program, length, out length, log); Console.WriteLine("Couldn't link program: " + log.ToString()); } GL.DeleteProgram(program); throw new InvalidOperationException("Unable to link program"); } RenderTriangle(util); }
protected void OnLoad(BBUtil util) { GL.Enable(All.CullFace); GL.ShadeModel(All.Smooth); GL.Hint(All.PerspectiveCorrectionHint, All.Nicest); // Run the render loop PlatformServices.Run(delegate { for (int j = 0; j < 3; j++) { _rot[j] += (float)(_rateOfRotationPS[j] * 0.02); } this.RenderCube(util); }); }
public void Run() { _ctx = new Context(BlackberryPlatformServices.Screen.Types.ContextType.SCREEN_APPLICATION_CONTEXT); PlatformServices.Initialize(); using (var win = new Window(_ctx, WindowType.SCREEN_APPLICATION_WINDOW)) { _util = new BBUtil(_ctx); this.Initialize(); string groupName = "TheTeam"; win.CreateWindowGroup(groupName); win.CreateBuffer(); while (true) { this.Draw(); } } }
public virtual void ToCString(StringBuilder builder, string macroName) { builder.AppendLine(string.Format("BBMacro {0} = new BBMacro();", macroName)); string[] fieldNames = new string[] { "code", "button", "key", "data", "times", "duration", "delay", "script", "scriptData" }; foreach (string fieldName in fieldNames) { FieldInfo fieldInfo = GetType().GetField(fieldName, BindingFlags.GetField | BindingFlags.Instance | BindingFlags.Public); builder.Append(string.Format("{0}.{1} = ", macroName, fieldName)); BBUtil.ConcatMemberString(builder, fieldInfo.FieldType, fieldInfo.GetValue(this)); builder.AppendLine(";"); } if (next != null) { string nextMacroName = macroName + "_n"; next.ToCString(builder, nextMacroName); builder.AppendLine(string.Format("{0}.next = {1};", macroName, nextMacroName)); } }
public void Run() { using (var nav = new Navigator()) using (var ctx = new Context(ContextType.SCREEN_APPLICATION_CONTEXT)) using (var win = new Window(ctx)) { _util = new BBUtil(ctx); this.Initialize(); nav.RotationLock = false; bool exit_application = false; nav.OnExit = () => { Console.WriteLine("I am asked to shutdown!?!"); PlatformServices.Shutdown(0); exit_application = true; }; //while (!exit_application) //{ //Event e = null; //for (; ; ) //{ // PlatformServices.GetEvent(out e, 0); // if (e != null) // { // int domain = PlatformServices.GetDomainByEvent(e.Handle); // if (domain == Screen.GetDomain()) // this.handleScreenEvent(e); // else if (domain == nav.Domain && (int)e.Code == (int)Navigator.EventType.NAVIGATOR_EXIT) // exit_application = true; // } // else // break; //} this.Render(); //} PlatformServices.Run(this.Render); _util.Dispose(); } }
private BBMacro Parse(List <BBInputSnapshot> snapshots) { BBMacro head = null; BBMacro current = null; for (int i = 0; i < snapshots.Count; i++) { BBInputSnapshot snapshot = snapshots[i]; BBMacro macro = new BBMacro(); macro.button = snapshot.button; macro.code = BBUtil.InputType2OpCode(snapshot.type); macro.key = snapshot.key; if (BBUtil.IsStrokeInputType(snapshot.type)) { var coord = mConfig.Screen2Axis(snapshot.inputPosition); if (snapshot.type == BBInputType.Wheel) { macro.data = new float[] { coord[0], coord[1], snapshot.delta }; } else { macro.data = coord; } } if (head == null) { head = macro; current = head; } else { current.next = macro; current = current.next; } } return(head); }
public void Run() { _rateOfRotationPS = new float[] { 30, 45, 60 }; _rot = new float[] { 0, 0, 0 }; BBUtil _util; using (var nav = new Navigator()) using (var ctx = new Context(ContextType.SCREEN_APPLICATION_CONTEXT)) using (var win = new Window(ctx)) { _util = new BBUtil(ctx); Egl.QuerySurface(_util.Display, _util.Surface, Egl.WIDTH, out _viewportWidth); Egl.QuerySurface(_util.Display, _util.Surface, Egl.HEIGHT, out _viewportHeight); this.OnLoad(_util); nav.OnExit += () => { Console.WriteLine("I am asked to shutdown!?!"); PlatformServices.Shutdown(0); }; } }
void RenderTriangle(BBUtil util) { vertices = new float[] { 0.0f, 0.5f, 0.0f, -0.5f, -0.5f, 0.0f, 0.5f, -0.5f, 0.0f }; GL.ClearColor(0.7f, 0.7f, 0.7f, 1); GL.Clear(ClearBufferMask.ColorBufferBit); GL.Viewport(0, 0, viewportWidth, viewportHeight); GL.UseProgram(program); GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, 0, vertices); GL.EnableVertexAttribArray(0); GL.DrawArrays(BeginMode.Triangles, 0, 3); util.Swap(); }