summaryrefslogtreecommitdiff
path: root/createcalls.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'createcalls.cpp')
-rw-r--r--createcalls.cpp148
1 files changed, 34 insertions, 114 deletions
diff --git a/createcalls.cpp b/createcalls.cpp
index 4ddaa7e..89d881b 100644
--- a/createcalls.cpp
+++ b/createcalls.cpp
@@ -217,13 +217,16 @@ Mask_TriangulateAndRasterize(memory *Memory, project_layer *Layer, mask *Mask)
glBindFramebuffer(GL_FRAMEBUFFER, Test.FramebufferObject);
glEnable(GL_STENCIL_TEST);
- glStencilOp(GL_KEEP, GL_REPLACE, GL_REPLACE);
+ // glStencilOp(GL_KEEP, GL_REPLACE, GL_REPLACE);
+ glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
- glStencilFunc(GL_ALWAYS, 1, 0xFF); // always write
+ glStencilFunc(GL_ALWAYS, 0, 0xFF); // always write
glStencilMask(0xff); // allow writing; ANDs any writes to the stencil buffer with this
+ glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
+
glUseProgram(MaskShaderProgram);
// secondary VBO
@@ -239,11 +242,21 @@ Mask_TriangulateAndRasterize(memory *Memory, project_layer *Layer, mask *Mask)
int Scale = glGetUniformLocation(MaskShaderProgram, "CompDimensions");
glUniform3f(Scale, (real32)Layer->Source->Info.Width, (real32)Layer->Source->Info.Height, 0);
+
+ glStencilOpSeparate(GL_FRONT, GL_KEEP, GL_KEEP, GL_INCR_WRAP);
+ glStencilOpSeparate(GL_BACK, GL_KEEP, GL_KEEP, GL_DECR_WRAP);
+
+ glDisable(GL_CULL_FACE);
+
glDrawArrays(GL_TRIANGLE_FAN, 0, Mask->NumberOfVerts);
+ // glEnable(GL_CULL_FACE);
+
+ glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
+
glBindVertexArray(0);
- glStencilFunc(GL_EQUAL, 1, 0xFF);
- glStencilMask(0x00); // disables stencil writing
+ // glStencilFunc(GL_EQUAL, 1, 0xFF);
+ // glStencilMask(0x00); // disables stencil writing
glBindRenderbuffer(GL_RENDERBUFFER, Test.Color_Renderbuffer);
glUseProgram(DefaultShaderProgram);
@@ -258,7 +271,13 @@ Mask_TriangulateAndRasterize(memory *Memory, project_layer *Layer, mask *Mask)
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void*)(3 * sizeof(float)));
glEnableVertexAttribArray(1);
- glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
+ //glStencilFunc(GL_EQUAL, 0, 0xFF);
+ //glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
+ //glDrawElements(GL_TRIANGLE_STRIP, 6, GL_UNSIGNED_INT, 0);
+
+ glStencilFunc(GL_NOTEQUAL, 0, 0xFF);
+ glStencilOp(GL_ZERO, GL_ZERO, GL_ZERO);
+ glDrawElements(GL_TRIANGLE_STRIP, 6, GL_UNSIGNED_INT, 0);
glDisable(GL_STENCIL_TEST);
glStencilMask(0xFF);
@@ -287,8 +306,9 @@ Layer_UpdateBitmap(project_layer *Layer, memory *Memory, int32 CurrentFrame) {
uint16 Height = Source->Info.Height;
uint16 BytesPerPixel = Source->Info.BytesPerPixel;
void *DestBuffer = BitmapInfo->BitmapBuffer;
- uint64 Size = Bitmap_CalcUnpackedBytes(Source->Info.Width, Source->Info.Height, Source->Info.BytesPerPixel);
- Bitmap_CopyToPointer(Bitmap->Data, DestBuffer, BytesPerPixel, Size);
+ uint64 UnpackedSize = Bitmap_CalcUnpackedBytes(Source->Info.Width, Source->Info.Height, Source->Info.BytesPerPixel);
+ uint64 PackedSize = Bitmap_CalcTotalBytes(Source->Info.Width, Source->Info.Height, Source->Info.BytesPerPixel);
+ Bitmap_CopyToPointer(Bitmap->Data, DestBuffer, BytesPerPixel, UnpackedSize);
TestGL_InitTexture(&BitmapInfo->Test, DestBuffer, Width, Height);
@@ -305,7 +325,7 @@ Layer_UpdateBitmap(project_layer *Layer, memory *Memory, int32 CurrentFrame) {
Layer->Effect[i]->func(Source, BitmapInfo, Memory, Layer->Effect[i]->Property);
}
Bitmap_ConvertPacking(DestBuffer, Memory->Scratch, Width, Height, BytesPerPixel, 0);
- Bitmap_CopyToPointer(Memory->Scratch, DestBuffer, BytesPerPixel, Size);
+ Bitmap_CopyToPointer(Memory->Scratch, DestBuffer, BytesPerPixel, PackedSize);
}
static void
@@ -418,6 +438,7 @@ LoadTestFootage(project_data *File, project_state *State, memory *Memory)
PostMsg(State, "File open fail...");
source *Source = &File->Source[0];
Layer_CreateFromSource(File, State, Memory, Source);
+
SelectLayer(File->Layer[0], State, 0);
// AddEffect(File->Layer[0], Memory, 3);
@@ -447,9 +468,13 @@ LoadTestFootage(project_data *File, project_state *State, memory *Memory)
Mask->Point[3].HandleBezier = true;
Mask->Point[4].HandleBezier = true;
-
Mask->NumberOfPoints = 5;
+ // if (!Source_Generate(File, Memory, "../asset/test.png"))
+ // PostMsg(State, "File open fail...");
+ if (!Source_Generate(File, Memory, "../asset/debug.png"))
+ PostMsg(State, "File open fail...");
+
// property_channel *Property = &File->Layer[0]->x;
// ManualKeyframeInsertF(Property, Memory, 1, 500);
// ManualKeyframeInsertF(Property, Memory, 30, 800);
@@ -538,108 +563,6 @@ CreateGrid(project_data *File, memory *Memory) {
}
}
#endif
-#if 0
-static void
-DrawHistogram(project_layer *Layer, pixel_buffer *UIBuffer, void *Scratch, memory *Memory, sdl_input Input, project_state *State,
- rectangle Box)
-{
- uint16 Padding = 20; //UI->LayerPadding / 5;
- uint16 Margin = 100;
-
- uint16 *Levels = (uint16 *)Scratch;
-
- uint16 *Mean = (Levels + 256*7);
-
- uint32 Color = 0;
- uint32 AltColor = ColToUint32(V4(0.1,0.1,0.1,1.0));
-
- // this is a bad idea
- real32 *Zoom = (real32 *)(Levels + 256*6);
- if (*Zoom < 0.0f)
- *Zoom = 0.0f;
- uint16 *SelectedChannel = (uint16 *)(Levels + 256*6 + 3);
-
- if (*SelectedChannel == 0) {
- Color = ColToUint32(V4(0.6,0.6,0.6,1.0));
- } else if (*SelectedChannel == 1) {
- Levels += 256;
- Color = ColToUint32(V4(0.6,0.0,0.0,1.0));
- } else if (*SelectedChannel == 2) {
- Levels += 256*2;
- Color = ColToUint32(V4(0.0,0.6,0.0,1.0));
- } else if (*SelectedChannel == 3) {
- Levels += 256*3;
- Color = ColToUint32(V4(0.0,0.0,0.6,1.0));
- } else if (*SelectedChannel == 4) {
- Levels += 256*4;
- Color = ColToUint32(V4(0.9,0.9,0.9,1.0));
- }
-
-
- /*
- if (TestRectangle(Box, Input.Mouse) &&
- Input.MouseButton[0].IsDown)
- {
- State->ArbitrarySlide = 1;
- State->Sliding.RandomPointer = Zoom;
- }
- */
-
- uint8 *Row = ((uint8 *)UIBuffer->OriginalBuffer +
- UIBuffer->BytesPerPixel +
- UIBuffer->Pitch);
- for (int Y = 0;
- Y > Box.Min.y;
- Y--)
- {
- uint32 *Pixel = (uint32 *)Row + Box.Min.x;
- for(int X = Box.Min.x;
- X < Box.Max.x;
- ++X)
- {
- real32 Span = (Box.Max.x - Box.Min.x) / 256.0f;
- int16 XLocal = (X - Box.Min.x) / Span;
- int16 YLocal = -(Y - Box.Max.y);
- if (*(Levels + XLocal) > (YLocal * RoundReal32ToInt32(*Zoom)) && XLocal < 256)
- *Pixel++ = Color;
- else
- *Pixel++ = AltColor;
- }
- Row -= UIBuffer->Pitch;
- }
-}
-
-static pixel_buffer
-CreateSolidBitmap(memory *Memory, uint16 Height, uint16 Width, v4 Color) {
- pixel_buffer Buffer = {};
- Buffer.BytesPerPixel = 4;
- Buffer.Height = Height;
- Buffer.Width = Width;
- CalculateFull(&Buffer);
- Buffer.Pitch = Buffer.FullWidth*Buffer.BytesPerPixel;
- Buffer.OriginalBuffer = AllocateMemory(Memory, Buffer.FullHeight * Buffer.FullWidth * Buffer.BytesPerPixel, B_Scratch);
- Buffer.EffectBuffer = AllocateMemory(Memory, Buffer.FullHeight * Buffer.FullWidth * Buffer.BytesPerPixel, B_Scratch);
- DebugFillSolid(&Buffer, Color);
- BitmapPackRGB(&Buffer);
- Buffer.ToUpdate = true;
- return Buffer;
-}
-
-static pixel_buffer
-CreateDebugBitmap(memory *Memory, uint16 Height, uint16 Width) {
- pixel_buffer Buffer = {};
- Buffer.BytesPerPixel = 4;
- Buffer.Height = Height;
- Buffer.Width = Width;
- CalculateFull(&Buffer);
- Buffer.Pitch = Buffer.FullWidth*Buffer.BytesPerPixel;
- Buffer.OriginalBuffer = AllocateMemory(Memory, Buffer.FullHeight * Buffer.FullWidth * Buffer.BytesPerPixel, B_Scratch);
- Buffer.EffectBuffer = AllocateMemory(Memory, Buffer.FullHeight * Buffer.FullWidth * Buffer.BytesPerPixel, B_Scratch);
- DebugBitmap(&Buffer);
- BitmapPackRGB(&Buffer);
- Buffer.ToUpdate = true;
- return Buffer;
-}
/*
{
@@ -659,6 +582,3 @@ CreateDebugBitmap(memory *Memory, uint16 Height, uint16 Width) {
Layer->EndFrame = File.EndFrame;
}
*/
-
-
-#endif