News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Can't get a rendering context, wglCreateContext fails

Started by hamper, November 11, 2013, 10:30:52 PM

Previous topic - Next topic

Gunther

Hi Dave and vertograd,

I've an i7 (Ivy Bridge) with on-chip graphics adaptor, but that's inactive. My card is an AMD Radeon 7570. But I think this isn't important, because the XP emulation under VirtualPC uses the same card, and that works fine.

Gunther
You have to know the facts before you can distort them.

FORTRANS

Quote from: dedndave on November 16, 2013, 10:33:27 AM
that is a little confusing, Steve   :redface:

Hi,

   Completely.  I can't see why starting from a full screen would
matter at all, ever.  And, up till now, I thought the two XP laptops
behaved the same, except for AV, keyboard, and speed.  And
the AV on the Sony is usually turned off (speed, lack of), which
makes that moot .

   I guess that the video chip needs some reprogramming to leave
a full screen session.  But really, how would a program know about
that?

Regards,

Steve N.

Gunther

Hi Steve,

Quote from: FORTRANS on November 17, 2013, 12:28:14 AM
   I guess that the video chip needs some reprogramming to leave
a full screen session.  But really, how would a program know about
that?

right. It seems impossible for the program.

Gunther
You have to know the facts before you can distort them.

dedndave

it may make a difference if you create a shortcut to the exe and run the shortcut
may be something in the startup settings
and, with a shortcut, you can alter some settings in the properties tab

at any rate, if we can make it run from an "explorer icon click", i am happy   :P
it's a GUI app - and the console window is known to be buggish in other ways

TWell

This function works in WinXP, but not in Win7-x64.model flat,stdcall
WIN32_LEAN_AND_MEAN equ <>
INCLUDE    Windows.inc
INCLUDE    GL\GL.inc
INCLUDELIB OpenGL32.lib

.DATA
ALIGN   4
r4Rotation      REAL4 0.0,0.0,0.0,1.0
r4Vertices      REAL4 0.0,1.0,1.0,0.87,-0.5,1.0,-0.87,-0.5,1.0
r4Colours       REAL4 1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0

.CODE
ALIGN   16

RenderTriangleASM PROC hWnd:HWND, dwAngle:DWORD
    INVOKE  glClear,GL_COLOR_BUFFER_BIT
    INVOKE  glPushMatrix
    mov     edx,offset r4Rotation
    fild    dwAngle
    fst real4 ptr [edx]
    INVOKE  glRotatef,[edx],[edx+4],[edx+8],[edx+12]
    INVOKE  glBegin,GL_TRIANGLES
        INVOKE  glColor3fv, offset r4Colours
        INVOKE  glVertex3fv,offset r4Vertices
        INVOKE  glColor3fv, offset r4Colours[12]
        INVOKE  glVertex3fv,offset r4Vertices[12]
        INVOKE  glColor3fv, offset r4Colours[24]
        INVOKE  glVertex3fv,offset r4Vertices[24]
    INVOKE  glEnd
    INVOKE  glFlush
    INVOKE  glPopMatrix
    INVOKE  GetDC,hWnd
    mov     edx, eax
    INVOKE  SwapBuffers,edx
    INVOKE  ReleaseDC,hWnd,edx
    ret
RenderTriangleASM ENDP
but this similar C function works in Win7-x64
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <gl/gl.h>

void __stdcall RenderTriangleC(HWND hwnd, int nAngle)
{
static GLfloat r4Vertices[] = {0.0,1.0,1.0,0.87,-0.5,1.0,-0.87,-0.5,1.0};
static GLfloat r4Colours[] = {1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0};
static GLdouble r4Rotation[] = {0.0,0.0,0.0,1.0};

glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
r4Rotation[0] = nAngle;
glRotatef(r4Rotation[0], r4Rotation[1], r4Rotation[2], r4Rotation[3]);
glBegin(GL_TRIANGLES);
glColor3fv(r4Colours);
glVertex3fv(r4Vertices);
glColor3fv(&r4Colours[3]);
glVertex3fv(&r4Vertices[3]);
glColor3fv(&r4Colours[6]);
glVertex3fv(&r4Vertices[6]);
glEnd();
glFlush();
glPopMatrix();
HDC hdc = GetDC(hwnd);
SwapBuffers(hdc);
ReleaseDC(hwnd, hdc);
}

dedndave

it seems to me that those should create the same code - lol
so - maybe it's the testbed that is different ?

are you building those as OBJ modules, then linking to the same program ?
i.e., how are we to determine what changes between one that works and one that doesn't ?

EDIT: ok - i see a potential issue:
    INVOKE  GetDC,hWnd
    mov     edx, eax
    INVOKE  SwapBuffers,edx
    INVOKE  ReleaseDC,hWnd,edx

the contents of EDX are destroyed across the SwapBuffers call
try this...
    INVOKE  GetDC,hWnd
    push    eax
    INVOKE  SwapBuffers,eax
    pop     eax
    INVOKE  ReleaseDC,hWnd,eax

it seems like that problem would it cause to:
work, for a little while, then hose up the system - lol

dedndave

this one is aimed at resolving the win7-64 issue
give it a try, guys   :P

jj2007


Gunther

Dave,

Quote from: dedndave on November 17, 2013, 05:49:02 AM
this one is aimed at resolving the win7-64 issue
give it a try, guys   :P

not solved. Black screen under Win 7, fast rotating triangle under XP.

Gunther
You have to know the facts before you can distort them.

TWell

Here is POAsm project for Gunther.
C version function used.

Gunther

TWell,

slow rotation under XP and Windows 7 (same machine).  :t

Gunther
You have to know the facts before you can distort them.

jj2007


dedndave

very interesting TWell   :t

let's see what i can learn from it   :biggrin:

dedndave

question - does Franck's (hitchhikr) example work under win7-64 ?

\Masm32\Examples\exampl04\opengl

Gunther

Dave,

Quote from: dedndave on November 17, 2013, 07:16:43 AM
question - does Franck's (hitchhikr) example work under win7-64 ?

\Masm32\Examples\exampl04\opengl

excellent idea.  :t Works on both (XP - fast, Win 7 - very fast).

Gunther
You have to know the facts before you can distort them.