Mercurial > hg > dmlib
annotate editor/edview.cpp @ 2266:ecc17b2e129e
Add constants for "full" C64 screen dimensions, including the border
regions. These are for future support of fullscreen image formats.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 17 Jun 2019 05:31:38 +0300 |
parents | b4992d9f72fe |
children |
rev | line source |
---|---|
385 | 1 #include "edview.h" |
391 | 2 #include <QtGui> |
385 | 3 |
4 | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
398
diff
changeset
|
5 QEDGLDemoView::QEDGLDemoView(QWidget *parent) : |
391 | 6 QGLWidget(QGLFormat(QGL::SampleBuffers|QGL::AlphaChannel), parent) |
385 | 7 { |
8 makeCurrent(); | |
9 | |
10 if (QGLFramebufferObject::hasOpenGLFramebufferBlit()) | |
11 { | |
12 QGLFramebufferObjectFormat format; | |
13 format.setSamples(4); | |
14 format.setAttachment(QGLFramebufferObject::CombinedDepthStencil); | |
15 | |
391 | 16 // render_fbo = new QGLFramebufferObject(512, 512, format); |
17 // texture_fbo = new QGLFramebufferObject(512, 512); | |
385 | 18 } |
19 else | |
20 { | |
391 | 21 // render_fbo = new QGLFramebufferObject(1024, 1024); |
22 // texture_fbo = render_fbo; | |
385 | 23 } |
398 | 24 |
25 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); | |
385 | 26 } |
27 | |
391 | 28 |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
398
diff
changeset
|
29 QEDGLDemoView::~QEDGLDemoView() |
385 | 30 { |
391 | 31 } |
32 | |
33 | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
398
diff
changeset
|
34 QSize QEDGLDemoView::minimumSizeHint() const |
398 | 35 { |
36 return QSize(320, 240); | |
37 } | |
38 | |
39 | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
398
diff
changeset
|
40 QSize QEDGLDemoView::sizeHint() const |
398 | 41 { |
42 return QSize(640, 480); | |
43 } | |
44 | |
45 | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
398
diff
changeset
|
46 void QEDGLDemoView::setEngineData(DMEngineData *mengine) |
391 | 47 { |
48 engine = mengine; | |
385 | 49 } |
50 | |
51 | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
398
diff
changeset
|
52 void QEDGLDemoView::render(int frameTime) |
385 | 53 { |
391 | 54 if (engine != NULL) |
55 { | |
56 engine->frameTime = frameTime; | |
57 | |
58 if (engine->demoRender != NULL) | |
59 { | |
60 engine->demoRender(engine); | |
61 } | |
62 else | |
63 { | |
1738 | 64 dmExecuteTimeline(engine->ptl, engine, engineGetTick(engine)); |
391 | 65 } |
66 | |
67 engine->frameCount++; | |
68 } | |
385 | 69 } |
70 | |
71 | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
398
diff
changeset
|
72 void QEDGLDemoView::paintEvent(QPaintEvent *) |
385 | 73 { |
74 // save the GL state set for QPainter | |
75 saveGLState(); | |
76 | |
77 // restore the GL state that QPainter expects | |
78 restoreGLState(); | |
79 } | |
80 | |
81 | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
398
diff
changeset
|
82 void QEDGLDemoView::saveGLState() |
385 | 83 { |
84 glPushAttrib(GL_ALL_ATTRIB_BITS); | |
85 glMatrixMode(GL_PROJECTION); | |
86 glPushMatrix(); | |
87 glMatrixMode(GL_MODELVIEW); | |
88 glPushMatrix(); | |
89 } | |
90 | |
91 | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
398
diff
changeset
|
92 void QEDGLDemoView::restoreGLState() |
385 | 93 { |
94 glMatrixMode(GL_PROJECTION); | |
95 glPopMatrix(); | |
96 glMatrixMode(GL_MODELVIEW); | |
97 glPopMatrix(); | |
98 glPopAttrib(); | |
99 } | |
391 | 100 |
101 | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
398
diff
changeset
|
102 QEDSWDemoView::QEDSWDemoView(QWidget *parent) : QEDGLDemoView(parent) |
391 | 103 { |
104 img = NULL; | |
105 } | |
106 | |
107 | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
398
diff
changeset
|
108 QEDSWDemoView::~QEDSWDemoView() |
391 | 109 { |
110 delete img; | |
111 } | |
112 | |
113 | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
398
diff
changeset
|
114 void QEDSWDemoView::setEngineData(DMEngineData *mengine) |
391 | 115 { |
116 engine = mengine; | |
117 delete img; | |
118 | |
119 img = new QImage((const uchar *)mengine->screen->pixels, | |
120 mengine->screen->w, mengine->screen->h, | |
121 mengine->screen->pitch, QImage::Format_RGB32); | |
122 } | |
123 | |
124 | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
398
diff
changeset
|
125 void QEDSWDemoView::paintEvent(QPaintEvent *) |
391 | 126 { |
127 if (img != NULL) | |
128 { | |
129 QPainter painter(this); | |
130 painter.drawImage(QPoint(0, 0), *img); | |
131 } | |
132 } | |
133 | |
134 | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
398
diff
changeset
|
135 void QEDSWDemoView::render(int frameTime) |
391 | 136 { |
137 if (SDL_MUSTLOCK(engine->screen) != 0 && SDL_LockSurface(engine->screen) != 0) | |
138 return; | |
139 | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
398
diff
changeset
|
140 QEDGLDemoView::render(frameTime); |
391 | 141 |
142 if (SDL_MUSTLOCK(engine->screen) != 0) | |
143 SDL_UnlockSurface(engine->screen); | |
144 | |
145 update(); | |
146 } | |
147 | |
148 |