*/}}

ourpaint.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * Our Paint: A light weight GPU powered painting program.
  3. * Copyright (C) 2022-2023 Wu Yiming
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include "ourpaint.h"
  19. extern LA MAIN;
  20. extern tnsMain* T;
  21. extern OurPaint *Our;
  22. #ifdef _WIN32
  23. __declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
  24. __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
  25. #endif
  26. int main(int argc, char *argv[]){
  27. if(ourProcessInitArgs(argc,argv) < 0){ return 0; }
  28. laInitArguments ia={0}; laSetDefaultInitArguments(&ia);
  29. ia.GLMajor=4; ia.GLMinor=5;
  30. ia.GLESMajor=3; ia.GLESMinor=2;
  31. ia.UseColorManagement=1;
  32. //ia.HasTextureInspector=1;
  33. ia.HasTerminal=1;
  34. ia.HasHistories=1;
  35. //MAIN.EnableGLDebug=1;
  36. //MAIN.GLDebugSync=1;
  37. laProcessInitArguments(argc, argv, &ia);
  38. laGetReadyWith(&ia);
  39. if(!ourInit()){ laShutoff(0); return -1; }
  40. laRefreshUDFRegistries();
  41. laEnsureUserPreferences();
  42. laLoadHyperResources("OURBRUSH");
  43. laLoadHyperResources("OURPALLETTE");
  44. laLoadHyperResources("OURLIGHT");
  45. laLoadHyperResources("OURSURF");
  46. laLoadHyperResources("OURPIGM");
  47. int anyload=0;
  48. for(int i=1;i<argc;i++){
  49. char* file=argv[i]; int mode=LA_UDF_MODE_APPEND;
  50. char* ext=strGetLastSegment(file,'.'); strToLower(ext);
  51. if(strSame(ext,"ourpaint")){ mode=LA_UDF_MODE_OVERWRITE; }
  52. laManagedUDF* m; laUDF* udf = laOpenUDF(file, 1, 0, &m);
  53. if(udf){ laExtractUDF(udf,m,mode); laCloseUDF(udf); anyload=1; }
  54. }
  55. if(anyload){ laRecordEverythingAndPush(); }
  56. laMarkMemClean(Our->CanvasSaverDummyList.pFirst);
  57. if(!MAIN.InputMapping->Toolboxes.pFirst){
  58. laInputMapping* im=laNewToolbox("Default Toolbox"); laInputMappingEntry* ime;
  59. ime=laNewInputMappingEntry(im,0,0,0,0,"la.undo"); strSafeSet(&ime->Key,"Undo");
  60. ime=laNewInputMappingEntry(im,0,0,0,0,"la.redo"); strSafeSet(&ime->Key,"Redo");
  61. ime=laNewInputMappingEntry(im,0,0,0,0,"la.save"); strSafeSet(&ime->Key,"Save");
  62. ime=laNewInputMappingEntry(im,0,0,0,0,"our.brush_smaller"); strSafeSet(&ime->Key,"Smaller");
  63. ime=laNewInputMappingEntry(im,0,0,0,0,"our.brush_bigger"); strSafeSet(&ime->Key,"Bigger");
  64. }
  65. //laAddRootDBInst("our.tools");
  66. if(!MAIN.Windows.pFirst){
  67. laWindow* w = laDesignWindow(-1,-1,35*LA_RH,25*LA_RH);
  68. laLayout* l = laDesignLayout(w, "Our Paint");
  69. laBlock* b = l->FirstBlock;
  70. #ifdef LAGUI_ANDROID
  71. laSplitBlockVertical(b,0.3);
  72. laSplitBlockHorizon(b->B1, 0.5);
  73. laCreatePanel(b->B1->B1, "panel_color");
  74. laCreatePanel(b->B1->B2, "panel_brushes");
  75. b->B2->Folded = 1; laCreatePanel(b->B2, "panel_canvas");
  76. l = laDesignLayout(w, "Our Paint");
  77. b = l->FirstBlock;
  78. b->Folded=1; laCreatePanel(b, "panel_canvas");
  79. #else
  80. laSplitBlockHorizon(b,0.7);
  81. b->B1->Folded = 1;
  82. laCreatePanel(b->B1, "panel_canvas");
  83. laBlock* br=b->B2;
  84. laSplitBlockVertical(br,0.6);
  85. laCreatePanel(br->B1, "panel_color");
  86. laCreatePanel(br->B1, "panel_tools");
  87. laCreatePanel(br->B1, "panel_brushes");
  88. laCreatePanel(br->B2, "panel_notes");
  89. laCreatePanel(br->B2, "panel_layers");
  90. laStartWindow(w);
  91. #endif
  92. }
  93. our_EnableSplashPanel();
  94. laMainLoop();
  95. }