The MASM Forum

General => The Campus => Topic started by: TouEnMasm on October 26, 2020, 04:19:00 AM

Title: Opengl sample Win10 64 help
Post by: TouEnMasm on October 26, 2020, 04:19:00 AM
Hello,
I try to translate a sample(C++) in asm.
There is no bug but ....Just black screen.
Any idea ?
Title: Re: Opengl sample Win10 64 help
Post by: kiptron on October 26, 2020, 05:33:00 AM
Dear Tou  I have stuggled with the opengl API for years now. I posted a full masm template
to this forum not to far down the list. It is called Simplest opengl implementation by Kiptron (me)
There are so many issues here I don't know where to start. #1 you need proper context creation.
This is a gray area. Different drivers have inconsistent methods for doing this. I am finding that
there may be alignment issues  with different drivers ?  I play "Whack A Mole" with protection
faults constantly. They pop up in unexpected places. A call will work here but not there for no known
reason. Maybe some of the "gurus" will help us out here. ?? I hope   Kiptron 
Title: Re: Opengl sample Win10 64 help
Post by: LiaoMi on October 26, 2020, 07:57:23 AM
Quote from: TouEnMasm on October 26, 2020, 04:19:00 AM
Hello,
I try to translate a sample(C++) in asm.
There is no bug but ....Just black screen.
Any idea ?

Hi TouEnMasm,

everything works for me, maybe you need to check the libraries. Through the debugger it would be clear which api does not work. I chose the wrong example, the screen is black.



(https://i.imgur.com/UOZhSoo.jpg)
Title: Re: Opengl sample Win10 64 help
Post by: kiptron on October 26, 2020, 09:15:22 AM
  Tou,  I forgot to mention that your .exe runs O.K. on my machine. AMD graphics
card. It is displaying to fast so you might want to tie it to vertical sync, in the
windows event loop. Looks good here  Kiptron
Title: Re: Opengl sample Win10 64 help
Post by: Mikl__ on October 26, 2020, 11:01:58 AM
Salut, Yves!
Je ne peux pas tester le programme sous Windows 10. J'ai Windows 7 64 bits
Title: Re: Opengl sample Win10 64 help
Post by: hutch-- on October 26, 2020, 11:13:12 AM
I get the same problem, my old box has an Nvidia GTX-960 where the later ones use an Amd RADEON RX-580. When I first tried kiptron's example, it did not work on my old box but worked fine on any that ran the Amd video cards.
Title: Re: Opengl sample Win10 64 help
Post by: Mikl__ on October 26, 2020, 11:37:50 AM
Hi, hutch--!
Did my program start normally or displays a black screen? Do you have Windows 10 or something else?
Title: Re: Opengl sample Win10 64 help
Post by: hutch-- on October 26, 2020, 12:03:25 PM
Hi Mikl__

00.zip worked fine, blue rotating frame, rabbit cursor and two shapes inside the frame.

This box has a GTX-960 Nvidia graphics card.
Title: Re: Opengl sample Win10 64 help
Post by: kiptron on October 26, 2020, 04:03:55 PM
Hi again dudes. I would like to add my thoughts on this as I have been at it for so long
and really like opengl. One of the main issues is that this API is losing support with the
hardware vendors who have to keep their drivers current and there is the problem. There
has not been a comprehensive upgrade to the "core" API since it was released by
Silicon Graphics in 1991  That's 29 years of HUGE advances in the GPU's but not in the
core API itself. The chip makers have tried to provide this improved functionality by
writing "extensions" to the original API. These extensions are an ad-hoc collection of
functions which are not consistent across the industry but differ from one chip maker
to another. The programmer (us) has to request an address pointer to these calls and
often has no documentation to go on when running these functions. Opengl is currently
un-maintained by any serious group, company or body. There is the "architectural review
board" ARB which approves these extensions for release but has no real authority to act
in any way. There is Khronos which is dropping opengl in favor of Vulkan. I run many of
these extensions and my projects are usually unstable and subject to crashes and
protection faults as I mentioned. It is a big frustrating mess.  Kiptron   
Title: Re: Opengl sample Win10 64 help
Post by: TouEnMasm on October 26, 2020, 09:12:51 PM

Thanks all for the answer,
Quote
Tou,  I forgot to mention that your .exe runs O.K. on my machine. AMD graphics
card. It is displaying to fast so you might want to tie it to vertical sync, in the
windows event loop. Looks good here  Kiptron
Happy are you.After further tests with the C++ prog,it seems it is a real problem to compile.
CL  used at command line give me a white graphics.
There is only with the visual studio compile that i can have the colors.


Title: Re: Opengl sample Win10 64 help
Post by: Mikl__ on October 26, 2020, 09:30:36 PM
Salut, Yves!
Le problème est bien différent. J'ai créé un programme sans Visual Studio. Mon programme fonctionne-t-il dans votre Windows 10?
Title: Re: Opengl sample Win10 64 help
Post by: TouEnMasm on October 27, 2020, 12:25:40 AM

C'est gentil de me le dire,mais je ne vois aucun lien
Title: Re: Opengl sample Win10 64 help
Post by: nidud on October 27, 2020, 12:59:15 AM
deleted
Title: Re: Opengl sample Win10 64 help
Post by: TouEnMasm on October 27, 2020, 02:58:42 AM

Just but not enough in asm 64 and 32 bits.
I find :
latitude GLfloat 0           ;change original GLdouble       generate stack problem in 32 bits
longitude GLfloat 0

polarView PROTO :GLdouble, :GLdouble, :GLfloat, :GLfloat           ;proto change


   follow changes in this proc
polarView PROC FRAME aradius:GLdouble ,twist:GLdouble ,alatitude:GLfloat ,alongitude:GLfloat 
Local moins:GLdouble,plus

movsd xmm0, aradius ;negate value help c
xorps xmm0, qword ptr [flip_bit]
movsd moins, xmm0
invoke glTranslated,REEL8(0.0), REEL8(0.0),moins ; -aradius
movsd xmm0,twist
xorps xmm0, qword ptr [flip_bit]
movsd moins, xmm0
invoke glRotated,moins,REEL8(0.0),REEL8(0.0),REEL8(1.0)
movss xmm0,alatitude
xorps xmm0, qword ptr [flip_bit]
movsd moins, xmm0
invoke glRotated,moins,REEL8(1.0),REEL8(0.0),REEL8(0.0)
xor R10,R10
mov R10D,alongitude
mov moins,R10
invoke glRotated,moins,REEL8(0.0),REEL8(0.0),REEL8(1.0) 
ret
polarView endp


And I stay with the same problem,no bug,no error,no problem with stack but .... black screen in asm

Title: Re: Opengl sample Win10 64 help
Post by: nidud on October 27, 2020, 03:35:35 AM
deleted
Title: Re: Opengl sample Win10 64 help
Post by: nidud on October 27, 2020, 03:52:02 AM
deleted
Title: Re: Opengl sample Win10 64 help
Post by: TouEnMasm on October 27, 2020, 04:05:48 AM

Opengl version 4.3 on my computer.
Is it the asm you have compiled ?
Title: Re: Opengl sample Win10 64 help
Post by: nidud on October 27, 2020, 04:30:06 AM
deleted
Title: Re: Opengl sample Win10 64 help
Post by: TouEnMasm on October 27, 2020, 04:49:50 AM
The Binary work
On wich system have compiled them ?
Is there a way to upgrade opengl ?
It isn't in c++ I want a result,visual studio is enough to do that but in ASM.
Title: Re: Opengl sample Win10 64 help
Post by: nidud on October 27, 2020, 05:15:28 AM
deleted
Title: Re: Opengl sample Win10 64 help
Post by: TouEnMasm on October 27, 2020, 06:02:54 AM

Thanks for help,
helas,don't made effect.
Title: Re: Opengl sample Win10 64 help
Post by: Mikl__ on October 27, 2020, 10:01:25 AM
Yves,
you still haven't answered my question. Does my program in http://masm32.com/board/index.php?topic=8880.msg96843#msg96843 work on Windows 10? There is just black screen? Or blue rotating sphere and two shapes inside the sphere?
Title: Re: Opengl sample Win10 64 help
Post by: TouEnMasm on October 27, 2020, 05:42:43 PM
Quote
Does my program in http://masm32.com/board/index.php?topic=8880.msg96843#msg96843 work on Windows 10?
OK,it's work
Title: Re: Opengl sample Win10 64 help
Post by: TouEnMasm on October 27, 2020, 07:51:14 PM
Found ,"ouf!",many thanks for all help.
it was the "aspect" who wasn't converted to real in resize.


resize PROC FRAME largeur:GLsizei,hauteur: GLsizei
Local aspect:GLfloat,raspect:REAL8

invoke glViewport,0, 0, largeur, hauteur
;----- Knock down by Math,let's it done by C: aspect,(GLfloat) width / height
cvtsi2ss xmm0, largeur ;DWORD PTR ;convert dword to real4
cvtsi2ss xmm1,  hauteur ;DWORD PTR
divss xmm0, xmm1
movss aspect, xmm0
cvtss2sd xmm0,aspect ; DWORD PTR convert real8
movsd raspect,xmm0

;invoke MathLabA ;aspect,(GLfloat) width / height;
invoke glMatrixMode,GL_PROJECTION
invoke glLoadIdentity
invoke gluPerspective,REEL8(45.0), raspect,REEL8(3.0),REEL8(7.0 ) ;<<<<<<<<<<<<<<< most important raspect REAL8
invoke glMatrixMode,GL_MODELVIEW
ret
resize endp


Title: Re: Opengl sample Win10 64 help
Post by: Mikl__ on October 27, 2020, 08:19:22 PM
movq xmm3,constd7
movq xmm2,constd1
cvtsi2sd xmm1,w
cvtsi2sd xmm0,h
divsd xmm1,xmm0
movq xmm0,constd45
invoke gluPerspective
variable aspect (used only once) it is better not used at all
variables declared as float
GLfloat latitude, longitude, latinc, longinc

are used where double is required

    glRotated(-latitude, 1.0, 0.0, 0.0);
    glRotated(longitude, 0.0, 0.0, 1.0);
although before calling the procedure polarView it is indicated that the arguments are double
void polarView(GLdouble radius, GLdouble twist, GLdouble latitude, GLdouble longitude)
masm64 did not understand this (no explicit float to double conversion), but C++ understood
Title: Re: Opengl sample Win10 64 help
Post by: hutch-- on October 27, 2020, 08:57:55 PM
Mikl__
see if these two instructions are any use to you.

        cvtsd2si    ; Convert Scalar Double-Precision Floating-Point Value to Doubleword Integer
        cvtsi2sd    ; Convert Doubleword Integer to Scalar Double-Precision Floating-Point Value
Title: Re: Opengl sample Win10 64 help
Post by: Mikl__ on October 27, 2020, 09:05:20 PM
Hi, hutch--!
I know about instructions cvtsd2si and cvtsi2sd. I wrote this post after analyzing the program openglw10_64 which at first displayed a dark screen, but x64dbg showed me where are the errors