outdated: 29.Blitter Function, RAW Texture Loading

本文介绍了OpenGL中纹理处理的方法,包括如何加载raw格式图片到OpenGL纹理,以及如何实现两个纹理之间的混合效果。通过示例代码详细展示了纹理数据读取、纹理创建、纹理混合等过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在这篇中两个点。

一个是raw格式图片的贴图:

int ReadTextureData(char* filename, P_TEXTURE_IMAGE buffer)
{
    FILE* f;
    int done = 0;
    int stride = buffer->width * buffer->format;
    unsigned char* p = NULL;

    f = fopen(filename, "rb");
    if (f != NULL) {
        for (int i = buffer->height - 1; i >= 0; --i) {
            p = buffer->data + (i * stride);
            for (int j = 0; j < buffer->width; ++j) {
                for (int k = 0; k < buffer->format - 1; ++k, ++p, ++done) {
                    *p = fgetc(f);
                }
                *p = 255;
                ++p;
            }
        }
        fclose(f);
    }
    else {
        MessageBox(NULL, "Unable To Open Image File", "IMAGE ERROR", MB_OK | MB_ICONINFORMATION);
    }
    return done;
}

一个双重贴图即部分覆盖,图像数据,以及两个贴图的开始部分,范围以及模式是重点:

// Copy any section of a (src) texture and paste it into a destination (dst) texture 
void Blit(P_TEXTURE_IMAGE src, P_TEXTURE_IMAGE dst, int src_xstart, int src_ystart, int src_width,
    int src_height, int dst_xstart, int dst_ystart, int blend, int alpha)
{
    unsigned char* s;
    unsigned char* d;          // Source and destination

    // Clamp alpha if value is out of range
    if (alpha > 255) alpha = 255;
    if (alpha < 0) alpha = 0;
    // Check for incorrect blend flag values
    if (blend < 0) blend = 0;
    if (blend > 1) blend = 1;
    // Start row-dst (row * width in pixel * bytes per pixel)
    d = dst->data + (dst_ystart * dst->width * dst->format);
    s = src->data + (src_ystart * src->width * src->format);
    // Start row-src (row * width in pixel * bytes per pixel)
    for (int i = 0; i < src_height; ++i) { 
        s = s + (src_xstart * src->format);    // Move through src data by bytes per pixel
        d = d + (dst_xstart * dst->format);    // Move through dst data by bytes per pixel
        for (int j = 0; j < src_width; ++j) {
            for (int k = 0; k < src->format; ++k, ++s, ++d) {
                if (blend) {
                    // Multiply src data*alpha add dst data(255-alpha)
                    *d = ((*s * alpha) + (*d * (255 - alpha))) >> 8;
                }
                else { // Keep in 0-255 range with >> 8
                    *d = *s; // No blending just do a straight copy
                }
            }
        }
        d = d + (dst->width - (src_width + dst_xstart)) * dst->format;
        s = s + (src->width - (src_width + src_xstart)) * src->format;
    }
}

下面为代码,同样修改部分位于双行星号内。

  1 /******************************************************************************************************************************************/
  2 /******************************************************************************************************************************************/
  3 #include <windows.h>
  4 #include <math.h>
  5 #include <stdio.h>
  6 #include <gl/glew.h>
  7 #include <GL\glut.h>
  8 #include <GL/GLUAX.H>
  9 #pragma comment(lib, "legacy_stdio_definitions.lib")
 10 
 11 /*
 12 *  Every OpenGL program is linked to a Rendering Context.
 13 *  A Rendering Context is what links OpenGL calls to the Device Context.
 14 *  In order for your program to draw to a Window you need to create a Device Context.
 15 *  The DC connects the Window to the GDI (Graphics Device Interface).
 16 */
 17 
 18 HGLRC     hRC = NULL;         // Permanent rendering context
 19 HDC       hDC = NULL;         // Private GDI device context
 20 HWND      hWnd = NULL;        // Holds our window handle
 21 HINSTANCE hInstance;          // Holds the instance of the application
 22 
 23 /*
 24 *  It's important to make this global so that each procedure knows if
 25 *  the program is running in fullscreen mode or not.
 26 */
 27 
 28 bool keys[256];         // Array used for the keyboard routine
 29 bool active = TRUE;     // Window active flag set to TRUE by default
 30 bool fullscreen = TRUE; // Fullscreen flag set to fullscreen mode by default
 31 
 32 DEVMODE DMsaved;        // Saves the previous sacreen settings
 33 
 34 GLfloat xrot;
 35 GLfloat yrot;
 36 GLfloat zrot;
 37 
 38 GLuint texture[1];
 39 
 40 typedef struct Texture_Image {
 41     int width;
 42     int height;
 43     int format;                    // Number of bytes per pixel
 44     unsigned char* data;
 45 } TEXTURE_IMAGE;
 46 
 47 typedef TEXTURE_IMAGE* P_TEXTURE_IMAGE;
 48 
 49 P_TEXTURE_IMAGE t1;
 50 P_TEXTURE_IMAGE t2;
 51 
 52 
 53 LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); // Declaration for WndProc
 54 
 55 P_TEXTURE_IMAGE AllocateTextureBuffer(GLint w, GLint h, GLint f)
 56 {
 57     P_TEXTURE_IMAGE ti = NULL;
 58     unsigned char* c = NULL;                 // Pointer to block memory for image
 59 
 60     ti = (P_TEXTURE_IMAGE)malloc(sizeof(TEXTURE_IMAGE));
 61     if (ti != NULL) {
 62         ti->width = w;
 63         ti->height = h;
 64         ti->format = f;
 65         c = (unsigned char*)malloc(w * h * f);
 66         if (c != NULL) {
 67             ti->data = c;
 68         }
 69         else {
 70             MessageBox(NULL, "Could Not Allocate Memory For A Texture Buffer", "BUFFER ERROR", MB_OK |
 71                 MB_ICONINFORMATION);
 72             return NULL;
 73         }
 74     }
 75     else {
 76         MessageBox(NULL, "Could Not Allocate An Image Structure", "IMAGE STRUCTURE ERROR", MB_OK |
 77             MB_ICONINFORMATION);
 78         return NULL;
 79     }
 80     return ti;
 81 }
 82 
 83 void DeallocateTexture(P_TEXTURE_IMAGE t)
 84 {
 85     if (t) {
 86         if (t->data) {
 87             free(t->data);
 88         }
 89         free(t);
 90     }
 91 }
 92 
 93 int ReadTextureData(char* filename, P_TEXTURE_IMAGE buffer)
 94 {
 95     FILE* f;
 96     int done = 0;
 97     int stride = buffer->width * buffer->format;
 98     unsigned char* p = NULL;
 99 
100     f = fopen(filename, "rb");
101     if (f != NULL) {
102         for (int i = buffer->height - 1; i >= 0; --i) {
103             p = buffer->data + (i * stride);
104             for (int j = 0; j < buffer->width; ++j) {
105                 for (int k = 0; k < buffer->format - 1; ++k, ++p, ++done) {
106                     *p = fgetc(f);
107                 }
108                 *p = 255;
109                 ++p;
110             }
111         }
112         fclose(f);
113     }
114     else {
115         MessageBox(NULL, "Unable To Open Image File", "IMAGE ERROR", MB_OK | MB_ICONINFORMATION);
116     }
117     return done;
118 }
119 
120 void BuildTexture(P_TEXTURE_IMAGE tex)
121 {
122     glGenTextures(1, &texture[0]);
123     glBindTexture(GL_TEXTURE_2D, texture[0]);
124     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
125     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
126     gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, tex->width, tex->height, GL_RGBA, GL_UNSIGNED_BYTE,
127         tex->data);
128 }
129 // Copy any section of a (src) texture and paste it into a destination (dst) texture 
130 void Blit(P_TEXTURE_IMAGE src, P_TEXTURE_IMAGE dst, int src_xstart, int src_ystart, int src_width,
131     int src_height, int dst_xstart, int dst_ystart, int blend, int alpha)
132 {
133     unsigned char* s;
134     unsigned char* d;          // Source and destination
135 
136     // Clamp alpha if value is out of range
137     if (alpha > 255) alpha = 255;
138     if (alpha < 0) alpha = 0;
139     // Check for incorrect blend flag values
140     if (blend < 0) blend = 0;
141     if (blend > 1) blend = 1;
142     // Start row-dst (row * width in pixel * bytes per pixel)
143     d = dst->data + (dst_ystart * dst->width * dst->format);
144     s = src->data + (src_ystart * src->width * src->format);
145     // Start row-src (row * width in pixel * bytes per pixel)
146     for (int i = 0; i < src_height; ++i) { 
147         s = s + (src_xstart * src->format);    // Move through src data by bytes per pixel
148         d = d + (dst_xstart * dst->format);    // Move through dst data by bytes per pixel
149         for (int j = 0; j < src_width; ++j) {
150             for (int k = 0; k < src->format; ++k, ++s, ++d) {
151                 if (blend) {
152                     // Multiply src data*alpha add dst data(255-alpha)
153                     *d = ((*s * alpha) + (*d * (255 - alpha))) >> 8;
154                 }
155                 else { // Keep in 0-255 range with >> 8
156                     *d = *s; // No blending just do a straight copy
157                 }
158             }
159         }
160         d = d + (dst->width - (src_width + dst_xstart)) * dst->format;
161         s = s + (src->width - (src_width + src_xstart)) * src->format;
162     }
163 }
164 /******************************************************************************************************************************************/
165 /******************************************************************************************************************************************/
166 GLvoid ReSizeGLScene(GLsizei width, GLsizei height)   // Resize and initialize the GL window
167 {
168     if (height == 0) {                                // Prevent a divide by zero by
169         height = 1;                                   // Making height equal one
170     }
171     
172     glViewport(0, 0, width, height);                  // Reset the current viewport
173 
174     /*
175      *  The following lines set the screen up for a perspective view. 
176      *  Meaning things in the distance get smaller. This creates a realistic looking scene. 
177      *  The perspective is calculated with a 45 degree viewing angle based on 
178      *  the windows width and height. The 0.1f, 100.0f is the starting point and 
179      *  ending point for how deep we can draw into the screen.
180      *
181      *  The projection matrix is responsible for adding perspective to our scene.
182      *  glLoadIdentity() restores the selected matrix to it's original state.
183      *  The modelview matrix is where our object information is stored.
184      *   Lastly we reset the modelview matrix.
185      */
186 
187     glMatrixMode(GL_PROJECTION);                      // Select the projection matrix
188     glLoadIdentity();                                 // Reset the projection matrix
189     
190                                                       // Calculate the aspect ratio of the window
191     gluPerspective(45.0f, (GLfloat)width / (GLfloat)height, 0.1f, 100.0f);
192 //    glOrtho(0.0f, width, height, 0.0f, -1.0f, 1.0f);  // Create orhto 640X480 view (0, 0, at the top)
193 
194     glMatrixMode(GL_MODELVIEW);                       // Seclet the modelview matrix
195     glLoadIdentity();                                 // Reset the modelview matrix
196 }
197 /******************************************************************************************************************************************/
198 /******************************************************************************************************************************************/
199 
200 int InitGL(GLvoid)                                    // All setup for OpenGL goes here
201 {
202     t1 = AllocateTextureBuffer(256, 256, 4);
203     if (ReadTextureData("Data/Monitor.raw", t1) == 0) {
204         MessageBox(NULL, "Could Not Read 'Monitor.raw' Image Data", "TEXTURE ERROR", MB_OK | MB_ICONINFORMATION);
205         return false;
206     }
207     t2 = AllocateTextureBuffer(256, 256, 4);
208     if (ReadTextureData("Data/GL.raw", t2) == 0) {
209         MessageBox(NULL, "Could Not Read 'GL.raw' Image Data", "TEXTURE ERROR", MB_OK | MB_ICONINFORMATION);
210         return false;
211     }
212 
213     // Image to blend in, original image, src start X & Y, src width & height, 
214     // dst location X & Y, blend flag, alpha value
215     Blit(t2, t1, 127, 127, 128, 128, 64, 64, 1, 127);
216 
217     BuildTexture(t1);
218     
219     DeallocateTexture(t1);
220     DeallocateTexture(t2);
221 
222     glEnable(GL_TEXTURE_2D);
223     glShadeModel(GL_SMOOTH);
224     glClearColor(0.0f, 0.0f, 0.0f, 0.0f);             // Background
225     glClearDepth(1.0f);                               // Depth buffer setup
226     glEnable(GL_DEPTH_TEST);
227     glDepthFunc(GL_LESS);
228 
229     return TRUE;
230 }
231 
232 /*
233  *  For now all we will do is clear the screen to the color we previously decided on,
234  *  clear the depth buffer and reset the scene. We wont draw anything yet.
235  */
236 bool DrawGLScene(GLvoid)                                  // Here's where we do all the drawing
237 {
238     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
239     
240     glLoadIdentity();
241     glTranslatef(0.0f, 0.0f, -5.0f);
242     glRotatef(xrot, 1.0f, 0.0f, 0.0f);
243     glRotatef(yrot, 1.0f, 0.0f, 0.0f);
244     glRotatef(zrot, 0.0f, 0.0f, 1.0f);
245 
246     glBindTexture(GL_TEXTURE_2D, texture[0]);
247     glBegin(GL_QUADS);
248         // Front face
249         glNormal3f(0.0f, 0.0f, 1.0f);
250         glTexCoord2f(1.0f, 1.0f); glVertex3f(1.0f, 1.0f, 1.0f);
251         glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f);
252         glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f);
253         glTexCoord2f(1.0f, 0.0f); glVertex3f(1.0f, -1.0f, 1.0f);
254         // Back face
255         glNormal3f(0.0f, 0.0f, -1.0f);
256         glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f);
257         glTexCoord2f(0.0f, 1.0f); glVertex3f(1.0f, 1.0f, -1.0f);
258         glTexCoord2f(0.0f, 0.0f); glVertex3f(1.0f, -1.0f, -1.0f);
259         glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
260         // Top face
261         glNormal3f(0.0f, 1.0f, 0.0f);
262         glTexCoord2f(1.0f, 1.0f); glVertex3f(1.0f, 1.0f, -1.0f);
263         glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f);
264         glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, 1.0f, 1.0f);
265         glTexCoord2f(1.0f, 0.0f); glVertex3f(1.0f, 1.0f, 1.0f);
266         // Bottom face
267         glNormal3f(0.0f, -1.0f, 0.0f);
268         glTexCoord2f(0.0f, 0.0f); glVertex3f(1.0f, -1.0f, 1.0f);
269         glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f);
270         glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
271         glTexCoord2f(0.0f, 1.0f); glVertex3f(1.0f, -1.0f, -1.0f);
272         // Right face
273         glNormal3f(1.0f, 0.0f, 0.0f);
274         glTexCoord2f(1.0f, 0.0f); glVertex3f(1.0f, -1.0f, -1.0f);
275         glTexCoord2f(1.0f, 1.0f); glVertex3f(1.0f, 1.0f, -1.0f);
276         glTexCoord2f(0.0f, 1.0f); glVertex3f(1.0f, 1.0f, 1.0f);
277         glTexCoord2f(0.0f, 0.0f); glVertex3f(1.0f, -1.0f, 1.0f);
278         // Left face
279         glNormal3f(-1.0f, 0.0f, 0.0f);
280         glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
281         glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f);
282         glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f);
283         glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f);
284     glEnd();
285 
286     xrot += 0.03f;
287     yrot += 0.02f;
288     zrot += 0.04f;
289     return true;
290 }
291 
292 /*
293  *  The job of KillGLWindow() is to release the Rendering Context, 
294  *  the Device Context and finally the Window Handle. 
295  */
296 
297 GLvoid KillGLWindow(GLvoid)                             // Properly kill the window
298 {
299     if (fullscreen) {                                   // Are we in fullscreen mode
300         if (!ChangeDisplaySettings(NULL, CDS_TEST)) {   // If the shortcut doesn't work
301             ChangeDisplaySettings(NULL, CDS_RESET);     // Do it anyway (to get the values out of the registry)
302             ChangeDisplaySettings(&DMsaved, CDS_RESET); 
303         }
304         else {
305             ChangeDisplaySettings(NULL, CDS_RESET);                  // If so switch back to the desktop
306         }
307 //******************************************************************************************************************************************/
308 //******************************************************************************************************************************************/
309         /*
310          *  We use ChangeDisplaySettings(NULL,0) to return us to our original desktop.
311          *  After we've switched back to the desktop we make the cursor visible again.
312          */
313         ShowCursor(TRUE);                                // Show mouse pointer
314     }
315 
316     if (hRC) {                                           // Do we have a rendering context
317         if (!wglMakeCurrent(NULL, NULL)) {                // Are we able to release the DC and RC contexts
318             MessageBox(NULL, "Release of DC and RC failed.", "SHUTDOWN ERROR", MB_OK | MB_ICONINFORMATION);
319         }
320 
321         if (!wglDeleteContext(hRC)) {                     // Are we able to delete the RC
322             MessageBox(NULL, "Release rendering context failed.", "SHUTDOWN ERROR", MB_OK | MB_ICONINFORMATION);
323             hRC = NULL;                                  // Set RC to NULL
324         }
325 
326         if (hDC && !ReleaseDC(hWnd, hDC)) {              // Are we able to release the DC
327             MessageBox(NULL, "Release device context failed.", "SHUTDOWN ERROR", MB_OK | MB_ICONINFORMATION);
328             hDC = NULL;                                  // Set DC to NULL
329         }
330         if (hWnd && !DestroyWindow(hWnd)) {              // Are we able to destroy the window
331             MessageBox(NULL, "Could not release hWnd.", "SHUTDOWN ERROR", MB_OK | MB_ICONINFORMATION);
332             hWnd = NULL;                                 // Set hWnd to NULL
333         }
334 
335         if (!UnregisterClass("OpenGL", hInstance)) {     // Are we able to unregister class
336             MessageBox(NULL, "Could not register class.", "SHUTDOWN ERROR", MB_OK | MB_ICONINFORMATION);
337             hInstance = NULL;                            // Set hInstance to NULL
338         }
339     }
340 }
341 /*
342  * The next section of code creates our OpenGL Window.
343  */
344 
345 BOOL CreateGLWindow(char* title, int width, int height, int bits, bool fullscreenflag)
346 {
347     /*
348      * Find  a pixel format that matches the one we want
349      */
350     GLuint PixelFormat;                                  // Holds the result after serching for a match
351     
352     /*
353      * Before you create a window, you MUST register a Class for the window
354      */
355     WNDCLASS wc;                                         // Windows class structure
356 
357     /*
358      *  dwExStyle and dwStyle will store the Extended and normal Window Style Information.
359     */
360     DWORD dwExStyle;                                     // Window extend style
361     DWORD dwStyle;                                       // Window style
362 
363 
364     RECT WindowRect;                                     // Grabs rectangle upper left/lower right values
365     WindowRect.left = (long)0;                           // Set left value to 0
366     WindowRect.right = (long)width;                      // Set right value to requested width
367     WindowRect.top = (long)0;                            // Set top value to 0
368     WindowRect.bottom = (long)height;                    // Set bottom value to requested height
369 
370     fullscreen = fullscreenflag;                         // Set the global fullscreen flag
371 
372     /*
373      *  The style CS_HREDRAW and CS_VREDRAW force the Window to redraw whenever it is resized. 
374      *  CS_OWNDC creates a private DC for the Window. Meaning the DC is not shared across applications. 
375      *  WndProc is the procedure that watches for messages in our program. 
376      *  No extra Window data is used so we zero the two fields. Then we set the instance. 
377      *  Next we set hIcon to NULL meaning we don't want an ICON in the Window, 
378      *  and for a mouse pointer we use the standard arrow. The background color doesn't matter 
379      *  (we set that in GL). We don't want a menu in this Window so we set it to NULL, 
380      *  and the class name can be any name you want. I'll use "OpenGL" for simplicity.
381      */
382     hInstance = GetModuleHandle(NULL);                   // Grab an instance for our window
383     wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;       // Redraw on move, and own DC for window
384     wc.lpfnWndProc = (WNDPROC)WndProc;                   // WndProc handles message
385     wc.cbClsExtra = 0;                                   // No extra window date
386     wc.cbWndExtra = 0;                                   // No extra window date
387     wc.hInstance = hInstance;                            // set the instance
388     wc.hIcon = LoadIcon(NULL, IDI_WINLOGO);              // Load the default icon
389     wc.hCursor = LoadCursor(NULL, IDC_ARROW);            // Load the arrow pointer
390     wc.hbrBackground = NULL;                             // No background requried for GL
391     wc.lpszMenuName = NULL;                              // We don't want a menu
392     wc.lpszClassName = "OpenGL";                         // set the class name
393 
394     EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &DMsaved);  // Save the current display state
395 
396     if (!RegisterClass(&wc)) {                           // Attempt to register the window class
397         MessageBox(NULL, "Failed to register the window class.", "ERROR", MB_OK | MB_ICONEXCLAMATION);
398         return FALSE;                                    // Exit and return false
399     }
400 
401     if (fullscreen) {                                    // attempt fullsreen model
402         
403         /*
404         T*  here are a few very important things you should keep in mind when switching to full screen mode.
405          *  Make sure the width and height that you use in fullscreen mode is the same as 
406          *  the width and height you plan to use for your window, and most importantly,
407          *  set fullscreen mode BEFORE you create your window.
408          */
409         DEVMODE dmScreenSettings;                        // Device mode
410         memset(&dmScreenSettings, 0, sizeof(dmScreenSettings)); // Make sure memory's cleared
411         dmScreenSettings.dmSize = sizeof(dmScreenSettings);     // Size of devmode structure
412         dmScreenSettings.dmPelsWidth = width;            // Select window width
413         dmScreenSettings.dmPelsHeight = height;          // Select window height
414         dmScreenSettings.dmBitsPerPel = bits;            // Select bits per pixel
415         dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
416         
417         /*
418          *  In the line below ChangeDisplaySettings tries to switch to a mode that matches 
419          *  what we stored in dmScreenSettings. I use the parameter CDS_FULLSCREEN when switching modes, 
420          *  because it's supposed to remove the start bar at the bottom of the screen, 
421          *  plus it doesn't move or resize the windows on your desktop when you switch to 
422          *  fullscreen mode and back.
423          */
424         //Try to set selected mode and get results. Note: CDS_FULLSCREEN gets rid of start bar
425         if (ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) {
426             //If the mode fails, offer two options. Quit or run in a window
427             if (MessageBox(NULL, "The requested fullscreen mode is not supported by\n your video card. Use"
428                 "windowed mode instead?", "GL", MB_YESNO | MB_ICONEXCLAMATION) == IDYES)
429             {
430                 fullscreen = FALSE;                       // Select windowed mode (fullscreen=FLASE)
431             }
432             else {
433                 // Pop up a message box letting user know the programe is closing.
434                 MessageBox(NULL, "Program will now close.", "ERROR", MB_OK | MB_ICONSTOP);
435                 return FALSE;                             // Exit and return FALSE
436             }
437         }
438     }
439 
440     if (fullscreen) {                                     // Are we still in fullscreen mode
441         
442         /*
443          *  If we are still in fullscreen mode we'll set the extended style to WS_EX_APPWINDOW, 
444          *  which force a top level window down to the taskbar once our window is visible. 
445          *  For the window style we'll create a WS_POPUP window. 
446          *  This type of window has no border around it, making it perfect for fullscreen mode.
447 
448          *  Finally, we disable the mouse pointer. If your program is not interactive, 
449          *  it's usually nice to disable the mouse pointer when in fullscreen mode. It's up to you though.
450          */
451         dwExStyle = WS_EX_APPWINDOW;                      // Window extended style
452         dwStyle = WS_POPUP;                               // Window style
453         ShowCursor(FALSE);                                // Hide mosue pointer 
454     }
455     else {
456 
457         /*
458          *  If we're using a window instead of fullscreen mode, 
459          *  we'll add WS_EX_WINDOWEDGE to the extended style. This gives the window a more 3D look. 
460          *  For style we'll use WS_OVERLAPPEDWINDOW instead of WS_POPUP. 
461          *  WS_OVERLAPPEDWINDOW creates a window with a title bar, sizing border, 
462          *  window menu, and minimize / maximize buttons.
463          */
464         dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;   // Window extended style
465         dwStyle = WS_OVERLAPPEDWINDOW;                    // Window style
466     }
467 
468     /*
469      *  By using the AdjustWindowRectEx command none of our OpenGL scene will be covered up by the borders, 
470      *  instead, the window will be made larger to account for the pixels needed to draw the window border. 
471      *  In fullscreen mode, this command has no effect.
472      */
473     AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, dwExStyle);  // Adjust window to true resqusted
474     
475     /*
476      *  WS_CLIPSIBLINGS and WS_CLIPCHILDREN are both REQUIRED for OpenGL to work properly. 
477      *  These styles prevent other windows from drawing over or into our OpenGL Window.
478      */
479     if (!(hWnd = CreateWindowEx(dwExStyle,                // Extended style for the window
480         "OpenGL",                                         // Class name
481         title,                                            // Window title
482         WS_CLIPSIBLINGS |                                 // Requried window style
483         WS_CLIPCHILDREN |                                 // Requried window style
484         dwStyle,                                          // Select window style
485         0, 0,                                             // Window position
486         WindowRect.right - WindowRect.left,               // Calculate adjusted window width
487         WindowRect.bottom - WindowRect.top,               // Calculate adjusted window height
488         NULL,                                             // No parent window
489         NULL,                                             // No menu
490         hInstance,                                        // Instance
491         NULL)))                                           // Don't pass anything to WM_CREATE
492     {
493         KillGLWindow();                                   //Reset the display
494         MessageBox(NULL, "Window creation error.", "ERROR", MB_OK | MB_ICONEXCLAMATION);
495         return FALSE;                                     // Retrurn FALSE;
496     }
497 
498     /*
499      *  aside from the stencil buffer and the (slow) accumulation buffer
500      */
501     static PIXELFORMATDESCRIPTOR pfd =                    // pfd tells windows how we want things to be 
502     {
503         sizeof(PIXELFORMATDESCRIPTOR),                    // Size of this pixel format descriptor
504         1,                                                // Version number
505         PFD_DRAW_TO_WINDOW |                              // Format must support window
506         PFD_SUPPORT_OPENGL |                              // Format must support OpenGL
507         PFD_DOUBLEBUFFER,                                 // Must support double buffer
508         PFD_TYPE_RGBA,                                    // Request an RGBA format
509         bits,                                             // Select our color depth
510         0, 0, 0, 0, 0, 0,                                 // Color bits ignored
511         0,                                                // No alpha buffer
512         0,                                                // shift bit ignored
513         0,                                                // No accumulation buffer
514         0, 0, 0, 0,                                       // Accumulation bits ignored
515         16,                                               // 16Bits Z_Buffer (depth buffer)
516         0,                                                // No stencil buffer
517         0,                                                // No auxiliary buffer
518         PFD_MAIN_PLANE,                                   // Main drawing layer
519         0,                                                // Reserved
520         0, 0, 0                                           // Layer makes ignored
521     };
522 
523     if (!(hDC = GetDC(hWnd))) {                           // Did we get a device context
524         KillGLWindow();                                   // Reset the display
525         MessageBox(NULL, "Can't create a GL device context.", "ERROR", MB_OK | MB_ICONEXCLAMATION);
526         return FALSE;                                     // Return FALSE
527     }
528 
529     if (!(PixelFormat = ChoosePixelFormat(hDC, &pfd))) {  // Did window find a matching pixel format
530         KillGLWindow();                                   // Reset the display
531         MessageBox(NULL, "Can't find a suitable pixelformat.", "ERROR", MB_OK | MB_ICONEXCLAMATION);
532         return FALSE;                                     // Return FALSE;
533     }
534 
535     if (!SetPixelFormat(hDC, PixelFormat, &pfd)) {        // Are we able to set the pixel format
536         KillGLWindow();                                   // Reset the display
537         MessageBox(NULL, "Can't set the pixelformat.", "ERROR", MB_OK | MB_ICONEXCLAMATION);
538         return FALSE;                                     // Return FALSE;
539     }
540 
541     if (!(hRC = wglCreateContext(hDC))) {                 // Are we able to rendering context
542         KillGLWindow();                                   // Reset the display
543         MessageBox(NULL, "Can't create a GL rendering context.", "ERROR", MB_OK | MB_ICONEXCLAMATION);
544         return FALSE;                                     // Return FASLE;
545     }
546 
547     if (!wglMakeCurrent(hDC, hRC)) {                      // Try to activate the rendering context
548         KillGLWindow();                                   // Reset the display
549         MessageBox(NULL, "Can't activate the GL rendering context.", "ERROR", MB_OK | MB_ICONEXCLAMATION);
550         return FALSE;                                     // Return FALSE    
551     }
552 
553     /*
554      *  ReSizeGLScene passing the screen width and height to set up our perspective OpenGL screen.
555      */
556     ShowWindow(hWnd, SW_SHOW);                            // Show the window
557     SetForegroundWindow(hWnd);                            // slightly higher priority
558     SetFocus(hWnd);                                       // Sets keyboard focus to the window
559     ReSizeGLScene(width, height);                         // Set up our perspective GL screen
560 
561 /*
562  *  we can set up lighting, textures, and anything else that needs to be setup in InitGL().
563  */
564     if (!InitGL()) {                                      // Initialize our newly created GL window
565         KillGLWindow();                                   // Reset the display
566         MessageBox(NULL, "Initialize Failed.", "ERROR", MB_OK | MB_ICONEXCLAMATION);
567         return FALSE;                                     // Return FALSE
568     }
569     return TRUE;
570 }
571 
572 LRESULT CALLBACK WndProc(HWND hWnd,                       // Handle for this window
573     UINT uMsg,                                            // Message for this window
574     WPARAM wParam,                                        // Additional message information
575     LPARAM lParam)                                        // Additional message information
576 {
577     switch (uMsg) {                                       // Check for window message
578     case WM_ACTIVATE: {                               // Check minimization state
579         if (!HIWORD(wParam)) {
580             active = TRUE;                            // Program is active
581         }
582         else {
583             active = FALSE;                           // Program is no longer active
584         }
585         return 0;                                     // Return to the message loop
586     }
587     case WM_SYSCOMMAND: {                             // Intercept system commands
588         switch (wParam) {                             // Check system calls
589         case SC_SCREENSAVE:                       // Screensaver trying to start
590         case SC_MONITORPOWER:                     // Monitor trying to enter powersave
591             return 0;                                 // Prevent form happening
592         }
593         break;                                        // Exit
594     }
595     case WM_CLOSE: {                                  // Did we receive a close message
596         PostQuitMessage(0);                           // Send a quit message
597         return 0;
598     }
599     case WM_KEYDOWN: {                                // Is a key being held down
600         keys[wParam] = TRUE;                          // if so, mark it as TRUE
601         return 0;                                     // Jump back
602     }
603     case WM_KEYUP: {                                  // Has a key been released
604         keys[wParam] = FALSE;                         // if so, mark it as FALSE
605         return 0;                                     // Jump back
606     }
607     case WM_SIZE: {                                   // Resize the OpenGL window
608         ReSizeGLScene(LOWORD(lParam), HIWORD(lParam));   // LoWord = width HiWord = height
609         return 0;                                     // Jump back
610     }
611     }
612     return DefWindowProc(hWnd, uMsg, wParam, lParam);     // Pass all unhandled message to DefWindwProc
613 }
614 
615 int WINAPI WinMain(HINSTANCE hInstance,                   // Instance
616     HINSTANCE hPrevInstance,                              // Previous instance
617     LPSTR lpCmdLine,                                      // Command line parameters
618     int nCmdShow)                                         // Window show state
619 {
620     MSG msg;                                              // Window message structure
621     BOOL done = FALSE;                                    // Bool variable to exit loop
622                                                           // Ask the user which screen mode they prefer
623     if (MessageBox(NULL, "Would you like to run in fullscreen mode?",
624         "Start fullscreen?", MB_YESNO | MB_ICONQUESTION) == IDNO)
625     {
626         fullscreen = FALSE;                               // Window mode
627     }
628     // Create our OpenGL window
629     if (!CreateGLWindow("3D Shapes", 800, 600, 32, fullscreen)) {  // (Modified)
630         return 0;                                         // Quit if window was not create
631     }
632     while (!done) {                                       // Loop that runs until donw = TRUE
633         if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {   // Is there a message wating
634             if (msg.message == WM_QUIT) {                 // Havw we received a quit message
635                 done = TRUE;                              // if so done  = TRUE
636             }
637             else {                                        // If not, deal with window message
638                 TranslateMessage(&msg);                   // Translate message
639                 DispatchMessage(&msg);                    // Dispatch message
640             }
641         }
642         else {
643             // Draw the scene. Watch for ESC key and quit message from DrawGLScene()
644             if (active) {                                 // Program active
645                 if (keys[VK_ESCAPE]) {                    // Was ESC pressed
646                     done = TRUE;                          // ESC signalled a quit
647                 }
648                 else {                                    // Not time to quit, update screen
649                     DrawGLScene();                        // Draw scene
650                     SwapBuffers(hDC);                     // Swap buffers (double buffering)
651 //******************************************************************************************************************************************/
652 //******************************************************************************************************************************************/
653                 }
654             }
655 //******************************************************************************************************************************************/
656 //******************************************************************************************************************************************/
657 
658             /*
659             *  It allows us to press the F1 key to switch from fullscreen mode to
660             *  windowed mode or windowed mode to fullscreen mode.
661             */
662             if (keys[VK_F1]) {                            // Is F1 being pressed
663                 keys[VK_F1] = FALSE;                      // If so make key FASLE
664                 KillGLWindow();                           // Kill our current window
665                 fullscreen = !fullscreen;                 // Toggle fullscreen / window mode
666                 //Recreate our OpenGL window(modified)
667                 if (!CreateGLWindow("3D Shapes", 640, 480, 16, fullscreen)) {
668                     return 0;                             // Quit if window was not create
669                 }
670             }
671         }
672     }
673     // Shutdown
674     KillGLWindow();                                       // Kill the window
675     return (msg.wParam);                                  // Exit the program
676 }
blitter.cpp

Thanks for Nehe's tutorials, this is his home.

转载于:https://www.cnblogs.com/clairvoyant/p/5767508.html

# ComfyUI Error Report ## Error Details - **Node ID:** 42 - **Node Type:** WanVideoSampler - **Exception Type:** AttributeError - **Exception Message:** 'WanModel' object has no attribute 'vace_patch_embedding' ## Stack Trace ``` File "F:\ComfyUI_Mie_V6.0\ComfyUI\execution.py", line 361, in execute output_data, output_ui, has_subgraph = get_output_data(obj, input_data_all, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\ComfyUI_Mie_V6.0\ComfyUI\execution.py", line 236, in get_output_data return_values = _map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\ComfyUI_Mie_V6.0\ComfyUI\execution.py", line 208, in _map_node_over_list process_inputs(input_dict, i) File "F:\ComfyUI_Mie_V6.0\ComfyUI\execution.py", line 197, in process_inputs results.append(getattr(obj, func)(**inputs)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\ComfyUI_Mie_V6.0\ComfyUI\custom_nodes\ComfyUI-WanVideoWrapper\nodes.py", line 3325, in process noise_pred, self.cache_state = predict_with_cfg( ^^^^^^^^^^^^^^^^^ File "F:\ComfyUI_Mie_V6.0\ComfyUI\custom_nodes\ComfyUI-WanVideoWrapper\nodes.py", line 2617, in predict_with_cfg noise_pred_cond, cache_state_cond = transformer( ^^^^^^^^^^^^ File "F:\ComfyUI_Mie_V6.0\python_embeded\Lib\site-packages\torch\nn\modules\module.py", line 1751, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\ComfyUI_Mie_V6.0\python_embeded\Lib\site-packages\torch\nn\modules\module.py", line 1762, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\ComfyUI_Mie_V6.0\ComfyUI\custom_nodes\ComfyUI-WanVideoWrapper\wanvideo\modules\model.py", line 1617, in forward vace_hints = self.forward_vace(x, data["context"], data["seq_len"], kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\ComfyUI_Mie_V6.0\ComfyUI\custom_nodes\ComfyUI-WanVideoWrapper\wanvideo\modules\model.py", line 1196, in forward_vace c = [self.vace_patch_embedding(u.unsqueeze(0).float()).to(x.dtype) for u in vace_context] ^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\ComfyUI_Mie_V6.0\python_embeded\Lib\site-packages\diffusers\models\modeling_utils.py", line 291, in __getattr__ return super().__getattr__(name) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\ComfyUI_Mie_V6.0\python_embeded\Lib\site-packages\torch\nn\modules\module.py", line 1940, in __getattr__ raise AttributeError( ``` ## System Information - **ComfyUI Version:** 0.3.43 - **Arguments:** ComfyUI\main.py --windows-standalone-build --listen 0.0.0.0 --enable-cors-header * - **OS:** nt - **Python Version:** 3.12.10 (tags/v3.12.10:0cc8128, Apr 8 2025, 12:21:36) [MSC v.1943 64 bit (AMD64)] - **Embedded Python:** true - **PyTorch Version:** 2.7.1+cu128 ## Devices - **Name:** cuda:0 NVIDIA GeForce RTX 3090 : cudaMallocAsync - **Type:** cuda - **VRAM Total:** 25769279488 - **VRAM Free:** 24347803648 - **Torch VRAM Total:** 67108864 - **Torch VRAM Free:** 50200576 ## Logs ``` 2025-07-24T17:17:54.612419 - 2025-07-24T17:17:54.663419 - INFO: IPAdapter model loaded from F:\ComfyUI_Mie_V6.0\ComfyUI\models\ipadapter\ip-adapter-plus_sd15.safetensors2025-07-24T17:17:54.663419 - 2025-07-24T17:17:54.663419 - end_vram - start_vram: 2537542306 - 2537542306 = 02025-07-24T17:17:54.663419 - 2025-07-24T17:17:54.664419 - #11 [IPAdapterUnifiedLoader]: 0.05s - vram 0b2025-07-24T17:17:54.664419 - 2025-07-24T17:17:54.924153 - end_vram - start_vram: 2639727650 - 2537542306 = 1021853442025-07-24T17:17:54.924153 - 2025-07-24T17:17:54.924670 - #10 [IPAdapterAdvanced]: 0.26s - vram 102185344b2025-07-24T17:17:54.924670 - 2025-07-24T17:17:54.931880 - end_vram - start_vram: 2733990564 - 2635766434 = 982241302025-07-24T17:17:54.931880 - 2025-07-24T17:17:54.931880 - #14 [RescaleCFG]: 0.01s - vram 98224130b2025-07-24T17:17:54.931880 - 2025-07-24T17:17:54.933882 - Requested to load BaseModel 2025-07-24T17:17:55.233473 - loaded completely 19197.46322517395 1639.406135559082 True 2025-07-24T17:18:23.076833 - 100%|██████████████████████████████████████████████████████████████████████████████████| 30/30 [00:27<00:00, 1.07it/s]2025-07-24T17:18:23.076833 - 100%|██████████████████████████████████████████████████████████████████████████████████| 30/30 [00:27<00:00, 1.08it/s]2025-07-24T17:18:23.076833 - 2025-07-24T17:18:23.078833 - end_vram - start_vram: 4711053742 - 2733990562 = 19770631802025-07-24T17:18:23.078833 - 2025-07-24T17:18:23.078833 - #3 [KSampler]: 28.15s - vram 1977063180b2025-07-24T17:18:23.078833 - 2025-07-24T17:18:23.711202 - end_vram - start_vram: 8100460554 - 3605411690 = 44950488642025-07-24T17:18:23.711239 - 2025-07-24T17:18:23.711239 - #8 [VAEDecode]: 0.63s - vram 4495048864b2025-07-24T17:18:23.711754 - 2025-07-24T17:18:23.864142 - end_vram - start_vram: 3605411690 - 3605411690 = 02025-07-24T17:18:23.864142 - 2025-07-24T17:18:23.864142 - #15 [SaveImage]: 0.15s - vram 0b2025-07-24T17:18:23.865143 - 2025-07-24T17:18:23.865143 - comfyui lumi batcher overwrite task done2025-07-24T17:18:23.865143 - 2025-07-24T17:18:23.866143 - Prompt executed in 31.05 seconds 2025-07-24T17:18:26.480125 - got prompt 2025-07-24T17:18:53.685302 - 100%|██████████████████████████████████████████████████████████████████████████████████| 30/30 [00:27<00:00, 1.14it/s]2025-07-24T17:18:53.686303 - 100%|██████████████████████████████████████████████████████████████████████████████████| 30/30 [00:27<00:00, 1.11it/s]2025-07-24T17:18:53.686303 - 2025-07-24T17:18:53.686303 - end_vram - start_vram: 4689507218 - 3605411690 = 10840955282025-07-24T17:18:53.686303 - 2025-07-24T17:18:53.687302 - #3 [KSampler]: 27.17s - vram 1084095528b2025-07-24T17:18:53.687302 - 2025-07-24T17:18:54.232028 - end_vram - start_vram: 8100460554 - 3605411690 = 44950488642025-07-24T17:18:54.232028 - 2025-07-24T17:18:54.233027 - #8 [VAEDecode]: 0.54s - vram 4495048864b2025-07-24T17:18:54.233027 - 2025-07-24T17:18:54.380027 - end_vram - start_vram: 3605411690 - 3605411690 = 02025-07-24T17:18:54.380027 - 2025-07-24T17:18:54.380027 - #15 [SaveImage]: 0.15s - vram 0b2025-07-24T17:18:54.380027 - 2025-07-24T17:18:54.381027 - comfyui lumi batcher overwrite task done2025-07-24T17:18:54.382027 - 2025-07-24T17:18:54.385027 - Prompt executed in 27.90 seconds 2025-07-24T17:24:25.352704 - got prompt 2025-07-24T17:24:25.445704 - end_vram - start_vram: 3507187562 - 3507187562 = 02025-07-24T17:24:25.446704 - 2025-07-24T17:24:25.446704 - #20 [LoraLoader]: 0.05s - vram 0b2025-07-24T17:24:25.446704 - 2025-07-24T17:24:25.447704 - Requested to load SD1ClipModel 2025-07-24T17:24:25.792290 - loaded completely 18695.929541397094 235.84423828125 True 2025-07-24T17:24:25.800290 - end_vram - start_vram: 3521486046 - 3507187562 = 142984842025-07-24T17:24:25.800290 - 2025-07-24T17:24:25.800290 - #7 [CLIPTextEncode]: 0.35s - vram 14298484b2025-07-24T17:24:25.800290 - 2025-07-24T17:24:25.808290 - end_vram - start_vram: 3519593078 - 3507187562 = 124055162025-07-24T17:24:25.808290 - 2025-07-24T17:24:25.809290 - #6 [CLIPTextEncode]: 0.01s - vram 12405516b2025-07-24T17:24:25.809290 - 2025-07-24T17:24:25.810290 - end_vram - start_vram: 3507187562 - 3507187562 = 02025-07-24T17:24:25.810290 - 2025-07-24T17:24:25.810290 - #11 [IPAdapterUnifiedLoader]: 0.00s - vram 0b2025-07-24T17:24:25.810290 - 2025-07-24T17:24:26.053290 - end_vram - start_vram: 3609372906 - 3507187562 = 1021853442025-07-24T17:24:26.053290 - 2025-07-24T17:24:26.054290 - #10 [IPAdapterAdvanced]: 0.24s - vram 102185344b2025-07-24T17:24:26.054290 - 2025-07-24T17:24:26.059290 - end_vram - start_vram: 3703635820 - 3605411690 = 982241302025-07-24T17:24:26.059290 - 2025-07-24T17:24:26.060290 - #14 [RescaleCFG]: 0.01s - vram 98224130b2025-07-24T17:24:26.060290 - 2025-07-24T17:24:26.061290 - Requested to load BaseModel 2025-07-24T17:24:26.644908 - loaded completely 19912.1512134552 1639.406135559082 True 2025-07-24T17:24:53.885378 - 100%|██████████████████████████████████████████████████████████████████████████████████| 30/30 [00:27<00:00, 1.08it/s]2025-07-24T17:24:53.885378 - 100%|██████████████████████████████████████████████████████████████████████████████████| 30/30 [00:27<00:00, 1.10it/s]2025-07-24T17:24:53.885378 - 2025-07-24T17:24:53.886378 - end_vram - start_vram: 4689507218 - 3703635818 = 9858714002025-07-24T17:24:53.886378 - 2025-07-24T17:24:53.886378 - #3 [KSampler]: 27.83s - vram 985871400b2025-07-24T17:24:53.887378 - 2025-07-24T17:24:54.482797 - end_vram - start_vram: 8100460554 - 3605411690 = 44950488642025-07-24T17:24:54.482797 - 2025-07-24T17:24:54.482797 - #8 [VAEDecode]: 0.60s - vram 4495048864b2025-07-24T17:24:54.482797 - 2025-07-24T17:24:54.640169 - end_vram - start_vram: 3605411690 - 3605411690 = 02025-07-24T17:24:54.640169 - 2025-07-24T17:24:54.640169 - #15 [SaveImage]: 0.16s - vram 0b2025-07-24T17:24:54.640169 - 2025-07-24T17:24:54.641169 - comfyui lumi batcher overwrite task done2025-07-24T17:24:54.641169 - 2025-07-24T17:24:54.643410 - Prompt executed in 29.28 seconds 2025-07-24T17:25:09.991282 - got prompt 2025-07-24T17:25:10.085282 - end_vram - start_vram: 3507187562 - 3507187562 = 02025-07-24T17:25:10.085282 - 2025-07-24T17:25:10.085282 - #20 [LoraLoader]: 0.05s - vram 0b2025-07-24T17:25:10.085282 - 2025-07-24T17:25:10.086282 - Requested to load SD1ClipModel 2025-07-24T17:25:10.369134 - loaded completely 18695.929541397094 235.84423828125 True 2025-07-24T17:25:10.377134 - end_vram - start_vram: 3521486046 - 3507187562 = 142984842025-07-24T17:25:10.377134 - 2025-07-24T17:25:10.377134 - #7 [CLIPTextEncode]: 0.29s - vram 14298484b2025-07-24T17:25:10.377134 - 2025-07-24T17:25:10.385134 - end_vram - start_vram: 3519593078 - 3507187562 = 124055162025-07-24T17:25:10.385134 - 2025-07-24T17:25:10.385134 - #6 [CLIPTextEncode]: 0.01s - vram 12405516b2025-07-24T17:25:10.385134 - 2025-07-24T17:25:10.386135 - end_vram - start_vram: 3507187562 - 3507187562 = 02025-07-24T17:25:10.386135 - 2025-07-24T17:25:10.386135 - #11 [IPAdapterUnifiedLoader]: 0.00s - vram 0b2025-07-24T17:25:10.386135 - 2025-07-24T17:25:10.631046 - end_vram - start_vram: 3609372906 - 3507187562 = 1021853442025-07-24T17:25:10.631046 - 2025-07-24T17:25:10.631046 - #10 [IPAdapterAdvanced]: 0.24s - vram 102185344b2025-07-24T17:25:10.631046 - 2025-07-24T17:25:10.637046 - end_vram - start_vram: 3703635820 - 3605411690 = 982241302025-07-24T17:25:10.637046 - 2025-07-24T17:25:10.637046 - #14 [RescaleCFG]: 0.01s - vram 98224130b2025-07-24T17:25:10.637046 - 2025-07-24T17:25:10.639047 - Requested to load BaseModel 2025-07-24T17:25:11.180881 - loaded completely 19912.1512134552 1639.406135559082 True 2025-07-24T17:25:39.272121 - 100%|██████████████████████████████████████████████████████████████████████████████████| 30/30 [00:28<00:00, 1.08it/s]2025-07-24T17:25:39.272121 - 100%|██████████████████████████████████████████████████████████████████████████████████| 30/30 [00:28<00:00, 1.07it/s]2025-07-24T17:25:39.272121 - 2025-07-24T17:25:39.273121 - end_vram - start_vram: 4689507218 - 3703635818 = 9858714002025-07-24T17:25:39.273121 - 2025-07-24T17:25:39.274121 - #3 [KSampler]: 28.64s - vram 985871400b2025-07-24T17:25:39.274121 - 2025-07-24T17:25:39.888702 - end_vram - start_vram: 8100460554 - 3605411690 = 44950488642025-07-24T17:25:39.888702 - 2025-07-24T17:25:39.888702 - #8 [VAEDecode]: 0.61s - vram 4495048864b2025-07-24T17:25:39.888702 - 2025-07-24T17:25:40.051703 - end_vram - start_vram: 3605411690 - 3605411690 = 02025-07-24T17:25:40.051703 - 2025-07-24T17:25:40.051703 - #15 [SaveImage]: 0.16s - vram 0b2025-07-24T17:25:40.051703 - 2025-07-24T17:25:40.052703 - comfyui lumi batcher overwrite task done2025-07-24T17:25:40.052703 - 2025-07-24T17:25:40.060703 - Prompt executed in 30.06 seconds 2025-07-24T17:43:56.476860 - got prompt 2025-07-24T17:43:57.039587 - end_vram - start_vram: 106744016 - 106744016 = 02025-07-24T17:43:57.039587 - 2025-07-24T17:43:57.039587 - #7 [WanVideoVAELoader]: 0.48s - vram 0b2025-07-24T17:43:57.040588 - 2025-07-24T17:43:57.040588 - end_vram - start_vram: 106744016 - 106744016 = 02025-07-24T17:43:57.040588 - 2025-07-24T17:43:57.040588 - #12 [WanVideoExperimentalArgs]: 0.00s - vram 0b2025-07-24T17:43:57.040588 - 2025-07-24T17:43:57.041588 - end_vram - start_vram: 106744016 - 106744016 = 02025-07-24T17:43:57.041588 - 2025-07-24T17:43:57.041588 - #10 [WanVideoEnhanceAVideo]: 0.00s - vram 0b2025-07-24T17:43:57.041588 - 2025-07-24T17:43:57.042588 - end_vram - start_vram: 106744016 - 106744016 = 02025-07-24T17:43:57.042588 - 2025-07-24T17:43:57.042588 - #21 [WanVideoVACEModelSelect]: 0.00s - vram 0b2025-07-24T17:43:57.042588 - 2025-07-24T17:44:00.282807 - Detected model in_channels: 36 2025-07-24T17:44:00.282807 - Model type: fl2v, num_heads: 40, num_layers: 40 2025-07-24T17:44:00.283807 - Model variant detected: i2v_720 2025-07-24T17:44:00.596667 - model_type FLOW 2025-07-24T17:44:00.597701 - Using accelerate to load and assign model weights to device... 2025-07-24T17:44:00.801188 - Loading transformer parameters to cpu: 83%|██████████████████████████████▋ | 1080/1304 [00:00<00:00, 5458.86it/s]2025-07-24T17:44:00.839187 - Loading transformer parameters to cpu: 100%|█████████████████████████████████████| 1304/1304 [00:00<00:00, 5446.33it/s]2025-07-24T17:44:00.839187 - 2025-07-24T17:44:00.844187 - end_vram - start_vram: 106744016 - 106744016 = 02025-07-24T17:44:00.844187 - 2025-07-24T17:44:00.844187 - #22 [WanVideoModelLoader]: 3.80s - vram 0b2025-07-24T17:44:00.844187 - 2025-07-24T17:44:02.947231 - end_vram - start_vram: 106744016 - 106744016 = 02025-07-24T17:44:02.948230 - 2025-07-24T17:44:02.948230 - #6 [LoadWanVideoT5TextEncoder]: 2.10s - vram 0b2025-07-24T17:44:02.948230 - 2025-07-24T17:44:02.948230 - Moving video model to cpu 2025-07-24T17:45:21.569551 - end_vram - start_vram: 11728619736 - 106744016 = 116218757202025-07-24T17:45:21.569558 - 2025-07-24T17:45:21.569558 - #8 [WanVideoTextEncode]: 78.62s - vram 11621875720b2025-07-24T17:45:21.569558 - 2025-07-24T17:45:21.624655 - end_vram - start_vram: 115132624 - 115132624 = 02025-07-24T17:45:21.625215 - 2025-07-24T17:45:21.625215 - #34 [LoadImage]: 0.05s - vram 0b2025-07-24T17:45:21.625215 - 2025-07-24T17:45:21.626235 - end_vram - start_vram: 115132624 - 115132624 = 02025-07-24T17:45:21.626242 - 2025-07-24T17:45:21.626242 - #19 [INTConstant]: 0.00s - vram 0b2025-07-24T17:45:21.626242 - 2025-07-24T17:45:21.671234 - end_vram - start_vram: 115132624 - 115132624 = 02025-07-24T17:45:21.671234 - 2025-07-24T17:45:21.671234 - #24 [ImageResizeKJ]: 0.04s - vram 0b2025-07-24T17:45:21.671234 - 2025-07-24T17:45:21.738079 - end_vram - start_vram: 115132624 - 115132624 = 02025-07-24T17:45:21.738592 - 2025-07-24T17:45:21.739108 - #30 [ImageResizeKJ]: 0.07s - vram 0b2025-07-24T17:45:21.739108 - 2025-07-24T17:45:21.782786 - end_vram - start_vram: 115132624 - 115132624 = 02025-07-24T17:45:21.782786 - 2025-07-24T17:45:21.782786 - #35 [ImageResizeKJ]: 0.04s - vram 0b2025-07-24T17:45:21.782786 - 2025-07-24T17:45:21.915384 - end_vram - start_vram: 115132624 - 115132624 = 02025-07-24T17:45:21.915902 - 2025-07-24T17:45:21.915902 - #29 [WanVideoVACEStartToEndFrame]: 0.13s - vram 0b2025-07-24T17:45:21.915902 - 2025-07-24T17:45:21.916414 - end_vram - start_vram: 115132624 - 115132624 = 02025-07-24T17:45:21.916918 - 2025-07-24T17:45:21.917002 - #40 [GetImageRangeFromBatch]: 0.00s - vram 0b2025-07-24T17:45:21.917002 - 2025-07-24T17:45:21.981944 - end_vram - start_vram: 115132624 - 115132624 = 02025-07-24T17:45:21.981944 - 2025-07-24T17:45:21.981944 - #25 [WanVideoVACEStartToEndFrame]: 0.06s - vram 0b2025-07-24T17:45:21.981944 - 2025-07-24T17:45:21.995235 - end_vram - start_vram: 115132624 - 115132624 = 02025-07-24T17:45:21.995235 - 2025-07-24T17:45:21.995235 - #41 [MaskBatchMulti]: 0.01s - vram 0b2025-07-24T17:45:21.995235 - 2025-07-24T17:45:22.039203 - end_vram - start_vram: 115132624 - 115132624 = 02025-07-24T17:45:22.039203 - 2025-07-24T17:45:22.039203 - #37 [ImageBatchMulti]: 0.04s - vram 0b2025-07-24T17:45:22.039708 - 2025-07-24T17:45:22.039713 - end_vram - start_vram: 115132624 - 115132624 = 02025-07-24T17:45:22.040227 - 2025-07-24T17:45:22.040227 - #26 [GetImageSizeAndCount]: 0.00s - vram 0b2025-07-24T17:45:22.040227 - 2025-07-24T17:45:22.883828 - input_masks shape2025-07-24T17:45:22.883828 - 2025-07-24T17:45:22.884341 - torch.Size([81, 496, 896])2025-07-24T17:45:22.884341 - 2025-07-24T17:45:34.863567 - VAE encoding: 100%|██████████████████████████████████████████████████████████████████████| 9/9 [00:11<00:00, 1.30s/it]2025-07-24T17:45:34.863567 - VAE encoding: 100%|██████████████████████████████████████████████████████████████████████| 9/9 [00:11<00:00, 1.32s/it]2025-07-24T17:45:34.864077 - 2025-07-24T17:45:46.589102 - VAE encoding: 100%|██████████████████████████████████████████████████████████████████████| 9/9 [00:11<00:00, 1.30s/it]2025-07-24T17:45:46.589612 - VAE encoding: 100%|██████████████████████████████████████████████████████████████████████| 9/9 [00:11<00:00, 1.30s/it]2025-07-24T17:45:46.589612 - 2025-07-24T17:45:46.600743 - refs shape2025-07-24T17:45:46.600743 - 2025-07-24T17:45:46.600743 - torch.Size([1, 3, 1, 496, 896])2025-07-24T17:45:46.600743 - 2025-07-24T17:45:46.715123 - VAE encoding: 56%|██████████████████████████████████████▉ | 5/9 [00:00<00:00, 44.31it/s]2025-07-24T17:45:46.805051 - VAE encoding: 100%|██████████████████████████████████████████████████████████████████████| 9/9 [00:00<00:00, 44.38it/s]2025-07-24T17:45:46.805583 - 2025-07-24T17:45:46.870662 - end_vram - start_vram: 2252473238 - 115132624 = 21373406142025-07-24T17:45:46.870662 - 2025-07-24T17:45:46.871171 - #16 [WanVideoVACEEncode]: 24.83s - vram 2137340614b2025-07-24T17:45:46.871171 - 2025-07-24T17:45:46.873216 - timesteps: tensor([1000.0000, 983.7124, 964.5367, 941.6301, 913.7864, 879.2166, 835.1485, 777.0445, 696.9283, 579.3684, 390.1099, 34.7826], device='cuda:0') 2025-07-24T17:45:46.887141 - Seq len: 38192 2025-07-24T17:49:31.510530 - Sampling 85 frames at 896x496 with 12 steps 2025-07-24T17:49:37.849674 - 0%| | 0/12 [00:00<?, ?it/s]2025-07-24T17:49:44.296375 - 0%| | 0/12 [00:06<?, ?it/s]2025-07-24T17:49:44.297376 - 2025-07-24T17:49:44.747159 - !!! Exception during processing !!! 'WanModel' object has no attribute 'vace_patch_embedding' 2025-07-24T17:49:44.783076 - Traceback (most recent call last): File "F:\ComfyUI_Mie_V6.0\ComfyUI\execution.py", line 361, in execute output_data, output_ui, has_subgraph = get_output_data(obj, input_data_all, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\ComfyUI_Mie_V6.0\ComfyUI\execution.py", line 236, in get_output_data return_values = _map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\ComfyUI_Mie_V6.0\ComfyUI\execution.py", line 208, in _map_node_over_list process_inputs(input_dict, i) File "F:\ComfyUI_Mie_V6.0\ComfyUI\execution.py", line 197, in process_inputs results.append(getattr(obj, func)(**inputs)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\ComfyUI_Mie_V6.0\ComfyUI\custom_nodes\ComfyUI-WanVideoWrapper\nodes.py", line 3325, in process noise_pred, self.cache_state = predict_with_cfg( ^^^^^^^^^^^^^^^^^ File "F:\ComfyUI_Mie_V6.0\ComfyUI\custom_nodes\ComfyUI-WanVideoWrapper\nodes.py", line 2617, in predict_with_cfg noise_pred_cond, cache_state_cond = transformer( ^^^^^^^^^^^^ File "F:\ComfyUI_Mie_V6.0\python_embeded\Lib\site-packages\torch\nn\modules\module.py", line 1751, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\ComfyUI_Mie_V6.0\python_embeded\Lib\site-packages\torch\nn\modules\module.py", line 1762, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\ComfyUI_Mie_V6.0\ComfyUI\custom_nodes\ComfyUI-WanVideoWrapper\wanvideo\modules\model.py", line 1617, in forward vace_hints = self.forward_vace(x, data["context"], data["seq_len"], kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\ComfyUI_Mie_V6.0\ComfyUI\custom_nodes\ComfyUI-WanVideoWrapper\wanvideo\modules\model.py", line 1196, in forward_vace c = [self.vace_patch_embedding(u.unsqueeze(0).float()).to(x.dtype) for u in vace_context] ^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\ComfyUI_Mie_V6.0\python_embeded\Lib\site-packages\diffusers\models\modeling_utils.py", line 291, in __getattr__ return super().__getattr__(name) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\ComfyUI_Mie_V6.0\python_embeded\Lib\site-packages\torch\nn\modules\module.py", line 1940, in __getattr__ raise AttributeError( AttributeError: 'WanModel' object has no attribute 'vace_patch_embedding'. Did you mean: 'patch_embedding'? 2025-07-24T17:49:44.785980 - end_vram - start_vram: 34183609272 - 173795536 = 340098137362025-07-24T17:49:44.785980 - 2025-07-24T17:49:44.785980 - #42 [WanVideoSampler]: 237.91s - vram 34009813736b2025-07-24T17:49:44.785980 - 2025-07-24T17:49:44.798561 - comfyui lumi batcher overwrite task done2025-07-24T17:49:44.798968 - 2025-07-24T17:49:44.868694 - Prompt executed in 348.38 seconds 2025-07-24T18:17:32.104770 - [ComfyUI-Manager] The ComfyRegistry cache update is still in progress, so an outdated cache is being used.2025-07-24T18:17:32.105296 - 2025-07-24T18:17:33.147891 - FETCH DATA from: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/custom-node-list.json2025-07-24T18:17:33.147891 - 2025-07-24T18:17:36.036752 - [DONE]2025-07-24T18:17:36.036752 - 2025-07-24T18:17:36.120191 - FETCH DATA from: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/github-stats.json2025-07-24T18:17:36.120191 - 2025-07-24T18:17:37.292226 - [DONE]2025-07-24T18:17:37.292226 - 2025-07-24T18:17:37.313785 - FETCH DATA from: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/extras.json2025-07-24T18:17:37.313785 - 2025-07-24T18:17:38.420206 - [DONE]2025-07-24T18:17:38.420897 - 2025-07-24T18:17:38.602146 - FETCH DATA from: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/extension-node-map.json2025-07-24T18:17:38.602146 - 2025-07-24T18:17:39.726647 - [DONE]2025-07-24T18:17:39.726647 - 2025-07-24T18:21:32.720524 - got prompt 2025-07-24T18:21:36.403235 - timesteps: tensor([1000.0000, 983.7124, 964.5367, 941.6301, 913.7864, 879.2166, 835.1485, 777.0445, 696.9283, 579.3684, 390.1099, 34.7826], device='cuda:0') 2025-07-24T18:21:36.571239 - Seq len: 38192 2025-07-24T18:21:36.578239 - Sampling 85 frames at 896x496 with 12 steps 2025-07-24T18:21:36.834814 - 0%| | 0/12 [00:00<?, ?it/s]2025-07-24T18:21:40.522225 - 0%| | 0/12 [00:03<?, ?it/s]2025-07-24T18:21:40.522225 - 2025-07-24T18:21:40.567079 - !!! Exception during processing !!! 'WanModel' object has no attribute 'vace_patch_embedding' 2025-07-24T18:21:40.572236 - Traceback (most recent call last): File "F:\ComfyUI_Mie_V6.0\ComfyUI\execution.py", line 361, in execute output_data, output_ui, has_subgraph = get_output_data(obj, input_data_all, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\ComfyUI_Mie_V6.0\ComfyUI\execution.py", line 236, in get_output_data return_values = _map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\ComfyUI_Mie_V6.0\ComfyUI\execution.py", line 208, in _map_node_over_list process_inputs(input_dict, i) File "F:\ComfyUI_Mie_V6.0\ComfyUI\execution.py", line 197, in process_inputs results.append(getattr(obj, func)(**inputs)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\ComfyUI_Mie_V6.0\ComfyUI\custom_nodes\ComfyUI-WanVideoWrapper\nodes.py", line 3325, in process noise_pred, self.cache_state = predict_with_cfg( ^^^^^^^^^^^^^^^^^ File "F:\ComfyUI_Mie_V6.0\ComfyUI\custom_nodes\ComfyUI-WanVideoWrapper\nodes.py", line 2617, in predict_with_cfg noise_pred_cond, cache_state_cond = transformer( ^^^^^^^^^^^^ File "F:\ComfyUI_Mie_V6.0\python_embeded\Lib\site-packages\torch\nn\modules\module.py", line 1751, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\ComfyUI_Mie_V6.0\python_embeded\Lib\site-packages\torch\nn\modules\module.py", line 1762, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\ComfyUI_Mie_V6.0\ComfyUI\custom_nodes\ComfyUI-WanVideoWrapper\wanvideo\modules\model.py", line 1617, in forward vace_hints = self.forward_vace(x, data["context"], data["seq_len"], kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\ComfyUI_Mie_V6.0\ComfyUI\custom_nodes\ComfyUI-WanVideoWrapper\wanvideo\modules\model.py", line 1196, in forward_vace c = [self.vace_patch_embedding(u.unsqueeze(0).float()).to(x.dtype) for u in vace_context] ^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\ComfyUI_Mie_V6.0\python_embeded\Lib\site-packages\diffusers\models\modeling_utils.py", line 291, in __getattr__ return super().__getattr__(name) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\ComfyUI_Mie_V6.0\python_embeded\Lib\site-packages\torch\nn\modules\module.py", line 1940, in __getattr__ raise AttributeError( AttributeError: 'WanModel' object has no attribute 'vace_patch_embedding'. Did you mean: 'patch_embedding'? 2025-07-24T18:21:40.574784 - end_vram - start_vram: 34183609272 - 32966353744 = 12172555282025-07-24T18:21:40.574784 - 2025-07-24T18:21:40.575297 - #42 [WanVideoSampler]: 7.68s - vram 1217255528b2025-07-24T18:21:40.575297 - 2025-07-24T18:21:40.575811 - comfyui lumi batcher overwrite task done2025-07-24T18:21:40.575811 - 2025-07-24T18:21:40.577866 - Prompt executed in 7.84 seconds ``` ## Attached Workflow Please make sure that workflow does not contain any sensitive information such as API keys or passwords. ``` Workflow too large. Please manually upload the workflow from local file system. ``` ## Additional Context (Please add any additional context or steps to reproduce the error here) 什么问题,该怎么解决
最新发布
07-25
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值