Author Topic: I have loose a point in Opengl, please help me!  (Read 1364 times)

0 Members and 1 Guest are viewing this topic.

This topic contains a post which is marked as Best Answer. Press here if you would like to see it.

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
I have loose a point in Opengl, please help me!
« on: December 15, 2020, 07:19:04 pm »
Hi guys
please test and correct my code to get the same result in normal graphic mode and in openg mode-
It seems that with my code I loose some point (I hope not loosing the point) on Opengl.
Please run the code at a first time, then change the value of _glpointsize and run again. Do you see any differences?
Code: QB64: [Select]
  1. DIM SHARED GlInit AS INTEGER, s AS SINGLE, Glactive AS INTEGER
  2.  
  3. A = _NEWIMAGE(800, 600, 32)
  4.  
  5. GlInit = 0
  6. Glactive = 0
  7. r = 50
  8. x = 400
  9. y = 300
  10. COLOR _RGB32(200, 200, 10, 255)
  11. PRINT "Standard graphic mode"
  12. FOR z = 4 TO 8
  13.     CLS
  14.     s = _PI(2) / z
  15.     FOR i = 0 TO _PI(2) STEP s
  16.         cx = (COS(i) * r) + x
  17.         cy = (SIN(i) * r) + y
  18.         PSET (cx, cy)
  19.     NEXT i
  20.     '  _DISPLAY
  21.     SLEEP 1
  22. '_AUTODISPLAY
  23. PRINT "Opengl graphic mode"
  24. GlInit = -1
  25. Glactive = -1
  26. FOR z = 4 TO 8
  27.     s = _PI(2) / z
  28.     _DELAY 1
  29. PRINT " End of demo"
  30.  
  31.  
  32.  
  33.  
  34.  
  35. 'area GL --------------------
  36. SUB _GL ()
  37.     IF NOT Glactive THEN EXIT SUB
  38.     IF GlInit THEN
  39.         _glViewport 0, 0, _WIDTH, _HEIGHT
  40.         _glClearColor 0, 0, 0, 1
  41.         GlInit = 0
  42.     END IF
  43.     _glClear _GL_COLOR_BUFFER_BIT
  44.     drawpoint 0.1, 0.2, .4
  45.  
  46.     _glFlush
  47.  
  48. SUB drawpoint (x AS SINGLE, y AS SINGLE, r AS SINGLE)
  49.     DIM i, cx AS SINGLE, cy AS SINGLE
  50.     _glColor4f 0.8, 8, 0.1, 1.0
  51.     _glPointSize 1 ' it works with 2 or more !
  52.     _glBegin _GL_POINTS
  53.     LOCATE 1, 1
  54.     FOR i = 0 TO _PI(2) STEP s
  55.         cx = (COS(i) * r) + x
  56.         cy = (SIN(i) * r) + y
  57.         _glVertex2f cx, cy
  58.     NEXT i
  59.     _glEnd
  60.  

Can you help me to find my mistake? Thanks for feedbacks
Programming isn't difficult, only it's  consuming time and coffee

Offline Kernelpanic

  • Newbie
  • Posts: 94
Re: I have loose a point in Opengl, please help me!
« Reply #1 on: December 16, 2020, 08:49:45 am »
"glPointSize = 1":
In OpenGL mode, only 4 points are displayed on the first screen and only 2 points on the second.

With "glPointSize = 3" all eight points are there.

  [ You are not allowed to view this attachment ]  

  [ You are not allowed to view this attachment ]  
Mark Twain
"Als wir das Ziel endgültig aus den Augen verloren hatten, verdoppelten wir unsere Anstrengungen."
„Having lost sight of our goals, we redoubled our efforts.“

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
Re: I have loose a point in Opengl, please help me!
« Reply #2 on: December 16, 2020, 08:15:21 pm »
Interesting results... it seems that _glpoint is dipendent to the video card of the pc on which it is running the program!
Please test also this code to compare the results
https://www.qb64.org/forum/index.php?topic=3254.msg125337#msg125337
Thanks for feedback
Programming isn't difficult, only it's  consuming time and coffee

Marked as best answer by TempodiBasic on December 17, 2020, 10:48:03 am

Offline Kernelpanic

  • Newbie
  • Posts: 94
Mark Twain
"Als wir das Ziel endgültig aus den Augen verloren hatten, verdoppelten wir unsere Anstrengungen."
„Having lost sight of our goals, we redoubled our efforts.“

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
Re: I have loose a point in Opengl, please help me!
« Reply #4 on: December 17, 2020, 03:49:50 pm »
Thanks
Kernelpanic
I think that these our results can be useful to developers of QB64 that work on Opengl.
Programming isn't difficult, only it's  consuming time and coffee

Offline Kernelpanic

  • Newbie
  • Posts: 94
Re: I have loose a point in Opengl, please help me!
« Reply #5 on: December 17, 2020, 06:03:15 pm »
TempoDiBasic, You are welcome. That would be good for development of course.
Mark Twain
"Als wir das Ziel endgültig aus den Augen verloren hatten, verdoppelten wir unsere Anstrengungen."
„Having lost sight of our goals, we redoubled our efforts.“